/* style.css — mirror of theme/Surfaces.kt.
   Every surface in the game is drawn from here, so a theme change is a change of
   visual language rather than a recolour. Three shapes: tile, panel, chip. */

*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-deep: #000; --bg-tile: #0C0C11; --tile-border: #1E1E26;
  --glow: #4FD8EB; --accent: #F5B83D; --text: #FFF; --dim: #8A8A93;
  --danger: #E0566B; --hint: #B07CF7;
  --tile-radius: 10px; --border-w: 1px;
  --shadow-light: rgba(255,255,255,0); --shadow-dark: rgba(0,0,0,0);
  --max-w: 520px;
  /* Standard mobile banner is 320x50. The slot keeps its height whether or not an
     ad fills, so the board never jumps when one arrives. */
  --ad-h: 56px;
}

html, body { height: 100%; }

body {
  background: var(--bg-deep);
  color: var(--text);
  font-family: "Space Grotesk", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overflow-x: hidden;
  transition: background-color .3s ease, color .3s ease;
}

/* Coloured grounds for the two themes that have one. */
body::before {
  content: ""; position: fixed; inset: 0; z-index: -1; pointer-events: none;
  transition: opacity .3s ease; opacity: 0;
}
[data-surface="aurora"] body::before {
  opacity: 1;
  background:
    radial-gradient(60% 45% at 15% 20%, rgba(85,245,192,.18), transparent 70%),
    radial-gradient(55% 40% at 85% 30%, rgba(176,107,255,.20), transparent 70%),
    radial-gradient(70% 50% at 50% 95%, rgba(85,245,192,.10), transparent 70%);
}
[data-surface="glass"] body::before {
  opacity: 1;
  background:
    radial-gradient(50% 40% at 20% 25%, rgba(185,160,255,.45), transparent 70%),
    radial-gradient(50% 40% at 80% 20%, rgba(125,226,252,.35), transparent 70%),
    radial-gradient(60% 45% at 60% 90%, rgba(255,122,156,.25), transparent 70%);
}

/* Content is inset by both banner heights so nothing ever hides underneath them. */
#app {
  max-width: var(--max-w); margin: 0 auto; min-height: 100%;
  padding:
    calc(var(--ad-h) + env(safe-area-inset-top, 0px) + 20px)
    16px
    calc(var(--ad-h) + env(safe-area-inset-bottom, 0px) + 24px);
}

/* ---------- banner slots ----------
   Empty by design: the space is held open so dropping a unit in never shifts the
   board. No label, no border — an unfilled slot should look like nothing at all. */
.ad-slot {
  position: fixed; left: 0; right: 0; z-index: 40;
  display: grid; place-items: center;
  background: var(--bg-deep);
  overflow: hidden;
}
#ad-top {
  top: 0;
  height: calc(var(--ad-h) + env(safe-area-inset-top, 0px));
  padding-top: env(safe-area-inset-top, 0px);
}
#ad-bottom {
  bottom: 0;
  height: calc(var(--ad-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* Direct Link creative. Reads as an ad on purpose — muted, outlined, labelled. It must
   never be mistakable for a game control, so it borrows none of the button styling. */
.ad-banner {
  display: flex; align-items: center; gap: 10px;
  width: min(100%, 420px); height: 40px;
  padding: 0 12px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.04);
  color: rgba(255, 255, 255, 0.66);
  font-size: 13px; letter-spacing: 0.02em;
  text-decoration: none;
}
.ad-banner:hover { background: rgba(255, 255, 255, 0.07); }

.ad-banner__tag {
  flex: none;
  padding: 1px 5px;
  border-radius: 3px;
  background: rgba(255, 255, 255, 0.14);
  color: rgba(255, 255, 255, 0.8);
  font-size: 10px; font-weight: 700; letter-spacing: 0.06em;
  text-transform: uppercase;
}
.ad-banner__text { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.ad-banner__go { flex: none; font-size: 18px; opacity: 0.5; }

.screen { display: flex; flex-direction: column; align-items: center; gap: 14px; }
/* Centre between the banners, not the raw viewport, or menus drift downward. */
.center-screen {
  justify-content: center;
  min-height: calc(100vh - (2 * var(--ad-h)) - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px) - 44px);
}

/* ---------- type ---------- */
.wordmark { font-weight: 900; font-size: clamp(2rem, 11vw, 2.9rem); letter-spacing: .18em; line-height: 1.05; }
.wordmark .b { color: var(--glow); }
h2.title { font-size: 1.5rem; font-weight: 800; letter-spacing: .22em; }
.label { font-size: .7rem; letter-spacing: .2em; color: var(--dim); text-transform: uppercase; }
.muted { color: var(--dim); font-size: .8rem; }
.wallet { color: var(--dim); font-size: .95rem; letter-spacing: .04em; }

/* ---------- panel ---------- */
.panel { width: 100%; padding: 18px; border-radius: 16px; background: var(--bg-tile); border: var(--border-w) solid var(--tile-border); }
[data-surface="brutal"] .panel { border: 2.5px solid var(--tile-border); box-shadow: 5px 5px 0 var(--shadow-dark); }
[data-surface="neu"] .panel { border: none; box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light); }
[data-surface="clay"] .panel { border: none; border-radius: 24px; background: linear-gradient(180deg, var(--shadow-light), var(--bg-tile)); box-shadow: 6px 10px 20px var(--shadow-dark); }
[data-surface="soft"] .panel { box-shadow: 0 4px 14px var(--shadow-dark); }
[data-surface="glass"] .panel { background: rgba(255,255,255,.10); backdrop-filter: blur(14px); -webkit-backdrop-filter: blur(14px); }

