/* ============ MINE-WORD ============ */
:root {
  --bg: #0a0e14;
  --panel: #0f1520;
  --panel-border: #1e2a3a;
  --text: #cdd6e4;
  --text-dim: #5b6b80;
  --green: #22c55e;
  --green-dark: #15803d;
  --blue: #38bdf8;
  --blue-dark: #0369a1;
  --red: #ef4444;
  --red-dark: #991b1b;
  --yellow: #eab308;
  --yellow-dark: #854d0e;
  --gray: #313d4f;
  --tile-size: 62px;
  --font: "SF Mono", ui-monospace, "Cascadia Code", "JetBrains Mono", Menlo, Consolas, monospace;
}

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

html {
  touch-action: manipulation; /* kill double-tap zoom on game controls */
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  overflow: hidden;
}

body {
  background-image:
    radial-gradient(ellipse 80% 60% at 50% -10%, rgba(56, 189, 248, 0.06), transparent),
    radial-gradient(ellipse 60% 50% at 90% 110%, rgba(239, 68, 68, 0.05), transparent);
}

body.daily-mode { --chrome-extra: 48px; }

#app {
  /* if a board still can't fit (unusually short window), scroll instead of
     letting panels overlap the footer */
  overflow-y: auto;
  height: 100vh;
  height: 100dvh;
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 24px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

#app.shake { animation: screenshake 0.3s linear; }
@keyframes screenshake {
  0%   { transform: translate(0, 0); }
  10%  { transform: translate(-9px, 4px); }
  25%  { transform: translate(8px, -6px); }
  40%  { transform: translate(-7px, -3px); }
  55%  { transform: translate(6px, 5px); }
  70%  { transform: translate(-5px, 2px); }
  85%  { transform: translate(3px, -2px); }
  100% { transform: translate(0, 0); }
}

/* ============ HEADER ============ */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--panel-border);
  padding-bottom: 12px;
  position: relative;
}

h1 {
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
  font-size: 28px;
  letter-spacing: 8px;
  font-weight: 700;
  color: #e8eef7;
  text-shadow: 0 0 18px rgba(56, 189, 248, 0.45);
}
h1 .dash { color: var(--red); text-shadow: 0 0 14px rgba(239, 68, 68, 0.7); }

.hud-btn {
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 13px;
  letter-spacing: 2px;
  padding: 8px 14px;
  cursor: pointer;
  transition: all 0.15s;
}
.hud-btn:hover {
  color: var(--blue);
  border-color: var(--blue);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.25);
}

.menu-wrap { position: relative; z-index: 30; }
#menu-dropdown {
  position: absolute;
  top: calc(100% + 6px);
  left: 0;
  min-width: 190px;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
}
#menu-dropdown button {
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--panel-border);
  color: var(--text);
  font-family: var(--font);
  font-size: 12px;
  letter-spacing: 1.5px;
  text-align: left;
  padding: 11px 14px;
  cursor: pointer;
}
#menu-dropdown button:last-child { border-bottom: none; }
#menu-dropdown button:hover { background: rgba(56, 189, 248, 0.08); color: var(--blue); }

.lives-wrap { display: flex; align-items: center; gap: 10px; }
.lives-label { font-size: 13px; letter-spacing: 2px; color: var(--text-dim); }
#lives { display: flex; gap: 6px; }
.life {
  width: 22px;
  height: 22px;
  background: var(--green);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.55), inset 0 0 4px rgba(255, 255, 255, 0.25);
  transition: all 0.3s;
}
.life.lost {
  background: #1c2431;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.8);
}
.life.losing { animation: lifepop 0.5s ease-out; }
@keyframes lifepop {
  0% { background: var(--red); box-shadow: 0 0 24px rgba(239, 68, 68, 1); transform: scale(1.6); }
  100% { transform: scale(1); }
}

/* ============ LAYOUT ============ */
main {
  flex: 1;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 20px;
  min-height: 0;
}

section, #defuse-panel, #log-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
}

.panel-title {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--text-dim);
  padding: 12px 16px 0;
}

#grid-panel {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding-bottom: 18px;
}
#grid-panel .panel-title { align-self: flex-start; }

