*{box-sizing:border-box;margin:0;padding:0;font-family:system-ui,-apple-system,"Segoe UI",Arial,sans-serif}

/* ═══════════════════════════════════════════════════════
   PALETTE
   One place to shift the whole look. The old background sat at #0b1220,
   which reads black rather than navy on most phone screens; these are the
   same hues pushed up in lightness and blue saturation so the page is
   visibly BLUE, and the panels lift off it instead of melting into it.
   Category colours (data.js) are deliberately NOT touched — the chips carry
   their letter codes, which is what actually distinguishes them.
   ═══════════════════════════════════════════════════════ */
:root{
  --navy-0:#31578f;      /* top of the page glow  */
  --navy-1:#21406e;      /* mid                    */
  --navy-2:#162c4f;      /* bottom / deepest       */
  --panel-a:rgba(44,73,117,.82);
  --panel-b:rgba(26,47,82,.88);
  --line:rgba(125,211,252,.22);
  --line-soft:rgba(125,211,252,.12);
  --ink:#e8f0fb;
  --ink-dim:#a9c0dd;
  --ink-faint:#7d97ba;
  --cyan:#38d9f0;
  --pink:#f472b6;
  --gold:#fbbf24;
}

/* Page — blueprint grid over a navy glow. background-attachment:fixed keeps the
   glow anchored to the viewport so scrolling doesn't drag a seam through it. */
