/* Noos Gammon */
/* Remove the browser's default 8px body margin so the global header sits flush. */
html, body { margin: 0; padding: 0; }
.gm-wrap { font-family: 'Quicksand', sans-serif; color: #fff; max-width: 1100px; margin: 0 auto; padding: 10px 12px 18px; box-sizing: border-box; }
.gm-wrap *, .gm-wrap *::before, .gm-wrap *::after { box-sizing: border-box; }
.gm-wrap [hidden] { display: none !important; }

/* ---- themes (colours only; the board is SVG and reads these variables) */
.gm-wrap { --gold: #ffd700; --panel: #1b2230; --panel2: #232c3e; --text-muted: #8b9bb4;
  --gm-board: #1b2230; --gm-ta: #2f3f5a; --gm-tb: #4a5d82; --gm-bar: #10151d; --gm-tray: #141a25;
  --p1a: #ff9a9a; --p1b: #d63a3a; --p1s: #8f1d1d; --p2a: #ffffff; --p2b: #cdd5e2; --p2s: #8a94a8; }
.gm-wrap[data-theme="walnut"] { --gm-board: #3b2a1e; --gm-ta: #6b4a30; --gm-tb: #c9a26a; --gm-bar: #26180f; --gm-tray: #2d1f15;
  --p1a: #ff8d7a; --p1b: #b8281c; --p1s: #6b140d; --p2a: #fffaf0; --p2b: #d9ccaa; --p2s: #8c7a52; }
.gm-wrap[data-theme="mint"] { --gm-board: #12302f; --gm-ta: #1f5a56; --gm-tb: #3fa39a; --gm-bar: #0b1f1e; --gm-tray: #0f2827;
  --p1a: #ff9d8f; --p1b: #d4453a; --p1s: #85231b; --p2a: #f7fffb; --p2b: #c3e3d6; --p2s: #6c9a89; }

/* ---- HUD */
.gm-hud { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.25fr) minmax(0, 1fr); gap: 10px; align-items: stretch; max-width: 1000px; margin: 0 auto 10px; }
.gm-pcard { display: flex; align-items: center; gap: 10px; background: var(--panel); border: 2px solid transparent; border-radius: 14px; padding: 8px 12px; min-width: 0; transition: border-color .2s, box-shadow .2s; }
.gm-pcard.on { border-color: var(--gold); box-shadow: 0 0 14px rgba(255, 215, 0, .25); }
.gm-chip { width: 22px; height: 22px; border-radius: 50%; flex: none; }
.gm-chip.c1 { background: radial-gradient(circle at 30% 30%, var(--p1a), var(--p1b)); }
.gm-chip.c2 { background: radial-gradient(circle at 30% 30%, var(--p2a), var(--p2b)); }
.gm-pinfo { display: flex; flex-direction: column; min-width: 0; flex: 1; }
.gm-nm { font-weight: 700; font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.gm-sub { font-size: .78rem; color: var(--text-muted); white-space: nowrap; }
.gm-sub b { color: #fff; }
.gm-sc { font-size: 1.5rem; font-weight: 700; color: var(--gold); min-width: 1.2em; text-align: right; }
.gm-mid { background: var(--panel); border-radius: 14px; padding: 8px 12px; text-align: center; display: flex; flex-direction: column; justify-content: center; min-width: 0; }
.gm-matchline { font-size: .74rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
.gm-status { font-weight: 600; font-size: .98rem; line-height: 1.25; margin-top: 2px; }

/* ---- board */
.gm-boardbox { position: relative; width: min(100%, 1000px, calc((100vh - 250px) * 1.5625)); min-width: min(100%, 560px); margin: 0 auto; aspect-ratio: 1000 / 640;
  border-radius: 24px; box-shadow: 0 16px 48px rgba(0, 0, 0, .45); transition: box-shadow .25s; }
@supports (height: 100dvh) { .gm-boardbox { width: min(100%, 1000px, calc((100dvh - 250px) * 1.5625)); } }
.gm-boardbox.turn1 { box-shadow: 0 16px 48px rgba(0, 0, 0, .45), 0 0 0 3px rgba(255, 120, 120, .35); }
.gm-boardbox.turn2 { box-shadow: 0 16px 48px rgba(0, 0, 0, .45), 0 0 0 3px rgba(220, 230, 255, .3); }
.gm-wrap.is-portrait .gm-boardbox { width: min(100%, 560px, calc((100vh - 215px) * .64)); min-width: min(100%, 300px); aspect-ratio: 640 / 1000; }
@supports (height: 100dvh) { .gm-wrap.is-portrait .gm-boardbox { width: min(100%, 560px, calc((100dvh - 215px) * .64)); } }
#gmBoard { display: block; width: 100%; height: 100%; touch-action: none; user-select: none; -webkit-user-select: none; cursor: pointer; }
#gmBoard.dragging { cursor: grabbing; }
#gmBoard .board { fill: var(--gm-board); }
#gmBoard .tri.ta { fill: var(--gm-ta); }
#gmBoard .tri.tb { fill: var(--gm-tb); }
#gmBoard .barbg { fill: var(--gm-bar); }
#gmBoard .traybg { fill: var(--gm-tray); stroke: rgba(255, 255, 255, .06); stroke-width: 2; stroke-dasharray: 6 6; }
#gmBoard .plabel { fill: rgba(255, 255, 255, .38); font: 700 15px 'Quicksand', sans-serif; text-anchor: middle; pointer-events: none; }
#gmBoard .ck .body { stroke-width: 2.5; }
#gmBoard .ck1 .body { fill: url(#gmG1); stroke: var(--p1s); }
#gmBoard .ck2 .body { fill: url(#gmG2); stroke: var(--p2s); }
#gmBoard .ck .rim { fill: none; stroke-width: 2.5; }
#gmBoard .ck1 .rim { stroke: rgba(255, 255, 255, .5); }
#gmBoard .ck2 .rim { stroke: rgba(0, 0, 0, .2); }
#gmBoard .ck .sym { display: none; pointer-events: none; }
.gm-sym #gmBoard .ck1 .s1 { display: block; fill: rgba(255, 255, 255, .95); }
.gm-sym #gmBoard .ck2 .s2 { display: block; fill: rgba(25, 32, 46, .9); }
#gmBoard .ck.sel .body { stroke: var(--gold); stroke-width: 6; }
#gmBoard .ck, #gmBoard .offck, #gmBoard .badge, #gmBoard .cube { pointer-events: none; }
#gmBoard .ghost { opacity: .85; }
#gmBoard .badge { font: 700 21px 'Quicksand', sans-serif; text-anchor: middle; }
#gmBoard .badge.b1 { fill: #fff; paint-order: stroke; stroke: rgba(120, 20, 20, .85); stroke-width: 4px; }
#gmBoard .badge.b2 { fill: #1a2230; paint-order: stroke; stroke: rgba(255, 255, 255, .8); stroke-width: 4px; }
#gmBoard .offck.o1 { fill: var(--p1b); stroke: var(--p1s); stroke-width: 1.5; }
#gmBoard .offck.o2 { fill: var(--p2b); stroke: var(--p2s); stroke-width: 1.5; }
#gmBoard .can { fill: none; stroke: rgba(255, 215, 0, .7); stroke-width: 3.5; stroke-dasharray: 7 6; pointer-events: none; animation: gmDash 1.4s linear infinite; }
@keyframes gmDash { to { stroke-dashoffset: -26; } }
#gmBoard .org { fill: rgba(255, 215, 0, .14); pointer-events: none; }
#gmBoard .tgt { fill: rgba(64, 255, 150, .2); stroke: rgba(64, 255, 150, .75); stroke-width: 2.5; pointer-events: none; }
#gmBoard .tgt.multi { fill: rgba(77, 208, 225, .2); stroke: rgba(77, 208, 225, .85); }
#gmBoard .dot { fill: rgba(64, 255, 150, .9); pointer-events: none; }
#gmBoard .dot.hitdot { fill: #ff5252; }
#gmBoard .harrow { fill: none; stroke: #4dd0e1; stroke-width: 5; stroke-linecap: round; opacity: .9; pointer-events: none; }
#gmBoard .cube rect { fill: #f5f0e1; stroke: #1a1a1a; stroke-width: 2; }
#gmBoard .cube text { fill: #1a1a1a; font: 700 26px 'Quicksand', sans-serif; text-anchor: middle; }
#gmBoard .cube.own1 rect { stroke: var(--p1b); stroke-width: 5; }
#gmBoard .cube.own2 rect { stroke: var(--p2b); stroke-width: 5; }
#gmBoard .pulse { fill: none; stroke: #ff5252; stroke-width: 6; transform-box: fill-box; transform-origin: center; animation: gmPulse .6s ease-out forwards; pointer-events: none; }
@keyframes gmPulse { from { opacity: 1; transform: scale(.6); } to { opacity: 0; transform: scale(1.9); } }

.gm-toast { position: absolute; left: 50%; top: 46%; transform: translate(-50%, 8px); background: rgba(10, 14, 22, .92); border: 1px solid rgba(255, 255, 255, .15); padding: 10px 18px; border-radius: 999px;
  font-weight: 700; opacity: 0; pointer-events: none; transition: opacity .2s, transform .2s; z-index: 5; white-space: nowrap; }
.gm-toast.on { opacity: 1; transform: translate(-50%, 0); }

/* ---- controls */
.gm-controls { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 10px; max-width: 1000px; margin: 12px auto 0; }
.gm-dice { display: flex; align-items: center; gap: 8px; min-height: 52px; }
.gm-dicehint { color: var(--text-muted); font-size: .85rem; }
.gm-vs { color: var(--text-muted); font-size: .8rem; }
.gm-die { width: 46px; height: 46px; border-radius: 10px; background: #fff; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); padding: 7px; gap: 2px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, .35); border-bottom: 4px solid #aeb7c7; transition: opacity .2s, transform .2s; }
.gm-die i { border-radius: 50%; }
.gm-die i.on { background: #1a1a1a; }
.gm-die.d1 { border-bottom-color: var(--p1b); }
.gm-die.d2 { border-bottom-color: var(--p2s); }
.gm-die.used { opacity: .25; transform: scale(.9); }
.gm-die.roll { animation: gmShake .14s linear infinite; }
@keyframes gmShake { 0% { transform: rotate(-6deg); } 50% { transform: rotate(6deg) translateY(-2px); } 100% { transform: rotate(-6deg); } }
.gm-btns { display: flex; flex-wrap: wrap; gap: 8px; }
.gm-btn { background: linear-gradient(135deg, #3a475c, #283243); border: 1px solid rgba(255, 255, 255, .12); color: #fff; padding: 11px 18px; min-height: 44px; border-radius: 10px; cursor: pointer;
  font: 700 .95rem 'Quicksand', sans-serif; transition: transform .15s, border-color .15s; white-space: nowrap; }
.gm-btn:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--gold); }
.gm-btn:focus-visible, .gm-seg:focus-visible, .gm-toggle:focus-visible { outline: 3px solid var(--gold); outline-offset: 2px; }
.gm-btn:disabled { opacity: .38; cursor: not-allowed; }
.gm-btn.primary { background: linear-gradient(135deg, #ffd700, #f4a300); color: #1a1a1a; border-color: transparent; }
.gm-btn.big { padding: 13px 36px; font-size: 1.1rem; }
.gm-btn.icon { padding: 11px 14px; font-size: 1.15rem; }
.gm-btn.pulse:not(:disabled) { animation: gmBtnPulse 1.4s ease-in-out infinite; }
@keyframes gmBtnPulse { 0%, 100% { box-shadow: 0 0 0 0 rgba(255, 215, 0, .5); } 50% { box-shadow: 0 0 0 9px rgba(255, 215, 0, 0); } }

/* ---- overlays (opaque; never centre a scrolling overlay with justify-content) */
.gm-ov { position: fixed; inset: 0; z-index: 9000; background: rgba(8, 11, 17, .985); display: flex; overflow-y: auto; padding: 16px; -webkit-overflow-scrolling: touch; }
.gm-ov > .gm-card { margin: auto; }
.gm-card { position: relative; background: var(--panel); border: 1px solid rgba(255, 255, 255, .08); border-radius: 18px; padding: 24px; width: 100%; max-width: 500px; box-shadow: 0 20px 60px rgba(0, 0, 0, .5); }
.gm-card.narrow { max-width: 400px; text-align: center; }
.gm-card h1 { margin: 0 0 4px; font-size: 1.9rem; }
.gm-card h2 { margin: 0 0 8px; font-size: 1.5rem; }
.gm-card h3 { margin: 16px 0 6px; font-size: .78rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; }
.gm-tag, .gm-desc, .gm-best, .gm-note { color: var(--text-muted); margin: 4px 0; line-height: 1.4; }
.gm-desc { min-height: 2.8em; font-size: .92rem; color: #cbd5e6; }
.gm-best { color: var(--gold); font-weight: 600; min-height: 1.3em; }
.gm-x { position: absolute; right: 10px; top: 8px; background: none; border: 0; color: var(--text-muted); font-size: 1.8rem; cursor: pointer; line-height: 1; padding: 6px 10px; }
.gm-row { display: flex; gap: 10px; margin-top: 18px; justify-content: center; flex-wrap: wrap; }
.gm-segs { display: flex; flex-wrap: wrap; gap: 8px; }
.gm-seg { background: var(--panel2); color: #fff; border: 2px solid transparent; border-radius: 999px; padding: 9px 15px; min-height: 40px; font: 700 .9rem 'Quicksand', sans-serif; cursor: pointer; }
.gm-seg[aria-checked="true"] { border-color: var(--gold); background: #2b3750; }
.gm-seg:disabled { opacity: .4; cursor: not-allowed; }
.gm-optlist { display: flex; flex-direction: column; gap: 4px; margin: 8px 0 4px; }
.gm-opt { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(255, 255, 255, .07); font-weight: 600; }
.gm-opt select { background: var(--panel2); color: #fff; border: 1px solid rgba(255, 255, 255, .15); border-radius: 8px; padding: 8px 10px; font: 600 .9rem 'Quicksand', sans-serif; }
.gm-toggle { width: 52px; height: 30px; border-radius: 999px; background: #3a4458; border: 0; position: relative; cursor: pointer; flex: none; transition: background .2s; }
.gm-toggle::after { content: ''; position: absolute; top: 3px; left: 3px; width: 24px; height: 24px; border-radius: 50%; background: #fff; transition: transform .2s; }
.gm-toggle[aria-pressed="true"] { background: #2fb36d; }
.gm-toggle[aria-pressed="true"]::after { transform: translateX(22px); }
#trophy-list { max-height: 40vh; overflow-y: auto; margin-top: 14px; }
.gm-big { font-size: 2rem; font-weight: 700; color: var(--gold); margin: 8px 0; text-align: center; }
.gm-big span { font-size: 1rem; color: var(--text-muted); }
#gmResultBody h2 { text-align: center; font-size: 1.7rem; }
.gm-matchscore { text-align: center; color: #cbd5e6; }
.gm-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px 0 6px; }
.gm-stats div { background: var(--panel2); border-radius: 12px; padding: 10px 6px; text-align: center; }
.gm-stats b { display: block; font-size: 1.4rem; }
.gm-stats span { font-size: .72rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .06em; }
#gmResultBody .gm-note { text-align: center; }

.gm-btn .ico { display: none; }
/* ---- small screens */
@media (max-width: 768px) {
  .gm-btn .lbl { display: none; }
  .gm-btn .ico { display: inline; font-size: 1.1rem; }
  .gm-wrap { padding: 8px 8px 14px; }
  .gm-hud { grid-template-columns: 1fr 1fr; gap: 8px; }
  .gm-mid { grid-column: 1 / -1; order: 3; padding: 6px 10px; }
  .gm-pcard { padding: 6px 10px; }
  .gm-sc { font-size: 1.25rem; }
  .gm-btn { padding: 8px 12px; min-width: 44px; }
  .gm-btn.primary { min-width: 64px; }
  .gm-die { width: 40px; height: 40px; padding: 6px; }
  .gm-status { font-size: .9rem; }
  .gm-matchline { font-size: .68rem; }
}
@media (max-width: 380px) {
  .gm-nm { font-size: .88rem; }
  .gm-sub { font-size: .7rem; }
  .gm-btn { padding: 9px 11px; font-size: .86rem; }
  .gm-card { padding: 18px; }
}
.gm-wrap.is-portrait .gm-controls { flex-wrap: wrap; margin-top: 8px; gap: 6px; }
.gm-wrap.is-portrait .gm-btns { flex-wrap: nowrap; gap: 6px; }
.gm-wrap.is-portrait .gm-dice { gap: 5px; min-height: 36px; }
.gm-wrap.is-portrait .gm-die { width: 34px; height: 34px; padding: 5px; border-bottom-width: 3px; }
.gm-wrap.is-portrait .gm-vs { display: none; }

/* phone landscape: board on the left, HUD and controls in a narrow column */
@media (orientation: landscape) and (max-height: 520px) {
  .gm-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 236px; grid-template-areas: "board hud" "board controls"; gap: 8px 10px; max-width: none; padding: 6px 8px; align-content: start; }
  .gm-hud { grid-area: hud; grid-template-columns: 1fr; margin: 0; gap: 6px; }
  .gm-mid { order: 0; grid-column: auto; }
  .gm-boardbox { grid-area: board; width: min(100%, calc((100vh - 70px) * 1.5625)); min-width: 0; align-self: start; }
  @supports (height: 100dvh) { .gm-boardbox { width: min(100%, calc((100dvh - 70px) * 1.5625)); } }
  .gm-controls { grid-area: controls; margin: 0; flex-direction: column; align-items: stretch; }
  .gm-dice { justify-content: center; min-height: 44px; }
  .gm-btns { justify-content: center; }
  .gm-pcard { padding: 4px 10px; }
  .gm-matchline { display: none; }
  .gm-mid { padding: 4px 8px; }
  .gm-status { font-size: .82rem; }
  .gm-btns { flex-wrap: nowrap; gap: 5px; }
  .gm-btn { padding: 6px 8px; min-width: 38px; min-height: 40px; }
  .gm-btn.primary { min-width: 56px; }
  .gm-die { width: 34px; height: 34px; padding: 5px; }
}
@media (max-width: 380px) { .gm-wrap.is-portrait .gm-die { width: 30px; height: 30px; padding: 4px; } }
@media (prefers-reduced-motion: reduce) {
  #gmBoard .can, .gm-btn.pulse, .gm-die.roll { animation: none; }
}