/* ============ GRID ============ */
#grid {
  flex: 1;
  display: grid;
  /* 10 rows must fit the viewport on desktop — tiles shrink on short windows */
  --tile-size: min(62px, calc((100dvh - 324px - var(--chrome-extra, 0px)) / 10));
  grid-template-rows: repeat(10, var(--tile-size));
  gap: 8px;
  align-content: center;
  padding: 12px 28px;
}
.grid-row {
  display: grid;
  grid-template-columns: repeat(5, var(--tile-size));
  gap: 8px;
}
.grid-row.invalid { animation: rowshake 0.35s; }
@keyframes rowshake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-7px); }
  40% { transform: translateX(7px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

.tile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 26px;
  font-weight: 700;
  color: var(--text);
  border: 2px solid #202b3b;
  background: #0c111a;
  text-transform: uppercase;
  transform-style: preserve-3d;
}
.tile.filled {
  border-color: #3b4c63;
  animation: tilepop 0.09s ease-out;
}
@keyframes tilepop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.tile.flipping { animation: tileflip 0.5s ease-in-out; }
@keyframes tileflip {
  0% { transform: rotateX(0deg); }
  50% { transform: rotateX(90deg); }
  100% { transform: rotateX(0deg); }
}

.tile.hit {
  background: var(--green-dark);
  border-color: var(--green);
  color: #fff;
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.35);
}
.tile.prox, .tile.hot {
  background: var(--blue-dark);
  border-color: var(--blue);
  color: #fff;
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}
.tile.shift {
  background: var(--yellow-dark);
  border-color: var(--yellow);
  color: #fff;
  box-shadow: 0 0 14px rgba(234, 179, 8, 0.3);
}
.tile .count {
  position: absolute;
  top: 2px;
  right: 5px;
  font-size: 12px;
  font-weight: 700;
  opacity: 0.9;
  color: #e0f2fe;
  text-shadow: 0 0 6px rgba(255, 255, 255, 0.6);
}
.tile.dead {
  background: var(--gray);
  border-color: #445468;
  color: #b6c2d4;
}
.tile.mine {
  background: var(--red-dark);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.6);
  animation: minethrob 1.6s ease-in-out infinite;
}
@keyframes minethrob {
  0%, 100% { box-shadow: 0 0 10px rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 22px rgba(239, 68, 68, 0.85); }
}
.tile.boom {
  background: #14090b;
  border-color: var(--red-dark);
  font-size: 24px;
}
.tile.pencil {
  color: #5b8bb0;
  font-style: italic;
  border-style: dashed;
}
.tile.pencil-sel {
  border-color: var(--blue);
  border-style: dashed;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.3);
  cursor: text;
}
.tile.win { animation: winbounce 0.6s ease; }
@keyframes winbounce {
  0%, 100% { transform: translateY(0); }
  40% { transform: translateY(-16px); }
  65% { transform: translateY(4px); }
}

/* ---- WORD FIELD (4×4 mode) ---- */
.mode-tag {
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--blue);
  vertical-align: middle;
  text-shadow: 0 0 10px rgba(56, 189, 248, 0.6);
}
#grid.field4 {
  --tile-size: 72px;
  grid-template-rows: repeat(4, var(--tile-size));
}
#grid.field4 .grid-row { grid-template-columns: repeat(4, var(--tile-size)); }
#grid.rows6 {
  --tile-size: min(62px, calc((100dvh - 324px - var(--chrome-extra, 0px)) / 6));
  grid-template-rows: repeat(6, var(--tile-size));
}
#grid.cols6w .grid-row { grid-template-columns: repeat(6, var(--tile-size)); }

/* ---- CHAIN REACTION ---- */
#grid.chain {
  --tile-size: min(50px, calc((100dvh - 420px - var(--chrome-extra, 0px)) / 10));
  grid-template-rows: repeat(10, var(--tile-size));
  gap: 6px;
}
#grid.chain .grid-row { grid-template-columns: repeat(4, var(--tile-size)); gap: 6px; }
#grid.chain .tile { font-size: 20px; }
.tile.curword { border-color: var(--blue); box-shadow: 0 0 10px rgba(56, 189, 248, 0.3); }
.goal-wrap {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 4px 0 16px;
}
.goal-label { font-size: 11px; letter-spacing: 2px; color: var(--text-dim); }
#goal { display: flex; gap: 6px; }
.tile.goal {
  width: 40px;
  height: 40px;
  font-size: 18px;
  border-color: var(--green-dark);
  color: var(--green);
  text-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
}

