:root {
  font-family: "Segoe UI", system-ui, sans-serif;
  color: #f3ecdb;
  background: #0e1818;
  font-synthesis: none;
  --panel: #172424;
  --line: #394a47;
  --muted: #afc2bb;
  --amber: #f3c782;
  --light: #d8c5a2;
  --dark: #63837b;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; min-width: 300px; min-height: 100dvh; background: radial-gradient(ellipse at 30% 0%, #1b3231, transparent 65%); }
.shell { width: min(100%, 1100px); margin: auto; padding: 0 clamp(12px, 4vw, 34px) calc(24px + env(safe-area-inset-bottom)); }
.top { min-height: 64px; display: flex; justify-content: space-between; align-items: center; border-bottom: 1px solid var(--line); margin-bottom: 24px; }
.brand { display: inline-flex; align-items: center; gap: 7px; padding: 0; border: 0; background: transparent; font-size: 20px; letter-spacing: -.5px; }
.brand span { color: var(--amber); font-family: "Segoe UI Symbol", "DejaVu Sans", sans-serif; font-size: 28px; }
.brand b { color: var(--amber); }
#connection, .muted { color: var(--muted); font-size: 14px; }

button, input { font: inherit; }
button, input { min-width: 0; border: 1px solid var(--line); border-radius: 8px; }
button { color: inherit; padding: 9px 13px; min-height: 42px; background: #243634; cursor: pointer; font-weight: 650; transition: background-color .16s, border-color .16s, box-shadow .16s; }
button:hover:not(:disabled) { border-color: var(--amber); }
button:disabled { cursor: default; opacity: .52; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--amber); outline-offset: 3px; }
button.primary { background: var(--amber); color: #24231a; border-color: var(--amber); }
input { width: 100%; color: inherit; padding: 9px 11px; background: #101c1c; }
#code { text-transform: uppercase; font-variant-numeric: tabular-nums; }
label { display: block; color: var(--muted); font-size: 13px; margin-bottom: 7px; }
h1, h2, p { margin: 0; }
h1 { font: 600 clamp(38px, 7.4vw, 84px)/.98 Georgia, serif; letter-spacing: -.055em; }
h2 { font-size: 19px; line-height: 1.2; }
p { line-height: 1.55; }
.hero { display: grid; align-items: center; min-height: clamp(300px, 44vw, 465px); overflow: hidden; border: 1px solid #5a5950; border-radius: 18px; background: linear-gradient(90deg, #071616f0, #071616c9 29%, transparent 68%), url('/pegasus.jpg') center 48% / cover #0b2324; box-shadow: 0 20px 50px #050b0b73; }
.title { padding: clamp(20px, 5vw, 58px); max-width: 80%; text-shadow: 0 2px 16px #081817; animation: enter .45s both; }
.title p { color: #e6dfcc; max-width: 32ch; margin-top: 23px; }

.lobby-actions { margin-top: 16px; display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.panel { border: 1px solid var(--line); background: var(--panel); border-radius: 12px; padding: 16px; box-shadow: 0 10px 24px #09111140; }
.panel h2 { margin-bottom: 13px; }
.form-row { display: grid; grid-template-columns: minmax(0, 1fr) auto; gap: 8px; }
.game-settings { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.game-settings input { display: block; margin-top: 6px; }
#create > button { margin-top: 5px; }
#resume { justify-self: start; }
#telegram-only { margin-top: 12px; }
.notice { margin-bottom: 14px; border: 1px solid #67583e; color: #ffe4b7; background: #332c20; border-radius: 8px; padding: 8px 12px; }

.waiting { max-width: 480px; margin: 32px auto; text-align: center; padding: 24px; }
.waiting p { margin-bottom: 15px; }
.room-code { display: inline-flex; align-items: center; gap: 10px; }
.room-code b { letter-spacing: .15em; font-variant-numeric: tabular-nums; color: var(--amber); }
.waiting .room-code b { font-size: 26px; }
.room-meta { display: flex; justify-content: space-between; align-items: center; gap: 12px; margin-bottom: 12px; }
.room-meta h2 { font-size: 17px; }
.room-meta button { min-height: 32px; padding: 4px 8px; }

.match { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(235px, 1fr); gap: 16px; align-items: start; }
.match.enter { animation: enter .27s ease-out both; }
.player { display: flex; align-items: center; gap: 9px; padding: 7px 10px; min-height: 46px; border: 1px solid var(--line); border-radius: 9px; background: var(--panel); }
.player.active { border-color: var(--amber); box-shadow: inset 3px 0 var(--amber); }
.player .piece { font-size: 25px; }
.player-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.ready { color: #bde4c8; font-size: 12px; }
.score { color: var(--amber); font-size: 19px; font-weight: 700; font-variant-numeric: tabular-nums; }
.board { display: grid; position: relative; isolation: isolate; grid-template-columns: repeat(8, minmax(0, 1fr)); margin: 9px 0; aspect-ratio: 1; border-radius: 9px; overflow: hidden; border: 1px solid #a49c80; box-shadow: 0 14px 30px #070f0f87; }
.square { position: relative; display: grid; place-items: center; min-height: 0; aspect-ratio: 1; padding: 0; border: 0; border-radius: 0; background: var(--light); color: #263630; touch-action: manipulation; }
.square.dark { background: var(--dark); color: #fbf2df; }
.square:disabled { opacity: 1; }
.square.off-limits { filter: brightness(.64) saturate(.54); }
.square.home-rank:hover:not(:disabled) { box-shadow: inset 0 0 0 3px #ffe7aaae; }
.square:focus-visible { outline-offset: -3px; z-index: 2; }
.square.selected { background: #d5a957; }
.square.in-check { background: #c97765; animation: check .56s ease-out; }
.square.last:not(.selected):not(.in-check) { box-shadow: inset 0 0 0 100px #e7c36338; }
.square.legal::after { content: ""; position: absolute; width: 22%; aspect-ratio: 1; border-radius: 50%; background: #11342d8f; pointer-events: none; animation: marker .15s ease-out both; }
.square.capture::after { width: 85%; background: none; border: 3px solid #133e33b0; }
.square.power::after { background: #8d481c; border-radius: 2px; transform: rotate(45deg); }
.coord { position: absolute; font-size: clamp(9px, 1.7vw, 12px); font-weight: 800; line-height: 1; pointer-events: none; }
.file { right: 3px; bottom: 2px; }
.rank { left: 3px; top: 3px; }
.piece { display: grid; place-items: center; font: 700 clamp(22px, 6.8vw, 60px)/1 "Segoe UI Symbol", "DejaVu Sans", sans-serif; pointer-events: none; }
.piece.w { color: #fff5db; -webkit-text-stroke: 1px #574330; filter: drop-shadow(0 2px 1px #251c1880); }
.piece.b { color: #152a2b; -webkit-text-stroke: .65px #dfc5a0; filter: drop-shadow(0 2px 1px #142624a8); }
.piece.variant { width: 78%; aspect-ratio: 1; border-radius: 50%; border: 1px solid currentColor; font-size: clamp(16px, 5vw, 43px); }
.piece.variant.w { color: #fff2d5; background: #744628; }
.piece.variant.b { color: #f9d69a; background: #1e3d3d; -webkit-text-stroke: 0; }
.piece.moving { z-index: 5; will-change: transform; }
.captured-piece { position: absolute; inset: 0; margin: auto; height: fit-content; width: fit-content; }
.captured-piece.variant { width: 78%; height: auto; }
.upgrade-dot { position: absolute; top: 2px; right: 3px; color: #291e12; background: #f4c376; border: 1px solid #423d2e; border-radius: 6px; font-size: 10px; font-weight: 800; line-height: 1; padding: 1px 2px; }

.side { display: grid; gap: 12px; }
.side .panel { min-width: 0; }
.controls { display: flex; flex-wrap: wrap; gap: 7px; }
.board-status { margin-bottom: 10px; color: var(--amber); font-weight: 700; }
.log { margin: 0; padding: 0; list-style: none; max-height: 220px; overflow: auto; }
.log li { display: grid; grid-template-columns: 28px 1fr 1fr; gap: 5px; padding: 4px 0; border-bottom: 1px solid var(--line); font-size: 13px; }
.log li span:first-child { color: var(--muted); }
.panel-title { display: flex; justify-content: space-between; align-items: center; flex-wrap: wrap; gap: 5px 12px; margin-bottom: 8px; }
.panel-title h2 { margin: 0; }
.panel-title output, .panel-title > span { color: var(--muted); font-size: 13px; }
.panel-title output b { color: var(--amber); font-size: 20px; }
.palette, .reward-cards { display: grid; gap: 6px; margin-block: 12px; }
.palette { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.palette-piece, .reward-card { display: grid; grid-template-columns: 25px minmax(0, 1fr) auto; align-items: center; gap: 7px; text-align: left; }
.palette-piece { padding: 5px 7px; font-size: 12px; }
.palette-piece b, .reward-card b { color: var(--amber); }
.palette-piece .piece, .reward-card .piece { font-size: 24px; }
.palette-piece .piece.variant, .reward-card .piece.variant { width: 100%; font-size: 16px; }
.reward-card { grid-template-columns: 32px minmax(0, 1fr) auto; padding: 9px; min-height: 58px; }
.reward-card small { display: block; font-size: 12px; color: var(--muted); line-height: 1.38; margin-top: 2px; font-weight: 400; }
.reward-card .bonus { color: var(--amber); }
.piece-hint { color: var(--muted); margin-bottom: 12px; min-height: 3em; font-size: 13px; }
button[aria-pressed="true"] { border-color: var(--amber); background: #3c3b2e; box-shadow: inset 2px 0 var(--amber); }
.promotion { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 9px; }
.promotion .piece { font-size: 30px; }
.history { margin: 10px 0 0; padding-left: 24px; color: var(--muted); font-size: 13px; }
@media (max-width: 720px) {
  .match { grid-template-columns: minmax(0, 1fr); gap: 11px; }
  .top { margin-bottom: 14px; min-height: 52px; }
  .hero { min-height: 310px; }
  .draft > .side { display: contents; }
  .draft .reward { grid-row: 1; }
  .piece { font-size: clamp(23px, 8.7vw, 66px); }
  .piece.variant { font-size: clamp(17px, 6vw, 48px); }
}
@media (max-width: 440px) {
  .lobby-actions { grid-template-columns: 1fr; }
  .hero { background-image: linear-gradient(90deg, #071616ef, #07161699 52%, #07161615), url('/pegasus.jpg'); background-position: 59% center; }
  .title { max-width: 92%; }
  .title p { margin-top: 13px; }
  .panel { padding: 12px; }
}

@keyframes enter { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }
@keyframes marker { from { opacity: 0; scale: .65; } to { opacity: 1; scale: 1; } }
@keyframes check { from { box-shadow: inset 0 0 0 6px #ffdfb2; } to { box-shadow: none; } }
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
