:root {
  --bg: #14161c; --panel: #1e2129; --tile: #2a2e39; --tile-text: #eef0f5; --muted: #8b91a1;
  --sel: #3d6df2; --ok: #2fa86a; --bad: #d64545; --accent: #f2b33d;
  --gap: 8px;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--tile-text);
  font: 16px/1.35 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif; }
body { overscroll-behavior: none; touch-action: manipulation; user-select: none; -webkit-user-select: none; }
#app { max-width: 520px; margin: 0 auto; height: 100%; display: flex; flex-direction: column;
  padding: max(12px, env(safe-area-inset-top)) 16px max(16px, env(safe-area-inset-bottom)); position: relative; }

#hud { margin-bottom: 14px; }
#timebar { height: 8px; background: var(--panel); border-radius: 4px; overflow: hidden; }
#timefill { height: 100%; width: 100%; background: var(--accent); transform-origin: left; }
#timefill.low { background: var(--bad); }
#stats { display: flex; justify-content: space-between; align-items: center; gap: 10px; margin-top: 8px; font-variant-numeric: tabular-nums; }
#clock { font-size: 22px; font-weight: 700; min-width: 64px; }
#solves { color: var(--muted); }
#strikes i { display: inline-block; width: 14px; height: 14px; border-radius: 50%; margin-left: 6px;
  border: 2px solid var(--muted); }
#strikes i.on { background: var(--bad); border-color: var(--bad); }

/* Tag cloud: every word gets a button sized to its text (one uniform font size), and the buttons wrap into centred
   rows. The rows sit in the middle of the space between the clock and the last-solve banner. */
#board { flex: 1; display: flex; flex-wrap: wrap; justify-content: center; align-content: center; gap: 12px 10px;
  padding: 8px 0; }
.tile { flex: 0 1 auto; max-width: 100%; min-height: 54px; border: 0; border-radius: 999px; background: var(--tile);
  color: var(--tile-text); padding: 12px 20px; font-family: inherit; font-weight: 600; font-size: 18px; line-height: 1.2;
  text-align: center; overflow-wrap: anywhere; cursor: pointer; box-shadow: 0 2px 8px rgba(0,0,0,.35);
  transition: background .12s, transform .12s; }
.tile:active { transform: scale(.97); }
.tile.sel { background: var(--sel); }
.tile.ok { background: var(--ok); }
.tile.bad { background: var(--bad); animation: shake .32s; }
.tile.enter { animation: pop .28s ease-out; }
.tile.gone { opacity: .25; transition: opacity .3s; }
@keyframes shake { 0%,100% { translate: 0 } 25% { translate: -6px 0 } 75% { translate: 6px 0 } }
@keyframes pop { from { opacity: 0; scale: .85 } to { opacity: 1; scale: 1 } }

#toast { position: absolute; left: 16px; right: 16px; bottom: calc(max(16px, env(safe-area-inset-bottom)) + 84px); text-align: center;
  pointer-events: none; opacity: 0; transition: opacity .2s; }
#toast span { display: inline-block; background: var(--panel); border-radius: 999px; padding: 8px 16px; font-weight: 600; }
#toast.show { opacity: 1; }
#toast .plus { color: var(--ok); margin-left: 8px; }
#toast.badmsg span { color: var(--bad); }

.overlay { position: absolute; inset: 0; background: rgba(12,13,17,.94); display: flex; align-items: center;
  justify-content: center; padding: 24px 16px; }
.overlay.solid { background: var(--bg); }   /* fully opaque: no words show through while the clock is paused */
.hidden { display: none; }
.card { background: var(--panel); border-radius: 16px; padding: 24px 20px; width: 100%; max-width: 420px; text-align: center; }
.card h1 { margin: 0 0 12px; font-size: 26px; }
.card p { margin: 8px 0; }
.big { font-size: 34px; font-weight: 800; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.primary { margin-top: 16px; width: 100%; padding: 16px; border: 0; border-radius: 12px; background: var(--accent);
  color: #1a1a1a; font-family: inherit; font-weight: 700; font-size: 18px; cursor: pointer; }
#endSolved { list-style: none; padding: 0; margin: 12px 0 0; max-height: 30vh; overflow: auto; text-align: left; }
#endSolved li { padding: 6px 10px; border-radius: 8px; background: var(--tile); margin: 4px 0; font-size: 14px; }
#endSolved li b { display: block; }
#endSolved li span { color: var(--muted); }

.ident { margin-top: 18px; padding-top: 14px; border-top: 1px solid #2f3340; }
.pidRow { display: flex; gap: 8px; align-items: center; justify-content: center; margin-top: 6px; }
.pidText { font: 600 15px ui-monospace, SFMono-Regular, Menlo, monospace; background: var(--tile); padding: 8px 10px;
  border-radius: 8px; user-select: all; -webkit-user-select: all; }
.copyBtn { border: 0; border-radius: 8px; padding: 9px 12px; background: var(--sel); color: #fff; font-family: inherit;
  font-weight: 600; font-size: 14px; cursor: pointer; }
.copyBtn:disabled { opacity: .4; }
.creditText { margin-top: 8px; }

/* Last solved group: stays along the bottom until the next solve or the end of the session. Fixed height so the
   board doesn't jump when it appears. */
#lastSolve { margin-top: 12px; min-height: 72px; border-radius: 12px; padding: 10px 14px; text-align: center;
  background: transparent; display: flex; flex-direction: column; justify-content: center; }
#lastSolve { border: 2px solid transparent; }
#lastSolve.on { background: var(--panel); border-color: var(--ok); }
#lastSolve.flash { animation: solved .6s ease-out; }
#lastSolve b { font-weight: 700; }
#lastSolve .plus { color: var(--ok); margin-left: 8px; }
#lastSolve span { display: block; color: var(--muted); font-size: 14px; margin-top: 2px; }
@keyframes solved { from { background: #24543d; } to { background: var(--panel); } }

/* Short screens (e.g. 320x568): tighter pills so a board of long words still fits above the banner. */
@media (max-height: 620px) {
  #board { gap: 8px 8px; }
  .tile { min-height: 46px; padding: 9px 16px; font-size: 17px; }
  #lastSolve { min-height: 60px; }
}

#newGameBtn { border: 1px solid #3a3f4c; border-radius: 999px; background: transparent; color: var(--muted);
  font-family: inherit; font-size: 13px; font-weight: 600; padding: 5px 11px; cursor: pointer; }
#newGameBtn:active { background: var(--tile); }
.secondary { margin-top: 10px; width: 100%; padding: 14px; border: 1px solid #3a3f4c; border-radius: 12px;
  background: transparent; color: var(--tile-text); font-family: inherit; font-weight: 600; font-size: 16px; cursor: pointer; }
.primary:disabled { opacity: .55; cursor: default; }

/* Page hidden mid-game (app switcher, another app): blank the board. The clock keeps running. */
body.away #board, body.away #lastSolve { visibility: hidden; }