body{
  background:
    linear-gradient(rgba(125,211,252,.075) 1px,transparent 1px) 0 0/40px 40px,
    linear-gradient(90deg,rgba(125,211,252,.075) 1px,transparent 1px) 0 0/40px 40px,
    radial-gradient(ellipse 130% 85% at 50% -12%,var(--navy-0) 0%,var(--navy-1) 42%,var(--navy-2) 100%);
  background-attachment:fixed,fixed,fixed;
  color:var(--ink);min-height:100vh;padding:16px;
  /* SAFE AREA. Android 15 (API 35) and up force apps edge-to-edge and no longer let
     them opt out, so since the targetSdk 36 migration the WebView draws UNDER the
     status bar and the camera cutout — which put the top bar out of reach on the
     Samsung. The page already sets viewport-fit=cover, so env() reports the real
     insets here. In a desktop browser every inset is 0 and these collapse back to
     the plain values above, so this costs nothing anywhere else. */
  padding-top:max(16px, env(safe-area-inset-top));
  padding-left:max(16px, env(safe-area-inset-left));
  padding-right:max(16px, env(safe-area-inset-right));
}
h1{
  text-align:center;font-size:30px;margin-bottom:4px;letter-spacing:6px;font-weight:800;
  background:linear-gradient(90deg,#5eead4,#7dd3fc,#c4b5fd);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;
}
.sub{text-align:center;font-size:12px;color:var(--ink-faint);margin-bottom:18px;letter-spacing:2px;text-transform:uppercase;font-family:ui-monospace,"SF Mono",Menlo,Consolas,monospace}
.game{max-width:1280px;margin:0 auto}
.board{display:grid;grid-template-columns:1fr 340px;gap:16px}
.left{display:flex;flex-direction:column;gap:14px}
.panel{
  background:linear-gradient(180deg,var(--panel-a),var(--panel-b));
  border:1px solid var(--line);border-radius:12px;padding:12px;
  box-shadow:0 1px 0 rgba(255,255,255,.07) inset, 0 12px 28px rgba(5,14,30,.38);
}
.panel h2{font-size:11px;text-transform:uppercase;letter-spacing:2px;color:#8fd8ff;margin-bottom:10px;font-weight:700;font-family:ui-monospace,"SF Mono",Menlo,Consolas,monospace}
.row{display:flex;flex-wrap:wrap;gap:8px;align-items:center;justify-content:center;min-height:120px}

/* ───── Element-tile cards ─────
   Now built on a true playing-card footprint: 5:7, the same proportion as a
   poker card, rather than the squarer 108×142 tile they were. Width is the only
   number that changes per context — height follows from aspect-ratio — so a card
   can never end up stretched. */
.card{
  width:94px;aspect-ratio:5/7;border-radius:12px;
  background:
    radial-gradient(ellipse 120% 90% at 50% 0%,#ffffff 0%,#f3f6fb 55%,#dfe6f1 100%);
  color:#0f172a;border:1px solid rgba(15,23,42,.3);
  position:relative;cursor:pointer;transition:transform .15s,box-shadow .15s,border-color .15s;
  flex-shrink:0;padding:5px 6px 5px 11px;display:flex;flex-direction:column;align-items:center;user-select:none;
  overflow:hidden;
  /* outer lift + the thin inner rule that makes it read as a printed card face */
  box-shadow:0 2px 5px rgba(0,0,0,.4),
             inset 0 1px 0 rgba(255,255,255,.9),
             inset 0 0 0 1px rgba(15,23,42,.07),
             inset 0 0 0 4px rgba(255,255,255,.55);
  font-family:ui-monospace,"SF Mono",Menlo,Consolas,monospace;
}
.card::before{
  content:"";position:absolute;left:0;top:0;bottom:0;width:5px;
  background:var(--catcol,#475569);
}

/* Bohr-model watermark — a nucleus with three electron rings, sitting behind the
   symbol. Drawn as an inline SVG so it scales cleanly to every card size and adds no
   HTTP request. Kept at very low opacity and tinted with the card's own category
   colour, so it reads as texture rather than decoration and never fights the type.
   `pointer-events:none` so it can't eat a click meant for the card. */
.card::after{
  content:"";position:absolute;inset:0;pointer-events:none;z-index:0;
  background-image:url("data:image/svg+xml;utf8,\
<svg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'>\
<g fill='none' stroke='%23000' stroke-width='2.2'>\
<ellipse cx='50' cy='50' rx='42' ry='16'/>\
<ellipse cx='50' cy='50' rx='42' ry='16' transform='rotate(60 50 50)'/>\
<ellipse cx='50' cy='50' rx='42' ry='16' transform='rotate(120 50 50)'/>\
</g>\
<g fill='%23000'>\
<circle cx='50' cy='50' r='7'/>\
<circle cx='92' cy='50' r='3.4'/>\
<circle cx='29' cy='13.6' r='3.4'/>\
<circle cx='29' cy='86.4' r='3.4'/>\
</g></svg>");
  background-repeat:no-repeat;
  background-position:center 46%;
  background-size:82% auto;
  opacity:.07;
}
/* The face-down back already has its own ⚛ glyph — don't stack two atoms. */
.card.facedown::after{opacity:1}
/* Keep every real element above the watermark. */
.card .top,.card .sym,.card .nm,.card .aw,.card .cats,.card .info{position:relative;z-index:1}
/* Mini tiles are too small for the rings to read as anything but noise. */
.card.mini::after{background-size:72% auto;opacity:.05}
.card:hover{transform:translateY(-4px);box-shadow:0 12px 24px rgba(0,0,0,.55),inset 0 0 0 4px rgba(255,255,255,.55)}
/* Selected: lifts AND comes forward a little (scale 1.06 — enough to read as "this one
   is out of the row", small enough that five selected cards still don't occlude each
   other or the board). The bigger cue is the next rule: everything NOT selected dims,
   which costs no space at all. */
.card.sel{transform:translateY(-10px) scale(1.06);z-index:5;
  border-color:#22d3ee;outline:2px solid #22d3ee;outline-offset:-2px;
  box-shadow:0 16px 32px rgba(34,211,238,.55),inset 0 0 0 4px rgba(207,250,254,.9)}
#playerHand:has(.card.sel) .card:not(.sel){opacity:.42;filter:saturate(.5)}
/* Headroom so a lifted, scaled-up selected card doesn't ride over the panel heading. */
#playerHand{padding-top:11px}
.card.dragging{opacity:.35}
.card.dropbefore{box-shadow:-4px 0 0 0 #facc15}
.card.dropafter{box-shadow:4px 0 0 0 #facc15}

.card .top{display:flex;justify-content:space-between;align-items:flex-start;width:100%;line-height:1}
.card .anum{font-size:13px;font-weight:700;color:#1e293b}
.card .grp{font-size:13px;font-weight:700;color:#475569;background:rgba(15,23,42,.08);padding:1px 5px;border-radius:3px;letter-spacing:.5px}
.card .sym{font-size:33px;font-weight:800;color:#0f172a;line-height:1;margin-top:5px;letter-spacing:-1px}
.card .nm{font-size:8.5px;text-align:center;color:#475569;font-weight:600;margin-top:3px;font-family:system-ui,sans-serif;letter-spacing:.4px;text-transform:uppercase}
.card .aw{font-size:9px;text-align:center;color:#64748b;margin-top:2px;line-height:1}
.card .cats{display:flex;gap:2px;justify-content:center;margin-top:auto;padding-top:4px;flex-wrap:wrap}
/* Keep the category chips clear of the ⓘ badge in the bottom-right corner. Cards
   without a badge (the toast, the sets list) keep their chips centred. */
.card:has(.info) .cats{padding-right:16px}
.card.mini:has(.info) .cats{padding-right:13px}
/* Colour comes from the category, ink from chipInk() in data.js. Sized up from 8px —
   two rows of chips fit fine, and the single letter is the whole point of the chip. */
.card .chip{font-size:9.5px;padding:1px 5px;border-radius:3px;color:#fff;font-weight:800;letter-spacing:.5px;min-width:20px;text-align:center;line-height:1.35;font-family:ui-monospace,Menlo,Consolas,monospace}

.card.mini{width:58px;padding:4px 4px 4px 8px;border-radius:8px;
  box-shadow:0 2px 4px rgba(0,0,0,.4),inset 0 1px 0 rgba(255,255,255,.9),inset 0 0 0 3px rgba(255,255,255,.5)}
.card.mini::before{width:4px}
.card.mini .sym{font-size:21px;margin-top:3px;letter-spacing:0}
.card.mini .nm{font-size:6.5px;letter-spacing:.2px;margin-top:1px}
.card.mini .aw{display:none}
.card.mini .cats{padding-top:2px;gap:1px}
.card.mini .chip{font-size:7.5px;padding:0 3px;min-width:15px;letter-spacing:0}
.card.mini .top{font-size:8px}
.card.mini .anum{font-size:9px}
.card.mini .grp{font-size:9px;padding:0 3px}

.card.facedown{
  background:
    repeating-linear-gradient(45deg,rgba(255,255,255,.07) 0 6px,transparent 6px 12px),
    linear-gradient(135deg,#2547a8 0%,#7c3aed 100%);
  border-color:#1e3a8a;padding:0;
  box-shadow:0 2px 5px rgba(0,0,0,.45),inset 0 0 0 3px rgba(255,255,255,.14);
}
.card.facedown::before{display:none}
.card.facedown::after{content:"⚛";position:absolute;inset:0;display:flex;align-items:center;justify-content:center;font-size:42px;color:rgba(255,255,255,.55);font-weight:400}
.card.mini.facedown::after{font-size:28px}

/* ───── Deck / discard + controls side-by-side ───── */
.deck-controls{display:grid;grid-template-columns:auto 1fr;gap:18px;align-items:center}
.controls-stack{display:flex;flex-direction:column;gap:8px}
.deckarea{display:flex;gap:14px;align-items:center;justify-content:space-around;padding:14px;background:rgba(12,26,48,.5);border-radius:10px;border:1px dashed var(--line-soft)}
.deckbtn{display:flex;flex-direction:column;align-items:center;gap:5px;cursor:pointer}
.deckbtn .label{font-size:10px;color:var(--ink-dim);letter-spacing:1px;text-transform:uppercase;font-family:ui-monospace,Menlo,Consolas,monospace}
.deckbtn.disabled{opacity:.4;pointer-events:none}
/* The pile you're allowed to take from gets a ring, so the draw phase reads
   without having to parse the turn line. */
.deckbtn.live .card{box-shadow:0 0 0 2px var(--cyan),0 6px 18px rgba(34,211,238,.35)}

/* ───── Controls ───── */
.controls-action{display:flex;gap:6px;justify-content:center;flex-wrap:wrap}
.controls-popup{display:flex;gap:6px;justify-content:center;flex-wrap:wrap}
.controls-game{display:flex;gap:6px;justify-content:center;flex-wrap:wrap}
button{padding:9px 13px;border-radius:8px;border:none;background:#3b82f6;color:#fff;font-weight:700;cursor:pointer;font-size:12px;transition:all .15s;-webkit-tap-highlight-color:transparent;letter-spacing:.3px}
button:hover{background:#2563eb;transform:translateY(-1px)}
button:disabled{background:#3a5170;cursor:not-allowed;transform:none;opacity:.7}
button.danger{background:#dc2626}
button.danger:hover{background:#b91c1c}
button.success{background:#16a34a}
button.success:hover{background:#15803d}
button.tracker{background:#7c3aed}
button.tracker:hover{background:#6d28d9}
button.numtracker{background:#0891b2}
button.numtracker:hover{background:#0e7490}
button.mysets{background:#06b6d4;color:#07223a}
button.mysets:hover{background:#22d3ee}
button.aisets{background:#ec4899}
button.aisets:hover{background:#db2777}
button.log{background:#4d6488}
button.log:hover{background:#3b5273}
button.help{background:#facc15;color:#0f172a}
button.help:hover{background:#eab308}
button.muted{background:#3f567a}
button.muted:hover{background:#334b6d}
button.learn{background:#0ea5e9}
button.learn:hover{background:#0284c7}
button.stats{background:#8b5cf6}
button.stats:hover{background:#7c3aed}
button.scoreref{background:#0d9488}
button.scoreref:hover{background:#0f766e}

/* ───── Turn actions ─────
   These four were all reading as "a button": Play and Discard differed only in shade,
   and End Turn was the same grey as Discard. They do very different things, so they now
   look different — reward, cost, advance, stop — rather than relying on a hue shift.
   That also means they stay distinguishable to a red-green colour-blind player: solid
   vs outlined vs dashed is the primary cue and hue is only a reinforcement. */
button.act-play{background:linear-gradient(180deg,#22c55e,#16a34a);font-size:13px;padding:11px 20px;box-shadow:0 3px 0 #14532d}
button.act-play:hover{background:linear-gradient(180deg,#16a34a,#15803d)}
button.act-play:active{transform:translateY(2px);box-shadow:0 1px 0 #14532d}
button.act-play:disabled{background:#2e4566;box-shadow:none;color:#6c85a8}

button.act-discard{background:transparent;color:#fcd34d;border:2px solid #d97706;padding:10px 16px}
button.act-discard:hover{background:rgba(217,119,6,.25);color:#fde68a}
button.act-discard:disabled{background:transparent;border-color:#2e4566;color:#5c749a}

button.act-end{background:transparent;color:#dbeafe;border:2px solid #5b7aa6;padding:10px 16px}
button.act-end:hover{background:rgba(91,122,166,.35);border-color:#8fb0da}
button.act-end:disabled{background:transparent;border-color:#26405f;color:#5c749a}

/* Finish ends the day, so it sits apart from the three in-turn actions. */
button.act-finish{background:transparent;color:var(--ink-dim);border:1.5px dashed #5b7aa6;
  padding:10px 16px;margin-left:14px;font-size:11px}
button.act-finish:hover{background:rgba(148,178,214,.16);color:var(--ink);border-style:solid}
/* When there is nothing left to score, this becomes the obvious move. */
button.act-finish.ready{background:#7c3aed;color:#fff;border:1.5px solid #a855f7;
  animation:finishpulse 1.6s ease-in-out infinite}
@keyframes finishpulse{0%,100%{box-shadow:0 0 0 0 rgba(168,85,247,.5)}50%{box-shadow:0 0 0 7px rgba(168,85,247,0)}}
button.act-finish:disabled{opacity:.35;animation:none}

/* ───── The turn-action bar (two-player) ─────
   Play Set / Discard / End Turn are the only three things you ever do on a turn, so
   they get their own raised surface instead of sharing a row with nine popups.
   On a wide screen they stack to the RIGHT OF THE DRAW PILE, at the top of the board,
   so they are on screen without scrolling. On phone the same three become a fixed bar
   at the bottom of the viewport, under the thumb. */
.deckrow{display:grid;grid-template-columns:1fr minmax(186px,224px);gap:16px;align-items:stretch}
.deckrow .deckarea{margin:0}
.actionbar{
  display:grid;grid-template-columns:1fr;gap:8px;padding:10px;align-content:center;
  background:linear-gradient(180deg,rgba(49,87,143,.92),rgba(18,36,66,.96));
  border:1px solid var(--line);border-radius:14px;
  box-shadow:0 1px 0 rgba(255,255,255,.08) inset,0 14px 30px rgba(5,14,30,.45);
}
.actionbar button{min-height:48px;font-size:14px;padding:10px 8px;border-radius:10px;line-height:1.15}
/* The Daily has a fourth action, Finish. Stacked on desktop like the other three;
   .act-finish's own margin-left would push it out of the grid, so clear it. */
.actionbar .act-finish{margin-left:0}
.actionbar.four{grid-template-columns:1fr}

/* ───── Inline meld strip (two-player) ─────
   Your own scored sets, as real tiles, sitting between the hand and the action bar.
   It fills the slack the pinned action bar leaves and means your melds are one of
   the things you do NOT have to open a popup to check. */
.meldpanel{display:flex;flex-direction:column;min-height:0}
.meldstrip{display:flex;flex-wrap:wrap;gap:8px;align-content:flex-start;
  overflow-y:auto;flex:1;min-height:64px}
.meldgroup{background:rgba(10,24,45,.55);border:1px solid var(--line-soft);
  border-radius:10px;padding:6px 7px}
.meldgroup .mg-lbl{display:block;font-size:9px;letter-spacing:1px;text-transform:uppercase;
  color:#8fd8ff;font-family:ui-monospace,Menlo,Consolas,monospace;margin-bottom:4px}
.meldgroup .mg-lbl .p{color:var(--gold);font-weight:800}
.meldgroup .mg-cards{display:flex;gap:4px;flex-wrap:wrap}
.meldstrip .card.mini{width:48px;border-radius:7px}
.meldstrip .card.mini .sym{font-size:17px;margin-top:2px}
.meldstrip .card.mini .nm{display:none}
.meldstrip .card.mini .top{font-size:7px}
.meldstrip .card.mini .anum{font-size:8px}
.meldstrip .card.mini .grp{font-size:8px;padding:0 2px}

/* ───── Top bar + drop-down menus ─────
   Categories / Table / Sets / Log are reference material you consult, not moves you
   make, so they live behind one "Strategy" button. Learn / Scoring / Stats / Rules and
   the game-lifecycle buttons are rarer still and sit behind "More". */
.topbar{display:flex;align-items:center;justify-content:space-between;gap:10px;margin-bottom:10px}
.topbar .brand{text-align:left;min-width:0}
.topbar h1{text-align:left;font-size:24px;letter-spacing:4px;margin:0}
.topbar .sub{text-align:left;margin:2px 0 0;font-size:10px}
/* The wordmark is a link back to elerummy.com on the web build only; see the
   script at the foot of index.html / game.html. It must look like the wordmark,
   not like a link, until you point at it. */
.topbar h1 .homelink{color:inherit;text-decoration:none}
.topbar h1 .homelink:hover{color:#7fe3f7;text-decoration:none}
.topbar .tools{display:flex;gap:8px;align-items:center;flex-shrink:0}

/* Above the scrim, so tapping the button a second time closes its own menu
   instead of the scrim swallowing the tap. */
.menuwrap{position:relative;z-index:90}
.menubtn{display:flex;align-items:center;gap:6px;padding:10px 14px;border-radius:10px;
  background:linear-gradient(180deg,rgba(66,104,160,.95),rgba(32,58,98,.95));
  border:1px solid var(--line);color:var(--ink);font-size:12px;font-weight:700;letter-spacing:.5px}
.menubtn:hover{background:linear-gradient(180deg,rgba(84,126,186,.95),rgba(42,72,118,.95));transform:none}
.menubtn .caret{font-size:9px;opacity:.75}
/* .go marks a button in the top bar that GOES somewhere rather than opening a menu —
   tinted so it doesn't read as a third drop-down. */
.menubtn.go{background:linear-gradient(180deg,#22d3ee,#0891b2);color:#07223a;
  border-color:rgba(34,211,238,.6)}
.menubtn.go:hover{background:linear-gradient(180deg,#67e8f9,#0e9bb8)}
/* .back is the way home — same neutral chrome as the menus, with the arrow doing
   the work. Quieter than .go on purpose: leaving is a choice, returning is a path. */
.menubtn.back{color:#bdf3fb;border-color:rgba(56,217,240,.35)}
.menubtn.back:hover{border-color:var(--cyan)}
.menubtn.open{border-color:var(--cyan);box-shadow:0 0 0 2px rgba(56,217,240,.28)}

.menu{
  position:absolute;right:0;top:calc(100% + 8px);z-index:80;min-width:216px;
  background:linear-gradient(180deg,#2c4c7d,#16294a);
  border:1px solid var(--line);border-radius:14px;padding:6px;
  box-shadow:0 22px 50px rgba(3,10,24,.65);display:none;
}
.menu.open{display:block}
.menu .hd{font-size:9px;letter-spacing:2px;text-transform:uppercase;color:#8fd8ff;
  padding:8px 12px 4px;font-family:ui-monospace,Menlo,Consolas,monospace}
.menu .sep{height:1px;background:var(--line-soft);margin:5px 6px}
.menu button{display:flex;width:100%;align-items:center;gap:10px;background:transparent;
  color:var(--ink);padding:10px 12px;border-radius:9px;font-size:13px;font-weight:600;
  letter-spacing:.2px;text-align:left}
.menu button:hover{background:rgba(125,211,252,.16);transform:none}
.menu button .dot{width:9px;height:9px;border-radius:50%;flex:0 0 9px}
.menu button .ct{margin-left:auto;font-size:11px;font-weight:800;color:#0b1b30;
  background:var(--cyan);border-radius:999px;padding:1px 8px;font-family:ui-monospace,Menlo,Consolas,monospace}
.menu .rowitem{display:flex;align-items:center;gap:8px;padding:8px 12px;font-size:12px;color:var(--ink-dim)}
.menu .rowitem select{flex:1}
.scrim{position:fixed;inset:0;z-index:70;display:none;background:rgba(4,12,26,0);transition:background .18s}
.scrim.open{display:block;background:rgba(4,12,26,.5)}

/* ───── AI play toast ─────
   The AI's whole turn — what it took, what it melded, what it threw away — shown
   once, over the board, then faded. This is what removes the need to open Categories
   or Table just to find out what happened. */
.aitoast{
  /* Below .modal (z-index 100) — a result or tracker popup always wins. */
  position:fixed;left:50%;top:10px;transform:translate(-50%,-16px);z-index:95;
  width:max-content;min-width:250px;max-width:min(94vw,470px);
  background:linear-gradient(180deg,rgba(74,35,88,.97),rgba(35,20,54,.97));
  border:1px solid rgba(244,114,182,.5);border-radius:16px;padding:11px 14px;
  box-shadow:0 20px 48px rgba(3,10,24,.7);
  opacity:0;transition:opacity .22s ease,transform .22s ease;
  /* NEVER blocks the board. A tap goes straight through to whatever is underneath —
     the draw pile, the discard, a card — and a document-level listener dismisses the
     toast on that same tap. So you can keep drawing at your own pace while the AI's
     last turn is still on screen, on phone exactly as on desktop. */
  pointer-events:none;
}
.aitoast.show{opacity:1;transform:translate(-50%,0)}
.aitoast .hd{font-size:10px;letter-spacing:2px;text-transform:uppercase;color:var(--pink);
  font-family:ui-monospace,Menlo,Consolas,monospace;display:flex;justify-content:space-between;
  align-items:center;gap:12px;margin-bottom:6px}
.aitoast .hd .pts{color:var(--gold);font-weight:800;letter-spacing:.5px}
.aitoast .ln{font-size:12px;color:#f0dcf6;line-height:1.55;text-align:center}
.aitoast .ln b{color:#fff}
.aitoast .cards{display:flex;gap:5px;flex-wrap:wrap;margin:8px 0 3px;justify-content:center}
.aitoast .setname{font-size:11px;color:#fbcfe8;text-align:center;margin-top:5px;
  font-family:ui-monospace,Menlo,Consolas,monospace;letter-spacing:.5px}
.aitoast .tap{font-size:9px;color:rgba(249,168,212,.6);text-align:center;margin-top:7px;letter-spacing:1px;text-transform:uppercase}

/* ⓘ element-info badge on cards */
.card .info{
  position:absolute; bottom:4px; right:4px; width:17px; height:17px; padding:0;
  border-radius:50%; background:rgba(15,23,42,.6); color:#e2e8f0;
  border:1px solid rgba(148,163,184,.55); font:italic 700 11px/1 Georgia,serif;
  display:flex; align-items:center; justify-content:center; cursor:pointer; z-index:4;
}
.card .info:hover{ background:#0ea5e9; color:#fff; transform:none; }

/* Difficulty picker */
.diff-picker{display:inline-flex;align-items:center;gap:6px;font-size:11px;color:var(--ink-dim);font-weight:600;letter-spacing:.3px}
.diff-picker select{background:#1c3559;color:var(--ink);border:1px solid #4d6b96;border-radius:8px;padding:8px 10px;font-size:12px;font-weight:700;cursor:pointer}
.diff-picker select:hover{border-color:#7da3d0}

/* ───── Score + turn indicator ───── */
.score{display:flex;justify-content:space-around;align-items:center;background:rgba(10,24,45,.6);padding:10px;border-radius:8px;margin-bottom:10px;border:1px solid var(--line-soft)}
.score .player{text-align:center}
.score .player .label{font-size:10px;color:var(--ink-dim);text-transform:uppercase;letter-spacing:2px;font-family:ui-monospace,Menlo,Consolas,monospace}
.score .player .val{font-size:30px;font-weight:800;color:var(--cyan);font-family:ui-monospace,Menlo,Consolas,monospace;letter-spacing:-1px}
.score .player.ai .val{color:var(--pink)}
.scoremeta{text-align:center;font-size:11px;color:var(--ink-dim);margin-bottom:8px;font-family:ui-monospace,Menlo,Consolas,monospace}
.turnind{text-align:center;font-size:13px;padding:8px;border-radius:8px;margin-bottom:10px;font-weight:600;letter-spacing:.5px}
.turnind.player{background:linear-gradient(90deg,rgba(34,211,238,.28),rgba(34,211,238,.1));color:#bdf3fb;border:1px solid rgba(34,211,238,.38)}
.turnind.ai{background:linear-gradient(90deg,rgba(236,72,153,.28),rgba(236,72,153,.1));color:#fbcfe8;border:1px solid rgba(236,72,153,.38)}
.turnind.gameover{background:linear-gradient(90deg,rgba(250,204,21,.24),rgba(250,204,21,.08));color:#fde68a;border:1px solid rgba(250,204,21,.4)}
.turnind.gameover a{color:#67e8f9;font-weight:700;text-decoration:underline}

/* ───── Log + sets ───── */
.log-box{max-height:260px;overflow-y:auto;font-size:12px;background:rgba(10,24,45,.6);padding:10px;border-radius:8px;line-height:1.55}
.log-box .entry{padding:3px 0;border-bottom:1px solid var(--line-soft)}
.log-box .entry.you{color:#7fe9f7}
.log-box .entry.ai{color:#f9a8d4}
.log-box .entry.score{color:#fcd34d;font-weight:600}
.set{background:rgba(10,24,45,.6);padding:8px;border-radius:8px;margin-bottom:8px;border:1px solid var(--line-soft)}
.set .meta{font-size:11px;color:var(--ink-dim);margin-bottom:4px;display:flex;justify-content:space-between;font-family:ui-monospace,Menlo,Consolas,monospace}
.set .meta .pts{color:var(--gold);font-weight:700}
.set .cards{display:flex;gap:4px;flex-wrap:wrap}
.empty{color:#6b86ab;font-style:italic;font-size:12px;text-align:center;padding:20px}

/* ───── Modals / popups ───── */
.modal{position:fixed;inset:0;background:rgba(4,12,26,.78);display:flex;align-items:center;justify-content:center;z-index:100;padding:20px;backdrop-filter:blur(4px)}
.modal .box{background:linear-gradient(180deg,#2a4771,#14284a);padding:22px;border-radius:16px;max-width:520px;text-align:center;border:1px solid var(--line);max-height:90vh;overflow-y:auto;box-shadow:0 24px 64px rgba(3,10,24,.7)}
.modal .box.wide{max-width:780px}
.modal .box.xwide{max-width:920px}
.modal h2{font-size:22px;margin-bottom:10px;background:linear-gradient(90deg,#5eead4,#f9a8d4);-webkit-background-clip:text;-webkit-text-fill-color:transparent;background-clip:text;letter-spacing:2px}
.modal p{margin-bottom:8px;color:#cfe0f3;line-height:1.6}
.modal .big{font-size:32px;font-weight:800;margin:14px 0;font-family:ui-monospace,Menlo,Consolas,monospace}
.tracker-table{width:100%;font-size:12px;color:#cfe0f3;border-collapse:collapse}
.tracker-table th{text-align:left;color:var(--ink-dim);font-size:11px;font-weight:600;padding:4px 0;border-bottom:1px solid #3c5a85}
.tracker-table td{padding:3px 0}
.tracker-table th.c, .tracker-table td.c{text-align:center}

/* Periodic-table popup */
.ptable{display:grid;grid-template-columns:repeat(18,1fr);gap:2px;font-family:ui-monospace,Menlo,Consolas,monospace}
.ptable .cell{aspect-ratio:1;border-radius:3px;display:flex;flex-direction:column;align-items:center;justify-content:center;font-size:9px;line-height:1;padding:2px;color:#fff;position:relative}
.ptable .cell .num{font-size:7px;color:rgba(255,255,255,.7);font-weight:400}
.ptable .cell .sym{font-size:11px;font-weight:700;color:#fff;display:block}
.ptable .cell.seen{background:#1d3357;color:#4f6c95;opacity:.45}
.ptable .cell.seen .sym{color:#6b88b1}
.ptable .cell.unseen{background:#38d9f0;color:#0f172a}
.ptable .cell.unseen .sym{color:#0f172a}
.ptable .cell.unseen .num{color:#0f172a;opacity:.7}
.ptable .cell.notindeck{background:#12233f;border:1px dashed #33507a;opacity:.3}
.ptable .cell.notindeck .sym,.ptable .cell.notindeck .num{color:#33507a}
.ptable .cell.spacer{background:transparent}
.ptable .cell.marker{background:#33507a;color:var(--ink-dim);font-style:italic;font-size:9px}

/* ───── Misc ───── */
.legend{display:grid;grid-template-columns:repeat(2,1fr);gap:4px;font-size:11px;margin-top:8px}
.legend .item{display:flex;align-items:center;gap:6px}
.legend .item .sw{width:14px;height:14px;border-radius:3px}
details{margin-top:8px}
summary{cursor:pointer;color:var(--ink-dim);font-size:12px;padding:4px 0}
.hint{background:rgba(34,211,238,.12);border-left:3px solid var(--cyan);padding:8px 12px;font-size:12px;border-radius:4px;margin-bottom:8px;color:#bdf3fb}
/* Sits inside the deck area as a third tile, using the space the two piles leave
   rather than a full-width banner of its own. */
.aiCount{display:flex;align-items:center;justify-content:center;text-align:center;
  font-size:10px;color:#f9a8d4;padding:12px 10px;max-width:108px;line-height:1.6;
  font-family:ui-monospace,Menlo,Consolas,monospace;background:rgba(236,72,153,.13);
  border:1px solid rgba(236,72,153,.3);border-radius:10px;margin:0;
  letter-spacing:1px;text-transform:uppercase;font-weight:700}

/* Desktop shows long button labels; mobile media query swaps to short */
.lbl-short{display:none}
.lbl-long{display:inline}

/* ═══════════════════════════════════════════════════════ */
/* MOBILE (≤900px) — single-screen fit                     */
/* ═══════════════════════════════════════════════════════ */
@media (max-width: 900px){
  body{
    padding:4px 6px 8px;background-size:30px 30px,30px 30px,auto;
    padding-top:calc(4px + env(safe-area-inset-top));
    padding-left:calc(6px + env(safe-area-inset-left));
    padding-right:calc(6px + env(safe-area-inset-right));
  }

  /* Compress header to a single thin line */
  h1{font-size:16px;letter-spacing:3px;margin-bottom:0;line-height:1.1}
  .sub{display:none}

  .game{max-width:100%}
  .board{grid-template-columns:1fr;gap:6px}

  /* Top bar stays one compact line */
  .topbar{margin-bottom:6px;gap:6px}
  .topbar h1{font-size:15px;letter-spacing:2px}
  .topbar .brand{overflow:hidden}
  .topbar .tools{flex-shrink:0}
  .menubtn{padding:8px 11px;font-size:11px;border-radius:9px}
  .menu{min-width:min(78vw,250px);max-height:74vh;overflow-y:auto}
  .menu button{padding:12px 12px;font-size:13px}

  /* Anything marked desktop-only is reachable from the menus instead */
  .deskonly{display:none}

  /* Reorder: score panel on top, hide help/log panels */
  .board > .left:nth-child(2){order:-1}
  .board > .left:nth-child(2) > .panel:nth-child(n+2){display:none}
  .board > .left:nth-child(2) > .panel:first-child{
    /* Sticks below the status bar, not under it. */
    padding:5px 6px;position:sticky;top:env(safe-area-inset-top);z-index:10;
    backdrop-filter:blur(8px);background:rgba(14,30,55,.94);
    border-radius:8px;
  }

  /* Tight score row */
  .score{padding:3px 6px;margin-bottom:3px;border-radius:6px}
  .score .player .val{font-size:20px}
  .score .player .label{font-size:8px;letter-spacing:1px}
  .scoremeta{display:none}
  .turnind{font-size:10px;padding:4px 6px;margin-bottom:0;letter-spacing:.3px}

  /* Hide AI hand panel — accessible via AI Sets popup */
  #aiPanel{display:none}
  .aiCount{padding:8px 6px;font-size:9px;letter-spacing:.5px;max-width:92px;border-radius:8px}

  /* Compact panels */
  .panel{padding:5px 6px;border-radius:8px}
  .panel h2{font-size:9px;margin-bottom:3px;letter-spacing:1px}
  .reorder-hint{display:none}

  /* Mobile: stack deck above controls (override desktop side-by-side grid) */
  .deck-controls{display:block}
  .controls-stack{gap:4px;margin-top:5px}

  /* Deck + discard: smaller, in-row */
  .deckarea{padding:5px;gap:16px;border-radius:6px}
  /* The pile cards were 58px against the hand's ~73px, so a three- or four-chip
     element (Pb, Hg) wrapped its category chips to a third row and the last row was
     cut off by the card edge. They now share the hand's metrics exactly — see the
     grouped selectors below — so a card looks the same wherever it appears. */
  .deckarea .card{width:74px;height:auto}
  .deckarea .card.facedown::after{font-size:34px}
  .deckbtn .label{font-size:8px;letter-spacing:.5px}
  .deckbtn{gap:2px}

  /* Action row — 3 buttons */
  .controls-action{display:grid;grid-template-columns:repeat(3,1fr);gap:4px;margin-top:5px}
  .controls-action button{padding:8px 2px;font-size:11px;border-radius:6px;min-height:38px;line-height:1.1}

  /* On phone the three turn actions leave the deck row and become a fixed thumb bar
     pinned to the bottom of the viewport. position:fixed (not sticky) so it does not
     matter that the markup lives inside the deck panel. The body gets bottom padding
     so nothing ends up hidden underneath it. */
  .deckrow{display:block}
  /* Clear the fixed action bar, plus whatever navigation sits under it. */
  .game,.daily{padding-bottom:calc(80px + max(8px, env(safe-area-inset-bottom)))}
  .actionbar{
    position:fixed;z-index:40;
    left:calc(6px + env(safe-area-inset-left));
    right:calc(6px + env(safe-area-inset-right));
    /* max(), not a sum: with three-button navigation Android reports ~48px here and
       the bar must clear the whole nav bar, or only the top slice of each button is
       tappable and presses feel like they're being ignored. With gesture navigation
       the inset is small and the 8px floor takes over. */
    bottom:max(8px, env(safe-area-inset-bottom));
    grid-template-columns:repeat(3,1fr);gap:6px;padding:8px;border-radius:12px;
    backdrop-filter:blur(8px);
  }
  .actionbar button{min-height:50px;font-size:13px;padding:8px 4px;border-radius:9px}
  /* Game over: three turn actions become two follow-ups. */
  .actionbar.over{grid-template-columns:repeat(2,1fr)}
  /* The Daily's four actions across one thumb bar — tighter type, short labels. */
  .actionbar.four{grid-template-columns:repeat(4,1fr);gap:5px}
  .actionbar.four button{font-size:12px;padding:8px 2px;letter-spacing:0}
  .actionbar.four .act-finish{font-size:11px}

  /* Popup row — 6 narrow buttons (short labels via .lbl-short swap) */
  .lbl-long{display:none}
  .lbl-short{display:inline}
  .controls-popup{display:grid;grid-template-columns:repeat(3,1fr);gap:3px;margin-top:4px}
  .controls-popup button{padding:6px 1px;font-size:10px;border-radius:5px;min-height:32px;line-height:1;letter-spacing:0;font-weight:700}
  .controls-popup button span{font-size:inherit}

  /* New Game + difficulty tucked beside */
  .controls-game{margin-top:3px;align-items:center}
  .controls-game button{padding:5px 8px;font-size:9px;min-height:26px;border-radius:5px;letter-spacing:.5px}
  .diff-picker{font-size:9px;gap:3px}
  .diff-picker select{padding:4px 6px;font-size:10px;border-radius:5px}

  /* Player hand — five across, so nine cards are two rows instead of three and each
     card keeps the 5:7 playing-card shape. Flex (not grid) so the short second row
     centres instead of hanging left. */
  #playerHand{display:flex;flex-wrap:wrap;justify-content:center;gap:5px;min-height:auto;padding:12px 2px 2px}
  #playerHand .card{width:calc(20% - 4px);max-width:78px;height:auto}
  #playerHand .card,.deckarea .card{padding:4px 4px 3px 8px;border-radius:9px}
  #playerHand .card::before,.deckarea .card::before{width:4px}
  #playerHand .card .sym,.deckarea .card .sym{font-size:23px;margin-top:3px;letter-spacing:-.5px}
  #playerHand .card .nm,.deckarea .card .nm{font-size:6.5px;margin-top:1px;letter-spacing:.2px}
  #playerHand .card .aw,.deckarea .card .aw{display:none}
  #playerHand .card .top,.deckarea .card .top{font-size:9px}
  #playerHand .card .anum,.deckarea .card .anum{font-size:10px}
  #playerHand .card .grp,.deckarea .card .grp{font-size:10px;padding:0 3px}
  #playerHand .card .chip,.deckarea .card .chip{font-size:8px;padding:0 3px;min-width:16px;font-weight:800}
  #playerHand .card .cats,.deckarea .card .cats{padding-top:2px;gap:1px}
  #playerHand .card .info,.deckarea .card .info{width:15px;height:15px;font-size:10px;bottom:2px;right:2px}

  /* AI toast — full width under the sticky score strip */
  .aitoast{top:auto;bottom:calc(88px + max(8px, env(safe-area-inset-bottom)));max-width:calc(100vw - 16px);padding:10px 11px;border-radius:14px}
  .aitoast.show{transform:translate(-50%,0)}
  .aitoast .ln{font-size:11.5px}

  /* Modal tighter */
  .modal{padding:6px}
  .modal .box{padding:14px;max-height:94vh}
  .modal .box.wide,.modal .box.xwide{max-width:100%}
  .modal h2{font-size:18px}
  .modal p{font-size:12px}
  .ptable{gap:1px}
  .ptable .cell{font-size:6px;padding:1px;border-radius:2px}
  .ptable .cell .sym{font-size:8px}
  .ptable .cell .num{font-size:5px}
  .ptable .cell.marker{font-size:7px}
  /* Stack tracker tables on phone. Must cover .xwide too — the deck inspector uses it,
     and without this its Categories and Groups tables sit side by side in a 400px box
     and the Groups column runs off the screen. */
  .modal .box.wide > div[style*="grid-template-columns"],
  .modal .box.xwide > div[style*="grid-template-columns"]{grid-template-columns:1fr !important;gap:14px !important}
}

/* ═══════════════════════════════════════════════════════ */
/* NARROW PHONES (≤400px)                                  */
/* Three top-bar controls plus the wordmark stop fitting one line around here —
   on a 360px screen "← Daily" was riding over the ELERUMMY lettering. Trim the
   wordmark and the button padding rather than wrapping to a second row.        */
/* ═══════════════════════════════════════════════════════ */
@media (max-width: 400px){
  .topbar{gap:5px}
  .topbar h1{font-size:13px;letter-spacing:1.2px}
  .topbar .tools{gap:5px}
  .topbar .menubtn{padding:7px 8px;font-size:10px;border-radius:8px}

  /* Hand cards are a percentage of the viewport, so below ~400px they get narrow
     enough that a four-chip element (mercury) can only fit ONE chip per row — four
     rows, and the card's fixed 5:7 height clips the last two. The chips have to
     shrink with the card. These values keep two chips per row down to 320px, so the
     worst case is two rows. */
  #playerHand .card .chip,.deckarea .card .chip{font-size:6.5px;padding:0 1px;min-width:11px}
  .card:has(.info) .cats{padding-right:12px}
  #playerHand .card .info,.deckarea .card .info{width:13px;height:13px;font-size:9px}
}

/* ═══════════════════════════════════════════════════════
   DESKTOP HAND — never more than five across (2026-11-13)
   Mark: nine cards ran 8 + 1 across a laptop screen, a lopsided row with one
   orphan. Capping the hand's width at exactly five cards gives an even 5 + 4
   (or 5 + 5 with ten). Desktop only; phone has its own five-across rule above.
   ═══════════════════════════════════════════════════════ */
@media (min-width: 901px){
  #playerHand{max-width:calc(5 * 94px + 4 * 8px);margin:0 auto}
}