/* ---------- chip / button ---------- */
.chip {
  font: inherit; font-size: .8rem; font-weight: 600; letter-spacing: .04em;
  padding: 10px 16px; border-radius: 20px; cursor: pointer;
  background: color-mix(in srgb, var(--chip-accent, var(--glow)) 15%, transparent);
  border: 1px solid var(--chip-accent, var(--glow));
  color: var(--chip-accent, var(--glow));
  transition: transform .12s ease, filter .12s ease;
}
.chip:hover:not(:disabled) { transform: translateY(-1px); filter: brightness(1.15); }
.chip:active:not(:disabled) { transform: translateY(1px); }
.chip:disabled { cursor: default; color: var(--dim); border-color: var(--tile-border); background: var(--bg-tile); }
.chip:focus-visible { outline: 2px solid var(--text); outline-offset: 3px; }
.chip.big { font-size: 1.15rem; padding: 16px 52px; letter-spacing: .16em; font-weight: 800; }

[data-surface="brutal"] .chip { border-radius: 3px; border: 2.5px solid var(--tile-border); background: var(--chip-accent, var(--glow)); color: #111; box-shadow: 4px 4px 0 var(--shadow-dark); }
[data-surface="brutal"] .chip:disabled { background: var(--bg-tile); color: var(--dim); box-shadow: 3px 3px 0 rgba(0,0,0,.25); }
[data-surface="brutal"] .chip:active:not(:disabled) { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--shadow-dark); }

[data-surface="neu"] .chip { border: none; background: var(--bg-tile); color: var(--chip-accent, var(--glow)); box-shadow: 5px 5px 10px var(--shadow-dark), -5px -5px 10px var(--shadow-light); }
[data-surface="neu"] .chip:active:not(:disabled) { transform: none; box-shadow: inset 4px 4px 8px var(--shadow-dark), inset -4px -4px 8px var(--shadow-light); }

[data-surface="clay"] .chip { border: none; border-radius: 22px; background: linear-gradient(180deg, color-mix(in srgb, var(--chip-accent, var(--glow)) 90%, white), var(--chip-accent, var(--glow))); color: #fff; box-shadow: 3px 6px 14px var(--shadow-dark); }
[data-surface="soft"] .chip { box-shadow: 0 3px 10px var(--shadow-dark); }
[data-surface="glass"] .chip { background: color-mix(in srgb, var(--chip-accent, var(--glow)) 22%, transparent); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); }

.row { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; align-items: center; }
.spread { display: flex; width: 100%; justify-content: space-between; align-items: center; gap: 10px; }

/* The APK link is an <a> wearing the chip's clothes. */
a.chip { display: inline-block; text-decoration: none; }
.apk-cta { display: flex; flex-direction: column; align-items: center; gap: 6px; margin-top: 10px; }

.linkish { background: none; border: none; color: var(--dim); font: inherit; font-size: .85rem; letter-spacing: .1em; cursor: pointer; padding: 8px; }
.linkish:hover { color: var(--text); }

