/* Full-screen play layout (desktop, tablet, non-touch): the arena owns the screen, the HUD
   floats on top and the old side panel becomes a drawer that only opens on request.
   Phones keep their dedicated touch layout (body.mobile-game). */
body:not(.mobile-game) { overflow: hidden; background: #120d2a; }
body:not(.mobile-game) main { max-width: none; padding: 0; margin: 0; height: 100dvh; }
body:not(.mobile-game) main > header { position: fixed; top: 12px; right: 16px; z-index: 30; margin: 0; display: flex; gap: 8px; pointer-events: none; }
body:not(.mobile-game) main > header > * { pointer-events: auto; }
body:not(.mobile-game) main > header .brand, body:not(.mobile-game) main > header .edition, body:not(.mobile-game) main > header .tagline,
body:not(.mobile-game) main > header > p, body:not(.mobile-game) main > header > a { display: none; }
body:not(.mobile-game) main > header .header-side { display: flex; align-items: center; gap: 8px; }
body:not(.mobile-game) main > header button { width: auto; margin: 0; min-height: 40px; padding: 8px 14px; border-radius: 14px; border: 3px solid #fff; background: rgba(20, 16, 44, .82); color: #fff; font-weight: 800; font-size: 13px; box-shadow: 0 4px 0 rgba(0,0,0,.35); }
body:not(.mobile-game) #status { position: fixed; left: 16px; bottom: 16px; z-index: 25; max-width: 40vw; padding: 6px 12px; border-radius: 12px; background: rgba(20, 16, 44, .7); color: #fff; font-size: 12px; font-weight: 700; pointer-events: none; }
body:not(.mobile-game) #status:empty { display: none; }
body:not(.mobile-game) .layout { display: block; position: fixed; inset: 0; }
body:not(.mobile-game) .stage { position: absolute; inset: 0; max-width: none; width: auto; height: auto; margin: 0; border: 0; border-radius: 0; box-shadow: none; background: transparent; overflow: hidden; }
body:not(.mobile-game) .board-wrap, body:not(.mobile-game) .canvas-wrap { position: absolute; inset: 0; background: transparent; }
body:not(.mobile-game) .stage canvas#game { width: 100%; height: 100%; aspect-ratio: auto; }
body:not(.mobile-game) .stage-footer, body:not(.mobile-game) .understage, body:not(.mobile-game) main > footer { display: none; }

/* the side panel as an on-demand drawer */
body:not(.mobile-game) aside#game-menu { position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(400px, 94vw); max-height: none; border-radius: 26px 0 0 26px; border: 3px solid #fff; border-right: 0;
  background: rgba(24, 19, 52, .96); color: #fff; transform: translateX(105%); transition: transform .28s cubic-bezier(.2, 1.2, .4, 1); box-shadow: -18px 0 40px rgba(0,0,0,.45); overflow-y: auto; }
body:not(.mobile-game).drawer-open aside#game-menu { transform: none; }
body:not(.mobile-game) .drawer-backdrop { position: fixed; inset: 0; z-index: 35; background: rgba(8, 6, 20, .45); backdrop-filter: blur(2px); opacity: 0; pointer-events: none; transition: opacity .2s; }
body:not(.mobile-game).drawer-open .drawer-backdrop { opacity: 1; pointer-events: auto; }
body.mobile-game .drawer-backdrop, body.mobile-game .drawer-close { display: none; }
body:not(.mobile-game) aside#game-menu nav { background: rgba(24, 19, 52, .98); padding-right: 52px; }
body:not(.mobile-game) aside#game-menu nav button.active { color: #ffd34d; box-shadow: inset 0 -3px #ffd34d; }
body:not(.mobile-game) aside#game-menu section { padding: 18px 20px; }
body:not(.mobile-game) aside#game-menu select, body:not(.mobile-game) aside#game-menu input:not([type=checkbox]):not([type=range]) { background: rgba(0,0,0,.35); color: #fff; border: 2px solid rgba(255,255,255,.35); border-radius: 12px; min-height: 42px; font-weight: 700; }
body:not(.mobile-game) aside#game-menu section button:not(.secondary):not(.subtle):not([data-tab]) { background: #f0b85a; color: #1a1030; border: 3px solid #fff; border-radius: 14px; font-weight: 900; font-size: 15px; min-height: 46px; box-shadow: 0 5px 0 rgba(0,0,0,.35); }
body:not(.mobile-game) aside#game-menu button.secondary { border-radius: 12px; }
.drawer-close { position: fixed; z-index: 41; top: 10px; right: 12px; width: 40px !important; height: 40px; min-height: 0 !important; margin: 0 !important; padding: 0 !important; border-radius: 50% !important; border: 3px solid #fff !important; background: #1a1030 !important; color: #fff !important; font-size: 18px !important; font-weight: 900; transform: translateX(450px); transition: transform .28s; }
body.drawer-open .drawer-close { transform: none; }

dialog { border: 3px solid #fff !important; border-radius: 24px !important; background: rgba(24, 19, 52, .97) !important; color: #fff !important; box-shadow: 0 10px 0 rgba(0,0,0,.35), 0 30px 80px rgba(0,0,0,.5) !important; }
dialog::backdrop { background: rgba(8, 6, 20, .55); backdrop-filter: blur(3px); }

body.drawer-open:not(.mobile-game) main > header { display: none; }

/* Chess: board in the centre, players and actions on the left, the score sheet on the right */
body:not(.mobile-game) .stage { position: absolute; inset: 0; display: grid; grid-template-columns: minmax(220px, 1fr) auto minmax(250px, 1fr); grid-template-rows: 1fr auto 1fr; align-items: center; gap: 16px 30px; padding: 72px 28px 24px; overflow: hidden;
  background: radial-gradient(90% 80% at 50% 45%, #3a2a1a 0%, #1b130c 60%, #0d0906 100%); }
body:not(.mobile-game) .stage .board-wrap { position: relative; inset: auto; grid-column: 2; grid-row: 1 / 4; width: min(calc(100dvh - 104px), 50vw); aspect-ratio: 1; margin: 0; border: 0; border-radius: 18px; overflow: hidden;
  box-shadow: 0 0 0 4px #f6e7c4, 0 0 0 10px #5a3a1e, 0 30px 70px rgba(0,0,0,.6); }
body:not(.mobile-game) .stage canvas#game { width: 100%; height: 100%; }
body:not(.mobile-game) #black-card { grid-column: 1; grid-row: 1; align-self: end; }
body:not(.mobile-game) #white-card { grid-column: 1; grid-row: 3; align-self: start; }
body:not(.mobile-game).board-flipped #black-card { grid-row: 3; align-self: start; }
body:not(.mobile-game).board-flipped #white-card { grid-row: 1; align-self: end; }
body:not(.mobile-game) .stage .player-card { justify-self: end; width: min(320px, 100%); padding: 14px 18px; border-radius: 20px; border: 3px solid rgba(255,255,255,.85); background: rgba(30, 22, 14, .88); color: #fff; box-shadow: 0 6px 0 rgba(0,0,0,.35); }
body:not(.mobile-game) .stage .player-card span { font-weight: 900; font-size: 17px; }
body:not(.mobile-game) .stage .player-card strong { font-size: 40px; font-weight: 900; color: #f6e7c4; }
body:not(.mobile-game) .stage .player-card.active { border-color: #f0b85a; box-shadow: 0 6px 0 rgba(0,0,0,.35), 0 0 0 6px rgba(240,184,90,.25); }
body:not(.mobile-game) .stage .player-card.low strong { color: #ff7a6b; animation: arc-blink 1s infinite; }
body:not(.mobile-game) .stage .board-actions { grid-column: 1; grid-row: 2; justify-self: end; display: flex; flex-wrap: wrap; gap: 8px; width: min(320px, 100%); margin: 0; }
body:not(.mobile-game) .stage .board-actions button { flex: 1; width: auto; margin: 0; min-height: 44px; border-radius: 14px; border: 3px solid #fff; background: #f0b85a; color: #2a1a0a; font-weight: 900; box-shadow: 0 4px 0 rgba(0,0,0,.35); }
body:not(.mobile-game) .stage .board-actions button:disabled { opacity: .45; }
body:not(.mobile-game) .stage .score-sheet { grid-column: 3; grid-row: 1 / 4; justify-self: start; width: min(320px, 100%); max-height: calc(100dvh - 110px); display: flex; flex-direction: column; gap: 10px; padding: 16px 18px; border-radius: 22px; border: 3px solid #fff; background: rgba(30, 22, 14, .9); color: #fff; box-shadow: 0 8px 0 rgba(0,0,0,.35); }
body:not(.mobile-game) .stage .score-sheet h3 { margin: 0; font-size: 20px; font-weight: 900; text-transform: uppercase; }
body:not(.mobile-game) .stage .score-sheet #moves { flex: 1; max-height: none; min-height: 80px; margin: 0; border-radius: 12px; background: rgba(0,0,0,.3); }
body:not(.mobile-game) .stage .score-sheet #moves li { border-color: rgba(255,255,255,.08); }
body:not(.mobile-game) .stage .score-sheet button { width: auto; margin: 0; min-height: 40px; border-radius: 12px; border: 2px solid rgba(255,255,255,.7); background: rgba(255,255,255,.08); color: #fff; font-weight: 800; }
body:not(.mobile-game) .stage .score-sheet .pair { display: flex; gap: 8px; }
body:not(.mobile-game) .stage .score-sheet .pair button { flex: 1; }
body:not(.mobile-game) #board-status, body:not(.mobile-game) #controls { display: none; }
@media (max-width: 1000px) and (min-width: 700px) and (min-height: 521px) {
  body:not(.mobile-game) .stage { grid-template-columns: auto minmax(220px, 1fr); grid-template-rows: auto auto auto 1fr; }
  body:not(.mobile-game) .stage .board-wrap { grid-column: 1; grid-row: 1 / 5; width: min(calc(100dvh - 104px), 62vw); }
  body:not(.mobile-game) #black-card, body:not(.mobile-game).board-flipped #white-card { grid-column: 2; grid-row: 1; }
  body:not(.mobile-game) #white-card, body:not(.mobile-game).board-flipped #black-card { grid-column: 2; grid-row: 2; align-self: start; }
  body:not(.mobile-game) .stage .board-actions { grid-column: 2; grid-row: 3; }
  body:not(.mobile-game) .stage .score-sheet { grid-column: 2; grid-row: 4; max-height: 100%; }
  body:not(.mobile-game) .stage .player-card, body:not(.mobile-game) .stage .board-actions { justify-self: start; }
}

/* phones already have a panel "Menu" button: the arcade main menu becomes a home icon */
body.mobile-game #arcade-menu { font-size: 0 !important; min-width: 44px; }
body.mobile-game #arcade-menu::before { content: "\2302"; font-size: 20px; }

/* short windows without touch: same three columns, smaller board, slimmer cards */
@media (max-height: 520px) {
  body:not(.mobile-game) .stage { padding: 56px 16px 12px; gap: 8px 16px; grid-template-columns: minmax(170px, 1fr) auto minmax(170px, 1fr); }
  body:not(.mobile-game) .stage .board-wrap { width: min(calc(100dvh - 72px), 46vw); }
  body:not(.mobile-game) .stage .player-card { padding: 8px 12px; }
  body:not(.mobile-game) .stage .player-card strong { font-size: 26px; }
  body:not(.mobile-game) .stage .board-actions button { min-height: 40px; font-size: 12px; }
  body:not(.mobile-game) .stage .score-sheet { padding: 10px 12px; max-height: calc(100dvh - 72px); }
  body:not(.mobile-game) main > header { top: 6px; }
}
