/* ===== Base / theme ===================================================== */
:root {
  --bg: #0f1226;
  --bg-2: #171b36;
  --panel: #1e2444;
  --panel-2: #262c52;
  --line: #313870;
  --text: #eef1ff;
  --muted: #9aa3d0;
  --accent: #6c8cff;
  --radius: 16px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  /* The app is a fixed, viewport-sized shell — no page scroll or rubber-band.
     Individual regions (e.g. Wortify's word list) still scroll internally. */
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  background: radial-gradient(1200px 600px at 50% -10%, #1b2148 0%, var(--bg) 60%);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

#app { position: fixed; inset: 0; overflow: hidden; }

.screen {
  height: 100vh;
  height: 100dvh;
  overflow-y: auto;              /* a screen scrolls internally only if its own content overflows */
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: calc(16px + var(--safe-top)) 16px calc(16px + var(--safe-bottom));
}
.hidden { display: none !important; }

/* The mounted game fills the (safe-area padded) host exactly, so game screens
   never overflow -> no scroll slack under the map / board. */
#game-root { height: 100%; }

button { font-family: inherit; cursor: pointer; }

/* ===== Hub ============================================================== */
.hub-header { text-align: center; margin: 24px 0 28px; }
.hub-title {
  margin: 0;
  font-size: 40px;
  font-weight: 800;
  letter-spacing: -0.02em;
  background: linear-gradient(120deg, #8ea8ff, #b28dff 60%, #5ec7a8);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}
.hub-subtitle { margin: 6px 0 0; color: var(--muted); font-size: 15px; }

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  gap: 14px;
  max-width: 640px;
  margin: 0 auto;
}

.game-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 16px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  color: var(--text);
  text-align: left;
  transition: transform 0.12s ease, border-color 0.12s ease;
  min-height: 132px;
  overflow: hidden;
}
/* Accent glow drawn with a simple overlay — avoids color-mix() so it renders
   on every browser (older Safari included). */
.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(120px 80px at 100% 0%, var(--accent), transparent 70%);
  opacity: 0.22;
  pointer-events: none;
}
.game-card > * { position: relative; }
.game-card:active { transform: scale(0.97); border-color: var(--accent); }
.game-card__icon { font-size: 34px; }
.game-card__name { font-weight: 700; font-size: 18px; margin-top: 4px; }
.game-card__tagline { color: var(--muted); font-size: 13px; line-height: 1.3; }
.game-card__best {
  margin-top: auto;
  align-self: flex-start;
  font-size: 12px;
  color: var(--accent);
  background: rgba(255, 255, 255, 0.08);
  padding: 3px 8px;
  border-radius: 999px;
}

.hub-footer { text-align: center; color: var(--muted); font-size: 13px; margin: 32px 0 8px; opacity: 0.7; }

/* ===== Generic buttons ================================================= */
.bk-back {
  background: var(--panel);
  border: 1px solid var(--line);
  color: var(--muted);
  padding: 8px 14px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
}
.bk-back:active { transform: scale(0.96); }

.bk-btn {
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  padding: 13px 18px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 700;
  width: 100%;
}
.bk-btn--primary {
  background: linear-gradient(120deg, var(--accent), #8a6cff);
  border-color: transparent;
  color: #fff;
}
.bk-btn:active { transform: scale(0.98); }

/* ===== Blockudoku: menu ================================================ */
.bk-menu { min-height: 100%; }
.bk-menu-inner {
  max-width: 420px;
  margin: 0 auto;
  text-align: center;
  padding-top: 6vh;
}
.bk-logo { font-size: 64px; }
.bk-menu-title { margin: 8px 0 4px; font-size: 30px; font-weight: 800; }
.bk-menu-sub { color: var(--muted); margin: 0 0 28px; }

.bk-diff-list { display: grid; gap: 12px; }
.bk-diff {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
}
.bk-diff:active { transform: scale(0.98); }
.bk-diff-name { font-size: 18px; font-weight: 700; }
.bk-diff-best { font-size: 13px; color: var(--muted); }
.bk-diff--easy   { border-left: 4px solid #5ec7a8; }
.bk-diff--medium { border-left: 4px solid #ffb454; }
.bk-diff--hard   { border-left: 4px solid #ff6b8b; }

/* Continue (resume) button + "new game" heading */
.bk-continue {
  display: flex;
  flex-direction: column;
  gap: 3px;
  width: 100%;
  padding: 16px 20px;
  margin-bottom: 8px;
  border: 1px solid transparent;
  border-radius: 14px;
  background: linear-gradient(120deg, var(--accent), #8a6cff);
  color: #fff;
  text-align: left;
}
.bk-continue:active { transform: scale(0.98); }
.bk-continue-top { font-size: 18px; font-weight: 800; }
.bk-continue-sub { font-size: 13px; opacity: 0.85; }
.bk-diff-heading {
  margin: 18px 0 10px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--muted);
  text-align: left;
}

/* ===== Blockudoku: game ================================================ */
.bk-game {
  max-width: 480px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.bk-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}
.bk-scorebox { display: flex; gap: 10px; }
.bk-score {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 6px 14px;
  text-align: right;
  min-width: 78px;
}
.bk-score-label { display: block; font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.06em; }
.bk-score-val { display: block; font-size: 20px; font-weight: 800; }
.bk-score--best .bk-score-val { color: var(--accent); }

.bk-board-wrap {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
}
.bk-board {
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  grid-template-rows: repeat(9, 1fr);
  gap: 3px;
  aspect-ratio: 1 / 1;
  width: 100%;
  padding: 6px;
  background: var(--bg-2);
  border: 1px solid var(--line);
  border-radius: 14px;
  touch-action: none;
}
.bk-cell {
  border-radius: 5px;
  background: var(--panel);
  transition: background 0.12s ease;
}
.bk-cell--shade { background: var(--panel-2); }
.bk-filled { box-shadow: inset 0 0 0 1px rgba(255,255,255,0.18); }
/* Where the piece would land */
.bk-preview-ok { background: #7c9cff !important; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.55); }
.bk-preview-bad { background: rgba(255,107,139,0.55) !important; box-shadow: inset 0 0 0 1px rgba(255,107,139,0.8); }
/* Rows/cols/boxes that this drop would clear — gold glow so it's obvious */
.bk-will-clear {
  background: #ffd35c !important;
  box-shadow: inset 0 0 0 2px #fff0b8, 0 0 10px rgba(255,211,92,0.9);
  animation: bk-willclear 0.7s ease-in-out infinite;
}
@keyframes bk-willclear {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
}
.bk-clear-flash { animation: bk-flash 0.32s ease; }
@keyframes bk-flash {
  0% { transform: scale(1); background: #fff !important; }
  100% { transform: scale(1); }
}

/* Thicker separators between 3x3 blocks (drawn via extra margins) */
.bk-board { position: relative; }

/* Tray */
.bk-tray {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  padding-top: 18px;
  min-height: 96px;
  align-items: center;
}
.bk-tray-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 84px;
  padding: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  touch-action: none;
  cursor: grab;
}
.bk-tray-slot--empty { opacity: 0.35; cursor: default; }
.bk-tray-slot--dead { opacity: 0.45; cursor: default; }
.bk-tray-slot:active { cursor: grabbing; }
/* Grid track sizes are set inline per piece (in JS); cells fill their track. */
.bk-piece { display: grid; touch-action: none; }
.bk-piece-cell { width: 100%; height: 100%; border-radius: 4px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.22); }
.bk-piece-gap { width: 100%; height: 100%; }
.bk-piece--dragging { opacity: 0.25; }

/* Ghost dragged piece */
.bk-ghost {
  position: fixed;
  z-index: 50;
  display: grid;
  gap: 3px;
  pointer-events: none;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.4));
}
.bk-ghost-cell { border-radius: 5px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25); }
.bk-ghost-gap { }

/* Toast (combos, bonuses) */
.bk-toast {
  position: absolute;
  top: 44%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  padding: 10px 18px;
  background: rgba(15, 18, 38, 0.85);
  border: 1px solid var(--accent);
  border-radius: 999px;
  font-weight: 800;
  font-size: 18px;
  color: #fff;
  pointer-events: none;
  opacity: 0;
  white-space: nowrap;
}
.bk-toast--show { animation: bk-toast 0.9s ease forwards; }
@keyframes bk-toast {
  0% { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.05); }
  75% { opacity: 1; transform: translate(-50%, -60%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -80%) scale(0.95); }
}

/* Game over overlay */
.bk-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(8, 10, 24, 0.72);
  backdrop-filter: blur(6px);
}
.bk-modal {
  width: 100%;
  max-width: 340px;
  text-align: center;
  padding: 28px 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 20px;
}
.bk-modal-emoji { font-size: 52px; }
.bk-modal-title { margin: 6px 0 2px; font-size: 24px; font-weight: 800; }
.bk-modal-score { font-size: 46px; font-weight: 900; color: var(--accent); }
.bk-modal-sub { color: var(--muted); margin-bottom: 22px; font-size: 14px; }
.bk-modal-actions { display: grid; gap: 10px; }