/* ---------- board ---------- */
.board-wrap { width: 100%; padding: 6px; border-radius: 16px; }
[data-surface="neu"] .board-wrap,
[data-surface="clay"] .board-wrap,
[data-surface="soft"] .board-wrap,
[data-surface="brutal"] .board-wrap,
[data-surface="glass"] .board-wrap { background: var(--bg-tile); }
[data-surface="brutal"] .board-wrap { border: 2.5px solid var(--tile-border); box-shadow: 5px 5px 0 var(--shadow-dark); }
[data-surface="neu"] .board-wrap { padding: 12px; box-shadow: 6px 6px 12px var(--shadow-dark), -6px -6px 12px var(--shadow-light); }
[data-surface="clay"] .board-wrap { border-radius: 26px; box-shadow: 6px 10px 22px var(--shadow-dark); }
[data-surface="soft"] .board-wrap { box-shadow: 0 4px 16px var(--shadow-dark); }
[data-surface="glass"] .board-wrap { background: rgba(255,255,255,.07); backdrop-filter: blur(12px); -webkit-backdrop-filter: blur(12px); }

.board { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
[data-surface="neu"] .board { gap: 12px; }

.tile {
  aspect-ratio: 1; display: grid; place-items: center; cursor: pointer;
  font-size: clamp(1.1rem, 5.5vw, 1.6rem); font-weight: 600;
  border-radius: var(--tile-radius);
  background: var(--bg-tile);
  border: var(--border-w) solid var(--tile-border);
  color: var(--tile-ink, var(--text));
  transition: transform .12s ease, box-shadow .18s ease, background .18s ease, border-color .18s ease;
  user-select: none;
}
.tile.pop { animation: pop .28s cubic-bezier(.34,1.56,.64,1); }
@keyframes pop { from { transform: scale(.55); } to { transform: scale(1); } }

/* ---- tile shape variants -------------------------------------------------
   Each theme picks a silhouette as well as a surface, so the board reads as a
   different object and not just a recolour. */
[data-shape="square"]   .tile, [data-shape="square"]   .mini { border-radius: 2px; }
[data-shape="rounded"]  .tile, [data-shape="rounded"]  .mini { border-radius: 10px; }
[data-shape="soft"]     .tile, [data-shape="soft"]     .mini { border-radius: 18px; }
[data-shape="squircle"] .tile, [data-shape="squircle"] .mini { border-radius: 30%; }
[data-shape="circle"]   .tile, [data-shape="circle"]   .mini { border-radius: 50%; }
[data-shape="blob"]     .tile, [data-shape="blob"]     .mini {
  border-radius: 62% 38% 55% 45% / 48% 58% 42% 52%;
}
/* A hexagon cannot carry a CSS border, so the edge is drawn as an inset ring. */
[data-shape="hex"] .tile, [data-shape="hex"] .mini {
  border-radius: 0; border: none;
  clip-path: polygon(50% 0%, 93% 25%, 93% 75%, 50% 100%, 7% 75%, 7% 25%);
  box-shadow: inset 0 0 0 1px var(--tile-border);
}
[data-shape="hex"] .tile.lit { box-shadow: inset 0 0 0 1.5px var(--glow), 0 0 18px color-mix(in srgb, var(--glow) 45%, transparent); }
[data-shape="hex"] .tile.sel { box-shadow: inset 0 0 0 2px var(--accent); }
[data-shape="hex"] .tile.hint { box-shadow: inset 0 0 0 2px var(--hint); }

/* lit — the shine wave. Each language says it differently. */
[data-surface="oled"] .tile.lit,
[data-surface="aurora"] .tile.lit {
  border-color: var(--glow);
  background: radial-gradient(circle at 50% 50%, color-mix(in srgb, var(--glow) 38%, transparent), var(--bg-tile));
  box-shadow: 0 0 18px color-mix(in srgb, var(--glow) 45%, transparent);
}
[data-surface="glass"] .tile.lit {
  border-color: var(--glow);
  background: linear-gradient(160deg, color-mix(in srgb, var(--glow) 36%, transparent), rgba(255,255,255,.06));
  box-shadow: 0 0 20px color-mix(in srgb, var(--glow) 40%, transparent);
}
[data-surface="brutal"] .tile.lit { background: var(--glow); border-color: #111; box-shadow: 6px 6px 0 var(--shadow-dark); }
[data-surface="neu"] .tile.lit { background: color-mix(in srgb, var(--bg-tile) 82%, var(--glow)); box-shadow: 8px 8px 14px var(--shadow-dark), -8px -8px 14px var(--shadow-light); }
[data-surface="clay"] .tile.lit { background: linear-gradient(180deg, color-mix(in srgb, var(--glow) 60%, white), var(--glow)); box-shadow: 5px 9px 18px var(--shadow-dark); }
[data-surface="soft"] .tile.lit { background: color-mix(in srgb, var(--bg-tile) 78%, var(--glow)); border-color: var(--glow); box-shadow: 0 6px 16px var(--shadow-dark); }

/* resting depth for the sculpted languages */
[data-surface="neu"] .tile { box-shadow: 4px 4px 8px var(--shadow-dark), -4px -4px 8px var(--shadow-light); }
[data-surface="clay"] .tile { background: linear-gradient(180deg, var(--shadow-light), var(--bg-tile)); box-shadow: 4px 7px 14px var(--shadow-dark); }
[data-surface="soft"] .tile { box-shadow: 0 3px 8px var(--shadow-dark); }
[data-surface="brutal"] .tile { box-shadow: 4px 4px 0 var(--shadow-dark); }

.tile.sel { border-color: var(--accent) !important; border-width: 2px; }
.tile.hint { border-color: var(--hint) !important; border-width: 2px; }
.tile.locked { cursor: not-allowed; color: var(--danger); font-weight: 900; border-color: color-mix(in srgb, var(--danger) 70%, transparent); background: color-mix(in srgb, var(--bg-tile) 70%, var(--danger)); box-shadow: none; }

/* ---------- timer ---------- */
.timer-track { width: 100%; height: 6px; border-radius: 3px; background: color-mix(in srgb, var(--dim) 25%, transparent); overflow: hidden; }
.timer-fill { height: 100%; background: var(--glow); transition: width .12s linear, background .3s ease; }
.timer-fill.low { background: var(--accent); }

/* ---------- overlay ---------- */
.overlay {
  /* Stops short of both banners: an overlay must never sit on top of an ad. */
  position: fixed;
  inset:
    calc(var(--ad-h) + env(safe-area-inset-top, 0px))
    0
    calc(var(--ad-h) + env(safe-area-inset-bottom, 0px))
    0;
  display: grid; place-items: center; padding: 24px; z-index: 20;
  /* Near-opaque plus a blur: on the light themes a translucent scrim let the board
     bleed through and the dialog stopped reading as the foreground. */
  background: color-mix(in srgb, var(--bg-deep) 96%, transparent);
  backdrop-filter: blur(6px); -webkit-backdrop-filter: blur(6px);
  /* Only the card moves. Animating the scrim itself left a transform on the
     container, which shifted its box down over the banner. */
  animation: fade .2s ease;
}
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
@keyframes rise { from { opacity: 0; transform: translateY(14px); } to { opacity: 1; transform: none; } }
.overlay .card {
  text-align: center; display: flex; flex-direction: column; align-items: center;
  gap: 14px; max-width: 420px; animation: rise .25s ease;
}
.overlay h3 { font-size: 1.5rem; font-weight: 800; letter-spacing: .06em; }

/* The hint line is quiet; only a live combo speaks up. Accent rather than glow,
   because on the light themes the glow colour is a fill, not readable ink. */
/* in-game navigation bar */
.gamebar { display: flex; gap: 10px; justify-content: center; flex-wrap: wrap; margin-top: 6px; padding-top: 14px; width: 100%; border-top: 1px solid color-mix(in srgb, var(--dim) 20%, transparent); }
.gamebar .chip { font-size: .72rem; padding: 8px 14px; }

.combo { color: var(--dim); font-weight: 500; letter-spacing: .02em; font-size: .8rem; min-height: 1.4em; text-align: center; }
.combo.hot { color: var(--accent); font-weight: 800; letter-spacing: .12em; font-size: .95rem; }
.flash { position: fixed; inset: 0; background: var(--glow); pointer-events: none; z-index: 30; animation: flash .7s ease-out forwards; }
@keyframes flash { from { opacity: .5; } to { opacity: 0; } }

/* ---------- lists ---------- */
.stat { display: flex; justify-content: space-between; padding: 9px 0; font-size: .9rem; }
.stat + .stat { border-top: 1px solid color-mix(in srgb, var(--dim) 20%, transparent); }
.stat .k { color: var(--dim); }
.stat .v { font-weight: 700; }

.theme-card { width: 100%; cursor: pointer; text-align: left; }
.theme-preview { display: flex; gap: 12px; align-items: center; padding: 12px 14px; border-radius: 12px; margin-top: 12px; }
.mini { width: 38px; height: 38px; border-radius: var(--mini-radius); display: grid; place-items: center; font-size: .95rem; font-weight: 600; flex: 0 0 auto; }

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
