/* Carrom: a wooden board on a dark cloth, a slim score bar, dark cards. */
@font-face { font-family: "Unbounded"; font-weight: 700; font-display: swap; src: url("/assets/fonts/unbounded-700.woff2") format("woff2"); }
@font-face { font-family: "Unbounded"; font-weight: 800; font-display: swap; src: url("/assets/fonts/unbounded-800.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-weight: 500; font-display: swap; src: url("/assets/fonts/sora-500.woff2") format("woff2"); }
@font-face { font-family: "Sora"; font-weight: 700; font-display: swap; src: url("/assets/fonts/sora-700.woff2") format("woff2"); }

:root { --spawn: #31e981; --ink-on-spawn: #0b1a12; --font-display: "Unbounded", system-ui, sans-serif; --font-body: "Sora", system-ui, sans-serif; --fg: #f4f1ea; --fg-2: rgba(244, 241, 234, 0.72); --line: rgba(255, 255, 255, 0.14); --glass: rgba(10, 12, 30, 0.55); --glass-2: rgba(255, 255, 255, 0.08);
  --page: #1a110a; --hud-glass: rgba(20, 12, 6, 0.55); --hud-line: rgba(255, 255, 255, 0.16); }
body[data-theme="rosewood"] { --page: #140b08; }
body[data-theme="midnight"] { --page: #070912; --hud-glass: rgba(10, 12, 30, 0.6); }
* { box-sizing: border-box; }
html, body { height: 100%; }
body { margin: 0; background: var(--page); color: var(--fg); font-family: var(--font-body); font-weight: 500; overflow: hidden; user-select: none; -webkit-user-select: none; -webkit-font-smoothing: antialiased; touch-action: none; transition: background 0.4s; }
button { font: inherit; color: inherit; }
#game { position: fixed; inset: 0; display: block; touch-action: none; outline: 0; }
#game.aiming { cursor: crosshair; }

.hud { position: fixed; left: 0; right: 0; top: 0; display: flex; align-items: center; gap: 10px; padding: max(10px, env(safe-area-inset-top)) 12px 6px; pointer-events: none; }
.hud-brand { display: flex; align-items: center; gap: 8px; color: inherit; text-decoration: none; pointer-events: auto; }
.hud-brand svg { width: 32px; height: 32px; display: block; filter: drop-shadow(0 4px 10px rgba(0,0,0,.4)); }
.hud-title { font-family: var(--font-display); font-size: 0.95rem; font-weight: 800; margin: 0; }
.hud-actions { margin-left: auto; display: flex; gap: 6px; pointer-events: auto; }
.icon-btn { width: 36px; height: 36px; border-radius: 999px; border: 1px solid var(--hud-line); background: var(--hud-glass); backdrop-filter: blur(10px); color: var(--fg); display: grid; place-items: center; cursor: pointer; transition: transform 0.15s, background 0.15s; }
.icon-btn:hover { transform: translateY(-1px); background: rgba(255, 255, 255, 0.14); }
.icon-btn svg { width: 18px; height: 18px; fill: currentColor; }
#btn-sound .ic-off { display: none; }
#btn-sound[aria-pressed="false"] .ic-on { display: none; }
#btn-sound[aria-pressed="false"] .ic-off { display: block; }

.scores { position: fixed; left: 50%; transform: translateX(-50%); top: calc(max(10px, env(safe-area-inset-top)) + 46px); display: flex; align-items: center; gap: 8px; pointer-events: none; z-index: 5; max-width: calc(100vw - 16px); }
.pl { display: flex; align-items: center; gap: 7px; background: var(--hud-glass); backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px); border: 1px solid var(--hud-line); border-radius: 999px; padding: 5px 12px; min-height: 34px; transition: box-shadow 0.25s, border-color 0.25s; }
.pl.active { border-color: var(--spawn); box-shadow: 0 0 0 2px rgba(49, 233, 129, 0.25), 0 6px 20px rgba(49, 233, 129, 0.15); }
.chip { width: 16px; height: 16px; border-radius: 50%; box-shadow: inset 0 -2px 3px rgba(0,0,0,.4), 0 0 0 2px rgba(255,255,255,.18); flex: none; }
.chip.w { background: #f3e9d0; } .chip.b { background: #2a211c; }
.pname { font-weight: 700; font-size: 0.86rem; white-space: nowrap; max-width: 26vw; overflow: hidden; text-overflow: ellipsis; }
.pcount { display: inline-flex; gap: 2px; }
.pcount i { width: 7px; height: 7px; border-radius: 50%; background: rgba(255,255,255,0.22); display: block; }
.pcount i.on { background: var(--spawn); }
.pqueen { color: #ff5a6a; font-size: 1rem; line-height: 1; }
.pqueen[hidden] { display: none; }
.vs { font-size: 0.74rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: var(--fg-2); text-align: center; min-width: 70px; white-space: nowrap; }

.banner { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); z-index: 15; font-family: var(--font-display); font-weight: 800; font-size: 1.15rem; color: #fff; background: rgba(20, 12, 6, 0.8); border: 1px solid rgba(255,255,255,.18); padding: 12px 22px; border-radius: 999px; text-shadow: 0 2px 10px rgba(0,0,0,.6); pointer-events: none; animation: banner-pop 0.3s cubic-bezier(.2,.9,.2,1.4); white-space: nowrap; max-width: 92vw; overflow: hidden; text-overflow: ellipsis; }
.banner[hidden] { display: none; }
@keyframes banner-pop { from { transform: translate(-50%, -50%) scale(0.7); opacity: 0; } }
.toast { position: fixed; left: 50%; bottom: 30px; transform: translateX(-50%) translateY(10px); z-index: 20; background: rgba(20, 20, 28, 0.92); border: 1px solid var(--line); color: var(--fg); padding: 10px 16px; border-radius: 999px; font-size: 0.88rem; font-weight: 700; opacity: 0; transition: opacity 0.2s, transform 0.2s; pointer-events: none; max-width: 90vw; text-align: center; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast[hidden] { display: none; }

.overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; padding: 16px; background: rgba(5, 7, 20, 0.55); backdrop-filter: blur(8px); -webkit-backdrop-filter: blur(8px); overflow: auto; }
.overlay[hidden] { display: none; }
.card { width: 100%; max-width: 460px; color: var(--fg); background: linear-gradient(180deg, rgba(44, 30, 20, 0.97), rgba(20, 12, 8, 0.99)); border: 1px solid var(--line); border-radius: 26px; padding: 24px 24px 22px; box-shadow: 0 30px 80px rgba(0, 0, 0, 0.5); animation: pop 0.28s cubic-bezier(.2,.9,.2,1.2); max-height: calc(100dvh - 32px); overflow: auto; }
@keyframes pop { from { transform: scale(0.92) translateY(10px); opacity: 0; } }
.kicker { margin: 0 0 6px; font-size: 0.72rem; font-weight: 700; letter-spacing: 0.14em; text-transform: uppercase; color: var(--spawn); }
.card h2 { margin: 0 0 14px; font-family: var(--font-display); font-weight: 800; font-size: 1.5rem; letter-spacing: -0.02em; line-height: 1.1; }
.muted { color: var(--fg-2); margin: 0; line-height: 1.55; font-size: 0.95rem; }
.card-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 20px; }
.btn { display: inline-flex; align-items: center; justify-content: center; gap: 8px; padding: 12px 20px; border-radius: 999px; border: 1.5px solid transparent; font-weight: 700; font-size: 0.95rem; cursor: pointer; text-decoration: none; color: inherit; transition: transform 0.15s, box-shadow 0.15s; }
.btn-primary { background: var(--spawn); color: var(--ink-on-spawn); }
.btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 24px rgba(49, 233, 129, 0.35); }
.btn-ghost { background: transparent; border-color: var(--line); }
.btn-ghost:hover { border-color: var(--fg); }
.btn[hidden] { display: none; }
.row { display: flex; align-items: center; gap: 12px; margin: 10px 0; }
.row[hidden] { display: none; }
.lbl { flex: none; width: 84px; font-size: 0.78rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: var(--fg-2); }
.seg { display: flex; gap: 4px; background: var(--glass-2); border: 1px solid var(--line); border-radius: 999px; padding: 3px; flex-wrap: wrap; }
.seg button { border: 0; background: transparent; border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: 0.86rem; cursor: pointer; color: var(--fg-2); transition: background 0.15s, color 0.15s; }
.seg button.on { background: var(--spawn); color: var(--ink-on-spawn); }
.note { margin: -2px 0 8px 96px; font-size: 0.8rem; color: var(--fg-2); line-height: 1.5; }
.how { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 14px; }
.how li { display: flex; gap: 14px; align-items: flex-start; color: var(--fg-2); line-height: 1.5; font-size: 0.93rem; }
.how-ic { flex: none; width: 44px; height: 44px; border-radius: 12px; display: grid; place-items: center; color: #fff; box-shadow: 0 6px 16px rgba(0, 0, 0, 0.35); }
.how-ic svg { width: 26px; height: 26px; fill: currentColor; }
.ic-a { background: linear-gradient(180deg, #ffd9a8, #c9742e); }
.ic-b { background: linear-gradient(180deg, #e8e2d2, #6a5a48); }
.ic-c { background: linear-gradient(180deg, #ff8a93, #b8232f); }
.keys { margin: 16px 0 0; font-size: 0.78rem; color: var(--fg-2); line-height: 1.7; }
.card kbd { font-family: inherit; font-weight: 700; font-size: 0.78em; border: 1px solid var(--line); border-bottom-width: 2px; border-radius: 6px; padding: 1px 6px; background: var(--glass-2); margin: 0 1px; }
.card-win { text-align: center; }
.card-win .card-actions { justify-content: center; }

@media (max-width: 520px) {
  .hud { gap: 6px; padding-left: 8px; padding-right: 8px; }
  .hud-title { display: none; }
  .icon-btn { width: 32px; height: 32px; }
  .icon-btn svg { width: 16px; height: 16px; }
  .scores { gap: 6px; row-gap: 3px; flex-wrap: wrap; justify-content: center; top: calc(max(10px, env(safe-area-inset-top)) + 42px); }
  .pl { padding: 4px 9px; min-height: 30px; gap: 5px; }
  .pname { font-size: 0.78rem; max-width: 24vw; }
  .pcount i { width: 6px; height: 6px; }
  .vs { order: 3; flex-basis: 100%; min-width: 0; font-size: 0.66rem; }
  .banner { font-size: 0.95rem; padding: 9px 16px; }
  .lbl { width: 70px; }
  .note { margin-left: 0; }
  .seg button { padding: 6px 11px; font-size: 0.8rem; }
}
@media (prefers-reduced-motion: reduce) { .card, .banner { animation: none; } }