@media (max-width: 360px) {
  .bk-score { min-width: 66px; padding: 5px 10px; }
  .bk-score-val { font-size: 18px; }
}

/* ===== Wortify ========================================================= */
.wf-game {
  max-width: 460px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100%;
}
.wf-error { text-align: center; color: var(--muted); padding: 40px; }

.wf-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}
.wf-rankbox { display: flex; align-items: baseline; gap: 10px; }
.wf-rank { font-size: 15px; font-weight: 700; color: var(--accent); }
.wf-score {
  font-size: 20px; font-weight: 800; min-width: 30px; text-align: right;
}

.wf-progress {
  height: 6px; border-radius: 999px; background: var(--panel-2);
  overflow: hidden; margin-bottom: 14px;
}
.wf-progress-bar {
  height: 100%; width: 0%;
  background: linear-gradient(90deg, var(--accent), #ffd35c);
  border-radius: 999px; transition: width 0.35s ease;
}

/* Found words */
.wf-found {
  border: 1px solid var(--line); border-radius: 12px;
  background: var(--panel); margin-bottom: 16px; overflow: hidden;
}
.wf-found-toggle {
  width: 100%; display: flex; align-items: center; justify-content: space-between;
  padding: 12px 16px; background: none; border: 0; color: var(--text);
  font-size: 14px; font-weight: 600;
}
.wf-chevron { color: var(--muted); transition: transform 0.2s ease; }
.wf-found--open .wf-chevron { transform: rotate(180deg); }
.wf-found-list {
  display: none; flex-wrap: wrap; gap: 6px;
  padding: 0 14px 14px; max-height: 160px; overflow-y: auto;
}
.wf-found--open .wf-found-list { display: flex; }
.wf-word {
  font-size: 13px; padding: 3px 9px; border-radius: 999px;
  background: var(--panel-2); color: var(--text); text-transform: lowercase;
}
.wf-word::first-letter { text-transform: uppercase; }
.wf-word--pan {
  background: linear-gradient(120deg, var(--accent), #ffd35c);
  color: #241a02; font-weight: 700;
}

/* Current word input */
.wf-input {
  min-height: 44px;
  display: flex; align-items: center; justify-content: center;
  gap: 1px; margin: 6px 0 4px;
  font-size: 30px; font-weight: 800; letter-spacing: 1px;
  text-transform: uppercase; min-height: 44px;
}
.wf-ch { color: var(--text); }
.wf-ch--center { color: var(--accent); }
.wf-ch--bad { color: #ff6b8b; }
.wf-caret {
  display: inline-block; width: 3px; height: 30px;
  background: var(--accent); margin-left: 2px;
  animation: wf-blink 1s steps(2, start) infinite;
}
@keyframes wf-blink { 0%,50% { opacity: 1; } 50.01%,100% { opacity: 0; } }
.wf-shake { animation: wf-shake 0.32s ease; }
@keyframes wf-shake {
  0%,100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-5px); }
  80% { transform: translateX(5px); }
}

/* Toast */
.wf-toast {
  align-self: center; margin: 2px auto 8px;
  padding: 6px 16px; border-radius: 999px;
  background: var(--panel); border: 1px solid var(--line);
  font-size: 14px; font-weight: 700; color: var(--text);
  opacity: 0; transform: translateY(-4px); pointer-events: none;
  min-height: 0;
}
.wf-toast--show { animation: wf-toast 1.4s ease forwards; }
.wf-toast--good { border-color: var(--accent); color: #ffe08a; }
.wf-toast--bad { border-color: #ff6b8b; color: #ff9db1; }
@keyframes wf-toast {
  0% { opacity: 0; transform: translateY(-4px); }
  12% { opacity: 1; transform: translateY(0); }
  80% { opacity: 1; transform: translateY(0); }
  100% { opacity: 0; transform: translateY(-4px); }
}

/* Hive */
.wf-hive {
  position: relative;
  width: min(84vw, 320px);
  aspect-ratio: 1 / 1;
  margin: 6px auto 14px;
}
.wf-hex {
  position: absolute;
  display: flex; align-items: center; justify-content: center;
  border: 0; padding: 0;
  font-size: 26px; font-weight: 800; text-transform: uppercase;
  color: var(--text);
  background: var(--panel-2);
  clip-path: polygon(25% 0, 75% 0, 100% 50%, 75% 100%, 25% 100%, 0 50%);
  transition: transform 0.08s ease, filter 0.08s ease;
  cursor: pointer; user-select: none;
}
.wf-hex:active { transform: scale(0.92); filter: brightness(1.15); }
.wf-hex--center { background: linear-gradient(135deg, var(--accent), #ffcf4d); color: #241a02; }

/* Controls */
.wf-controls {
  display: flex; align-items: center; justify-content: center; gap: 12px;
  margin-top: auto;
}
.wf-btn {
  border: 1px solid var(--line); background: var(--panel-2);
  color: var(--text); padding: 13px 22px; border-radius: 999px;
  font-size: 15px; font-weight: 700;
}
.wf-btn:active { transform: scale(0.96); }
.wf-btn--round { padding: 13px; width: 48px; height: 48px; font-size: 20px; line-height: 1; }
.wf-btn--primary { background: linear-gradient(120deg, var(--accent), #ffcf4d); border-color: transparent; color: #241a02; }

.wf-newpuzzle {
  margin: 14px auto 2px; display: block;
  background: none; border: 0; color: var(--muted);
  font-size: 13px; text-decoration: underline; padding: 6px;
}

/* Wortify: max-score label + seed sharing */
.wf-max { color: var(--muted); font-weight: 600; font-size: 15px; }
.wf-seedbar {
  display: flex; gap: 8px; justify-content: center; align-items: center;
  margin-top: 14px; flex-wrap: wrap;
}
.wf-seed {
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  font-size: 12.5px; font-weight: 600; padding: 7px 14px; border-radius: 999px;
}
.wf-seed b { color: var(--accent); letter-spacing: 1px; }
.wf-seed:active { transform: scale(0.97); }
.wf-seed--load { color: var(--text); }

/* ===== Sudoku ========================================================== */
.sd-game { max-width: 480px; margin: 0 auto; display: flex; flex-direction: column;
  min-height: 100%; }
.sd-topbar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.sd-info { display: flex; align-items: center; gap: 12px; }
.sd-diff-tag { font-size: 13px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.05em; }
.sd-time { font-size: 20px; font-weight: 800; font-variant-numeric: tabular-nums; min-width: 52px; text-align: right; }

.sd-continue { flex-direction: column; gap: 2px; }
.sd-continue-sub { font-size: 12px; font-weight: 600; opacity: 0.85; }

/* Board */
.sd-board {
  --sd-thin: #2b3160;
  --sd-strong: #55609c;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
  aspect-ratio: 1 / 1;
  width: 100%;
  border: 2px solid var(--sd-strong);
  border-radius: 10px;
  overflow: hidden;
  background: var(--bg-2);
  touch-action: manipulation;
}
.sd-cell {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  border-right: 1px solid var(--sd-thin);
  border-bottom: 1px solid var(--sd-thin);
  font-size: clamp(18px, 5.4vw, 26px); font-weight: 600;
  color: var(--accent);
  cursor: pointer; user-select: none;
  background: transparent;
}
.sd-cell.sd-br { border-right: 2px solid var(--sd-strong); }
.sd-cell.sd-bb { border-bottom: 2px solid var(--sd-strong); }
.sd-given { color: var(--text); font-weight: 800; }
.sd-peer { background: rgba(255,255,255,0.045); }
.sd-same { background: rgba(94,199,168,0.20); }
.sd-sel { background: rgba(94,199,168,0.34); box-shadow: inset 0 0 0 2px var(--accent); }
.sd-conflict { color: #ff6b8b !important; background: rgba(255,107,139,0.16); }

.sd-notes {
  display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr);
  width: 100%; height: 100%; padding: 2px;
}
.sd-notes span {
  display: flex; align-items: center; justify-content: center;
  font-size: clamp(8px, 2.1vw, 11px); font-weight: 600; color: var(--muted);
}

/* Action row */
.sd-actions { display: flex; justify-content: space-between; gap: 8px; margin: 16px 0 10px; }
.sd-action {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: var(--panel); border: 1px solid var(--line); color: var(--muted);
  border-radius: 12px; padding: 9px 4px; font-size: 12px; font-weight: 600;
}
.sd-action:active { transform: scale(0.96); }
.sd-action-ic { font-size: 19px; line-height: 1; color: var(--text); }
.sd-action--on { border-color: var(--accent); color: var(--accent); }
.sd-action--on .sd-action-ic { color: var(--accent); }

/* Number pad */
.sd-pad { display: grid; grid-template-columns: repeat(9, 1fr); gap: 5px; margin-top: auto; }
.sd-num {
  position: relative; aspect-ratio: 3 / 4;
  background: var(--panel-2); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; font-weight: 800; display: flex; align-items: center; justify-content: center;
}
.sd-num:active { transform: scale(0.94); }
.sd-num-d { font-size: clamp(18px, 5vw, 24px); }
.sd-num-left {
  position: absolute; bottom: 2px; right: 0; left: 0; text-align: center;
  font-size: 10px; font-weight: 600; color: var(--muted);
}
.sd-num--done { opacity: 0.32; }

@media (max-width: 380px) {
  .sd-action { font-size: 11px; }
}

/* ===== Geo-Quiz ======================================================== */
.geo-menu-inner { max-width: 460px; }
.geo-lang { display: inline-flex; gap: 4px; margin-bottom: 18px; background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 3px; }
.geo-lang button { background: none; border: 0; color: var(--muted); padding: 6px 16px; border-radius: 999px; font-size: 13px; font-weight: 700; }
.geo-lang button.on { background: var(--accent); color: #06121a; }
.geo-mode-list { display: grid; gap: 10px; }
.geo-mode {
  display: flex; align-items: center; justify-content: space-between;
  padding: 15px 18px; border-radius: 13px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); border-left: 4px solid var(--accent);
}
.geo-mode:active { transform: scale(0.98); }
.geo-mode-name { font-size: 16px; font-weight: 700; }
.geo-mode-meta { font-size: 12px; color: var(--muted); }

.geo-game { display: flex; flex-direction: column; height: 100%; max-width: 760px; margin: 0 auto; }
.geo-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 8px; }
.geo-stats { display: flex; gap: 8px; }
.geo-stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 12px; font-size: 14px; font-weight: 800; font-variant-numeric: tabular-nums;
}
.geo-stat--bad { color: #ff8fa3; }

.geo-prompt {
  text-align: center; font-size: 22px; padding: 10px 12px; margin-bottom: 8px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 13px;
}
.geo-find { color: var(--muted); font-size: 15px; }
.geo-prompt b { color: var(--accent); }

.geo-mapwrap {
  position: relative; flex: 1; min-height: 0;
  border: 1px solid var(--line); border-radius: 14px; overflow: hidden;
  background: #17335f;   /* ocean */
  touch-action: none;    /* set on the HTML wrapper (reliable) so map drags never scroll the page */
}
.geo-map { width: 100%; height: 100%; display: block; touch-action: none; cursor: grab; }
.geo-map:active { cursor: grabbing; }

.geo-c {
  fill: #5f77b8; stroke: #26365f; stroke-width: var(--geo-stroke, 0.5px);
  stroke-linejoin: round;
}
.geo-m {
  fill: #ffd76a; stroke: #7a5a12; stroke-width: var(--geo-mstroke, 0.8px); opacity: 0.92;
}
.geo-found { fill: #2fd08a !important; stroke: #12603f; }
.geo-missed { fill: #ff6b8b !important; stroke: #7a2233; }
.geo-fl-ok { fill: #7bf5c0 !important; }
.geo-fl-wrong { fill: #ff9d5c !important; }
.geo-fl-reveal { fill: #ffe27a !important; stroke: #fff; }

.geo-skip {
  position: absolute; left: 8px; bottom: 8px;
  background: rgba(20,26,54,0.9); border: 1px solid var(--line); color: var(--text);
  border-radius: 10px; padding: 10px 14px; font-size: 14px; font-weight: 700;
}
.geo-skip:active { transform: scale(0.96); }
.geo-zoom { position: absolute; right: 8px; bottom: 8px; display: flex; flex-direction: column; gap: 6px; }
.geo-zoom button {
  width: 40px; height: 40px; border-radius: 10px; font-size: 20px; font-weight: 800;
  background: rgba(20,26,54,0.9); border: 1px solid var(--line); color: var(--text);
}
.geo-zoom button:active { transform: scale(0.94); }

.geo-toast {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  padding: 7px 16px; border-radius: 999px; font-weight: 800; font-size: 15px;
  background: rgba(12,22,51,0.92); border: 1px solid var(--line); color: var(--text);
  opacity: 0; pointer-events: none; white-space: nowrap;
}
.geo-toast--good { border-color: #34c78a; color: #7bf5c0; }
.geo-toast--bad { border-color: #ff6b8b; color: #ff9db1; }
.geo-toast--show { animation: geo-toast 1.3s ease forwards; }
@keyframes geo-toast {
  0% { opacity: 0; transform: translate(-50%, -6px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -6px); }
}

/* ===== Tower Defense =================================================== */
.td-maplist { display: grid; gap: 10px; }
.td-mapbtn {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-radius: 13px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text); border-left: 4px solid #e0a34e;
}
.td-mapbtn:active { transform: scale(0.98); }
.td-mapbtn-name { font-size: 17px; font-weight: 700; }
.td-mapbtn-meta { font-size: 12px; color: var(--muted); }

/* Full-screen field; all UI floats over the canvas */
.td-game { position: relative; height: 100%; overflow: hidden; background: #12211a; touch-action: none; }
.td-game canvas { position: absolute; inset: 0; display: block; touch-action: none; }

.td-hud {
  position: absolute; top: 6px; left: 0; right: 0; z-index: 3;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 0 8px; pointer-events: none;
}
.td-hud > * { pointer-events: auto; }
.td-stats { display: flex; align-items: center; gap: 6px; }
.td-stat {
  background: rgba(18,26,20,0.85); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 10px; font-size: 13px; font-weight: 700; font-variant-numeric: tabular-nums;
}
.td-life b { color: #ff8fa3; } .td-gold b { color: #ffd35c; }
.td-speed {
  background: rgba(38,44,82,0.9); border: 1px solid var(--line); color: var(--text);
  border-radius: 999px; padding: 5px 11px; font-size: 13px; font-weight: 800;
}
.td-speed:active { transform: scale(0.95); }
.td-hud .bk-back { background: rgba(18,26,20,0.85); }

.td-toast {
  position: absolute; top: 46px; left: 50%; transform: translateX(-50%); z-index: 4;
  padding: 6px 14px; border-radius: 999px; font-size: 13px; font-weight: 700;
  background: rgba(12,20,16,0.92); border: 1px solid var(--line); color: var(--text);
  opacity: 0; pointer-events: none; white-space: nowrap;
}
.td-toast--show { animation: td-toast 1.6s ease forwards; }
@keyframes td-toast { 0%{opacity:0;transform:translate(-50%,-6px);} 12%{opacity:1;transform:translate(-50%,0);} 80%{opacity:1;} 100%{opacity:0;} }

/* Floating wave controls (bottom) */
.td-controls { position: absolute; left: 0; right: 0; bottom: 12px; z-index: 3; display: flex; justify-content: center; pointer-events: none; }
.td-controls > * { pointer-events: auto; }
.td-start {
  padding: 13px 26px; border-radius: 999px; border: 0;
  background: linear-gradient(120deg, #e0a34e, #ffb454); color: #241a02;
  font-size: 16px; font-weight: 800; box-shadow: 0 6px 18px rgba(0,0,0,0.4);
}
.td-start:active { transform: scale(0.97); }
.td-wavebar {
  background: rgba(12,20,16,0.85); border: 1px solid var(--line); color: var(--muted);
  border-radius: 999px; padding: 9px 18px; font-size: 14px; font-weight: 700;
}
.td-wavebar b { color: var(--text); }

/* Hovering build / upgrade popover */
.td-pop {
  position: absolute; z-index: 5; width: 236px;
  background: rgba(20,30,24,0.97); border: 1px solid var(--line); border-radius: 14px;
  padding: 10px; box-shadow: 0 10px 30px rgba(0,0,0,0.55); backdrop-filter: blur(4px);
}
.td-pop-title { font-size: 12px; font-weight: 700; color: var(--muted); margin: 0 2px 8px; text-transform: uppercase; letter-spacing: 0.04em; }
.td-shop { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; }
.td-buy {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 8px 3px; border-radius: 11px; border: 1px solid var(--line);
  background: var(--panel); color: var(--text);
}
.td-buy:active { transform: scale(0.95); }
.td-buy--no { opacity: 0.4; }
.td-buy-ic { width: 32px; height: 32px; border-radius: 9px; display: flex; align-items: center; justify-content: center; font-size: 17px; }
.td-buy-name { font-size: 10.5px; font-weight: 600; text-align: center; line-height: 1.05; }
.td-buy-cost { font-size: 11.5px; font-weight: 800; color: #ffd35c; }

.td-tower-info { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.td-tower-txt { display: flex; flex-direction: column; }
.td-tower-txt b { font-size: 15px; }
.td-tower-txt span { font-size: 12px; color: var(--muted); }
.td-target { display: flex; align-items: center; gap: 5px; margin-bottom: 9px; }
.td-target > span { font-size: 12px; color: var(--muted); }
.td-tbtn { flex: 1; padding: 6px 4px; border-radius: 9px; border: 1px solid var(--line); background: var(--panel); color: var(--muted); font-size: 12px; font-weight: 700; }
.td-tbtn.on { background: var(--accent); border-color: transparent; color: #06121a; }
.td-tower-actions { display: flex; gap: 7px; }
.td-up, .td-sell { flex: 1; padding: 12px; border-radius: 11px; border: 1px solid var(--line); font-size: 13px; font-weight: 800; }
.td-up { background: linear-gradient(120deg, #5ec7a8, #4fc3f7); border-color: transparent; color: #06121a; }
.td-sell { background: var(--panel-2); color: var(--text); }
.td-up:active, .td-sell:active { transform: scale(0.97); }

/* ===== Länder-Gitter =================================================== */
.grid-game { display: flex; flex-direction: column; height: 100%; max-width: 560px; margin: 0 auto; position: relative; }
.grid-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.grid-info { display: flex; gap: 7px; }
.grid-stat {
  background: var(--panel); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 11px; font-size: 13px; font-weight: 700;
}
.grid-score b { color: var(--accent); }

.grid-board {
  display: grid;
  grid-template-columns: 0.85fr 1fr 1fr 1fr;
  grid-template-rows: auto 1fr 1fr 1fr;
  gap: 5px; flex: 1; min-height: 0;
}
.grid-corner { }
.grid-head {
  display: flex; align-items: center; justify-content: center; text-align: center;
  background: var(--panel-2); border: 1px solid var(--line); border-radius: 10px;
  font-size: 11.5px; font-weight: 700; line-height: 1.15; padding: 5px 4px; color: var(--text);
}
.grid-head--col { min-height: 52px; }
.grid-head--row { }

.grid-cell {
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  background: var(--panel); border: 1px solid var(--line); border-radius: 12px; color: var(--text);
  padding: 4px; overflow: hidden;
}
.grid-cell:active { transform: scale(0.97); }
.grid-cell--sel { border-color: var(--accent); box-shadow: inset 0 0 0 2px var(--accent); background: rgba(94,199,168,0.12); }
.grid-cell--filled { background: rgba(94,199,168,0.16); border-color: #34734f; }
.grid-flag { font-size: 26px; line-height: 1; }
.grid-cname { font-size: 11px; font-weight: 700; text-align: center; line-height: 1.05; }
.grid-rarity { font-size: 10px; font-weight: 800; color: var(--accent); }

.grid-inputbar { display: flex; gap: 8px; margin-top: 12px; }
.grid-input {
  flex: 1; background: var(--panel); border: 1px solid var(--line); border-radius: 12px;
  color: var(--text); font-size: 16px; padding: 13px 14px; outline: none;
}
.grid-input:focus { border-color: var(--accent); }
.grid-submit {
  padding: 0 22px; border-radius: 12px; border: 0; font-size: 15px; font-weight: 800;
  background: linear-gradient(120deg, var(--accent), #4fc3f7); color: #06121a;
}
.grid-submit:active { transform: scale(0.97); }
.grid-again { width: 100%; padding: 14px; border-radius: 12px; border: 0; font-size: 15px; font-weight: 800;
  background: linear-gradient(120deg, var(--accent), #4fc3f7); color: #06121a; }

.grid-actions { display: flex; justify-content: center; gap: 16px; margin-top: 12px; }
.grid-linkbtn { background: none; border: 0; color: var(--muted); font-size: 13px; text-decoration: underline; padding: 4px; }

.grid-hints { text-align: left; margin: 4px 0 18px; max-height: 150px; overflow-y: auto; }
.grid-hint { font-size: 12.5px; color: var(--muted); padding: 3px 0; }
.grid-hint b { color: var(--text); font-weight: 600; }

.grid-toast {
  position: absolute; top: 52px; left: 50%; transform: translateX(-50%); z-index: 5;
  padding: 7px 16px; border-radius: 999px; font-weight: 800; font-size: 14px;
  background: rgba(20,26,40,0.94); border: 1px solid var(--line); color: var(--text);
  opacity: 0; pointer-events: none; white-space: nowrap;
}
.grid-toast--good { border-color: var(--accent); color: #9ef0cd; }
.grid-toast--bad { border-color: #ff6b8b; color: #ff9db1; }
.grid-toast--show { animation: grid-toast 1.5s ease forwards; }
@keyframes grid-toast { 0%{opacity:0;transform:translate(-50%,-6px);} 12%{opacity:1;transform:translate(-50%,0);} 80%{opacity:1;} 100%{opacity:0;} }
