/* Layout: full-bleed 3D narra sungkaan on a banig, lit by capiz windows at night; HUD floats over top and bottom edges. Single dark look by choice. */
:root {
  --night: #0d0a09;
  --panel: rgba(22, 15, 12, .84);
  --ink: #fbf1e0;
  --muted: #c4b5a3;
  --gold: #f0b54a;
  --narra: #6b2f17;
  --them: #ff9a6b;
  --win: #66e38c;
  --lose: #ff8270;
  --line: rgba(251, 241, 224, .14);
  --display: 'Bungee', Impact, 'Arial Black', sans-serif;
  --body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
  color-scheme: dark;
}
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; background: var(--night); color: var(--ink); font-family: var(--body); overflow: hidden; }
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
.hud { position: fixed; inset: 0; pointer-events: none; display: flex; flex-direction: column; justify-content: space-between;
  padding: max(12px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(12px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.lbl { font-size: 11px; font-weight: 800; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); }
.num { font-family: var(--display); font-variant-numeric: tabular-nums; }
.panel { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; backdrop-filter: blur(8px); pointer-events: auto; }

.top { display: grid; grid-template-columns: 1fr auto 1fr; align-items: start; gap: 12px; }
.side { padding: 10px 14px; display: grid; gap: 2px; transition: box-shadow .25s, border-color .25s; min-width: 0; }
.side.them { justify-self: start; }
.side.you { justify-self: end; text-align: right; }
.side .row { display: flex; align-items: baseline; gap: 10px; }
.side.you .row { justify-content: flex-end; }
.side .score { font-size: 28px; }
.side.them .score { color: var(--them); }
.side.you .score { color: var(--gold); }
.side .who { font-weight: 800; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.side.turn.them { border-color: var(--them); box-shadow: 0 0 0 2px var(--them), 0 0 24px rgba(255, 154, 107, .3); }
.side.turn.you { border-color: var(--gold); box-shadow: 0 0 0 2px var(--gold), 0 0 24px rgba(240, 181, 74, .3); }

.sign { font-family: var(--display); font-size: clamp(18px, 2.6vw, 30px); letter-spacing: .06em; color: var(--gold); white-space: nowrap;
  padding: 10px 24px 8px; border-radius: 10px; text-shadow: 0 2px 0 #2a0f05, 0 0 18px rgba(255, 190, 80, .45);
  background: repeating-linear-gradient(176deg, #6b2f17 0 7px, #5c2712 7px 9px, #74361b 9px 15px);
  box-shadow: 0 0 0 3px #2a0f05, 0 0 0 5px #b98a4a, 0 10px 30px rgba(0, 0, 0, .5); pointer-events: auto; }
.sign small { display: block; font: 800 10px var(--body); letter-spacing: .3em; color: #f5d9a8; text-align: center; margin-top: 2px; text-shadow: none; }

.middle { flex: 1; display: grid; place-items: start center; padding-top: 12px; pointer-events: none; }
.toast { background: var(--narra); color: var(--ink); font-weight: 800; letter-spacing: .02em; padding: 8px 16px; border-radius: 10px;
  box-shadow: 0 0 0 2px var(--gold), 0 8px 20px rgba(0,0,0,.4); animation: pop .3s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes pop { from { transform: scale(.85); opacity: 0; } }

.foot { display: grid; gap: 8px; justify-items: center; }
.bar { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 10px 18px; padding: 10px 14px; max-width: 100%; box-sizing: border-box; }
#status { font-weight: 600; font-size: 15px; min-width: 0; text-align: center; }
#status b { color: var(--gold); }
.tools { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.btn { font: 800 13px var(--body); letter-spacing: .04em; padding: 10px 14px; border-radius: 11px; cursor: pointer; border: 1px solid var(--line); background: rgba(255,255,255,.07); color: var(--ink); min-height: 40px; box-sizing: border-box; }
.btn:hover:not(:disabled) { background: rgba(255,255,255,.14); }
.btn:disabled { opacity: .4; cursor: not-allowed; }
.btn.primary { font: 400 17px var(--display); padding: 11px 22px; background: var(--gold); color: #3a1a05; border: 0; box-shadow: 0 4px 0 #9c6c14, 0 0 24px rgba(240, 181, 74, .3); }
.btn.primary:hover:not(:disabled) { background: #ffc965; }
.btn.primary:active:not(:disabled) { transform: translateY(2px); box-shadow: 0 2px 0 #9c6c14; }
button:focus-visible { outline: 3px solid #8fd3ff; outline-offset: 3px; }
.help { margin: 0; font-size: 12px; color: var(--muted); text-shadow: 0 1px 3px #000; text-align: center; }
kbd { font: 600 11px var(--body); border: 1px solid var(--line); border-radius: 4px; padding: 0 4px; }

/* shell counts pinned to each pit */
#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.cnt { position: absolute; left: 0; top: 0; font: 400 13px var(--display); font-variant-numeric: tabular-nums; padding: 2px 7px; border-radius: 7px;
  background: rgba(15, 10, 8, .72); color: var(--ink); border: 1px solid var(--line); will-change: transform; }
.cnt.theirs { color: #ffd2bd; }
.cnt.store { font-size: 18px; padding: 3px 10px; color: var(--gold); border-color: rgba(240, 181, 74, .5); }
.cnt.store.theirs { color: var(--them); border-color: rgba(255, 154, 107, .5); }
.cnt.hand { background: var(--gold); color: #3a1a05; border: 0; }
.cnt.zero { opacity: .45; }

/* overlays */
.overlay { position: fixed; inset: 0; display: flex; background: rgba(8, 6, 5, .55); backdrop-filter: blur(3px); overflow-y: auto;
  padding: max(16px, env(safe-area-inset-top, 0px)) max(16px, env(safe-area-inset-right, 0px)) max(16px, env(safe-area-inset-bottom, 0px)) max(16px, env(safe-area-inset-left, 0px)); }
.sheet { margin: auto; background: var(--panel); border: 1px solid var(--line); border-radius: 18px; padding: 22px; width: min(720px, 100%); box-sizing: border-box; display: grid; gap: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.55); animation: pop .3s cubic-bezier(.2, 1.4, .4, 1); }
.sheet.small { width: min(440px, 100%); text-align: center; }
.sheet h1, .sheet h2 { font: 400 clamp(24px, 4vw, 34px)/1.1 var(--display); color: var(--gold); margin: 0; text-wrap: balance; }
.sheet p { margin: 0; line-height: 1.5; color: var(--muted); }
.sheet header { display: grid; gap: 6px; }
.ladder { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.rung { width: 100%; display: grid; grid-template-columns: 44px 1fr auto; gap: 14px; align-items: center; text-align: left; cursor: pointer;
  padding: 12px 14px; border-radius: 12px; border: 1px solid var(--line); background: rgba(255,255,255,.05); color: var(--ink); font: inherit; }
.rung:hover:not(:disabled) { background: rgba(255,255,255,.1); border-color: rgba(240,181,74,.5); }
.rung:disabled { cursor: not-allowed; opacity: .5; }
.rung .n { font: 400 24px var(--display); color: var(--gold); text-align: center; }
.rung .info { display: grid; gap: 2px; min-width: 0; }
.rung .nm { font-weight: 800; font-size: 16px; }
.rung .role { font-size: 12px; font-weight: 800; letter-spacing: .1em; text-transform: uppercase; color: var(--muted); }
.rung .blurb { font-size: 13px; color: var(--muted); }
.rung .st { display: grid; gap: 4px; justify-items: end; font-size: 12px; font-weight: 800; letter-spacing: .06em; text-transform: uppercase; white-space: nowrap; }
.rung .pips { color: var(--gold); letter-spacing: 2px; font-size: 11px; }
.rung.beat .st span:first-child { color: var(--win); }
.rung.next { border-color: var(--gold); }
.row-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
.linkbtn { background: none; border: 0; color: var(--muted); font: 600 12px var(--body); text-decoration: underline; cursor: pointer; justify-self: center; min-height: 40px; padding: 0 16px; }
.rules { margin: 0; padding-left: 20px; display: grid; gap: 8px; line-height: 1.5; }
.rules b { color: var(--ink); }
.final { font: 400 40px var(--display); color: var(--ink) !important; }
.final .y { color: var(--gold); } .final .t { color: var(--them); }
#rTitle.lose { color: var(--lose); }
#loading { position: fixed; inset: 0; display: grid; place-items: center; font-family: var(--display); color: var(--gold); background: var(--night); }

@media (max-width: 700px) {
  .top { grid-template-columns: 1fr 1fr; }
  .sign { display: none; }
  .side .score { font-size: 22px; }
  .help { display: none; }
  .rung { grid-template-columns: 32px 1fr; }
  .rung .st { grid-column: 2; justify-items: start; }
  .rung .blurb { display: none; }
  .lg { display: none; }
  .rung .st { display: flex; gap: 10px; align-items: center; }
  .side { padding: 8px 12px; }
  .side .who { font-size: 13px; }
  .bar { gap: 8px; padding: 8px 10px; width: 100%; }
  #status { width: 100%; font-size: 14px; }
  .tools { flex-wrap: nowrap; gap: 6px; }
  .btn { padding: 9px 11px; font-size: 12px; }
  .cnt { font-size: 11px; padding: 1px 5px; }
  .cnt.store { font-size: 14px; padding: 2px 7px; }
  .sheet { padding: 18px 16px; gap: 12px; }
  .final { font-size: 32px; }
}
/* short landscape phones: shrink the HUD so the board keeps the middle */
@media (max-height: 500px) {
  .sign, .help { display: none; }
  .top { grid-template-columns: 1fr 1fr; }
  .side { padding: 6px 12px; }
  .side .score { font-size: 20px; }
  .bar { padding: 6px 10px; }
  .btn { padding: 7px 10px; font-size: 12px; }
  .lg { display: none; }
}
@media (prefers-reduced-motion: reduce) { .toast, .sheet { animation: none; } }
.linkbox { width: 100%; box-sizing: border-box; margin: 6px 0 14px; padding: 10px 12px; border-radius: 10px; border: 1px solid var(--line); background: rgba(0,0,0,.35); color: var(--ink); font: 600 14px var(--body); pointer-events: auto; }
a.btn { display: inline-flex; align-items: center; text-decoration: none; }
.sheet p a { color: var(--gold); }
