:root{
    --bg: #0b1226; --bg-2: #04060d; --felt: #101a33;
    --chalk: #eef1e6; --chalk-dim: #aab6c8;
    --gold-hi: #f6e3a1; --gold-mid: #d9a941; --gold-lo: #8a5a1c; --copper: #b4672f; --blood: #6d1620; --ember: #c8381f;
    --parchment-1: #ecdcb4; --parchment-2: #d6bd86;
    --wood: #ecdcb4; --wood-edge: #c8a25f; --ink: #2b2118;
    --red: #b9433a; --gold: #d9a941; --blue: #3d7aa8; --orange: #d9853f;
    --accent: #e7c25f; --danger: #e2645a; --good: #7fbf8f;
    --teamA: #6fa8e0; --teamB: #e08a6f;
  }
  *{box-sizing:border-box;}
  body{
    margin:0;
    background:
      radial-gradient(ellipse at 50% -12%, rgba(109,22,32,0.55) 0%, rgba(109,22,32,0) 55%),
      radial-gradient(ellipse at 50% 110%, rgba(20,40,96,0.5) 0%, rgba(20,40,96,0) 55%),
      var(--bg-2);
    color: var(--chalk); font-family:'Inter','Noto Sans Thai',sans-serif; min-height:100vh; padding: 18px 12px 40px;
  }
  .wrap{ max-width: 1080px; margin: 0 auto; }
  header{ text-align:center; margin-bottom: 14px; position:relative;}
  header h1{
    font-family:'Fraunces','Noto Sans Thai',serif; font-weight:700; font-size: clamp(2rem, 6vw, 3.2rem);
    margin: 4px 0 0; letter-spacing: 0.5px; color: var(--gold-hi); background: linear-gradient(180deg, var(--gold-hi), var(--gold-mid) 55%, var(--copper)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; filter: drop-shadow(0 2px 0 rgba(0,0,0,0.55));
  }
  header .sub{ font-family:'Caveat','Noto Sans Thai',cursive; font-size: clamp(1.05rem, 3vw, 1.4rem); color: var(--accent); margin-top: -4px; }
  header .eyebrow{ font-family:'Space Mono','Noto Sans Thai',monospace; font-size: 0.7rem; letter-spacing: 3px; color: var(--chalk-dim); text-transform: uppercase; }
  .homelink{ position:absolute; left:0; top:6px; background:transparent; border:1px solid var(--chalk-dim); color:var(--chalk); border-radius:20px; padding:6px 14px; font-size:0.8rem; cursor:pointer; }
  .homelink:hover{ border-color:var(--accent); color:var(--accent); }
  .howto-btn{ position:absolute; right:0; top:6px; background: transparent; border:1px solid var(--chalk-dim); color: var(--chalk); border-radius: 20px; padding: 6px 14px; font-size:0.8rem; cursor:pointer; }
  .howto-btn:hover{ border-color: var(--accent); color:var(--accent); }

  /* ---------- generic menu screens ---------- */
  .menu-wrap{ max-width: 560px; margin: 20px auto; display:flex; flex-direction:column; gap:16px; }
  .card{ background: linear-gradient(160deg, rgba(20,30,62,0.78), rgba(8,12,26,0.82)); border: 1px solid rgba(217,169,65,0.28); border-radius: 14px; padding: 18px 20px; box-shadow: 0 8px 24px rgba(0,0,0,0.35), inset 0 1px 0 rgba(246,227,161,0.08); }
  .card h2{ font-family:'Fraunces','Noto Sans Thai',serif; margin:0 0 4px; color:var(--accent); font-size:1.3rem; }
  .card p.hint{ font-size:0.82rem; color:var(--chalk-dim); margin: 2px 0 12px; }
  .choice-cards{ display:flex; gap:12px; flex-wrap:wrap; }
  .choice-card{
    flex:1; min-width:200px; background: rgba(255,255,255,0.05); border:1.5px solid rgba(255,255,255,0.1);
    border-radius:12px; padding:16px; cursor:pointer; text-align:center; transition: 0.12s;
  }
  .choice-card:hover{ border-color: var(--accent); background: rgba(231,194,95,0.08); transform: translateY(-2px); }
  .choice-card .icon{ font-size:2rem; }
  .choice-card .title{ font-family:'Fraunces','Noto Sans Thai',serif; font-weight:700; font-size:1.1rem; margin-top:6px; }
  .choice-card .desc{ font-size:0.78rem; color:var(--chalk-dim); margin-top:4px; }
  .choice-card.selected{ border-color: var(--accent); background: rgba(231,194,95,0.14); }
  .choice-card.disabled{ opacity:0.4; cursor:not-allowed; }

  .field{ margin-bottom: 12px; }
  .field label{ display:block; font-size:0.8rem; color:var(--chalk-dim); margin-bottom:5px; }
  .field input{
    width:100%; padding: 10px 12px; border-radius:8px; border:1px solid rgba(255,255,255,0.15);
    background: rgba(0,0,0,0.2); color: var(--chalk); font-size:0.95rem; font-family:'Space Mono','Noto Sans Thai',monospace;
  }
  .field input:focus{ outline: 2px solid var(--accent); }
  .btn-row{ display:flex; gap:10px; flex-wrap:wrap; margin-top:8px; }
  button.big{
    font-family:'Inter','Noto Sans Thai',sans-serif; font-weight:700; font-size:0.92rem; padding: 12px 20px; border-radius: 10px;
    border:1px solid var(--accent); background: var(--accent); color:#2b2118; cursor:pointer;
  }
  button.big:hover{ background:#f0cf78; }
  button.big.secondary{ background:transparent; color:var(--chalk); border-color:rgba(255,255,255,0.2); }
  button.big.secondary:hover{ border-color:var(--accent); color:var(--accent); }
  button.big:disabled{ opacity:0.35; cursor:not-allowed; }

  .room-code{
    font-family:'Space Mono','Noto Sans Thai',monospace; font-size:2.1rem; font-weight:700; letter-spacing:6px;
    text-align:center; color:var(--accent); background: rgba(0,0,0,0.25); border-radius:10px; padding:12px;
    margin: 6px 0 14px; user-select:all;
  }
  .seat-list{ display:flex; flex-direction:column; gap:8px; }
  .seat-row{
    display:flex; align-items:center; justify-content:space-between; padding:10px 12px;
    background: rgba(0,0,0,0.18); border-radius:8px; border:1px solid rgba(255,255,255,0.08);
  }
  .seat-row.filled{ border-color: rgba(127,191,143,0.4); }
  .seat-row.me{ outline: 2px solid var(--accent); }
  .seat-row .seat-name{ font-weight:600; }
  .seat-row .seat-team{ font-size:0.72rem; padding:2px 8px; border-radius:10px; margin-left:8px; }
  .seat-row .seat-team.A{ background: var(--teamA); color:#0d241d; }
  .seat-row .seat-team.B{ background: var(--teamB); color:#0d241d; }
  .seat-row .empty-label{ color: var(--chalk-dim); font-style:italic; font-size:0.85rem; }

  .banner-msg{ text-align:center; font-size:0.85rem; padding:8px; border-radius:8px; margin-bottom:8px; }
  .banner-msg.err{ background: rgba(226,100,90,0.15); color: var(--danger); }
  .banner-msg.ok{ background: rgba(127,191,143,0.15); color: var(--good); }
  .banner-msg.info{ background: rgba(231,194,95,0.12); color: var(--accent); }

  .pulse-dot{ display:inline-block; width:8px; height:8px; border-radius:50%; background:var(--accent); margin-right:6px; animation: pulse 1.2s infinite; }
  @keyframes pulse{ 0%,100%{opacity:1;} 50%{opacity:0.25;} }

  /* ---------- BOARD ----------
     The board is four layers stacked in one square stage, all sharing the same 15 x 15 grid:
       1. .layer-bg        the background picture (default art, or the one an admin uploaded)
       2. .layer-grid      the playable cells. Only this layer takes clicks.
       3. .layer-specials  the bonus tiles and the centre star
       4. .layer-pieces    the tiles players have placed, with their points
     Layers 3 and 4 never catch the pointer, so a picture can never block play. */
  .layout{ display:flex; gap: 22px; flex-wrap: wrap; align-items:flex-start; justify-content:center; }
  .board-panel{ flex: 1 1 520px; max-width: 620px; }
  .board-frame{
    --frame: clamp(9px, 2.4vw, 14px);
    position:relative; padding: var(--frame); border-radius: 16px;
    background:
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M2 62V30C2 14 14 2 30 2h32' fill='none' stroke='%23f6e3a1' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M9 62V34C9 20 20 9 34 9h28' fill='none' stroke='%23b4672f' stroke-width='2'/%3E%3Cpath d='M14 14l10 4-4 10-6-6z' fill='%23c8381f' stroke='%23f6e3a1' stroke-width='1.5'/%3E%3C/svg%3E") left top / 52px 52px no-repeat,
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M62 62V30C62 14 50 2 34 2H2' fill='none' stroke='%23f6e3a1' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M55 62V34C55 20 44 9 30 9H2' fill='none' stroke='%23b4672f' stroke-width='2'/%3E%3Cpath d='M50 14l-10 4 4 10 6-6z' fill='%23c8381f' stroke='%23f6e3a1' stroke-width='1.5'/%3E%3C/svg%3E") right top / 52px 52px no-repeat,
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M2 2V34C2 50 14 62 30 62h32' fill='none' stroke='%23f6e3a1' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M9 2V30C9 44 20 55 34 55h28' fill='none' stroke='%23b4672f' stroke-width='2'/%3E%3Cpath d='M14 50l10-4-4-10-6 6z' fill='%23c8381f' stroke='%23f6e3a1' stroke-width='1.5'/%3E%3C/svg%3E") left bottom / 52px 52px no-repeat,
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 64 64'%3E%3Cpath d='M62 2V34C62 50 50 62 34 62H2' fill='none' stroke='%23f6e3a1' stroke-width='3' stroke-linecap='round'/%3E%3Cpath d='M55 2V30C55 44 44 55 30 55H2' fill='none' stroke='%23b4672f' stroke-width='2'/%3E%3Cpath d='M50 50l-10-4 4-10 6 6z' fill='%23c8381f' stroke='%23f6e3a1' stroke-width='1.5'/%3E%3C/svg%3E") right bottom / 52px 52px no-repeat,
      linear-gradient(160deg, var(--blood), #2a0a10 55%, #0c0a18);
    box-shadow: 0 22px 46px rgba(0,0,0,0.6), 0 0 0 2px var(--gold-lo), 0 0 0 4px var(--gold-hi), 0 0 0 6px var(--gold-lo), inset 0 0 0 2px rgba(246,227,161,0.55), inset 0 0 22px rgba(0,0,0,0.7);
    margin: 6px;
  }
  .board-stage{
    --pad: 1.2cqw; --gap: 0.32cqw;
    position:relative; aspect-ratio: 1/1; width:100%; container-type: inline-size; border-radius: 6px; overflow:hidden;
    background: #0b1226; box-shadow: inset 0 0 0 2px var(--gold-lo), 0 0 0 1px #000;
  }
  .layer{ position:absolute; inset:0; }
  .layer-bg{
    /* Default art: an ink-blue night with a faint number pattern and a warm glow. An uploaded picture replaces it. */
    background-color: #0b1226;
    background-image:
      var(--board-bg-image, none),
      radial-gradient(ellipse at 50% 50%, rgba(180,103,47,0.35), rgba(180,103,47,0) 62%),
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='120' height='120'%3E%3Cg font-family='serif' font-size='26' fill='%23f6e3a1' fill-opacity='.09'%3E%3Ctext x='8' y='34'%3E7%3C/text%3E%3Ctext x='70' y='28'%3E%C3%97%3C/text%3E%3Ctext x='34' y='70'%3E%3D%3C/text%3E%3Ctext x='88' y='88'%3E12%3C/text%3E%3Ctext x='6' y='108'%3E%C3%B7%3C/text%3E%3C/g%3E%3C/svg%3E"),
      linear-gradient(160deg, #16224a, #0a1020);
    background-size: cover, auto, 120px 120px, auto; background-position: center; background-repeat: no-repeat, no-repeat, repeat, no-repeat;
    pointer-events:none;
  }
  .layer-grid, .layer-specials, .layer-pieces{
    display:grid; grid-template-columns: repeat(15, 1fr); grid-template-rows: repeat(15, 1fr);
    gap: var(--gap); padding: var(--pad);
  }
  .layer-specials, .layer-pieces{ pointer-events:none; }
  .cell{
    position:relative; border-radius: 12%; cursor:pointer; user-select:none; transition: box-shadow 0.1s, transform 0.1s;
    background: linear-gradient(145deg, rgba(236,220,180,0.93), rgba(214,189,134,0.93));
    box-shadow: inset 0 0 0 1px rgba(120,84,36,0.45), inset 0 -2px 3px rgba(90,60,20,0.25), inset 0 1px 0 rgba(255,255,255,0.35);
  }
  .cell:hover{ box-shadow: inset 0 0 0 2px var(--gold-mid), 0 0 7px rgba(246,227,161,0.75); z-index:1; }
  .special{
    grid-row: var(--r); grid-column: var(--c); margin: 4%; border-radius: 16%;
    display:flex; align-items:center; justify-content:center; text-align:center; line-height:1; white-space:nowrap; overflow:hidden;
    font-family:'Space Mono','Noto Sans Thai',monospace; font-weight:800; letter-spacing:-0.02em;
    font-size: clamp(0.62rem, 2.8vw, 1.1rem); font-size: max(9px, 2.9cqw);
    box-shadow: inset 0 2px 0 rgba(255,255,255,0.38), inset 0 -3px 0 rgba(0,0,0,0.3), 0 1px 3px rgba(0,0,0,0.55);
    text-shadow: 0 1px 2px rgba(0,0,0,0.55);
  }
  .special.TW{ background: var(--red); color:#fff; }
  .special.DW{ background: var(--gold); color:#2b2118; text-shadow: 0 1px 0 rgba(255,255,255,0.35); }
  .special.TL{ background: var(--blue); color:#fff; }
  .special.DL{ background: var(--orange); color:#2b2118; text-shadow: 0 1px 0 rgba(255,255,255,0.3); }
  .special.center{ background: var(--gold); color:#2b2118; }
  .special.center svg{ width:68%; height:68%; fill:#fff3c4; stroke:#7a4a12; stroke-width:1.2; stroke-linejoin:round; filter: drop-shadow(0 1px 1px rgba(0,0,0,0.5)); }
  .tile{
    grid-row: var(--r); grid-column: var(--c); margin: 5%; position:relative; border-radius: 14%;
    display:flex; align-items:center; justify-content:center; line-height:1; color: var(--ink); overflow:hidden;
    font-family:'Space Mono','Noto Sans Thai',monospace; font-weight:800;
    font-size: clamp(0.8rem, 3.6vw, 1.5rem); font-size: max(12px, 4.1cqw);
    background: linear-gradient(160deg, var(--wood), #d9c391); border: 1.5px solid var(--wood-edge);
    box-shadow: 0 2px 3px rgba(0,0,0,0.45), inset 0 0 0 1px rgba(255,255,255,0.3);
  }
  .tile[data-len="2"]{ font-size: clamp(0.66rem, 2.9vw, 1.2rem); font-size: max(10px, 3.2cqw); letter-spacing:-0.06em; }
  .tile[data-len="3"]{ font-size: max(9px, 2.5cqw); letter-spacing:-0.08em; }
  .tile.pending{ outline: 2px dashed var(--accent); box-shadow: 0 4px 10px rgba(0,0,0,0.5), 0 0 0 2px rgba(231,194,95,0.5); }
  .tile .pts{ position:absolute; bottom: 4%; right: 8%; font-size: clamp(0.5rem, 1.6vw, 0.72rem); font-size: max(7px, 1.75cqw); font-weight:800; line-height:1; opacity:0.85; }
  .tile.blank-mark::after{ content:'★'; position:absolute; top: 2%; left: 8%; font-size: max(7px, 1.7cqw); line-height:1; color:#8a6d2f; }

  /* ---------- SIDE PANEL ---------- */
  .side-panel{ flex: 1 1 320px; max-width: 380px; display:flex; flex-direction:column; gap:14px; }
  .scores{ display:flex; gap:8px; flex-wrap:wrap; }
  .score-box{ flex:1; min-width:70px; padding:8px; border-radius:10px; text-align:center; background: rgba(0,0,0,0.18); border:1px solid rgba(255,255,255,0.08); }
  .score-box.active{ border-color: var(--accent); box-shadow: 0 0 0 2px rgba(231,194,95,0.25) inset; }
  .score-box.me{ border-color: var(--good); }
  .score-box .name{ font-size:0.72rem; color:var(--chalk-dim); overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .score-box .num{ font-family:'Fraunces','Noto Sans Thai',serif; font-weight:700; font-size:1.5rem; color:var(--accent); }
  .team-totals{ display:flex; gap:8px; margin-top:8px; }
  .team-totals .tt{ flex:1; text-align:center; padding:6px; border-radius:8px; font-size:0.8rem; font-weight:700; }
  .team-totals .tt.A{ background: rgba(111,168,224,0.18); color: var(--teamA); }
  .team-totals .tt.B{ background: rgba(224,138,111,0.18); color: var(--teamB); }
  .bag-count{ text-align:center; font-family:'Space Mono','Noto Sans Thai',monospace; font-size:0.78rem; color:var(--chalk-dim); margin-top:6px;}
  .turn-banner{ font-family:'Caveat','Noto Sans Thai',cursive; font-size:1.4rem; text-align:center; color:var(--chalk); background: rgba(0,0,0,0.15); border-radius:10px; padding: 6px 10px; }
  .rack{ display:flex; gap:6px; justify-content:center; flex-wrap:wrap; padding: 10px 4px; }
  .rack-tile{ width: 44px; height: 44px; position:relative; background: linear-gradient(160deg, var(--wood), #d9c391); border: 1.5px solid var(--wood-edge); border-radius:6px; display:flex; align-items:center; justify-content:center; font-family:'Space Mono','Noto Sans Thai',monospace; font-weight:700; font-size:1.1rem; color: var(--ink); cursor:pointer; box-shadow: 0 3px 4px rgba(0,0,0,0.35); transition: transform 0.08s; }
  .rack-tile:hover{ transform: translateY(-3px); }
  .rack-tile.selected{ outline:3px solid var(--accent); transform: translateY(-4px); }
  .rack-tile.marked{ outline:3px solid var(--danger); opacity:0.6; }
  .rack-tile .pts{ position:absolute; bottom:1px; right:3px; font-size:0.52rem; opacity:0.65; }
  .rack-tile .wild{ position:absolute; top:1px; left:3px; font-size:0.52rem; color:#8a6d2f; }
  .preview{ font-family:'Caveat','Noto Sans Thai',cursive; font-size:1.25rem; text-align:center; color: var(--accent); min-height: 1.6em; }
  .message{ font-size:0.83rem; text-align:center; min-height:1.3em; padding: 2px 4px; }
  .message.err{ color: var(--danger); }
  .message.ok{ color: var(--good); }
  .actions{ display:flex; gap:8px; flex-wrap:wrap; justify-content:center; }
  button.act{ font-family:'Inter','Noto Sans Thai',sans-serif; font-weight:600; font-size:0.8rem; padding: 9px 13px; border-radius: 8px; border:1px solid rgba(255,255,255,0.15); background: rgba(255,255,255,0.06); color: var(--chalk); cursor:pointer; }
  button.act:hover{ background: rgba(255,255,255,0.14); }
  button.act.primary{ background: var(--accent); color:#2b2118; border-color: var(--accent); }
  button.act.primary:hover{ background:#f0cf78; }
  button.act.danger{ border-color: rgba(226,100,90,0.5); color:#f0a8a2;}
  button.act:disabled{ opacity:0.35; cursor:not-allowed; }
  button.act.toggled{ background: var(--danger); color:white; border-color: var(--danger); }
  .legend{ display:flex; gap:10px; flex-wrap:wrap; font-size:0.72rem; color:var(--chalk-dim); justify-content:center; margin-top:8px;}
  .legend span{ display:inline-flex; align-items:center; gap:5px; }
  .legend .dot{ width:10px; height:10px; border-radius:2px; display:inline-block; }
  .waiting-overlay{ text-align:center; padding: 14px; font-family:'Caveat','Noto Sans Thai',cursive; font-size:1.3rem; color:var(--chalk-dim); }

  /* ---------- MODAL ---------- */
  .overlay{ position:fixed; inset:0; background: rgba(6,14,11,0.72); display:flex; align-items:center; justify-content:center; z-index:50; padding: 20px; }
  .modal{ background: linear-gradient(160deg, #18244a, #0a1020); border: 1px solid rgba(217,169,65,0.4); border-radius: 14px; padding: 20px 22px; max-width: 460px; width:100%; box-shadow: 0 20px 50px rgba(0,0,0,0.5); max-height: 82vh; overflow-y:auto; }
  .modal h3{ font-family:'Fraunces','Noto Sans Thai',serif; margin-top:0; color:var(--accent); }
  .modal p, .modal li{ font-size:0.86rem; line-height:1.55; color: var(--chalk); }
  .choice-grid{ display:grid; grid-template-columns: repeat(6, 1fr); gap:6px; margin: 10px 0; }
  .choice-grid.ops{ grid-template-columns: repeat(2, 1fr); }
  .choice-btn{ padding: 10px 4px; border-radius:8px; border:1px solid var(--wood-edge); background: var(--wood); color: var(--ink); font-family:'Space Mono','Noto Sans Thai',monospace; font-weight:700; cursor:pointer; font-size:0.95rem; }
  .choice-btn:hover{ background: #f5e6bf; }
  .modal-close{ text-align:right; margin-top:10px; }
  .modal-close button{ background:none; border:1px solid var(--chalk-dim); color:var(--chalk); border-radius:8px; padding:7px 14px; cursor:pointer; }
  .endgame-title{ font-family:'Fraunces','Noto Sans Thai',serif; font-size:1.5rem; color:var(--accent); text-align:center; }

  @media (max-width: 640px){
    .rack-tile{ width:38px; height:38px; font-size:1rem; }
    .homelink, .howto-btn{ position:static; margin: 4px 4px 0; display:inline-block; }
  }

  .brand-mark{ display:block; margin: 0 auto 4px; border-radius: 10px; box-shadow: 0 0 0 2px var(--gold-lo), 0 4px 12px rgba(0,0,0,0.5); }
  header .eyebrow{ color: var(--gold-mid); }
  .vrc-back{ position:absolute; left:0; top:44px; color:var(--chalk-dim); font-size:0.75rem; text-decoration:none; }
  .vrc-back:hover{ color:var(--accent); }

  /* ---------- TURN TIMER ---------- */
  .timer-card{ text-align:center; transition: border-color 0.2s, box-shadow 0.2s; }
  .timer-head{ font-size:0.8rem; color: var(--chalk-dim); }
  .timer-head strong{ color: var(--chalk); }
  .timer-clock{ font-family:'Space Mono','Noto Sans Thai',monospace; font-weight:800; font-size: clamp(2.2rem, 9vw, 3rem); letter-spacing: 2px; color: var(--gold-hi); line-height:1.15; font-variant-numeric: tabular-nums; }
  .timer-status{ font-size:0.82rem; min-height:1.3em; color: var(--chalk-dim); margin-bottom:8px; }
  .timer-actions{ display:flex; gap:8px; flex-wrap:wrap; justify-content:center; }
  .timer-card.warn{ border-color: var(--orange); box-shadow: 0 0 0 2px rgba(217,133,63,0.35) inset, 0 8px 24px rgba(0,0,0,0.35); }
  .timer-card.warn .timer-clock{ color: var(--orange); animation: pulse 1s infinite; }
  .timer-card.warn .timer-status{ color: var(--orange); font-weight:700; }
  .timer-card.expired{ border-color: var(--danger); box-shadow: 0 0 0 2px rgba(226,100,90,0.45) inset, 0 8px 24px rgba(0,0,0,0.35); }
  .timer-card.expired .timer-clock{ color: var(--danger); }
  .timer-card.expired .timer-status{ color: var(--danger); font-weight:700; }
  .timer-card.paused .timer-clock, .timer-card.ready .timer-clock{ opacity:0.65; }
  .timer-card.over{ opacity:0.7; }
  .penalty-title{ margin-top:10px; font-size:0.72rem; color: var(--chalk-dim); text-transform:uppercase; letter-spacing:1px; }
  .penalty-log ul{ list-style:none; margin:4px 0 0; padding:0; max-height:7.5em; overflow:auto; text-align:left; font-size:0.8rem; }
  .penalty-log li{ display:flex; justify-content:space-between; gap:8px; padding:3px 6px; border-bottom:1px dashed rgba(255,255,255,0.08); }
  .penalty-log li b{ color: var(--danger); }
  .penalty-log li span{ color: var(--chalk-dim); }
  .timer-setup .check{ display:flex; gap:8px; align-items:center; font-size:0.85rem; color: var(--chalk); cursor:pointer; }
  .timer-pick{ display:flex; gap:8px; flex-wrap:wrap; align-items:center; margin-top:8px; }
  .timer-pick[hidden]{ display:none; }
  .timer-pick label{ font-size:0.8rem; color: var(--chalk-dim); display:inline-flex; gap:6px; align-items:center; }
  .timer-pick input[type=number]{ width:4.5em; padding:6px 8px; border-radius:8px; border:1px solid rgba(255,255,255,0.15); background: rgba(0,0,0,0.25); color: var(--chalk); font-family:'Space Mono','Noto Sans Thai',monospace; }
  .chip{ padding:6px 12px; border-radius:16px; border:1px solid rgba(217,169,65,0.4); background: transparent; color: var(--chalk); cursor:pointer; font-size:0.8rem; }
  .chip.on{ background: var(--accent); color:#2b2118; border-color: var(--accent); font-weight:700; }

  /* ---------- TOP SCORES ---------- */
  .board-panel{ min-width:0; }
  .score-board{ margin-top: 14px; padding: 14px 16px; min-width:0; }
  .top-head{ display:flex; justify-content:space-between; align-items:baseline; gap:8px; flex-wrap:wrap; font-family:'Fraunces','Noto Sans Thai',serif; font-weight:700; color: var(--gold-hi); }
  .top-head small{ font-family:'Inter','Noto Sans Thai',sans-serif; font-weight:400; font-size:0.72rem; color: var(--chalk-dim); }
  .top-list{ list-style:none; margin:8px 0 0; padding:0; display:flex; flex-direction:column; gap:3px; }
  .top-list li{ display:flex; align-items:center; gap:10px; padding:5px 8px; border-radius:8px; background: rgba(255,255,255,0.04); font-size:0.85rem; }
  .top-list li.you{ outline:1px solid var(--accent); background: rgba(231,194,95,0.12); }
  .top-rank{ min-width:1.7em; height:1.7em; border-radius:50%; display:inline-flex; align-items:center; justify-content:center; font-family:'Space Mono','Noto Sans Thai',monospace; font-weight:800; font-size:0.78rem; background: rgba(255,255,255,0.1); color: var(--chalk); }
  .top-rank.rank-1{ background: linear-gradient(160deg, var(--gold-hi), var(--gold-mid)); color:#2b2118; }
  .top-rank.rank-2{ background: linear-gradient(160deg, #eef1f5, #aab6c8); color:#2b2118; }
  .top-rank.rank-3{ background: linear-gradient(160deg, #f0b27a, var(--copper)); color:#2b2118; }
  .top-name{ flex:1 1 0; width:0; min-width:0; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
  .top-score{ font-family:'Space Mono','Noto Sans Thai',monospace; color: var(--accent); }
  .top-empty{ color: var(--chalk-dim); justify-content:center; }
  .top-note{ margin-top:8px; font-size:0.78rem; color: var(--chalk); text-align:center; }
  .top-foot{ margin-top:4px; font-size:0.7rem; color: var(--chalk-dim); text-align:center; }

  /* ---------- THAI TEXT ----------
     Real weights only (Noto Sans Thai is loaded at 400, 500 and 600), room for stacked tone marks. */
  html{ -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; font-synthesis: none; }
  body{ line-height: 1.6; }
  h1, h2, h3{ line-height: 1.4; letter-spacing: 0; }
  header h1{ padding-bottom: 0.12em; }
  p, li, label, .hint, .message, .top-note, .timer-status{ line-height: 1.65; }
  button{ line-height: 1.5; }