/* ---- SWEEP ---- */
#grid.sweep.rows6 { --tile-size: min(56px, calc((100dvh - 380px - var(--chrome-extra, 0px)) / 6)); }
#grid.sweep {
  --tile-size: min(64px, calc((100dvh - 360px - var(--chrome-extra, 0px)) / 5));
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
}
.sweep-row { display: flex; align-items: center; gap: 8px; }
.sweep-row .tile {
  width: var(--tile-size);
  height: var(--tile-size);
  flex: none;
}
.sweep-row.invalid { animation: rowshake 0.35s; }
.sweep-row.selrow .tile.facedown {
  border-color: var(--blue);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}
.row-solve {
  width: 34px;
  height: var(--tile-size);
  flex: none;
  background: transparent;
  border: 1px solid var(--panel-border);
  color: var(--text-dim);
  font-family: var(--font);
  font-size: 13px;
  cursor: pointer;
  transition: all 0.15s;
}
.row-solve:hover { color: var(--blue); border-color: var(--blue); }
.sweep-row.selrow .row-solve { color: var(--blue); border-color: var(--blue); }
.tile.facedown {
  background: #131c2c;
  border-color: #2a3b55;
  cursor: pointer;
  user-select: none;
  -webkit-touch-callout: none;
}
.tile.facedown:hover { border-color: #3b5578; }
.tile.revealed { background: #0c111a; border-color: #3b4c63; }
.tile .sensor {
  position: absolute;
  bottom: 2px;
  right: 5px;
  font-size: 11px;
  font-weight: 700;
  color: var(--red);
  text-shadow: 0 0 6px rgba(239, 68, 68, 0.5);
}
/* every mine this sensor counts is already visible (☢/✓) — threat over */
.tile .sensor.cleared {
  color: #5b6b80;
  text-shadow: none;
}
.tile .defused-mark {
  position: absolute;
  top: 1px;
  left: 4px;
  font-size: 13px;
  filter: drop-shadow(0 0 3px rgba(0, 0, 0, 0.8));
}

/* ---- SHORT FUSE ---- */
.fuse-time {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--green);
  text-shadow: 0 0 10px rgba(34, 197, 94, 0.4);
}
.fuse-time.low {
  color: var(--red);
  text-shadow: 0 0 10px rgba(239, 68, 68, 0.6);
  animation: minethrob 1s ease-in-out infinite;
}
.field-row { cursor: pointer; }
.field-row .tile { transition: border-color 0.12s, box-shadow 0.12s; }
.field-row:hover .tile:not(.hit) { border-color: #3b5578; }
.field-row.selrow .tile:not(.hit) {
  border-color: var(--blue);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.25);
}
.field-row.selrow .tile.hit { box-shadow: 0 0 12px rgba(34, 197, 94, 0.4); }

/* scan: spotlight the tiles a blue-pinged letter could be hiding in */
#grid .tile.scan {
  border-style: dashed;
  border-color: var(--blue);
  animation: scanthrob 1.1s ease-in-out infinite;
}
#grid .tile.scan-src {
  border-color: #bae6fd;
  box-shadow: 0 0 18px rgba(56, 189, 248, 0.8);
}
@keyframes scanthrob {
  0%, 100% { box-shadow: 0 0 6px rgba(56, 189, 248, 0.3); }
  50% { box-shadow: 0 0 18px rgba(56, 189, 248, 0.75); }
}

.tripped-flash { animation: redflash 0.3s ease-out 2; }
@keyframes redflash {
  0%, 100% { background: #0c111a; }
  50% { background: rgba(239, 68, 68, 0.35); }
}

.particle {
  position: fixed;
  width: 5px;
  height: 5px;
  pointer-events: none;
  z-index: 100;
}

.confetti {
  position: fixed;
  pointer-events: none;
  z-index: 100;
}

/* ============ SIDE PANEL ============ */
#side-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  background: transparent;
  border: none;
  min-height: 0;
}

#defuse-panel { padding-bottom: 14px; }

#keyboard {
  display: flex;
  flex-direction: column;
  gap: 8px;
  align-items: center;
  padding: 16px 12px 10px;
}
.kb-row { display: flex; gap: 8px; }

