/* The page around the board, shared by games/gomoku.html, chess.html and othello.html (tokens.css + base.css load first). */
.wrap{max-width:760px;margin:0 auto;padding:24px 16px 60px}
.brand em{color:var(--green)}
[hidden]{display:none !important}
h2{font-size:20px;font-weight:800;margin-bottom:12px}
.muted,.note{color:var(--muted);font-size:13px}
.note{margin-top:16px;text-align:center}
.error{background:rgba(248,81,73,.12);border:1px solid var(--red);color:var(--text);border-radius:10px;padding:10px 14px;margin-bottom:14px}

.hero{background:linear-gradient(135deg,rgba(63,185,80,.22),var(--card) 60%);border:1px solid var(--border);border-radius:16px;padding:26px 24px;margin-bottom:18px}
.hero h1{font-size:30px;font-weight:900}
.hero .sub{font-size:15px;font-weight:600;color:var(--green);margin-left:6px}
.hero p{color:var(--muted);margin-top:6px}
.choices{display:grid;grid-template-columns:repeat(auto-fit,minmax(190px,1fr));gap:12px}
.choice{display:flex;flex-direction:column;align-items:flex-start;gap:2px;text-align:left;background:var(--card);border:1px solid var(--border);border-radius:14px;padding:18px;color:var(--text);font:inherit;cursor:pointer}
.choice:hover,.choice:focus-visible{border-color:var(--green)}
.choice .ic{font-size:30px}
.choice b{font-size:16px}
.choice small{color:var(--muted)}

