/* Apex Towers: jungle temple theme. All artwork is drawn here with CSS and inline SVG (original, no image files). */
:root {
  --bg: #0b2512;
  --felt: #1c4a20;
  --felt-dark: #0e2a11;
  --text: #f1efe4;
  --muted: #b9c2ad;
  --accent: #f2c14e;
  --accent-ink: #2a1d00;
  --glow: #a6ff3c;
  --glow-soft: rgba(140, 255, 50, 0.55);
  --good: #8fe05a;
  --bad: #ff6b6b;
  --red: #c4222d;
  --ink: #15191c;
  --stone-hi: #7d867e;
  --stone: #5a635c;
  --stone-lo: #394039;
  --stone-dark: #262c27;
  --line: rgba(255, 255, 255, 0.14);
  --radius: 10px;
  --sal: env(safe-area-inset-left, 0px);
  --sar: env(safe-area-inset-right, 0px);
  --sat: env(safe-area-inset-top, 0px);
  --sab: env(safe-area-inset-bottom, 0px);
  --leaves: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='220' height='220' viewBox='0 0 220 220'%3E%3Cdefs%3E%3Cg id='l'%3E%3Cpath d='M0 0C14-18 46-18 62 0C46 18 14 18 0 0Z'/%3E%3Cpath d='M3 0H58' stroke='%23000' stroke-opacity='.25' stroke-width='1.5'/%3E%3C/g%3E%3C/defs%3E%3Cg fill='%23194d1f'%3E%3Cuse href='%23l' transform='translate(10 30) rotate(25)'/%3E%3Cuse href='%23l' transform='translate(120 10) rotate(110) scale(1.2)'/%3E%3Cuse href='%23l' transform='translate(160 150) rotate(-40)'/%3E%3Cuse href='%23l' transform='translate(30 170) rotate(-100) scale(.9)'/%3E%3C/g%3E%3Cg fill='%232c7a2c'%3E%3Cuse href='%23l' transform='translate(70 90) rotate(-20) scale(1.3)'/%3E%3Cuse href='%23l' transform='translate(190 60) rotate(150)'/%3E%3Cuse href='%23l' transform='translate(100 200) rotate(200) scale(.8)'/%3E%3C/g%3E%3Cg fill='%2346a03a'%3E%3Cuse href='%23l' transform='translate(20 110) rotate(60) scale(.8)'/%3E%3Cuse href='%23l' transform='translate(150 100) rotate(-80) scale(.9)'/%3E%3Cuse href='%23l' transform='translate(200 200) rotate(230) scale(.7)'/%3E%3C/g%3E%3Cg fill='%2387cf4a' fill-opacity='.8'%3E%3Cuse href='%23l' transform='translate(90 40) rotate(80) scale(.55)'/%3E%3Cuse href='%23l' transform='translate(60 150) rotate(10) scale(.6)'/%3E%3C/g%3E%3C/svg%3E");
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; color: var(--text); overflow: hidden; overscroll-behavior: none; }
/* the leaves sit on the root, so they also fill the parts of the screen behind Safari's toolbars */
html {
  background:
    radial-gradient(ellipse at 50% 50%, rgba(10, 40, 14, 0) 30%, rgba(3, 14, 5, 0.75) 100%),
    var(--leaves) 0 0 / 220px 220px,
    var(--leaves) 110px 70px / 330px 330px,
    #0f3615;
}
body {
  /* --gap-fix: see fixGap() in app.js (iOS home-screen apps can be a status bar's height too short) */
  position: fixed; top: 0; left: 0; right: 0; bottom: calc(-1 * var(--gap-fix, 0px)); background: transparent;
  font: 15px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-user-select: none; user-select: none; -webkit-touch-callout: none;
  touch-action: manipulation;
}
/*
 * iPhone Safari shows a blurred copy of the top of the page behind its status bar. Over the leaves that looked
 * like fog, so held upright the top of the page is one plain colour: the home screen gets a solid header bar
 * that runs up to the very top edge, and the other upright screens a plain band that fades into the leaves.
 */