.key {
  position: relative;
  width: 46px;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: var(--font);
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
  background: #182234;
  border: 1px solid #263752;
  cursor: pointer;
  transition: background 0.12s, box-shadow 0.12s, border-color 0.12s;
  user-select: none;
}
.key:hover { background: #223048; border-color: #3b5578; }
.key:active { transform: translateY(1px); }
.key { -webkit-touch-callout: none; }

.key.key-wide {
  width: 74px;
  font-size: 11px;
  letter-spacing: 1px;
  color: #9fb2c8;
}

.key.hit { background: var(--green-dark); border-color: var(--green); color: #fff; }
.key.prox, .key.hot { background: var(--blue-dark); border-color: var(--blue); color: #fff; }
.key.shift { background: var(--yellow-dark); border-color: var(--yellow); color: #fff; }
.key.dead { background: #202835; border-color: #2a3644; color: #62738c; }
.key.mine {
  background: var(--red-dark);
  border-color: var(--red);
  color: #fff;
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.45);
}
.key .flag {
  position: absolute;
  top: -7px;
  right: -5px;
  font-size: 14px;
  filter: drop-shadow(0 0 4px rgba(239, 68, 68, 0.8));
}
.key.flagged { border-color: var(--red); }

.board-hint {
  text-align: center;
  font-size: 10px;
  letter-spacing: 1.5px;
  color: var(--text-dim);
  padding-top: 4px;
}

/* ============ SYSTEM LOG ============ */
#log-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}
#log {
  flex: 1;
  overflow-y: auto;
  padding: 10px 16px 14px;
  font-size: 12.5px;
  line-height: 1.85;
  min-height: 0;
}
#log::-webkit-scrollbar { width: 6px; }
#log::-webkit-scrollbar-thumb { background: var(--panel-border); }

.log-entry { color: var(--text-dim); animation: logfade 0.3s ease-out; }
.log-entry::before { content: "> "; color: #34506e; }
.log-entry.info { color: #9fb2c8; }
.log-entry.good { color: var(--green); }
.log-entry.ping { color: var(--blue); }
.log-entry.warn {
  color: var(--red);
  font-weight: 700;
  text-shadow: 0 0 8px rgba(239, 68, 68, 0.4);
}
@keyframes logfade {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============ MODALS ============ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 7, 12, 0.82);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
}
.hidden { display: none !important; }

.modal {
  width: min(560px, 92vw);
  max-height: 88vh;
  max-height: 88dvh;
  overflow-y: auto;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  box-shadow: 0 0 60px rgba(56, 189, 248, 0.12), 0 20px 60px rgba(0, 0, 0, 0.7);
  padding: 28px 32px;
  animation: modalin 0.25s ease-out;
}
@keyframes modalin {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}
.modal h2 {
  font-size: 18px;
  letter-spacing: 4px;
  margin-bottom: 16px;
  color: #e8eef7;
  text-shadow: 0 0 14px rgba(56, 189, 248, 0.4);
}
.modal h2.lost { text-shadow: 0 0 14px rgba(239, 68, 68, 0.6); color: #fecaca; }
.modal-body { font-size: 13.5px; line-height: 1.75; color: #a9b8cc; }
.modal-body p { margin-bottom: 12px; }
.modal-body ul { list-style: none; margin: 14px 0; display: flex; flex-direction: column; gap: 10px; }
.modal-body strong { color: #dde6f2; }
.danger-text { color: var(--red); }

.chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  font-weight: 700;
  font-size: 15px;
  color: #fff;
  margin-right: 8px;
  vertical-align: middle;
}
.chip sup { font-size: 9px; margin-left: 1px; }
.chip-green { background: var(--green-dark); border: 1px solid var(--green); }
.chip-yellow { background: var(--yellow-dark); border: 1px solid var(--yellow); }
.chip-blue { background: var(--blue-dark); border: 1px solid var(--blue); }
.chip-gray { background: var(--gray); border: 1px solid #445468; }
.chip-red { background: var(--red-dark); border: 1px solid var(--red); }

.modal-close { margin-top: 20px; width: 100%; }
.modal-close + .modal-close { margin-top: 10px; }

.reveal-row { display: flex; align-items: center; gap: 14px; margin: 14px 0; }
.reveal-label { font-size: 11px; letter-spacing: 2px; color: var(--text-dim); width: 110px; }
.reveal-tiles { display: flex; gap: 6px; }
.reveal-tiles.reveal-stack { flex-wrap: wrap; }
.reveal-tiles .chip { margin-right: 0; }
.chip-word {
  width: auto;
  padding: 0 8px;
  letter-spacing: 2px;
}

/* ============ FOOTER ============ */
#site-footer {
  display: flex;
  flex-direction: column;
  gap: 7px;
  font-size: 10px;
  letter-spacing: 1px;
  color: var(--text-dim);
  border-top: 1px solid var(--panel-border);
  padding-top: 10px;
}
.footer-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.footer-legal {
  display: flex;
  flex-direction: column;
  gap: 2px;
  text-align: center;
  font-size: 9.5px;
  letter-spacing: 0.5px;
  color: #46566c;
}
#site-footer a {
  color: #7a92b0;
  text-decoration: none;
}
#site-footer a:hover { color: var(--blue); }
#site-footer .sep { margin: 0 6px; }

/* ============ LEGAL BANNER ============ */
#legal-banner {
  position: fixed;
  left: 50%;
  bottom: 18px;
  transform: translateX(-50%);
  width: min(720px, 94vw);
  display: flex;
  align-items: center;
  gap: 18px;
  background: var(--panel);
  border: 1px solid var(--blue-dark);
  box-shadow: 0 0 30px rgba(56, 189, 248, 0.15), 0 10px 40px rgba(0, 0, 0, 0.6);
  padding: 14px 18px;
  z-index: 40;
  font-size: 12px;
  line-height: 1.6;
  color: #a9b8cc;
  animation: modalin 0.3s ease-out;
}
#legal-banner a { color: var(--blue); }
#legal-banner .hud-btn { white-space: nowrap; flex-shrink: 0; }

/* ============ TUTORIAL COACH ============ */
.menu-wrap { display: flex; gap: 8px; align-items: center; }
#coach {
  position: fixed;
  bottom: 84px;
  left: 50%;
  transform: translateX(-50%);
  width: min(640px, 92vw);
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--panel);
  border: 1px solid var(--green-dark);
  box-shadow: 0 0 26px rgba(34, 197, 94, 0.18), 0 10px 40px rgba(0, 0, 0, 0.6);
  padding: 13px 17px;
  z-index: 35;
  font-size: 12.5px;
  line-height: 1.65;
  color: #b9c8da;
  animation: modalin 0.3s ease-out;
}
#coach p::before { content: "▸ "; color: var(--green); }
#coach .hud-btn { white-space: nowrap; flex-shrink: 0; }

/* ============ GAME HUB ============ */
#app.hub { overflow-y: auto; }
.daily-hero {
  margin-top: 20px;
  margin-bottom: 22px;
  padding: 18px 20px 16px;
  background: linear-gradient(180deg, rgba(34, 197, 94, 0.07), rgba(34, 197, 94, 0.02)), var(--panel);
  border: 1px solid var(--green-dark);
  animation: dailyglow 2.4s ease-in-out infinite;
}
@keyframes dailyglow {
  0%, 100% { box-shadow: 0 0 14px rgba(34, 197, 94, 0.15); }
  50% { box-shadow: 0 0 30px rgba(34, 197, 94, 0.35); }
}
.daily-head h2 {
  font-size: 16px;
  letter-spacing: 3px;
  color: var(--green);
  text-shadow: 0 0 12px rgba(34, 197, 94, 0.5);
}
.daily-date {
  font-size: 12px;
  letter-spacing: 2px;
  color: #bbf7d0;
  margin-left: 8px;
}
.daily-sub {
  margin-top: 7px;
  font-size: 11.5px;
  letter-spacing: 0.5px;
  color: #9fb2c8;
}
.daily-links {
  margin-top: 14px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 10px;
}
.daily-links a {
  display: flex;
  flex-direction: column;
  gap: 5px;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  background: rgba(10, 14, 20, 0.5);
  text-decoration: none;
  transition: border-color 0.15s, box-shadow 0.15s;
}
.daily-links a:hover {
  border-color: var(--green);
  box-shadow: 0 0 14px rgba(34, 197, 94, 0.3);
}
.dl-name { font-size: 12px; letter-spacing: 2px; color: #e8eef7; }
.dl-status { font-size: 10px; letter-spacing: 1.5px; color: var(--blue); }
.dl-status.dl-won { color: var(--green); }
.dl-status.dl-lost { color: var(--red); }
.daily-links a.dl-done { opacity: 0.75; }
.dl-global { font-size: 9px; letter-spacing: 1px; color: var(--text-dim); }

.hub-blurb {
  margin: 0 auto 18px;
  max-width: 720px;
  text-align: center;
  font-size: 11.5px;
  line-height: 1.7;
  color: #7a92b0;
}

/* in-game banner: you are playing the daily */
.daily-flag {
  text-align: center;
  padding: 8px 12px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--green);
  background: rgba(34, 197, 94, 0.06);
  border: 1px solid var(--green-dark);
  animation: dailyglow 2.4s ease-in-out infinite;
}
.hub-header {
  text-align: center;
  padding: 26px 0 20px;
  border-bottom: 1px solid var(--panel-border);
}
.hub-header h1 {
  position: static;
  transform: none;
  font-size: 34px;
}
.tagline {
  margin-top: 14px;
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--text-dim);
}
.hub-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
  padding: 26px 0;
}
.game-card {
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  text-decoration: none;
  color: var(--text);
  transition: border-color 0.15s, box-shadow 0.15s, transform 0.15s;
}
.game-card:hover {
  border-color: var(--blue);
  box-shadow: 0 0 26px rgba(56, 189, 248, 0.2);
  transform: translateY(-3px);
}
.game-card img {
  display: block;
  width: 100%;
  aspect-ratio: 16 / 10;
  object-fit: cover;
  object-position: top;
  border-bottom: 1px solid var(--panel-border);
  background: var(--bg);
}
.card-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 15px 16px 16px;
}
.card-body h2 {
  font-size: 15px;
  letter-spacing: 3px;
  color: #e8eef7;
}
.card-sub {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--blue);
}
.card-body p {
  flex: 1;
  font-size: 12px;
  line-height: 1.65;
  color: #9fb2c8;
}
.card-cta {
  font-size: 11px;
  letter-spacing: 2px;
  color: var(--blue);
}

