:root {
  --bg0: #060a12; --panel: rgba(20, 28, 44, 0.86); --panel2: rgba(34, 46, 70, 0.92); --line: rgba(255,255,255,0.1);
  --ink: #f6f8fc; --muted: #a3afc5; --gold: #ffc83d; --go: #22c97c;
  --p0: #ff6b4a; --p1: #38b6ff; --bgA: #1e2b4d; --bgB: #0b1120; --wall: #e0a95e;
  --sa-left: env(safe-area-inset-left); --sa-right: env(safe-area-inset-right); --sa-bottom: env(safe-area-inset-bottom); --sa-top: env(safe-area-inset-top);
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; color: var(--ink); font-family: ui-rounded, 'SF Pro Rounded', 'Nunito', 'Segoe UI', system-ui, -apple-system, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; -webkit-tap-highlight-color: transparent; }
body { background: radial-gradient(ellipse 120% 80% at 50% 40%, var(--bgA) 0%, var(--bgB) 70%, var(--bg0) 100%); transition: background 0.3s; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; }
[hidden] { display: none !important; }
svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 2.2; stroke-linecap: round; stroke-linejoin: round; flex: none; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; }

/* ---------- chunky buttons ---------- */
.big-btn { --c1: #4ea0ff; --c2: #2a6cf0; --c3: #1a4bb4; position: relative; display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; padding: 14px 16px; border: 0; border-radius: 18px; color: #fff; font-weight: 900; font-size: 17px; letter-spacing: 0.2px; text-shadow: 0 2px 0 rgba(0,0,0,0.22); background: linear-gradient(180deg, var(--c1), var(--c2)); box-shadow: 0 5px 0 var(--c3), 0 10px 22px rgba(0,0,0,0.35), inset 0 2px 0 rgba(255,255,255,0.35); transition: transform 0.08s, box-shadow 0.08s, filter 0.15s; }
.big-btn:hover { filter: brightness(1.08); }
.big-btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--c3), 0 4px 12px rgba(0,0,0,0.35), inset 0 2px 0 rgba(255,255,255,0.35); }
.big-btn:disabled { filter: grayscale(0.7) brightness(0.8); cursor: default; }
.big-btn.play { --c1: #48eba3; --c2: #1fbf74; --c3: #0b7f47; }
.big-btn.blue { --c1: #5aa8ff; --c2: #2f6ff0; --c3: #1b48a8; }
.big-btn.orange { --c1: #ffa14d; --c2: #f26a1f; --c3: #a8420c; }
.big-btn.purple { --c1: #b98aff; --c2: #7c47f0; --c3: #4f25a8; }
.big-btn.teal { --c1: #4fe0e6; --c2: #13a9b8; --c3: #0a6d78; }
.big-btn.red { --c1: #ff7a6a; --c2: #e2382a; --c3: #962015; }
.big-btn.sm { padding: 10px 14px; font-size: 15px; border-radius: 14px; }
.big-btn .bi { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; background: rgba(255,255,255,0.18); box-shadow: inset 0 -2px 0 rgba(0,0,0,0.15); flex: none; }
.big-btn .bi svg { width: 26px; height: 26px; }
.big-btn.hero { justify-content: flex-start; padding: 16px 20px; border-radius: 22px; overflow: hidden; }
.big-btn.hero .bi { width: 58px; height: 58px; border-radius: 18px; }
.big-btn.hero .bi svg { width: 34px; height: 34px; }
.big-btn.hero .bt { display: flex; flex-direction: column; align-items: flex-start; }
.big-btn.hero b { font-size: 30px; line-height: 1.05; }
.big-btn.hero small { font-size: 14px; font-weight: 700; opacity: 0.92; }
.big-btn.hero::after { content: ''; position: absolute; inset: 0; border-radius: inherit; background: linear-gradient(105deg, transparent 35%, rgba(255,255,255,0.3) 50%, transparent 65%); background-size: 250% 100%; animation: shine 3.4s ease-in-out infinite; pointer-events: none; }
@keyframes shine { 0%, 60% { background-position: 120% 0; } 100% { background-position: -120% 0; } }
.big-btn.level { flex-direction: column; align-items: flex-start; gap: 2px; padding: 12px 18px; }
.big-btn.level b { font-size: 20px; }
.big-btn.level small { font-size: 13px; font-weight: 700; opacity: 0.92; text-shadow: none; }
.text-btn { background: none; border: 0; color: var(--muted); font-weight: 800; padding: 10px; }
.text-btn:hover { color: var(--ink); }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 10px 16px; border-radius: 14px; border: 1px solid var(--line); background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.05)); font-weight: 800; box-shadow: 0 3px 0 rgba(0,0,0,0.35); }
.btn.primary { background: linear-gradient(180deg, #48eba3, #1fbf74); color: #fff; box-shadow: 0 3px 0 #0b7f47; border-color: transparent; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* ---------- menus ---------- */
#menu { position: fixed; background: radial-gradient(ellipse 70% 60% at 50% 40%, rgba(6,10,18,0.72), rgba(6,10,18,0.94) 100%) !important; inset: 0; overflow-y: auto; touch-action: pan-y; background: radial-gradient(ellipse 70% 60% at 50% 40%, rgba(6,10,18,0.5), rgba(6,10,18,0.86) 100%); }
.screen { max-width: 560px; margin: 0 auto; padding: max(18px, 4vh) max(18px, env(safe-area-inset-right)) max(32px, env(safe-area-inset-bottom)) max(18px, env(safe-area-inset-left)); animation: rise 0.28s ease-out; }
.screen.wide { max-width: 760px; }
.screen.center { text-align: center; padding-top: 12vh; }
.screen.center .stack { margin: 0 auto; }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.logo { display: flex; align-items: center; justify-content: center; gap: 12px; margin: 0 0 18px; }
.logo-mark { width: 56px; height: 56px; filter: drop-shadow(0 6px 10px rgba(0,0,0,0.6)); animation: bob 3s ease-in-out infinite; }
@keyframes bob { 50% { transform: translateY(-4px) rotate(-6deg); } }
h1 { margin: 0; font-size: 38px; font-weight: 900; letter-spacing: -0.6px; line-height: 1; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,0.35), 0 10px 30px rgba(0,0,0,0.6); }
h2 { font-size: 26px; font-weight: 900; margin: 12px 0 6px; letter-spacing: -0.3px; }
.blurb { color: var(--muted); margin: 0 0 14px; line-height: 1.45; }
.blurb b { color: var(--ink); }
.grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-top: 14px; }
.grid .big-btn { flex-direction: column; gap: 8px; padding: 16px 10px 14px; min-height: 108px; }
.grid .big-btn b { font-size: 16px; }
.panel { margin-top: 20px; padding: 12px 14px 14px; border-radius: 22px; background: var(--panel); border: 1px solid var(--line); box-shadow: 0 14px 34px rgba(0,0,0,0.4); }
.kicker { color: var(--gold); font-size: 12px; font-weight: 900; text-transform: uppercase; letter-spacing: 1.3px; margin: 0 2px 10px; }
.sizes { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.panel .sizes { margin-bottom: 0; }
.size { display: flex; flex-direction: column; align-items: center; gap: 1px; padding: 10px 6px; min-height: 56px; border-radius: 16px; border: 2px solid transparent; background: linear-gradient(180deg, var(--panel2), rgba(16,22,34,0.9)); box-shadow: 0 4px 0 rgba(0,0,0,0.4); transition: transform 0.12s, border-color 0.15s, box-shadow 0.15s; }
.size b { font-size: 19px; font-weight: 900; }
.size small { font-size: 11px; font-weight: 700; color: var(--muted); }
.size:active { transform: translateY(2px); }
.size.on { border-color: var(--gold); box-shadow: 0 4px 0 rgba(0,0,0,0.4), 0 0 18px rgba(255,200,61,0.3); }

.bar { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-top: 18px; flex-wrap: wrap; }
.profile { display: flex; align-items: center; gap: 8px; padding: 5px 12px 5px 5px; border-radius: 999px; background: var(--panel); border: 1px solid var(--line); }
.profile input { width: 120px; background: none; border: 0; outline: none; user-select: text; font-weight: 800; }
.av { width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center; font-weight: 900; font-size: 14px; color: #fff; background: linear-gradient(135deg, #3d8bff, #8a4fff); box-shadow: inset 0 -2px 0 rgba(0,0,0,0.25); flex: none; position: relative; }
.coins { display: flex; align-items: center; gap: 7px; padding: 8px 14px 8px 9px; border-radius: 999px; background: linear-gradient(180deg, rgba(255,200,61,0.22), rgba(255,157,28,0.1)); border: 1px solid rgba(255,200,61,0.4); font-weight: 900; }
.coins .shop { display: flex; align-items: center; gap: 4px; color: var(--gold); font-size: 13px; padding-left: 9px; margin-left: 2px; border-left: 1px solid rgba(255,200,61,0.3); }
.coins .shop svg { width: 15px; height: 15px; }
.coins.static { cursor: default; }
.coin { display: inline-block; width: 18px; height: 18px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff6c4 0 12%, #ffd34d 30%, #e9a20c 70%, #a86c00); box-shadow: inset 0 0 0 2px rgba(150,90,0,0.35), 0 1px 3px rgba(0,0,0,0.4); vertical-align: -4px; flex: none; }

.back { display: inline-flex; align-items: center; gap: 4px; min-height: 40px; background: rgba(255,255,255,0.06); border: 1px solid var(--line); border-radius: 999px; color: var(--ink); padding: 7px 14px 7px 9px; font-weight: 800; }
.back svg { width: 18px; height: 18px; }
.stack { display: flex; flex-direction: column; gap: 12px; max-width: 420px; }
.levels-stack { max-width: none; }
.row { display: flex; gap: 8px; margin-top: 8px; align-items: center; }
.row .big-btn { width: auto; }
.or { margin: 18px 0 0; text-align: center; }
#btn-create { margin-top: 6px; }
#join-code { flex: 1; min-width: 0; text-transform: uppercase; background: rgba(0,0,0,0.4); border: 2px solid var(--line); border-radius: 14px; padding: 11px 12px; letter-spacing: 4px; font-weight: 900; user-select: text; outline: none; }
#join-code:focus { border-color: var(--go); }
.how { margin: 8px 0 16px; padding-left: 22px; line-height: 1.5; color: var(--muted); }
.how li { margin-bottom: 8px; }
.how b { color: var(--ink); }
.spinner { position: relative; width: 74px; height: 74px; margin: 0 auto 10px; }
.spinner::before { content: ''; position: absolute; inset: 0; border-radius: 50%; border: 5px solid rgba(255,255,255,0.08); border-top-color: var(--gold); animation: spin 0.9s linear infinite; }
.spinner span { position: absolute; inset: 24px; border-radius: 6px; border: 4px solid var(--p0); border-right-color: var(--p1); border-bottom-color: var(--p1); animation: spin 2.4s linear infinite reverse; }
@keyframes spin { to { transform: rotate(360deg); } }
.share { margin: 16px auto; max-width: 420px; }
.share .code { font-size: 46px; font-weight: 900; letter-spacing: 10px; color: var(--gold); text-shadow: 0 4px 20px rgba(255,200,61,0.35); user-select: text; }
.share .link { flex: 1; min-width: 0; background: rgba(0,0,0,0.4); border: 1px solid var(--line); border-radius: 12px; padding: 11px; color: var(--muted); user-select: text; }
#btn-cancel { margin-top: 18px; }
.shop-head { display: flex; align-items: center; justify-content: space-between; margin-top: 8px; }
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 12px; }
.tcard { padding: 10px; background: linear-gradient(180deg, var(--panel2), var(--panel)); border: 2px solid var(--line); border-radius: 18px; text-align: center; }
.tcard.on { border-color: var(--go); box-shadow: 0 0 24px rgba(32,199,122,0.25); }
.tcard canvas { width: 100%; aspect-ratio: 1; display: block; margin-bottom: 6px; border-radius: 12px; }
.tcard .btn { width: 100%; margin-top: 8px; min-height: 40px; }
.trophy { position: relative; width: 96px; height: 96px; margin: 0 auto; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #fff 0 8%, #ffd34d 25%, #e39b00 70%, #8a5a00); box-shadow: 0 0 0 8px rgba(255,200,61,0.15), 0 10px 40px rgba(255,200,61,0.4); animation: pop 0.5s cubic-bezier(.2,1.6,.4,1); }
.trophy.lose { background: radial-gradient(circle at 35% 30%, #fff 0 8%, #9aa6bd 30%, #4a5468 75%, #252b38); box-shadow: 0 10px 30px rgba(0,0,0,0.5); }
.trophy.draw { background: radial-gradient(circle at 35% 30%, #fff 0 8%, #d6dcea 30%, #8792ab 75%, #3c4459); box-shadow: 0 0 0 8px rgba(255,255,255,0.08), 0 10px 30px rgba(0,0,0,0.5); }
@keyframes pop { from { transform: scale(0.3); opacity: 0; } to { transform: none; opacity: 1; } }
.rscore { font-size: 22px; font-weight: 900; margin: 0 0 10px; }
.rscore .s0 { color: var(--p0); } .rscore .s1 { color: var(--p1); }
.reward { font-size: 24px; font-weight: 900; color: var(--gold); }

/* ---------- modal ---------- */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; background: rgba(4,7,12,0.6); animation: fade 0.15s; }
@keyframes fade { from { opacity: 0; } }
.modal .box { width: min(360px, 90vw); padding: 22px 20px 18px; border-radius: 22px; text-align: center; background: linear-gradient(180deg, #24304a, #161e30); border: 1px solid var(--line); box-shadow: 0 24px 60px rgba(0,0,0,0.6); animation: pop 0.25s cubic-bezier(.2,1.4,.4,1); }
.modal b { font-size: 21px; }
.modal p { color: var(--muted); margin: 8px 0 14px; }
.modal .row { justify-content: center; }
.modal .row .big-btn { flex: 1; }

/* ---------- HUD ---------- */
#hud { position: fixed; top: 0; left: 0; right: 0; display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right)) 8px max(10px, env(safe-area-inset-left)); pointer-events: none; z-index: 3; }
#hud > * { pointer-events: auto; }
.hud-right { display: flex; gap: 6px; }
.icon-btn { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 14px; border: 1px solid var(--line); background: rgba(16,22,34,0.88); box-shadow: 0 3px 0 rgba(0,0,0,0.4); }
.icon-btn:active { transform: translateY(2px); box-shadow: 0 1px 0 rgba(0,0,0,0.4); }
.icon-btn:disabled { opacity: 0.35; cursor: default; }
.icon-btn.sound .off { display: none; }
.icon-btn.sound.muted .on { display: none; }
.icon-btn.sound.muted .off { display: inline; }
.players { display: flex; align-items: center; gap: 10px; flex: 1; justify-content: center; min-width: 0; }
.pl { --t: 1; --pc: var(--p0); display: flex; align-items: center; gap: 8px; min-width: 0; max-width: 44%; padding: 5px 12px 5px 5px; border-radius: 999px; background: linear-gradient(180deg, rgba(34,44,66,0.94), rgba(16,22,34,0.94)); border: 2px solid var(--line); box-shadow: 0 4px 12px rgba(0,0,0,0.35); transition: box-shadow 0.25s, border-color 0.25s, opacity 0.25s; opacity: 0.72; }
#pl1 { --pc: var(--p1); }
.pl.right { padding: 5px 5px 5px 12px; }
.pl.right .who { align-items: flex-end; }
.pl.turn { opacity: 1; border-color: var(--pc); box-shadow: 0 0 22px color-mix(in srgb, var(--pc) 55%, transparent); }
.pl .av { width: 36px; height: 36px; background: var(--pc); font-size: 16px; }
.pl .av svg { width: 18px; height: 18px; fill: #fff; stroke: none; }
.pl.turn .av::after { content: ''; position: absolute; inset: -5px; border-radius: 50%; background: conic-gradient(var(--gold) calc(var(--t) * 360deg), rgba(255,255,255,0.08) 0); -webkit-mask: radial-gradient(circle, transparent 58%, #000 60%); mask: radial-gradient(circle, transparent 58%, #000 60%); }
.who { display: flex; flex-direction: column; gap: 1px; min-width: 0; flex: 1; }
.pl .name { font-weight: 900; font-size: 14px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pl .sub { color: var(--muted); font-size: 11px; font-weight: 700; white-space: nowrap; }
.pl .score { font-size: 26px; font-weight: 900; min-width: 28px; text-align: center; color: var(--pc); text-shadow: 0 2px 0 rgba(0,0,0,0.4); }
.pl .score.bump { animation: bump 0.35s ease-out; }
@keyframes bump { 50% { transform: scale(1.4); } }
.vs { display: flex; flex-direction: column; align-items: center; font-weight: 900; font-size: 12px; color: var(--gold); text-shadow: 0 0 10px rgba(255,200,61,0.5); }
#timer { font-size: 18px; color: #ff6a4d; text-shadow: 0 0 12px rgba(255,80,50,0.6); animation: pulse 1s ease-in-out infinite; }
@keyframes pulse { 50% { transform: scale(1.25); } }
#turn { position: fixed; left: 50%; bottom: max(14px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; align-items: center; gap: 8px; padding: 8px 16px 8px 10px; border-radius: 999px; background: rgba(8,12,20,0.88); border: 2px solid var(--tc, var(--p0)); font-weight: 900; font-size: 15px; white-space: nowrap; box-shadow: 0 8px 24px rgba(0,0,0,0.4), 0 0 18px color-mix(in srgb, var(--tc, var(--p0)) 35%, transparent); pointer-events: none; transition: border-color 0.2s; z-index: 2; }
#turn .mark { width: 22px; height: 22px; display: grid; place-items: center; border-radius: 50%; background: var(--tc, var(--p0)); }
#turn .mark svg { width: 13px; height: 13px; fill: #fff; stroke: none; }
#turn.pop { animation: turnpop 0.35s cubic-bezier(.2,1.6,.4,1); }
@keyframes turnpop { from { transform: translateX(-50%) scale(0.85); } }
#toast { position: fixed; left: 50%; top: 70px; transform: translate(-50%, -6px); max-width: 90%; padding: 9px 18px; border-radius: 999px; background: rgba(8,12,20,0.92); border: 1px solid var(--line); font-weight: 800; text-align: center; opacity: 0; transition: opacity 0.25s, transform 0.25s; pointer-events: none; box-shadow: 0 8px 24px rgba(0,0,0,0.4); z-index: 5; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }
#hint { position: fixed; left: 50%; bottom: calc(max(14px, env(safe-area-inset-bottom)) + 52px); transform: translateX(-50%); max-width: 86%; display: flex; align-items: center; gap: 10px; padding: 10px 16px; border-radius: 16px; background: rgba(8,12,20,0.9); border: 1px solid rgba(255,200,61,0.45); font-weight: 700; font-size: 14px; pointer-events: none; animation: rise 0.3s ease-out; z-index: 2; }
#hint .hand { width: 20px; height: 20px; border-radius: 50%; border: 3px solid var(--gold); animation: tap 1.4s ease-in-out infinite; flex: none; }
@keyframes tap { 0%, 100% { transform: scale(1); opacity: 1; } 50% { transform: scale(0.6); opacity: 0.5; } }

/* ---------- win celebration ---------- */
.confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 50; }
.win-banner { position: fixed; left: 50%; top: 45%; z-index: 40; transform: translate(-50%, -50%); pointer-events: none; white-space: nowrap;
  font-size: clamp(40px, 10vw, 96px); font-weight: 900; letter-spacing: -1px; color: #fff3a8;
  background: linear-gradient(180deg, #fffbe0, #ffd34d 55%, #ff9d1c); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 4px 0 #8a4a00) drop-shadow(0 10px 30px rgba(0,0,0,0.6));
  animation: banner 1.6s cubic-bezier(.2,1.5,.4,1) both; }
@keyframes banner { 0% { transform: translate(-50%, -50%) scale(0.2) rotate(-8deg); opacity: 0; } 18% { transform: translate(-50%, -50%) scale(1.12) rotate(2deg); opacity: 1; } 30% { transform: translate(-50%, -50%) scale(1) rotate(0); } 82% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -60%) scale(0.96); } }
.trophy.win::before { content: ''; position: absolute; inset: -70px; z-index: -1; border-radius: 50%;
  background: repeating-conic-gradient(rgba(255,211,77,0.28) 0 10deg, transparent 10deg 20deg);
  -webkit-mask: radial-gradient(circle, #000 25%, transparent 70%); mask: radial-gradient(circle, #000 25%, transparent 70%);
  animation: rays 8s linear infinite; }
.trophy.win::after { content: '★'; position: absolute; inset: 0; display: grid; place-items: center; font-size: 46px; color: #fff6c4; text-shadow: 0 2px 0 #a86c00; }
@keyframes rays { to { transform: rotate(360deg); } }
#s-result.won .rtitle { font-size: 40px; background: linear-gradient(180deg, #fffbe0, #ffd34d 60%, #ff9d1c); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 3px 0 rgba(0,0,0,0.35)); animation: pop 0.5s 0.1s cubic-bezier(.2,1.6,.4,1) both; }
.reward.bump { animation: bump 0.35s ease-out; }

@media (max-width: 600px), (max-height: 500px) {
  h1 { font-size: 28px; } .logo-mark { width: 42px; height: 42px; }
  .big-btn.hero b { font-size: 24px; } .grid .big-btn { min-height: 88px; }
  #hint { font-size: 12px; padding: 7px 12px; } #toast { font-size: 13px; padding: 6px 14px; top: 56px; }
  #hud { padding-top: max(5px, env(safe-area-inset-top)); padding-bottom: 4px; }
  .icon-btn { width: 40px; height: 40px; border-radius: 12px; }
  .pl .name { font-size: 12px; } .pl .av { width: 28px; height: 28px; font-size: 12px; } .pl .score { font-size: 21px; min-width: 22px; }
  .pl .sub { display: none; }
  #turn { font-size: 13px; padding: 6px 14px 6px 8px; }
}

/* Phones held sideways: compact menus, and the players sit in the HUD row. */
@media (max-height: 500px) and (min-aspect-ratio: 4/3) {
  .screen { max-width: 680px; padding: max(10px, env(safe-area-inset-top)) max(56px, env(safe-area-inset-right)) 16px max(56px, env(safe-area-inset-left)); }
  .logo { margin-bottom: 10px; } h1 { font-size: 24px; } .logo-mark { width: 34px; height: 34px; }
  .big-btn.hero { padding: 10px 16px; } .big-btn.hero .bi { width: 44px; height: 44px; } .big-btn.hero b { font-size: 22px; }
  .grid { grid-template-columns: repeat(4, 1fr); gap: 10px; margin-top: 10px; }
  .grid .big-btn { min-height: 0; padding: 10px 6px; gap: 4px; }
  .grid .big-btn .bi { width: 34px; height: 34px; border-radius: 10px; } .grid .big-btn .bi svg { width: 20px; height: 20px; }
  .grid .big-btn b { font-size: 14px; }
  .panel { margin-top: 12px; padding: 10px 12px; } .size { min-height: 0; padding: 6px; } .size b { font-size: 16px; }
  .levels-stack { flex-direction: row; } .big-btn.level { padding: 10px 12px; } .big-btn.level small { font-size: 11px; }
  .bar { margin-top: 10px; }
  .screen.center { padding-top: 4vh; }
  .players { gap: 6px; } .pl { max-width: 40%; }
}
/* Phones held upright: the players get their own row under the buttons. */
@media (max-width: 500px) and (orientation: portrait) {
  #hud { flex-wrap: wrap; row-gap: 6px; }
  .players { order: 3; flex: 0 0 100%; gap: 6px; }
  .pl { max-width: 46%; flex: 1 1 0; }
  .vs { font-size: 10px; }
  #toast { top: calc(max(5px, env(safe-area-inset-top)) + 100px); }
}

/* Phones held sideways: the turn pill and the first-game hint sit in the space
   beside the board instead of on top of it. */
@media (max-height: 500px) and (min-aspect-ratio: 4/3) {
  #turn { left: max(12px, env(safe-area-inset-left)); bottom: 50%; transform: translateY(50%); white-space: normal; max-width: calc(50vw - 50vh - 4px); }
  #turn.pop { animation: none; }
  #hint { left: auto; right: max(12px, env(safe-area-inset-right)); bottom: 50%; transform: translateY(50%); max-width: calc(50vw - 50vh - 4px); }
}

/* ---------- Wall Race ---------- */
.pl .score { display: flex; align-items: center; gap: 5px; }
.pl.right .score { flex-direction: row-reverse; }
.pl .score .wl { display: block; width: 7px; height: 22px; border-radius: 3px; background: linear-gradient(90deg, color-mix(in srgb, var(--wall) 70%, #fff), var(--wall) 50%, color-mix(in srgb, var(--wall) 70%, #000)); box-shadow: 0 2px 0 rgba(0,0,0,0.45), inset 0 0 0 1px rgba(0,0,0,0.15); position: relative; }
.pl .score .wl::after { content: ''; position: absolute; left: 2px; right: 2px; top: 5px; bottom: 5px; border-radius: 2px; background: var(--pc); }
#wallbar { position: fixed; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); z-index: 4; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; width: min(380px, calc(100vw - 20px)); padding: 10px; border-radius: 20px; background: rgba(8,12,20,0.94); border: 2px solid rgba(255,255,255,0.14); box-shadow: 0 10px 30px rgba(0,0,0,0.5); animation: rise 0.18s ease-out; }
#wallbar .big-btn { width: 100%; padding: 10px 12px; white-space: nowrap; }
#wallbar .wb-txt { grid-column: 1 / -1; grid-row: 1; font-weight: 900; font-size: 15px; color: var(--gold); text-align: center; line-height: 1.2; }
#wallbar.bad .wb-txt { color: #ff8a7a; }
#wallbar:not([hidden]) ~ #turn, body:has(#wallbar:not([hidden])) #turn { visibility: hidden; }
#hint .txt { line-height: 1.3; }
.logo-mark { width: 64px; height: 64px; animation: none; }
.tcard canvas { background: rgba(0,0,0,0.25); }
@media (max-height: 500px) and (min-aspect-ratio: 4/3) {
  #wallbar { left: auto; right: max(10px, env(safe-area-inset-right)); bottom: 50%; transform: translateY(50%); grid-template-columns: 1fr; width: min(180px, calc(50vw - 50vh - 10px)); }
  #wallbar .wb-txt { font-size: 13px; }
}
.sizes { grid-template-columns: repeat(2, 1fr); }
