    * { box-sizing: border-box; margin: 0; padding: 0; }
    html { overflow-x: auto; }
    body {
      display: flex; flex-direction: column; align-items: center;
      justify-content: center; min-height: 100vh;
      background: #1a1a2e; font-family: system-ui, -apple-system, sans-serif;
      color: #eee; padding: 20px; gap: 0;
    }
    h1 { font-size: 2rem; letter-spacing: 6px; margin-bottom: 12px; opacity: 0.85; }
    #board-area {
      display: flex; flex-direction: row; gap: 16px; align-items: stretch;
    }
    #board-col { display: flex; flex-direction: column; }
    #side-col {
      display: flex; flex-direction: column;
      width: 170px; background: #0d0d1a;
      border: 2px solid #2d2d4e; border-radius: 8px; padding: 10px 8px;
    }
    #status {
      font-size: 1.05rem; min-height: 1.6em; margin-bottom: 10px;
      font-weight: 500; letter-spacing: 1px; text-align: center;
    }

    /* ── Shop ── */
    #shop {
      background: #0d0d1a; border: 2px solid #2d2d4e; border-radius: 8px;
      padding: 16px 20px; width: 1152px; margin-bottom: 10px;
    }
    #shop-header {
      display: flex; justify-content: space-between; align-items: center;
      margin-bottom: 12px;
    }
    #shop-header h2 { font-size: 1rem; letter-spacing: 2px; opacity: 0.8; }
    #shop-budget { font-size: 1.1rem; font-weight: 700; color: #f0c040; }
    #shop-rows { display: flex; flex-direction: column; gap: 6px; }
    .shop-row {
      display: flex; align-items: center; gap: 10px;
      background: #16213e; border-radius: 6px; padding: 6px 10px;
    }
    .shop-glyph { font-size: 32px; width: 36px; text-align: center; }
    .shop-name  { width: 160px; font-size: 0.9rem; letter-spacing: 1px; display: flex; flex-direction: column; justify-content: center; }
    .shop-name-sub { font-size: 0.72rem; opacity: 0.6; letter-spacing: 0.5px; margin-top: 1px; }
    .shop-cost  { font-size: 0.85rem; color: #f0c040; width: 80px; }
    .shop-owned { font-size: 0.85rem; width: 80px; opacity: 0.7; }
    #shop-rows  { width: fit-content; margin: 0 auto; }
    .shop-btn {
      padding: 4px 12px; font-size: 0.8rem; border-radius: 4px;
      border: 1px solid #3a3a5c; cursor: pointer; letter-spacing: 1px;
      transition: background 0.15s;
    }
    .shop-btn.buy  { background: #1a3a1a; color: #8f8; }
    .shop-btn.buy:hover  { background: #2a5a2a; }
    .shop-btn.sell { background: #3a1a1a; color: #f88; }
    .shop-btn.sell:hover { background: #5a2a2a; }
    .shop-btn:disabled { opacity: 0.3; cursor: default; }

    /* ── Reserve panels ── */
    .reserve {
      display: flex; flex-wrap: wrap; gap: 4px; padding: 8px;
      background: #0d0d1a;
      border: 2px solid #2d2d4e; border-left-width: 4px; border-right-width: 4px;
      width: 1160px; min-height: 58px; align-items: center;
    }
    #black-reserve { border-bottom: none; border-radius: 8px 8px 0 0; }
    #white-reserve { border-top: none;    border-radius: 0 0 8px 8px; }
    .res-piece {
      width: 44px; height: 44px; display: flex; align-items: center;
      justify-content: center; font-size: 34px; border-radius: 6px;
      border: 2px solid transparent; cursor: default; user-select: none;
      transition: background 0.15s, border-color 0.15s;
    }
    .res-piece.clickable { cursor: pointer; }
    .res-piece.clickable:hover { background: rgba(255,255,255,0.1); }
    .res-piece.res-selected { border-color: #7fc480; background: rgba(127,196,128,0.2); }
    .res-label { font-size: 10px; opacity: 0.5; padding: 0 4px; letter-spacing: 1px; align-self: center; }

    /* ── Board ── */
    #board {
      display: grid; grid-template-columns: repeat(16, 72px);
      grid-template-rows: repeat(8, 72px);
      border-left: 4px solid #2d2d4e; border-right: 4px solid #2d2d4e;
      box-shadow: 0 20px 60px rgba(0,0,0,0.7); overflow: hidden;
    }
    .sq {
      width: 72px; height: 72px; display: flex; align-items: center;
      justify-content: center; cursor: pointer; position: relative;
      font-size: 50px; line-height: 1; user-select: none; transition: filter 0.1s;
    }
    .sq:hover { filter: brightness(1.08); }
    .light { background: #a08060; }
    .dark  { background: #5a3a20; }
    .sq.selected    { background: #7fc480 !important; }
    .sq.last-from   { background: #cdd16f !important; }
    .sq.last-to     { background: #aaa23a !important; }
    .sq.setup-zone  { background: #5a9fd4 !important; }
    .sq.field-target{ background: #6ab0e0 !important; }
    .sq.pickup-hint { outline: 3px solid #e8a838; outline-offset: -3px; }
    .sq.engaged     { box-shadow: inset 0 0 10px 3px rgba(255,190,0,0.55); }
    .sq.under-attack{ outline: 4px solid rgba(220,30,30,0.9); outline-offset: -4px; }
    .sq.ranged-outline{ outline: 3px solid rgba(60,210,80,0.9); outline-offset: -3px; }
    .sq.under-attack.ranged-outline{ outline: 3px solid rgba(60,210,80,0.9); outline-offset: -3px; box-shadow: 0 0 0 4px rgba(220,30,30,0.9); }
    .sq.hint::after {
      content: ''; position: absolute; width: 32%; height: 32%;
      border-radius: 50%; background: rgba(0,0,0,0.22); pointer-events: none;
    }
    .sq.hint-cap::after {
      content: ''; position: absolute; inset: 4px; border-radius: 50%;
      border: 6px solid rgba(0,0,0,0.22); pointer-events: none;
    }
    .lbl {
      position: absolute; font-size: 11px; font-weight: 700;
      opacity: 0.55; pointer-events: none; line-height: 1;
    }
    .lbl-rank { top: 3px; left: 4px; }
    .lbl-file { bottom: 3px; right: 4px; }
    .lbl-hp {
      position: absolute; top: 3px; right: 4px;
      font-size: 10px; font-weight: 700; pointer-events: none;
      color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000;
      line-height: 1; z-index: 2;
    }
    .heavily-injured .lbl-hp { color: #ff4444; text-shadow: 0 0 4px #000, 0 0 4px #000; }
    .light .lbl { color: #b58863; }
    .dark  .lbl { color: #f0d9b5; }

    #clock {
      font-size: 1.8rem; font-weight: 700; letter-spacing: 4px;
      min-height: 2rem; margin-bottom: 8px; font-variant-numeric: tabular-nums;
      color: #f0c040; text-align: center;
    }
    #clock.urgent { color: #f05040; animation: pulse 0.5s infinite alternate; }
    @keyframes pulse { from { opacity: 1; } to { opacity: 0.5; } }

    #mode-select { display:flex; gap:8px; margin-bottom:10px; flex-wrap:wrap; justify-content:center; }
    .mode-btn { padding:7px 16px; font-size:0.82rem; letter-spacing:1px; }
    .mode-btn.active { background:#1a3a5a !important; border-color:#4a9adc !important; color:#8cf !important; }

    #controls {
      display: flex; flex-direction: column; gap: 6px;
      flex: 1;
    }
    #controls > button {
      flex: 1; width: 100%; text-align: center;
      white-space: normal; word-break: break-word; line-height: 1.3;
    }
    /* Buy phase: revert controls to original horizontal layout */
    body.is-buying #board-area { display: block; }
    body.is-buying #board-col  { display: none; }
    body.is-buying #side-col   { width: auto; background: none; border: none; padding: 0; border-radius: 0; }
    body.is-buying #controls   { flex-direction: row; flex-wrap: wrap; gap: 10px; margin-top: 14px; justify-content: center; }
    body.is-buying #controls > button { flex: auto; width: auto; }
    button {
      padding: 9px 22px; background: #16213e; color: #ddd;
      border: 1px solid #3a3a5c; border-radius: 6px; cursor: pointer;
      font-size: 0.9rem; letter-spacing: 1px;
      transition: background 0.2s, border-color 0.2s;
    }
    button:hover  { background: #0f3460; border-color: #6a6aac; }
    button:disabled { opacity: 0.35; cursor: default; }
    #btn-confirm { background: #1a3a1a; border-color: #3a6a3a; }
    #btn-confirm:hover:not(:disabled) { background: #2a5a2a; }

    .pc-white { color:#fff; -webkit-text-stroke:2px #000; }
    .pc-black { color:#111; -webkit-text-stroke:2px #000; }

    .dir-arrow {
      position: absolute; width: 13px; height: 13px;
      clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
      background: rgba(255,220,50,0.92); pointer-events: none;
    }
    .removal-x {
      position: absolute; top: 50%; left: 50%;
      transform: translate(-50%, -50%);
      font-size: 30px; font-weight: 900; pointer-events: none; z-index: 2; opacity: 0.9;
    }
    .removal-x.white { color: #fff; -webkit-text-stroke: 2px #000; text-shadow: 0 0 4px #000; }
    .removal-x.black { color: #111; -webkit-text-stroke: 1.5px #000; text-shadow: 0 0 4px rgba(0,0,0,0.6); }
    .prev-move-arrow {
      position: absolute; width: 18px; height: 18px;
      clip-path: polygon(50% 0%, 0% 100%, 100% 100%);
      background: rgba(80,180,255,0.75); pointer-events: none;
      z-index: 1;
    }
    .sq.range-hi     { background: #3a7a3a !important; }
    .sq.range-target { background: #5ab85a !important; cursor: crosshair; outline: 3px solid #8f8 !important; outline-offset: -3px; }

    /* ── Online Lobby ── */
    #lobby-overlay {
      display: none; position: fixed; inset: 0;
      background: rgba(0,0,0,0.88); z-index: 100;
      align-items: center; justify-content: center;
    }
    #lobby-box {
      background: #0d0d1a; border: 2px solid #2d2d4e; border-radius: 12px;
      padding: 32px 40px; min-width: 380px; max-width: 520px; width: 90%;
    }
    #lobby-box h2 { font-size: 1.3rem; letter-spacing: 4px; margin-bottom: 20px; text-align: center; }
    #lobby-name-input {
      width: 100%; padding: 10px 14px; font-size: 1rem; border-radius: 6px;
      border: 1px solid #3a3a5c; background: #16213e; color: #eee;
      margin-bottom: 12px; letter-spacing: 1px; box-sizing: border-box;
    }
    #lobby-player-list {
      display: flex; flex-direction: column; gap: 6px;
      margin: 12px 0; max-height: 260px; overflow-y: auto;
    }
    .lobby-player {
      display: flex; align-items: center; gap: 8px; padding: 7px 10px;
      background: #16213e; border-radius: 6px; border: 1px solid #2d2d4e;
    }
    .lobby-me { border-color: #4a9adc !important; }
    .lp-name { flex: 1; font-size: 0.9rem; }
    .lp-status { font-size: 0.75rem; opacity: 0.65; }
    #lobby-challenge-popup {
      display: none; background: #1a1a2e; border: 2px solid #4a9adc;
      border-radius: 8px; padding: 14px 18px; margin-top: 8px; text-align: center;
    }
    #lobby-challenge-popup p { margin-bottom: 10px; font-size: 0.9rem; }
    #lobby-challenge-actions { display: flex; gap: 8px; justify-content: center; }
    #lobby-status-msg { text-align: center; font-size: 0.82rem; opacity: 0.7; margin-top: 8px; min-height: 1.2em; }
    #lobby-bottom { display: flex; gap: 8px; justify-content: center; margin-top: 10px; }

    /* ── Landing Page ── */
    #landing {
      position: fixed; inset: 0; z-index: 9000;
      background: #1a1a2e;
      display: flex; align-items: center; justify-content: center;
      flex-direction: column;
    }
    #landing-splash { text-align: center; }
    #landing-splash .ls-title {
      font-size: 3.5rem; letter-spacing: 14px; font-weight: 700;
      opacity: 0.92; color: #eee;
    }
    #landing-splash .ls-sub {
      font-size: 1rem; letter-spacing: 4px; opacity: 0.5; margin-top: 10px; color: #ccc;
    }
    #landing-menu { display: none; flex-direction: column; align-items: center; gap: 18px; }
    #landing-menu .lm-title {
      font-size: 2rem; letter-spacing: 10px; font-weight: 700; opacity: 0.85; color: #eee;
    }
    #landing-mode-btns { display: flex; gap: 10px; flex-wrap: wrap; justify-content: center; }
    .lm-btn {
      padding: 10px 22px; font-size: 0.95rem; letter-spacing: 2px; cursor: pointer;
      background: #16213e; border: 1px solid #3a3a5c; border-radius: 6px; color: #eee;
      transition: background 0.15s, border-color 0.15s;
    }
    .lm-btn:hover { background: #1f2f50; border-color: #6a6a9c; }
    .lm-btn.lm-active { background: #2a3a60; border-color: #8a8adc; }
    #landing-extras { display: flex; gap: 12px; }
    .lm-extra-btn {
      padding: 8px 20px; font-size: 0.85rem; letter-spacing: 1px; cursor: pointer;
      background: #0d0d1a; border: 1px solid #2d2d4e; border-radius: 6px; color: #aaa;
      transition: background 0.15s;
    }
    .lm-extra-btn:hover { background: #16213e; color: #eee; }
    #landing-htp {
      display: none; flex-direction: column; align-items: center;
      width: 100%; max-width: 700px; max-height: 75vh; overflow-y: auto;
    }
    #landing-htp-content {
      background: #0d0d1a; border: 1px solid #2d2d4e; border-radius: 8px;
      padding: 24px 28px; color: #ccc; font-size: 0.88rem; line-height: 1.7; letter-spacing: 0.3px;
      width: 100%;
    }
    #landing-htp-back {
      margin-top: 14px; padding: 8px 24px; font-size: 0.85rem; letter-spacing: 1px;
      cursor: pointer; background: #16213e; border: 1px solid #3a3a5c; border-radius: 6px; color: #eee;
    }