@media (orientation: portrait) {
  body:not([data-screen="home"]):not([data-screen="idle"]):not([data-screen="scape"])::before {
    content: ""; position: fixed; top: 0; left: 0; right: 0; height: calc(var(--sat) + 56px); z-index: 0; pointer-events: none;
    background: linear-gradient(#10141d 0, #10141d calc(var(--sat) + 28px), rgba(16, 20, 29, 0) 100%);
  }
  #screen-home .lobby-head {
    margin: calc(-8px - var(--sat)) calc(-12px - var(--sar)) 12px calc(-12px - var(--sal));
    padding: calc(var(--sat) + 2px + 2vh) calc(var(--sar) + 16px) 8px calc(var(--sal) + 16px);
    border-radius: 0 0 16px 16px; background: #10141d; border-bottom: 1px solid rgba(166, 255, 60, 0.18);
  }
  #screen-home { padding-top: calc(var(--sat) + 8px); }
}
/* Apex Idle is navy blue from edge to edge: also behind the notch, the home bar and Safari's bars */
html:has(body[data-screen="idle"]) { background: #10141d; }
html:has(body[data-screen="scape"]) { background: #17140f; }
input { -webkit-user-select: text; user-select: text; }
.hidden { display: none !important; }

#app { position: absolute; inset: 0; }
.screen { position: absolute; inset: 0; padding: calc(var(--sat) + 8px) calc(var(--sar) + 12px) calc(var(--sab) + 8px) calc(var(--sal) + 12px); }
.screen.center { display: flex; align-items: center; justify-content: center; }

/* carved-stone headings */
h1, h2, h3, .engraved {
  text-transform: uppercase; letter-spacing: 2px; color: #e4e6d8;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.7), 0 1px 0 rgba(255, 255, 255, 0.18);
}
h1 { margin: 0; font-size: 38px; font-weight: 900; line-height: 1; }
h1 span { color: var(--glow); margin-left: 8px; text-shadow: 0 0 10px rgba(140, 255, 50, 0.6), 0 -1px 0 rgba(0, 0, 0, 0.7); }
h1.small { font-size: 20px; }
h2 { margin: 0 0 6px; font-size: 19px; }

/* stone tablet */
.panel, .plaque {
  background:
    radial-gradient(circle at 20% 15%, rgba(255, 255, 255, 0.07), transparent 40%),
    repeating-linear-gradient(115deg, rgba(0, 0, 0, 0.05) 0 2px, transparent 2px 7px),
    linear-gradient(170deg, var(--stone), var(--stone-lo));
  border: 2px solid var(--stone-dark);
  border-radius: var(--radius);
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.16), inset 0 -3px 0 rgba(0, 0, 0, 0.35), 0 6px 18px rgba(0, 0, 0, 0.55);
  padding: 14px 16px;
}
.row { display: flex; gap: 10px; justify-content: center; align-items: center; margin-top: 10px; }
.status { margin: 6px 0; color: var(--muted); text-align: center; min-height: 1.35em; }
.error { color: #ffb0a8; margin: 4px 0; min-height: 1.35em; font-size: 13px; font-weight: 700; }

.btn {
  appearance: none; border: 1px solid rgba(0, 0, 0, 0.55); color: var(--text);
  background: linear-gradient(#4a524b, #30372f);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18), 0 2px 4px rgba(0, 0, 0, 0.4);
  padding: 10px 16px; border-radius: 8px; font: inherit; font-weight: 800; min-height: 44px; cursor: pointer;
}
.btn:active { transform: translateY(1px) scale(0.98); }
.btn.primary {
  background: linear-gradient(#9fe25a, #4f9a2d); color: #102806; border-color: #c8ff8e;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.5), 0 0 12px rgba(140, 255, 50, 0.35), 0 2px 4px rgba(0, 0, 0, 0.4);
}
.btn.ghost { background: rgba(0, 0, 0, 0.25); }
.btn.small { min-height: 34px; padding: 4px 12px; font-size: 13px; }
.btn:disabled { opacity: 0.45; box-shadow: none; cursor: default; }
.btn.primary:disabled { filter: grayscale(1); }

input[type="text"], input[type="password"] {
  width: 100%; min-height: 44px; border-radius: 8px; border: 1px solid rgba(0, 0, 0, 0.6);
  background: rgba(10, 18, 12, 0.55); color: var(--text); padding: 8px 12px; font-size: 16px; /* 16px stops iOS zooming on focus */
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}
input:focus { outline: 2px solid var(--glow); outline-offset: 1px; }
label { display: block; font-size: 12px; color: var(--muted); margin-bottom: 8px; font-weight: 700; }
label input { margin-top: 3px; }

/* ---- auth ---- */
.auth-grid { display: grid; grid-template-columns: 1fr 340px; gap: 28px; align-items: center; width: min(760px, 100%); }
.brand { padding: 18px 20px; background: rgba(5, 20, 8, 0.55); border-radius: 14px; }
.brand p { color: var(--muted); max-width: 30ch; margin: 12px 0 0; }
.tabs { display: flex; gap: 6px; margin-bottom: 10px; }
.tab { flex: 1; appearance: none; background: transparent; color: var(--muted); border: 0; border-bottom: 2px solid transparent; padding: 6px; font: inherit; font-weight: 800; min-height: 36px; }
.tab.active { color: var(--text); border-bottom-color: var(--glow); }
#auth-submit { width: 100%; }

/* ---- lobby ---- */
/* home: one tile per game */
.home { width: min(900px, 100%); display: flex; flex-direction: column; }
.tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 14px; }
.tile {
  appearance: none; font: inherit; color: var(--text); position: relative; cursor: pointer;
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 22px 16px 18px;
  border-radius: 18px; border: 1px solid var(--line); background: rgba(5, 20, 8, 0.62);
  transition: transform 0.15s, box-shadow 0.15s;
}
.tile svg { width: 116px; height: 116px; margin-bottom: 6px; filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.55)); }
.tile .tt { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.tile b { font-size: 20px; font-weight: 900; letter-spacing: 2px; text-transform: uppercase; }
.tile small { color: var(--muted); font-size: 13px; }
.tile.towers { box-shadow: 0 0 0 1px rgba(166, 255, 60, 0.35), 0 0 22px rgba(140, 255, 50, 0.18); }
.tile.towers:hover { box-shadow: 0 0 0 2px var(--glow), 0 0 26px var(--glow-soft); }
.tile:active { transform: scale(0.97); }
.tile.soon { cursor: default; }
.tile.soon svg { opacity: 0.8; filter: grayscale(0.25) drop-shadow(0 6px 12px rgba(0, 0, 0, 0.55)); }
.tile.soon b { color: #d9d4f5; }
.tile .badge {
  position: absolute; top: 12px; right: 12px; font-style: normal; font-weight: 900; font-size: 11px;
  letter-spacing: 1px; text-transform: uppercase; padding: 3px 9px; border-radius: 999px;
  background: var(--accent); color: var(--accent-ink);
}
.tile.idle-tile { box-shadow: 0 0 0 1px rgba(242, 193, 78, 0.4), 0 0 22px rgba(242, 193, 78, 0.15); }
.tile.idle-tile:hover { box-shadow: 0 0 0 2px #f2c14e, 0 0 26px rgba(242, 193, 78, 0.45); }
.tile .badge.new { background: linear-gradient(#ff8a7a, #c4222d); color: #fff; }
/* phones held upright: one tile per row, icon on the left */
@media (max-width: 560px) and (orientation: portrait) {
  #screen-home { align-items: flex-start; overflow-y: auto; }
  .tiles { grid-template-columns: 1fr; gap: 10px; }
  .tile { flex-direction: row; text-align: left; padding: 12px 14px; gap: 14px; }
  .tile svg { width: 72px; height: 72px; margin: 0; flex: none; }
  .tile b { font-size: 17px; display: block; }
  .tile .tt { align-items: flex-start; gap: 2px; }
  .tile .badge { top: 10px; right: 10px; }
  .home .lobby-head h1.small { font-size: 18px; }
}
@media (max-height: 480px) {
  .tile { padding: 14px 12px 12px; }
  .tile svg { width: 92px; height: 92px; margin-bottom: 2px; }
  .tile b { font-size: 17px; }
}
.lobby { width: min(1180px, 100%); height: 100%; max-height: 640px; display: flex; flex-direction: column; }
.lobby-head { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; padding: 6px 12px; background: rgba(5, 20, 8, 0.6); border-radius: 10px; }
.lobby-head .chip { margin-left: auto; }
.chip { background: rgba(0, 0, 0, 0.35); border: 1px solid var(--line); padding: 4px 12px; border-radius: 999px; font-size: 13px; color: var(--muted); }
/* two columns: quick play + players on the left, rooms on the right (the rankings have their own screen) */
.lobby-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(220px, 0.9fr) minmax(0, 1.25fr); gap: 10px; }
.lobby-body > * { min-width: 0; }
.btn.big { display: flex; flex-direction: column; align-items: flex-start; justify-content: center; padding: 12px 14px; min-height: 76px; text-align: left; }
.btn.big strong { font-size: 18px; }
.btn.big small { opacity: 0.8; font-weight: 600; margin-top: 2px; }

.rooms { display: flex; flex-direction: column; min-height: 0; padding: 10px 12px; }
/* the create form wraps onto its own full-width row when the column is narrow (phones) */
.rooms-head { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 10px; margin-bottom: 8px; }
.rooms-head h3, .top5 h3 { margin: 0; font-size: 14px; color: var(--accent); }
.room-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }
.room-list li.rm { display: flex; align-items: center; gap: 10px; padding: 7px 8px; margin-bottom: 6px; border-radius: 8px; background: rgba(0, 0, 0, 0.28); border: 1px solid rgba(0, 0, 0, 0.35); }
.room-list li.rm.open { border-color: rgba(166, 255, 60, 0.45); box-shadow: inset 0 0 10px rgba(140, 255, 50, 0.08); }
.room-list .info { flex: 1; min-width: 0; }
.room-list .info b { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.room-list .info small { color: var(--muted); font-size: 12px; }
.seats { display: flex; gap: 3px; }
.seats i { width: 10px; height: 14px; border-radius: 2px; background: rgba(0, 0, 0, 0.45); border: 1px solid rgba(255, 255, 255, 0.15); }
.seats i.on { background: var(--glow); border-color: #e2ffc0; box-shadow: 0 0 5px var(--glow-soft); }
.room-list .btn { min-width: 70px; }
.room-list li.empty { color: var(--muted); text-align: center; padding: 22px 8px; }

.top5 { overflow: hidden; padding: 10px 12px; }
.top5 h3 { margin-bottom: 6px; }
.top5 ol { list-style: none; margin: 0; padding: 0; }
.top5 li { display: grid; grid-template-columns: 18px 1fr auto; gap: 6px; padding: 5px 0; border-bottom: 1px solid rgba(0, 0, 0, 0.3); font-size: 14px; align-items: baseline; }
.top5 li:last-child { border-bottom: 0; }
.top5 .rk { color: var(--muted); font-weight: 800; }
.top5 .nm { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; }
.top5 .sc { font-variant-numeric: tabular-nums; color: var(--accent); font-weight: 800; }
.top5 li.me .nm { color: var(--glow); }
.top5 li.empty { display: block; color: var(--muted); border: 0; padding: 14px 0; }
.top5 h3 small, .players h3 small { color: var(--muted); font-weight: 600; font-size: 11px; }
.top5 { display: flex; flex-direction: column; min-height: 0; }
.top5 ol { overflow-y: auto; flex: 1; min-height: 0; }
.top5 .nm small { display: block; color: var(--muted); font-size: 10.5px; font-weight: 600; line-height: 1.2; }
.top5 .foot { margin: 6px 0 0; color: var(--muted); font-size: 10.5px; line-height: 1.3; }
.ranked li { grid-template-columns: 18px 1fr auto; }
.ranked .nm { display: flex; align-items: center; gap: 3px; }
.ranked .nm b { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; min-width: 0; }
.ranked .sc small { color: var(--muted); font-weight: 600; font-size: 10px; margin-left: 2px; }

/* trophies (gold / silver / bronze), drawn with a mask so the colour comes from CSS */
.tr {
  display: inline-block; width: 14px; height: 14px; flex: none; vertical-align: -2px;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 2h12v2h4v3a5 5 0 0 1-5 5h-.4A6 6 0 0 1 13 15.9V18h3a2 2 0 0 1 2 2v2H6v-2a2 2 0 0 1 2-2h3v-2.1A6 6 0 0 1 7.4 12H7a5 5 0 0 1-5-5V4h4V2zm-2 4v1a3 3 0 0 0 2.2 2.9A6 6 0 0 1 6 8V6H4zm14 0v2c0 .7-.1 1.3-.2 1.9A3 3 0 0 0 20 7V6h-2z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M6 2h12v2h4v3a5 5 0 0 1-5 5h-.4A6 6 0 0 1 13 15.9V18h3a2 2 0 0 1 2 2v2H6v-2a2 2 0 0 1 2-2h3v-2.1A6 6 0 0 1 7.4 12H7a5 5 0 0 1-5-5V4h4V2zm-2 4v1a3 3 0 0 0 2.2 2.9A6 6 0 0 1 6 8V6H4zm14 0v2c0 .7-.1 1.3-.2 1.9A3 3 0 0 0 20 7V6h-2z'/%3E%3C/svg%3E") center / contain no-repeat;
}
.tr.gold { background: linear-gradient(#fff2a8, #f2c14e 45%, #b8860b); }
.tr.silver { background: linear-gradient(#ffffff, #c9d1d6 45%, #8a959c); }
.tr.bronze { background: linear-gradient(#ffd2a6, #cd7f32 45%, #8a4f1d); }
.trophies { display: inline-flex; align-items: center; gap: 1px; font-size: 10px; font-weight: 800; color: var(--muted); flex: none; }
.trophies .n { margin-right: 3px; }

/* everyone who has an account: online first, else when they last played */
.players { display: flex; flex-direction: column; min-height: 0; padding: 8px 10px; }
.players h3 { margin: 0 0 4px; font-size: 14px; color: var(--accent); }
.players-list { list-style: none; margin: 0; padding: 0; overflow-y: auto; flex: 1; min-height: 0; -webkit-overflow-scrolling: touch; }
/* name + trophies on the first line, status ("playing", "3 days ago") underneath */
.players-list li { display: grid; grid-template-columns: 8px minmax(0, 1fr); align-items: center; column-gap: 6px; padding: 3px 0; font-size: 13px; line-height: 1.25; border-bottom: 1px solid rgba(0, 0, 0, 0.25); }
.players-list li .st { grid-column: 2; font-size: 10.5px; }
.players-list li:last-child { border-bottom: 0; }
.players-list .dot { width: 8px; height: 8px; border-radius: 50%; flex: none; background: #59615a; }
.players-list li.on .dot { background: var(--glow); box-shadow: 0 0 6px var(--glow-soft); }
.players-list .nm { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-weight: 700; display: flex; align-items: center; gap: 3px; }
.players-list .nm b { overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.players-list .st { color: var(--muted); font-size: 11px; white-space: nowrap; }
.players-list li.on .st { color: var(--glow); }
.players-list li.me .nm b { color: var(--glow); }
/* where an online player is: lobby (green), waiting room, single player game, multiplayer game, watching */
.players-list li.s-solo .st { color: #8fd3ff; }
.players-list li.s-multi .st { color: #ffcf6b; }
.players-list li.s-room .st { color: #c8f59a; }
.players-list li.s-watching .st { color: #9fb6ff; }
.players-list li.s-solo .dot { background: #8fd3ff; box-shadow: 0 0 6px rgba(143, 211, 255, 0.6); }
.players-list li.s-multi .dot { background: #ffcf6b; box-shadow: 0 0 6px rgba(255, 207, 107, 0.6); }
.players-list li.s-watching .dot { background: #9fb6ff; }
/* all-time personal bests */
.players-list li { font-size: 14.5px; padding: 4px 0; }
.players-list li .st { font-size: 11.5px; }
.players-list .best { grid-column: 2; font-size: 11.5px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.players-list .best b { color: var(--accent); font-weight: 800; font-variant-numeric: tabular-nums; }

/* ---- Rankings button and Hall of fame ---- */
.rank-btn { display: inline-flex; align-items: center; gap: 6px; background: linear-gradient(#5a4310, #2f2306); border: 1px solid #c99a2e; color: #ffe28a; }
.rank-btn .tr { width: 16px; height: 16px; }
.hof { width: min(980px, 100%); height: 100%; max-height: 640px; display: flex; flex-direction: column; gap: 8px; }
.hof-head { display: flex; align-items: center; gap: 10px; padding: 4px 10px; background: rgba(5, 20, 8, 0.6); border-radius: 10px; }
.hof-head h2 { margin: 0; font-size: 20px; color: #ffe28a; letter-spacing: 1px; text-transform: uppercase; }
.hof-head .seg { margin-left: auto; }
/* segmented switches */
.seg { display: inline-flex; background: rgba(0, 0, 0, 0.4); border: 1px solid var(--line); border-radius: 999px; padding: 3px; gap: 2px; }
.seg button { appearance: none; border: 0; background: transparent; color: var(--muted); font: inherit; font-weight: 800; font-size: 13px; padding: 6px 14px; border-radius: 999px; min-height: 32px; cursor: pointer; }
.seg button.on { background: linear-gradient(#a6ff3c, #5fae1e); color: #10270a; }
.seg.off { opacity: 0.35; pointer-events: none; }
.seg.views { align-self: center; }
.seg.views button.on { background: linear-gradient(#ffe28a, #c99a2e); color: #3a2800; }
.hof-body { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(0, 1fr); gap: 14px; padding: 12px 16px; }
/* podium: 2nd, 1st (highest), 3rd */
.podium { display: flex; align-items: flex-end; justify-content: center; gap: 8px; min-height: 0; }
.pod { flex: 1 1 0; max-width: 170px; display: flex; flex-direction: column; align-items: center; justify-content: flex-end; text-align: center; min-width: 0; height: 100%; }
.pod .pn { font-size: 15px; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pod.p1 .pn { font-size: 18px; color: #ffe28a; }
.pod .pv { font-weight: 900; font-variant-numeric: tabular-nums; color: var(--accent); }
.pod .ps { font-size: 11px; color: var(--muted); min-height: 15px; display: inline-flex; align-items: center; gap: 2px; }
.pod.me .pn { color: var(--glow); }
.pod.empty { opacity: 0.4; }
.pod .crown { width: 30px; height: 30px; margin-bottom: 2px; }
.pod .step { width: 100%; margin-top: 4px; border-radius: 8px 8px 0 0; display: grid; place-items: start center; padding-top: 6px; font-size: 22px; font-weight: 900; transform-origin: bottom; }
.pod.p1 .step { height: 46%; background: linear-gradient(#fff2a8, #f2c14e 45%, #b8860b); color: #3a2800; box-shadow: 0 0 18px rgba(242, 193, 78, 0.35); }
.pod.p2 .step { height: 32%; background: linear-gradient(#ffffff, #c9d1d6 45%, #8a959c); color: #26303a; }
.pod.p3 .step { height: 22%; background: linear-gradient(#ffd2a6, #cd7f32 45%, #8a4f1d); color: #3b1e05; }
.podium.rise .step { animation: rise 0.5s cubic-bezier(.3, 1.3, .5, 1) both; }
.podium.rise .p2 .step { animation-delay: 0.08s; }
.podium.rise .p3 .step { animation-delay: 0.16s; }
@keyframes rise { from { transform: scaleY(0); } to { transform: scaleY(1); } }
.hof-main { display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.hof-main .podium { flex: 1; }
.hof-side { display: flex; flex-direction: column; min-height: 0; }
.hof-main h3, .hof-side h3 { margin: 0 0 6px; font-size: 13px; color: var(--accent); text-transform: uppercase; letter-spacing: 0.5px; }
.hof-list { list-style: none; margin: 0; padding: 0; flex: 1; min-height: 0; overflow-y: auto; }
.hof-list li { display: grid; grid-template-columns: 22px minmax(0, 1fr) auto; gap: 8px; align-items: center; padding: 7px 0; border-bottom: 1px solid rgba(0, 0, 0, 0.3); font-size: 15px; }
.hof-list .rk { color: var(--muted); font-weight: 900; }
.hof-list .nm { font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hof-list .nm small { display: flex; align-items: center; gap: 2px; color: var(--muted); font-size: 11px; font-weight: 600; }
.hof-list .sc { font-weight: 900; color: var(--accent); font-variant-numeric: tabular-nums; }
.hof-list li.me .nm { color: var(--glow); }
.hof-list li.empty { display: block; color: var(--muted); border: 0; }
.hof-side .foot { margin: 6px 0 0; color: var(--muted); font-size: 12px; line-height: 1.35; }
.hof-side .foot .tr { width: 12px; height: 12px; }

/* multiplayer and single player top 5 stacked in one column */
.top-col { display: flex; flex-direction: column; gap: 8px; min-height: 0; }
.top-col .top5 { flex: 1 1 0; padding: 7px 10px; }
.top-col .top5 h3 { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; margin-bottom: 3px; }
.top-col .top5 h3 small { font-size: 9.5px; letter-spacing: 0.2px; }
.top-col .top5 h3 { font-size: 12.5px; letter-spacing: 0.4px; }
.top-col .ranked h3 { letter-spacing: 0; }
/* narrow columns: the "multiplayer / single player" label goes on its own line instead of being cut off */
.top-col .top5 { container-type: inline-size; }
@container (max-width: 200px) {
  .top5 h3 { white-space: normal; line-height: 1.1; }
  .top5 h3 small { display: block; }
}
.top-col .ranked h3 small { font-size: 9px; letter-spacing: 0; }
/* one line per entry so all 5 fit: name, then the day/time small next to it */
.top-col .top5 li { padding: 2px 0; font-size: 13px; align-items: center; }
.top-col .top5 .nm small { display: inline; margin-left: 4px; font-size: 9.5px; }
.top-col .top5 .foot { margin-top: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 9.5px; }
.top-col .top5 .foot .tr { width: 10px; height: 10px; vertical-align: -1px; }
.players-list { overflow-x: hidden; }

/* the create-room button sits at the right of the Rooms title */
.rooms-head #btn-create { margin-left: auto; }
/* members-only room */
.room-list .rm.crew { border-color: rgba(242, 193, 78, 0.6); background: linear-gradient(90deg, rgba(242, 193, 78, 0.14), transparent 70%); }
.room-list .rm.crew .info b::before { content: "\2605 "; color: #f2c14e; }
.lobby-actions { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.lobby-actions .btn.big { flex: none; }
.lobby-actions .players { flex: 1; }

/* ---- room ---- */
.room { width: min(560px, 100%); text-align: center; }
.slots { list-style: none; padding: 0; margin: 10px 0; display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; }
.slots li { background: rgba(0, 0, 0, 0.3); border: 1px solid rgba(0, 0, 0, 0.4); border-radius: 8px; padding: 10px 6px; min-height: 52px; font-weight: 800; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slots li.empty { color: var(--muted); font-weight: 500; border-style: dashed; border-color: rgba(255, 255, 255, 0.2); }
.slots li.you { border-color: var(--glow); box-shadow: 0 0 8px rgba(140, 255, 50, 0.3); }
.slots li small { display: block; color: var(--muted); font-weight: 600; font-size: 11px; }

/* ================= game table ================= */
#screen-game {
  --opp-h: 0px;
  display: grid; grid-template-rows: var(--opp-h) auto minmax(0, 1fr) auto; gap: 2px;
}
#opps { grid-row: 1; grid-column: 1; }
.midband { grid-row: 2; grid-column: 1; }
#board-wrap { grid-row: 3; grid-column: 1; }
#bar { grid-row: 4; }
/* Multiplayer: your own cards come first. The opponents' row stays low, and the timer moves out of its own row
   into the empty top-left corner of your table (next to the left pyramid), so your tower gets that height back. */
#screen-game:is([data-opps="1"], [data-opps="2"], [data-opps="3"]) {
  --opp-h: clamp(52px, 16%, 120px);
  grid-template-rows: var(--opp-h) 0 minmax(0, 1fr) auto;
}
#screen-game:is([data-opps="1"], [data-opps="2"], [data-opps="3"]) .midband {
  grid-row: 3; align-self: start; justify-content: space-between; z-index: 6; pointer-events: none;
  min-height: 0; padding: 2px 4px 0; gap: 8px;
}
#screen-game:is([data-opps="1"], [data-opps="2"], [data-opps="3"]) .altar { display: none; }
#screen-game:is([data-opps="1"], [data-opps="2"], [data-opps="3"]) .timer { order: -1; }
#screen-game:is([data-opps="1"], [data-opps="2"], [data-opps="3"]) .spec-tag { position: static; transform: none; max-width: 26%; order: 1; }
#screen-game:is([data-opps="1"], [data-opps="2"], [data-opps="3"]) .opps { gap: 8px; }
/* the felt clearing in the middle of the jungle */
#screen-game::before {
  content: ""; position: absolute; z-index: -1;
  inset: calc(var(--sat) + 6px) calc(var(--sar) + 8px) calc(var(--sab) + 6px) calc(var(--sal) + 8px);
  border-radius: 28px;
  background:
    radial-gradient(ellipse at 50% 55%, rgba(80, 160, 60, 0.25), transparent 60%),
    radial-gradient(circle at 30% 30%, rgba(0, 0, 0, 0.18) 0 2px, transparent 3px) 0 0 / 14px 14px,
    linear-gradient(var(--felt), var(--felt-dark));
  box-shadow: inset 0 0 40px 12px rgba(2, 12, 4, 0.85), 0 0 0 3px rgba(0, 0, 0, 0.25);
}

/* stone pillars with the engraved name (wide screens only) */
.pillar { display: none; }
@media (min-width: 760px) {
  #screen-game { padding-left: calc(var(--sal) + 66px); padding-right: calc(var(--sar) + 66px); }
  .pillar {
    display: flex; align-items: center; justify-content: center; position: absolute; top: 16%; bottom: 26%; width: 46px;
    background: repeating-linear-gradient(0deg, rgba(0, 0, 0, 0.25) 0 2px, transparent 2px 46px), linear-gradient(90deg, var(--stone-lo), var(--stone-hi) 45%, var(--stone-lo));
    border: 2px solid var(--stone-dark); border-radius: 6px;
    box-shadow: inset 0 0 10px rgba(0, 0, 0, 0.5), 0 6px 14px rgba(0, 0, 0, 0.6);
  }
  .pillar.left { left: calc(var(--sal) + 12px); }
  .pillar.right { right: calc(var(--sar) + 12px); }
  .pillar span {
    writing-mode: vertical-rl; font-weight: 900; letter-spacing: 4px; font-size: 15px; color: #2b302b;
    text-shadow: 0 1px 0 rgba(255, 255, 255, 0.3), 0 -1px 0 rgba(0, 0, 0, 0.5);
  }
  .pillar.left span { transform: rotate(180deg); }
}

/* opponents across the table */
.opps { display: flex; justify-content: center; gap: 12px; min-height: 0; overflow: hidden; }
.opp { flex: 1 1 0; max-width: 360px; min-width: 0; display: flex; flex-direction: column; gap: 3px; transition: opacity 0.3s; }
.opp-plaque {
  display: flex; align-items: center; gap: 6px; padding: 1px 8px; font-size: 11px; line-height: 1.5; white-space: nowrap;
  background: linear-gradient(var(--stone), var(--stone-lo)); border: 1px solid var(--stone-dark); border-radius: 6px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.15);
}
.opp-plaque b { overflow: hidden; text-overflow: ellipsis; min-width: 0; flex: 0 1 auto; }
.opp-plaque .meta { color: var(--muted); overflow: hidden; text-overflow: ellipsis; flex: 1 1 auto; min-width: 0; }
.opp-plaque .sc { color: var(--accent); font-weight: 800; font-variant-numeric: tabular-nums; }
.mini-card { background: #fbfaf4; color: var(--ink); border-radius: 3px; padding: 0 3px; font-weight: 900; font-size: 11px; box-shadow: 0 1px 2px rgba(0, 0, 0, 0.5); }
.mini-card.red { color: var(--red); }
.mt-wrap { flex: 1; min-height: 0; position: relative; display: flex; align-items: center; justify-content: center; }
.mini-tower { position: relative; filter: drop-shadow(0 0 1px var(--glow)) drop-shadow(0 0 4px var(--glow-soft)); }
.mc {
  position: absolute; width: 9.434%; height: 40%; border-radius: 10% / 7%;
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, 0.07) 0 2px, transparent 2px 4px), linear-gradient(var(--stone), var(--stone-lo));
  border: 1px solid rgba(0, 0, 0, 0.6);
}
.mc.up { background: linear-gradient(#ffffff, #e9e8df); }
.mc.gone { visibility: hidden; }
.opp.off { opacity: 0.4; }
.opp.done .opp-plaque { border-color: var(--accent); box-shadow: 0 0 8px rgba(242, 193, 78, 0.6); }

/* middle band: timer between two small stone pyramids */
.midband { display: flex; align-items: center; justify-content: center; gap: 14px; min-height: 30px; }
.altar {
  width: 34px; height: 22px; display: block;
  background: linear-gradient(var(--stone-hi), var(--stone-lo));
  clip-path: polygon(0 100%, 0 70%, 14% 70%, 14% 40%, 30% 40%, 30% 12%, 70% 12%, 70% 40%, 86% 40%, 86% 70%, 100% 70%, 100% 100%);
  filter: drop-shadow(0 0 3px var(--glow-soft));
}
.timer {
  display: flex; align-items: baseline; gap: 6px; font: 900 16px/1 ui-monospace, Menlo, monospace;
  background: linear-gradient(var(--stone), var(--stone-lo)); border: 2px solid var(--stone-dark); border-radius: 999px;
  padding: 5px 14px; min-width: 96px; justify-content: center;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 10px rgba(140, 255, 50, 0.25);
}
.timer small { font-size: 11px; color: var(--accent); }
.timer.low { color: var(--bad); box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 0 12px rgba(255, 80, 80, 0.5); }

/* your tower */
#board-wrap { position: relative; min-height: 0; --cw: 60px; }
#board, #plinths { position: absolute; inset: 0; }
#plinths { filter: drop-shadow(0 0 1.5px var(--glow)) drop-shadow(0 0 7px var(--glow-soft)); pointer-events: none; }
.plinth {
  position: absolute; display: block; border-radius: 4px;
  background: linear-gradient(var(--stone), #4a524b);
  box-shadow: inset 0 calc(var(--cw) * -0.16) 0 var(--stone-lo), inset 0 1px 0 rgba(255, 255, 255, 0.15);
}

/* cards: everything scales from --cw (card width in px) */
.card { position: absolute; width: var(--cw); height: calc(var(--cw) * 1.4); border-radius: calc(var(--cw) * 0.1); font-size: calc(var(--cw) * 0.3); }
.card.up {
  background: linear-gradient(#ffffff, #f1f0e8); color: var(--ink); border: 1px solid rgba(0, 0, 0, 0.35);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.5); cursor: pointer; overflow: hidden;
}
.card.up.red { color: var(--red); }
.card .c { position: absolute; font-weight: 800; line-height: 0.95; text-align: center; font-size: 0.95em; }
.card .c.tl { left: 6%; top: 5%; }
.card .c.br { right: 6%; bottom: 5%; transform: rotate(180deg); }
.card .mid { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; font-size: 1.9em; line-height: 1; }
.card.face .mid { font-size: 1.6em; font-weight: 900; }
/* carved stone card back */
.card.down {
  background:
    radial-gradient(circle at 50% 50%, rgba(166, 255, 60, 0.35) 0 8%, transparent 9%),
    linear-gradient(45deg, transparent 42%, rgba(0, 0, 0, 0.35) 42% 46%, transparent 46% 54%, rgba(0, 0, 0, 0.35) 54% 58%, transparent 58%),
    linear-gradient(-45deg, transparent 42%, rgba(0, 0, 0, 0.35) 42% 46%, transparent 46% 54%, rgba(0, 0, 0, 0.35) 54% 58%, transparent 58%),
    linear-gradient(160deg, var(--stone-hi), var(--stone-lo));
  border: 1px solid rgba(0, 0, 0, 0.7);
  box-shadow: inset 0 0 0 calc(var(--cw) * 0.06) rgba(0, 0, 0, 0.18), inset 0 1px 0 rgba(255, 255, 255, 0.2), 0 2px 4px rgba(0, 0, 0, 0.55);
}
.card.gone { visibility: hidden; pointer-events: none; }
/* round over with cards left: they are chained shut */
.card.locked { cursor: default; }
.card.locked::before { content: ""; position: absolute; inset: 0; background: rgba(10, 14, 12, 0.45); z-index: 4; pointer-events: none; }
.card.locked::after {
  content: ""; position: absolute; inset: 0; z-index: 5; pointer-events: none;
  background: var(--padlock) center / 46% auto no-repeat, var(--chains) center / 100% 100% no-repeat;
  filter: drop-shadow(0 1px 1px rgba(0, 0, 0, 0.7));
  animation: chain-in 0.35s cubic-bezier(.3, 1.6, .5, 1) both;
}
@keyframes chain-in { from { opacity: 0; transform: scale(1.35) rotate(-6deg); } to { opacity: 1; transform: none; } }
.card.locked { animation: rattle 0.3s 0.15s; }
@keyframes rattle { 25% { transform: translateX(-2px) rotate(-1deg); } 60% { transform: translateX(2px) rotate(1deg); } }
.card.shake { animation: shake 0.28s; }
@keyframes shake { 20% { transform: translateX(-4px); } 50% { transform: translateX(4px); } 80% { transform: translateX(-2px); } }
.card.pop { animation: pop 0.22s; }
@keyframes pop { from { transform: scale(0.85); } to { transform: scale(1); } }

/* your stone plaque at the bottom */
#bar {
  position: relative; display: flex; align-items: center; gap: 14px; justify-self: stretch;
  min-height: 70px; padding: 4px 10px 4px 6px; border-radius: 12px;
}
/* on wide screens the bar runs under the pillars, all the way to the left edge, so the pile is in thumb reach */
@media (min-width: 760px) { #bar { margin: 0 -54px; } }
.who { display: flex; flex-direction: column; min-width: 0; flex: 1 1 0; }
.who b { font-size: 15px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.who span { color: var(--muted); font-size: 12px; white-space: nowrap; }
.deck { display: flex; gap: 8px; align-items: center; padding: 4px 8px; background: rgba(0, 0, 0, 0.3); border-radius: 8px; box-shadow: inset 0 2px 5px rgba(0, 0, 0, 0.55); }
.bar-card, .pile { --cw: 44px; position: relative; flex: none; }
.pile {
  appearance: none; padding: 0; width: 54px; height: 76px; border-radius: 6px; color: #fff; font: 900 20px/1 system-ui;
  background:
    linear-gradient(45deg, transparent 42%, rgba(0, 0, 0, 0.3) 42% 46%, transparent 46% 54%, rgba(0, 0, 0, 0.3) 54% 58%, transparent 58%),
    linear-gradient(160deg, var(--stone-hi), var(--stone-lo));
  border: 2px solid var(--glow); box-shadow: 0 0 8px var(--glow-soft), 0 2px 5px rgba(0, 0, 0, 0.5); cursor: pointer;
}
.pile:active { transform: scale(0.95); }
.pile:disabled { opacity: 0.4; border-color: #555; box-shadow: none; }
.pile span { text-shadow: 0 1px 3px #000, 0 0 2px #000; }
/* your play card is larger than the pile */
.bar-card { --cw: 58px; width: 58px; height: 81px; box-shadow: 0 0 10px rgba(140, 255, 50, 0.35), 0 3px 8px rgba(0, 0, 0, 0.6); border-color: rgba(166, 255, 60, 0.7); }
.bar-card.incoming { visibility: hidden; }
/* bonus play card from a 3-card chain: golden glow so it reads as a gift */
.bar-card.extra { border-color: #ffd86b; box-shadow: 0 0 12px rgba(255, 210, 80, 0.75), 0 3px 8px rgba(0, 0, 0, 0.6); }
.bar-card.extra::after {
  content: "BONUS"; position: absolute; left: 50%; bottom: -1px; transform: translate(-50%, 50%);
  font: 900 9px/1 system-ui, sans-serif; letter-spacing: 1px; color: #3a2a00; background: #ffd86b;
  padding: 2px 4px; border-radius: 4px; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}
.bar-card.extra { overflow: visible; }
.bar-card.extra.hidden { display: none; }

/* spectator view */
.midband { position: relative; }
.spec-tag {
  position: absolute; left: 6px; top: 50%; transform: translateY(-50%); z-index: 3;
  font-size: 12px; font-weight: 800; color: #eaffd2; padding: 3px 10px; border-radius: 999px;
  background: rgba(0, 0, 0, 0.5); border: 1px solid var(--glow); white-space: nowrap; max-width: 40%; overflow: hidden; text-overflow: ellipsis;
}
/* spectating is unmistakable: blue frame around the table, blue name tag and a ribbon on the bottom bar */
#screen-game.spectating::before {
  box-shadow: inset 0 0 40px 12px rgba(2, 12, 4, 0.85), 0 0 0 3px rgba(110, 160, 255, 0.85), 0 0 22px rgba(110, 160, 255, 0.5);
}
.spectating .spec-tag { background: rgba(30, 55, 110, 0.9); border-color: #8fb4ff; color: #e6efff; font-size: 13px; }
.spectating #bar { box-shadow: 0 0 0 2px rgba(110, 160, 255, 0.8), 0 0 14px rgba(110, 160, 255, 0.4); }
.spectating #bar::after {
  content: "\1F441\FE0E  " attr(data-ribbon); position: absolute; left: 50%; top: 0; transform: translate(-50%, -55%); z-index: 4;
  font: 900 11px/1 system-ui, sans-serif; letter-spacing: 1.5px; text-transform: uppercase; white-space: nowrap;
  color: #fff; background: linear-gradient(#4f7fd6, #2c4f99); border: 1px solid #a9c4ff; border-radius: 999px;
  padding: 4px 12px; box-shadow: 0 2px 6px rgba(0, 0, 0, 0.6); pointer-events: none;
}
.spectating .notice { transform: translate(-50%, -16px); }
.spectating #pile { opacity: 0.55; }
.spectating .opp { cursor: pointer; }
.spectating .opp:hover .opp-plaque, .spectating .opp:active .opp-plaque { border-color: var(--glow); }
.spectating #board .card, .spectating #pile { cursor: default; }
.spectating #btn-quit { width: auto; padding: 0 8px; }
.room-list .btn.watch { background: linear-gradient(#3d5a8a, #243a60); border-color: #7fa6e0; color: #e6efff; }
/* pile sits 20% of the bar's width in from the left: within comfortable reach of the left thumb */
.deck { padding: 3px 8px 3px 5px; margin-left: 20%; }

/* card in flight from the tower / pile to your play card */
.card.flying { position: fixed; z-index: 60; pointer-events: none; transform-origin: 0 0; will-change: transform; }

/* settings dialog (gear in the lobby) */
.icon-btn.gear { font-size: 19px; line-height: 1; width: 36px; height: 36px; border-radius: 50%; color: var(--accent); }
.icon-btn.gear:active { transform: rotate(40deg); }
#settings { position: fixed; z-index: 80; }
.settings { width: min(360px, calc(100vw - 32px)); }
.settings h2 { margin: 0 0 8px; }
.switch-row { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(0, 0, 0, 0.3); cursor: pointer; }
.switch-row span { flex: 1; display: flex; flex-direction: column; text-align: left; }
.switch-row small { color: var(--muted); font-size: 12px; }
.switch-row input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.switch { position: relative; width: 50px; height: 28px; border-radius: 999px; flex: none; background: rgba(0, 0, 0, 0.5); border: 1px solid rgba(255, 255, 255, 0.2); transition: background 0.2s; }
.switch::after { content: ""; position: absolute; top: 2px; left: 2px; width: 22px; height: 22px; border-radius: 50%; background: #d9dcd6; box-shadow: 0 1px 3px rgba(0, 0, 0, 0.6); transition: transform 0.2s; }
.switch-row input:checked + .switch { background: var(--glow); border-color: #e2ffc0; box-shadow: 0 0 8px var(--glow-soft); }
.switch-row input:checked + .switch::after { transform: translateX(22px); background: #fff; }
.switch-row input:focus-visible + .switch { outline: 2px solid #fff; outline-offset: 2px; }
.settings .row { margin-top: 12px; justify-content: center; }

/* pyramid cleared banner */
.celebrate {
  position: fixed; z-index: 66; pointer-events: none; text-align: center; opacity: 0;
  padding: 10px 22px; border-radius: 14px; white-space: nowrap;
  background: radial-gradient(ellipse at 50% 40%, rgba(60, 140, 30, 0.85), rgba(10, 40, 8, 0.8));
  border: 2px solid #c8ff8e; box-shadow: 0 0 24px rgba(140, 255, 50, 0.6);
}
.celebrate b { display: block; font: 900 26px/1.1 system-ui, sans-serif; text-transform: uppercase; letter-spacing: 2px; color: #eaffd2; text-shadow: 0 0 10px rgba(140, 255, 50, 0.8), 0 2px 3px #000; }
.celebrate .bl { display: flex; justify-content: space-between; gap: 18px; font: 800 15px/1.45 system-ui, sans-serif; text-shadow: 0 1px 3px #000; }
.celebrate .bl .lb { color: #e3f5d2; }
.celebrate .bl .pt { color: var(--accent); font-variant-numeric: tabular-nums; }
.celebrate .bl.tot { border-top: 1px solid rgba(200, 255, 142, 0.45); margin-top: 3px; padding-top: 3px; font-size: 18px; }
/* one pyramid cleared: smaller banner over that pyramid, see-through so it does not block the view */
.celebrate.small { padding: 5px 12px; border-width: 1px; }
.celebrate.small b { font-size: 15px; letter-spacing: 1px; }
.celebrate.small .bl { font-size: 14px; justify-content: center; gap: 6px; }

/* green points coin */
.coin {
  position: fixed; z-index: 65; pointer-events: none; display: flex; flex-direction: column; align-items: center; gap: 2px;
  opacity: 0; perspective: 200px;
}
.coin-disc {
  width: 34px; height: 34px; border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font: 900 12px/1 system-ui, sans-serif; font-style: normal; color: #0f2a05;
  background: radial-gradient(circle at 35% 30%, #e6ffc4 0 12%, #9ff05a 30%, #4fae25 70%, #2f7614);
  border: 2px solid #c8ff8e;
  box-shadow: inset 0 0 0 3px rgba(20, 70, 5, 0.35), 0 0 12px rgba(140, 255, 50, 0.7);
}
.coin-pts {
  font: 900 17px/1 system-ui, sans-serif; color: #c9ff8f; white-space: nowrap;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.9), 0 0 8px rgba(120, 255, 40, 0.6);
}
.stats { flex: 1 1 0; text-align: right; min-width: 0; }
.score.hit { animation: hit 0.5s; }
@keyframes hit { 0%, 60% { color: var(--bad); transform: scale(1.08); } 100% { color: var(--accent); transform: scale(1); } }
.score { font: 900 24px/1.05 ui-monospace, Menlo, monospace; color: var(--accent); text-shadow: 0 1px 2px rgba(0, 0, 0, 0.6); }
.sub { display: flex; gap: 10px; color: var(--muted); font-size: 12px; white-space: nowrap; justify-content: flex-end; }
.notice { position: absolute; left: 50%; bottom: 100%; transform: translate(-50%, -4px); color: #ffd2cc; font-size: 12px; font-weight: 800; white-space: nowrap; text-shadow: 0 1px 3px #000; pointer-events: none; }
.icon-btn { appearance: none; border: 1px solid rgba(0, 0, 0, 0.6); background: rgba(0, 0, 0, 0.35); color: var(--text); width: 34px; height: 34px; border-radius: 8px; font-size: 14px; flex: none; cursor: pointer; }

/* ---- overlays ---- */
.overlay { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: rgba(3, 12, 5, 0.7); z-index: 20; }
.results { min-width: 360px; max-width: 520px; text-align: center; }
#res-table { width: 100%; border-collapse: collapse; margin: 8px 0; font-size: 14px; }
#res-table td { padding: 4px 8px; border-bottom: 1px solid rgba(0, 0, 0, 0.3); text-align: left; }
#res-table td:last-child { text-align: right; font-variant-numeric: tabular-nums; }
#res-table tr.me td { color: var(--glow); font-weight: 800; }
.count { font-size: 64px; font-weight: 900; color: var(--glow); text-shadow: 0 0 16px rgba(140, 255, 50, 0.6); }

#rotate, #rotate-p { display: none; z-index: 100; background: #06130a; text-align: center; color: var(--muted); }
.phone { width: 54px; height: 90px; border: 4px solid var(--glow); border-radius: 12px; margin: 0 auto 14px; animation: turn 2.2s ease-in-out infinite; }
#rotate-p { background: #0f131c; }
#rotate-p .phone { border-color: #f2c14e; animation-name: turn-back; }
@keyframes turn { 0%, 30% { transform: rotate(0); } 60%, 100% { transform: rotate(90deg); } }
@keyframes turn-back { 0%, 30% { transform: rotate(90deg); } 60%, 100% { transform: rotate(0); } }
/* Apex Towers is played sideways, Apex Idle upright; the sign-in and home screens work both ways */
@media (orientation: portrait) and (max-width: 820px) {
  body:is([data-screen="lobby"], [data-screen="rank"], [data-screen="room"], [data-screen="game"]) #rotate { display: flex; }
}
@media (orientation: landscape) and (max-height: 500px) {
  body:is([data-screen="idle"], [data-screen="scape"]) #rotate-p { display: flex; }
}

.banner { position: fixed; top: calc(var(--sat) + 4px); left: 50%; transform: translateX(-50%); background: var(--bad); color: #200; font-weight: 800; padding: 4px 14px; border-radius: 999px; z-index: 90; font-size: 13px; }
.toast { position: fixed; bottom: calc(var(--sab) + 110px); left: 50%; transform: translate(-50%, 10px); background: rgba(0, 0, 0, 0.85); border: 1px solid var(--line); padding: 8px 14px; border-radius: 10px; opacity: 0; pointer-events: none; transition: opacity 0.2s, transform 0.2s; z-index: 95; font-size: 14px; max-width: 80vw; text-align: center; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

/* wrong-tap popup */
.pen { position: fixed; z-index: 70; transform: translate(-50%, -50%); pointer-events: none; color: #ff5d5d; font: 900 22px/1 system-ui, sans-serif; text-shadow: 0 2px 4px #000, 0 0 8px rgba(0, 0, 0, 0.8); white-space: nowrap; }

/* between rounds */
.intro { text-align: center; min-width: 240px; }
.intro-title { font-size: 20px; font-weight: 900; text-transform: uppercase; letter-spacing: 1px; }
#res-table th { text-align: left; font-size: 11px; color: var(--muted); font-weight: 700; padding: 2px 8px; text-transform: uppercase; letter-spacing: 0.5px; }
#res-table th:last-child { text-align: right; }
#res-table td.num, #res-table th.num { text-align: right; font-variant-numeric: tabular-nums; }
/* places 1-3 in the game table */
.medal { display: inline-grid; place-items: center; min-width: 24px; height: 24px; padding: 0 4px; border-radius: 12px; font-weight: 900; font-size: 13px; color: var(--muted); background: rgba(0, 0, 0, 0.3); }
.medal.m1 { color: #3a2800; background: linear-gradient(#fff2a8, #f2c14e 50%, #b8860b); box-shadow: 0 0 10px rgba(242, 193, 78, 0.55); }
.medal.m2 { color: #26303a; background: linear-gradient(#ffffff, #c9d1d6 50%, #8a959c); }
.medal.m3 { color: #3b1e05; background: linear-gradient(#ffd2a6, #cd7f32 50%, #8a4f1d); }
#res-table tr.p1 td { font-weight: 800; font-size: 1.08em; }
#res-table tr.p1 td:last-child { color: #f2c14e; }
#res-table tr.out td { opacity: 0.6; }
/* round winner / game winner banner */
.res-win { display: grid; grid-template-columns: auto 1fr; column-gap: 10px; align-items: center; text-align: left; margin: 6px 0 4px; padding: 8px 12px; border-radius: 10px;
  background: linear-gradient(90deg, rgba(242, 193, 78, 0.22), rgba(242, 193, 78, 0.05)); border: 1px solid rgba(242, 193, 78, 0.55); }
.res-win .tr.big { width: 34px; height: 34px; grid-row: span 2; }
.res-win .wt { font-size: 18px; font-weight: 900; color: #ffe28a; line-height: 1.15; }
.res-win .ws { font-size: 14px; font-weight: 800; color: var(--text, #fff); font-variant-numeric: tabular-nums; }
.res-win.mine { background: linear-gradient(90deg, rgba(201, 255, 143, 0.25), rgba(201, 255, 143, 0.05)); border-color: rgba(201, 255, 143, 0.6); }
.res-win.mine .wt { color: var(--glow); }
.hs { color: var(--accent); font-weight: 800; margin: 4px 0; min-height: 1.35em; }
.results .status { margin: 2px 0; }

/* short landscape screens (phones) */
/* phones in landscape (a Pro Max is 440 px high, so up to 480) */
@media (max-height: 480px) {
  h1 { font-size: 30px; }
  .panel { padding: 10px 14px; }
  .btn.big { min-height: 64px; }
  .btn.big strong { font-size: 16px; }
  .lobby-head { margin-bottom: 6px; padding: 4px 10px; }
  /* phones in landscape: the notch eats width on both sides, so the columns share what is left and Rooms
     always keeps enough room for its Join buttons */
  .lobby-body { grid-template-columns: minmax(200px, 0.9fr) minmax(0, 1.25fr); gap: 6px; }
  .hof-head h2 { font-size: 17px; }
  .hof-body { padding: 8px 12px; }
  .podium { min-height: 0; }
  .room-list .seats { display: none; }   /* the player count is in the text; room names need the space */
  .room-list li.rm { gap: 6px; padding: 6px 7px; }
  .room-list .btn { min-width: 58px; padding-left: 10px; padding-right: 10px; flex: none; }
  .rooms-head #btn-create { padding-left: 10px; padding-right: 10px; }
  .lobby-actions { gap: 6px; }
  .btn.big { min-height: 52px; padding: 7px 10px; }
  .top5, .rooms { padding: 7px 9px; }
  .top5 li { font-size: 13px; padding: 3px 0; }
  #bar { min-height: 60px; padding: 2px 10px; }
  .bar-card, .pile { --cw: 38px; }
  .pile { width: 48px; height: 67px; }
  .bar-card { --cw: 50px; width: 50px; height: 70px; }
  .score { font-size: 20px; }
  .midband { min-height: 26px; }
  .timer { padding: 3px 12px; font-size: 14px; }
  .altar { width: 26px; height: 17px; }
  .results { padding: 8px 14px; }
  #res-table { margin: 4px 0; font-size: 13px; }
  #res-table td { padding: 3px 8px; }
  .results h2 { font-size: 18px; margin-bottom: 2px; }
}
@media (max-width: 680px) {
  .lobby-body { grid-template-columns: minmax(0, 0.9fr) minmax(0, 1.1fr); }
  .hof-body { grid-template-columns: minmax(0, 1.5fr) minmax(0, 1fr); gap: 10px; }
  .seg button { padding: 5px 10px; font-size: 12px; }
}
@media (max-width: 520px) {
  .lobby-body { grid-template-columns: 1fr; overflow-y: auto; }
  .hof-head { flex-wrap: wrap; }
  .rank-btn span { display: none; }
  .auth-grid { grid-template-columns: 1fr; }
}
@media (prefers-reduced-motion: reduce) { * { animation: none !important; transition: none !important; } }
