:root {
  color-scheme: light;
  --ink: #172a24;
  --muted: #586961;
  --paper: #f5f4ed;
  --card: #fffefa;
  --line: #ddded3;
  --nav: #142b23;
  --green: #285b48;
  --light: #eae4d0;
  --dark: #789381;
  font-family: "DM Sans", "Segoe UI", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; font-size: 1rem; line-height: 1.5; min-width: 280px; }
a { color: inherit; }
button, input, select { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: wait; opacity: .65; }
:focus-visible { outline: 3px solid #c58c37; outline-offset: 3px; }
h1, h2, p { margin: 0; }
h1, h2 { line-height: 1.12; }
h1 { font-family: Georgia, serif; font-size: clamp(2.3rem, 5vw, 4rem); font-weight: 500; letter-spacing: -.045em; }
h2 { font-size: 1.25rem; letter-spacing: -.025em; }
.wrap { width: min(1120px, calc(100% - 3rem)); margin-inline: auto; }
.top { background: var(--nav); color: #fbfaf3; }
.navbar { min-height: 76px; display: flex; gap: 1rem; justify-content: space-between; align-items: center; }
.brand { display: inline-flex; gap: .65rem; align-items: center; text-decoration: none; font-size: 1.1rem; }
.brand span { border: 1px solid #655f49; border-radius: 10px; color: #edc779; display: grid; place-items: center; height: 2.4rem; width: 2.4rem; font-size: 1.55rem; line-height: 1; }
.nav-actions, .button-row { display: flex; flex-wrap: wrap; align-items: center; gap: .7rem; }
.nav-actions a { font-size: .9rem; }
.nav-actions .secondary { background: #223c32; border-color: #51685d; color: #fff; }
#identity { color: #dfdfcf; font-size: .9rem; }
main { padding: 2.3rem 0 4rem; }
.hero { background: var(--nav); color: #f8f5e8; border-radius: 22px; display: grid; grid-template-columns: 1fr minmax(0, .9fr); align-items: center; gap: 2rem; padding: clamp(1.5rem,5vw,4rem); overflow: hidden; }
.hero h1 { font-size: clamp(3.3rem, 8vw, 6.6rem); line-height: .92; max-width: 10ch; overflow-wrap: anywhere; padding: .7rem 0 1.05rem; }
.kicker { color: #edc779; font-size: .85rem; font-weight: 700; letter-spacing: .15em; }
.subtitle { max-width: 30ch; color: #e3e8da; font-size: 1.08rem; }
.announcement { margin-top: .85rem; border-left: 3px solid #edc779; padding-left: .75rem; color: #f0dfb3; }
.preview { width: min(100%, 335px); margin-inline: auto; transform: rotate(-5deg); padding: .55rem; background: #2e493a; border: 1px solid #637763; border-radius: 12px; box-shadow: 13px 19px 0 #0d211a; }
.home-grid { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); align-items: start; gap: 1.2rem; margin-top: 1.25rem; }
.card { padding: clamp(1rem,3vw,1.6rem); border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.section-head { display: flex; justify-content: space-between; align-items: center; gap: .65rem; }
.muted { color: var(--muted); margin-top: .45rem; }
form { display: grid; gap: .8rem; margin-top: 1rem; }
label { display: grid; gap: .3rem; font-size: .9rem; font-weight: 650; }
input:not([type=checkbox]), select { width: 100%; min-width: 0; padding: .64rem .7rem; border-radius: 8px; border: 1px solid #b6c0b5; background: #fff; color: var(--ink); font-size: 1rem; }
input[type=color] { min-height: 2.75rem; padding: .25rem .4rem; }
input[type=checkbox] { accent-color: var(--green); width: 1.05rem; height: 1.05rem; margin: 0; }
.check { display: flex; gap: .55rem; align-items: center; font-weight: 400; }
.two { display: grid; grid-template-columns: repeat(2,minmax(0,1fr)); gap: .7rem; }
.button { border-radius: 8px; padding: .62rem .95rem; display: inline-flex; align-items: center; justify-content: center; width: fit-content; min-height: 2.65rem; border: 1px solid transparent; font-weight: 650; text-decoration: none; font-size: .91rem; }
.button.primary { color: #fff; background: var(--green); }
.button.primary:hover { background: #174132; }
.button.secondary { background: #f6f6ef; color: var(--ink); border-color: var(--line); }
.button.secondary:hover { filter: brightness(.93); }
.button.compact { padding: .34rem .6rem; min-height: 2rem; }
.button.danger { color: #792c28; }
.tag { background: #ede9d9; padding: .22rem .65rem; font-weight: 700; border-radius: 100px; white-space: nowrap; }
.back { display: inline-block; margin-bottom: .5rem; color: var(--green); font-weight: 650; }
#notice, #auth-error { border: 1px solid #b8c89f; border-radius: 8px; background: #eef1e2; padding: .65rem .9rem; margin-bottom: 1rem; }
#notice.error, #auth-error { background: #f9e9e4; border-color: #d4b2a6; color: #742f2a; }
#lobby, #users { margin-top: 1rem; }
.row { display: flex; align-items: center; justify-content: space-between; gap: .6rem; padding: .7rem 0; }
.row + .row { border-top: 1px solid var(--line); }
.row > div { min-width: 0; overflow-wrap: anywhere; }
.game-grid { display: grid; grid-template-columns: minmax(0, 660px) minmax(245px, 1fr); gap: 1.3rem; margin-top: 1rem; align-items: start; }
.board { display: grid; grid-template-columns: repeat(8,minmax(0,1fr)); aspect-ratio: 1; overflow: hidden; border-radius: 5px; user-select: none; container-type: inline-size; }
.board[data-theme=forest] { --light: #eae4d0; --dark: #789381; }
.board[data-theme=ocean] { --light: #dfedf2; --dark: #6387a2; }
.board[data-theme=walnut] { --light: #f2d6ab; --dark: #a57253; }
.square { min-width: 0; position: relative; display: grid; place-items: center; padding: 0; border-radius: 0; border: 0; aspect-ratio: 1; background: var(--light); line-height: 1; font-size: clamp(14px, 10cqw, 74px); color: #182521; }
.square.dark { background: var(--dark); }
.square:focus-visible { z-index: 1; outline-offset: -4px; }
.square.last { box-shadow: inset 0 0 0 100px #d9bd5847; }
.square.selected { box-shadow: inset 0 0 0 4px #f4c74c; }
.square.target::after { position: absolute; content: ""; border-radius: 50%; width: 19%; aspect-ratio: 1; background: #142b2366; }
.square.target.occupied::after { width: 80%; background: transparent; border: 3px solid #183b3680; }
.piece { font-family: "DejaVu Sans", "Segoe UI Symbol", "Arial Unicode MS", sans-serif; pointer-events: none; }
.piece.white { color: #fff9e9; text-shadow: -1px -1px #292f21, 1px -1px #292f21, -1px 1px #292f21, 1px 1px #292f21, 0 2px #22332556; }
.piece.black { color: #1a291f; text-shadow: 0 1px #d3ddc997; }
.board[data-pieces=outline] .piece.white { color: #29382d; text-shadow: 0 0 1px #fff; }
.coordinate { position: absolute; left: 4%; top: 4%; font: 700 clamp(.55rem,2cqw,.82rem)/1 system-ui,sans-serif; }
.coordinate.file { left: auto; top: auto; bottom: 4%; right: 4%; }
.player { min-height: 3.15rem; display: flex; justify-content: space-between; align-items: center; gap: .5rem; }
.player strong { overflow-wrap: anywhere; }
.clock { background: #e6e7dc; min-width: 5rem; text-align: center; padding: .22rem .55rem; border-radius: 6px; font-weight: 750; font-size: 1.16rem; font-variant-numeric: tabular-nums; }
.clock.active { color: white; background: var(--green); }
.game-panel > * + * { margin-top: .75rem; }
.move-list { max-height: 285px; overflow: auto; }
.move-list ol { margin: 0; padding-left: 1.8rem; }
.move-list li { padding: .18rem .4rem; }
.move-list li:nth-child(odd) { background: #f0f0e8; }
.move-entry { min-width: 4rem; text-align: left; background: transparent; border: 0; color: var(--ink); border-radius: 3px; padding: .22rem .35rem; }
.move-entry[aria-current=true] { background: #dbe5d9; font-weight: 750; }
#history-list, #history-pages { margin-top: 1rem; }
#users form { border-top: 1px solid var(--line); padding-top: .65rem; }
#users form .muted { overflow-wrap: anywhere; }
dialog { width: min(28rem,calc(100% - 2rem)); border: 1px solid var(--line); border-radius: 16px; padding: 1.4rem; color: var(--ink); background: var(--card); }
dialog form { margin-top: 0; }
dialog::backdrop { background: #132821a9; }
#promotion-options { margin-top: .75rem; }
@media (max-width: 730px) {
  .wrap { width: calc(100% - 1.65rem); }
  .hero { gap: 1rem; }
  .hero h1 { font-size: clamp(2.4rem, 9vw, 4rem); }
  .home-grid { grid-template-columns: 1fr; }
  .game-grid { grid-template-columns: minmax(0,1fr); }
  .navbar { padding: .65rem 0; align-items: flex-start; }
  .nav-actions { justify-content: flex-end; gap: .4rem; }
  #identity { display: none; }
  main { padding-top: 1.1rem; }
}
@media (max-width: 435px) {
  .hero { grid-template-columns: minmax(0,1fr); }
  .preview { width: min(64%, 190px); margin: .5rem .3rem .5rem auto; }
  .brand { font-size: .95rem; }
  .room-title h1 { font-size: 2rem; }
}

.analysis-panel { border-top: 1px solid var(--line); padding-top: .85rem; }
.analysis-panel h3 { margin: 0; font-size: 1rem; }
.analysis-panel dl { display: grid; grid-template-columns: minmax(0,1fr) minmax(0,1.2fr); gap: .4rem .6rem; margin: .55rem 0 0; }
.analysis-panel dt { color: var(--muted); }
.analysis-panel dd { margin: 0; font-weight: 650; }
.analysis-panel h4 { margin: .65rem 0 .2rem; font-size: .95rem; }
.analysis-panel ol { margin: 0; padding-left: 1.45rem; }
.analysis-panel li { padding: .2rem 0; }
.live-title { font-size: 1.1rem; margin: 1rem 0 .4rem; padding-top: .8rem; border-top: 1px solid var(--line); }
.analysis-license { display: inline-block; margin-top: .55rem; color: var(--muted); font-size: .875rem; }
#analysis-status:empty { display: none; }
.square.analysis-from::before, .square.analysis-to::before {
  content: "";
  position: absolute;
  inset: 2px;
  border: 3px solid #1d548b;
  border-radius: 3px;
  pointer-events: none;
}
.square.analysis-to::before { border-color: #1d548b; background: #2980c235; }