/* ============ MOBILE / SMALL SCREENS ============ */
@media (max-width: 960px) {
  :root {
    --tile-size: min(56px, calc((100vw - 78px) / 5));
  }
  /* stacked layout scrolls vertically, so width is the only constraint here */
  #grid, #grid.rows6 { --tile-size: min(56px, calc((100vw - 78px) / 5)); }
  #grid.cols6w { --tile-size: min(56px, calc((100vw - 86px) / 6)); }
  #grid.field4 { --tile-size: min(72px, calc((100vw - 74px) / 4)); }
  #grid.chain { --tile-size: min(50px, calc((100vw - 70px) / 4)); }
  #grid.sweep { --tile-size: min(56px, calc((100vw - 116px) / 5)); padding: 10px 8px; }
  #grid.sweep.cols6 { --tile-size: min(48px, calc((100vw - 112px) / 6)); }

  /* stacked layout is taller than the screen — let the page scroll */
  html, body { overflow: auto; }
  #app {
    height: auto;
    min-height: 100vh;
    min-height: 100dvh;
    padding: 10px 10px 20px;
    gap: 10px;
  }

  header { padding-bottom: 8px; gap: 8px; }
  h1 {
    position: static;
    transform: none;
    font-size: 17px;
    letter-spacing: 3px;
    white-space: nowrap;
  }
  .hud-btn { font-size: 11px; letter-spacing: 1px; padding: 7px 8px; white-space: nowrap; }
  .mode-tag { display: block; font-size: 10px; letter-spacing: 2px; }
  .menu-wrap { gap: 5px; }
  .lives-label { display: none; }
  .life { width: 16px; height: 16px; }

  main { grid-template-columns: 1fr; gap: 10px; }

  #grid-panel { padding-bottom: 10px; }
  #grid { padding: 10px 8px 4px; gap: 6px; }
  .grid-row { gap: 6px; }
  .tile { font-size: 20px; }
  .tile .count { font-size: 10px; top: 1px; right: 3px; }

  #side-panel { gap: 10px; }
  #keyboard { gap: 5px; padding: 10px 4px 8px; }
  .kb-row { gap: 4px; }
  .key {
    width: clamp(24px, calc((100vw - 66px) / 11.2), 46px);
    height: 46px;
    font-size: 14px;
  }
  .key.key-wide {
    width: clamp(38px, calc((100vw - 66px) / 11.2 * 1.6), 74px);
    font-size: 9px;
  }
  .key .flag { top: -6px; right: -4px; font-size: 12px; }

  #log-panel { flex: none; }
  #log { flex: none; height: 130px; font-size: 11.5px; }

  .board-hint { padding: 4px 8px 0; }

  .modal { padding: 20px 16px; }
  .modal-body { font-size: 12.5px; }
  .reveal-label { width: 84px; font-size: 10px; }

  #coach { bottom: 8px; }

  #site-footer { font-size: 9px; }
  .footer-row {
    flex-direction: column;
    gap: 4px;
    text-align: center;
  }

  .hub-header { padding: 16px 0 14px; }
  .hub-header h1 { font-size: 22px; letter-spacing: 5px; }
  .tagline { font-size: 9px; padding: 0 10px; }
  .hub-grid { gap: 14px; padding: 16px 0; }
}