.card{background:var(--card);border:1px solid var(--border);border-radius:13px;padding:18px 20px}
.form{display:flex;flex-direction:column;gap:16px}
.field{display:flex;flex-direction:column;gap:4px;font-weight:700}
.field input{font:inherit;font-weight:400;padding:9px 11px;border-radius:8px;border:1px solid var(--border);background:var(--bg);color:var(--text);max-width:320px}
.field input:invalid:not(:placeholder-shown){border-color:var(--red)}
.hint,small{color:var(--muted);font-weight:400;font-size:12px}
fieldset{border:0;display:flex;flex-direction:column;gap:6px}
legend{font-weight:700;margin-bottom:4px}
fieldset label{display:flex;gap:8px;align-items:baseline;cursor:pointer}
.actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:6px}
.btn{font:inherit;font-size:14px;font-weight:700;padding:8px 14px;border-radius:8px;border:1px solid var(--border);background:var(--bg2);color:var(--text);cursor:pointer}
.btn:hover{border-color:var(--muted)}
.btn.primary{background:var(--green);border-color:var(--green);color:#04130a}
.btn:disabled{opacity:.45;cursor:not-allowed}
.btn:focus-visible,.choice:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
.link-row{display:flex;gap:8px;flex-wrap:wrap;margin:12px 0}
.link-row input{flex:1 1 220px;font:inherit;font-size:13px;padding:8px 10px;border-radius:8px;border:1px solid var(--border);background:var(--bg);color:var(--text)}

/* Players and turn */
.players{display:grid;grid-template-columns:1fr auto 1fr;align-items:center;gap:8px;margin-bottom:12px}
.player{display:flex;align-items:center;gap:8px;background:var(--card);border:1px solid var(--border);border-radius:10px;padding:6px 12px;font-weight:700;min-width:0;justify-self:start;max-width:100%}
.players .player:last-child{justify-self:end}
.dot{width:16px;height:16px;border-radius:50%;flex-shrink:0;box-shadow:0 0 0 1px rgba(255,255,255,.35)}
.player.active{border-color:var(--green);box-shadow:0 0 0 1px var(--green)}
.pname{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}
.turn{text-align:center;font-weight:700;color:var(--green)}

.game-bar{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:14px}
.spacer{flex:1}

dialog{margin:auto;max-width:min(520px,calc(100% - 32px));background:var(--card);color:var(--text);border:1px solid var(--border);border-radius:14px;padding:22px}
dialog::backdrop{background:rgba(0,0,0,.6)}
dialog ul{padding-left:18px;display:flex;flex-direction:column;gap:8px;margin-bottom:14px}
#result-title{font-size:24px}
#result-text{color:var(--muted);margin-bottom:12px}
footer{text-align:center}

@media (max-width:480px){
  .hero h1{font-size:24px}
  .game-bar .btn{padding:7px 10px;font-size:13px}
  .players{grid-template-columns:1fr 1fr}
  .player{padding:5px 9px;font-size:13px}
  .turn{grid-column:1/-1;order:3}
}

/* Wide screens: the move list stands to the right of the board, as high as the game;
   narrow screens keep it under the board. The page grows wider to make room. */
@media (min-width:960px){
  .wrap:has(> #v-game:not([hidden])){max-width:1080px}
  #v-game{position:relative;padding-right:292px}
  #v-game > .movelist-card{position:absolute;top:0;right:0;width:272px;max-height:100%;margin-top:0;overflow-y:auto;display:flex;flex-direction:column}
  #v-game > .movelist-card[open]{bottom:0}
  #v-game .movelist{max-height:none;flex:1 1 auto;min-height:0;grid-template-columns:1fr}
}

/* Move list (all board games) and looking back through the game */
.movelist-card{margin-top:14px;padding:10px 16px}
.movelist-card summary{cursor:pointer;font-weight:700;color:var(--muted)}
.mv-nav{display:flex;gap:6px;margin-top:8px}
.mv-nav .btn{padding:4px 12px;font-size:14px}
.movelist{list-style:decimal;padding-left:34px;margin-top:8px;max-height:150px;overflow-y:auto;display:grid;grid-template-columns:repeat(auto-fill,minmax(150px,1fr));column-gap:14px;row-gap:2px;font-size:14px;font-variant-numeric:tabular-nums}
.movelist li{color:var(--muted)}
.mv{display:inline-block;min-width:56px;padding:1px 4px;margin:0;border:0;border-radius:5px;background:none;color:var(--text);font:inherit;text-align:left;cursor:pointer}
button.mv:hover{background:var(--bg2)}
.mv.cur{background:var(--green);color:#04130a;font-weight:700}
.mv.pass{color:var(--muted);font-style:italic;cursor:default}
.mv:focus-visible{outline:2px solid var(--blue);outline-offset:1px}
.replay{opacity:.92;filter:saturate(.75)}

.rewards{margin-top:16px;font-size:14px}
.rewards p{color:var(--muted);margin-top:4px}
.rewards ul{list-style:none;display:flex;flex-direction:column;gap:4px;margin:8px 0}
.rewards li{color:var(--muted)}
.rewards li.got{color:var(--text)}
#reward-note{margin:0}
.reward{background:rgba(240,165,0,.12);border:1px solid var(--accent);border-radius:10px;padding:10px 12px;margin-bottom:12px}

/* Turning the board (after the 3D unlock; js/shared/board-game.js, turnable()). #board sits in .bview;
   .turned is set as soon as the view is not flat from your own side. --view is the board's transform,
   --bb the pieces' rotation back towards the viewer and --lift how far they rise (0 when flat).
   --ph is a piece's height, so that a lifted piece just touches the board. */
.bview{perspective:1600px;overflow:clip;touch-action:none;padding:2px 0}
.bview > *{transition:transform .25s ease}
.bview.dragging > *{transition:none}
.bview.turned > *{transform:var(--view);transform-style:preserve-3d}
.bview.turned > * > *{transform-style:preserve-3d}
.bview.turned :is(.cboard .pc,.board .pt.b .st,.board .pt.w .st,.tboard .piece,.sboard .piece){rotate:var(--bb);translate:0 0 calc(1px + var(--lift) * var(--ph,8cqw))}
.cboard{--ph:10.6cqw}
.board{--ph:calc(85cqw / var(--n))}
/* Othello discs lie flat, like the real ones (css/othello-board.css): only the square's own perspective goes */
.bview.turned .osq{perspective:none}
.tboard{--ph:7cqw}
.sboard{--ph:8.2cqw}
/* Things that would flatten the 3D view: the chess board's clipped corners, and the dimmed look-back (moved to .bview) */
.bview.turned > .cboard{overflow:visible}
.bview.turned > .replay{filter:none;opacity:1}
.bview.turned:has(> .replay){opacity:.92;filter:saturate(.75)}
.view-bar{display:flex;align-items:center;gap:6px;flex-wrap:wrap;margin-top:10px}
.view-bar .btn{padding:5px 10px;font-size:13px}
@media (prefers-reduced-motion:reduce){.bview > *{transition:none}}

/* Settings: ⚙ in the menu bar opens a dialog with the move speed (js/shared/board-game.js speedBar()) */
.settings-open{font:inherit;font-size:17px;line-height:1;padding:6px 9px;border-radius:8px;border:1px solid var(--border);background:var(--bg2);color:var(--text);cursor:pointer}
.settings-open:hover{border-color:var(--muted)}
.settings-open:focus-visible{outline:2px solid var(--blue);outline-offset:2px}
#settings p{margin-top:8px}
.speed-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:6px;font-size:14px}
.speed-row label{font-weight:700}
.speed-row input{width:160px;max-width:45vw;accent-color:var(--green)}
.speed-row output{min-width:3.2em;font-variant-numeric:tabular-nums;color:var(--text);font-weight:700}
/* The square of a piece that is moving (showMove()) stays above the other squares until it lands */
#board .moving{z-index:5}
