:root {
  color-scheme: light;
  --paper: #f5f2e9;
  --ink: #202820;
  --muted: #777d70;
  --line: #dcded2;
  --green: #416b4a;
  --green-dark: #2d5036;
  --lime: #d5ed91;
  --orange: #f2a66c;
  --card: #fffef9;
  font-family: "DM Sans", sans-serif;
  background: var(--paper);
  color: var(--ink);
}
* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; background: var(--paper); }
button, input { font: inherit; }
button { cursor: pointer; }
.app-shell { width: min(1100px, 100%); margin: 0 auto; min-height: 100vh; padding: 0 28px; display: flex; flex-direction: column; }
.topbar { height: 78px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--line); }
.brand { display: inline-flex; gap: 9px; align-items: center; color: var(--ink); text-decoration: none; font: 700 20px "Space Grotesk", sans-serif; letter-spacing: -1px; }
.brand-logo { display: block; width: 34px; height: 34px; }
.brand-light { font-weight: 500; color: var(--green); }
.top-actions { display: flex; align-items: center; gap: 13px; }
.top-note { display: flex; align-items: center; gap: 8px; color: var(--muted); font-size: 12px; }
.language-toggle { min-width: 37px; min-height: 31px; padding: 0 8px; border: 1px solid var(--line); border-radius: 8px; background: #fbfaf4; color: var(--green-dark); font-size: 10px; font-weight: 700; letter-spacing: .5px; }
.language-toggle:hover { border-color: #a8b99b; background: #edf1e5; }
.live-dot { width: 7px; height: 7px; border-radius: 50%; background: #82ad69; box-shadow: 0 0 0 4px #82ad6922; }
main { flex: 1; }
footer { padding: 24px 0 20px; color: #92978d; font-size: 11px; text-align: center; }
footer > span:last-child { color: var(--green); margin-left: 3px; }
.hero { max-width: 760px; margin: 62px auto 0; text-align: center; }
.eyebrow { color: var(--green); font-weight: 700; font-size: 11px; letter-spacing: 2px; text-transform: uppercase; }
h1, h2, h3, p { margin-top: 0; }
h1 { margin: 14px 0 14px; font: 600 clamp(40px, 7vw, 70px)/.99 "Space Grotesk", sans-serif; letter-spacing: -4px; }
h1 em { color: var(--green); font-style: normal; }
.intro { max-width: 500px; margin: 0 auto; color: var(--muted); font-size: 15px; line-height: 1.7; }
.join-panel { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; max-width: 650px; margin: 38px auto 0; text-align: left; }
.panel { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); box-shadow: 0 7px 20px #44513608; }
.panel h2 { margin: 0 0 5px; font: 600 18px "Space Grotesk", sans-serif; }
.panel p { margin: 0 0 17px; color: var(--muted); font-size: 12px; }
.field-label { display: block; margin: 0 0 6px; color: #73796d; font-size: 11px; font-weight: 700; }
input { width: 100%; min-height: 43px; margin-bottom: 12px; padding: 0 12px; border: 1px solid var(--line); border-radius: 9px; outline: none; color: var(--ink); background: #fbfaf5; }
input:focus { border-color: #7c9a72; box-shadow: 0 0 0 3px #7c9a721b; }
.button { width: 100%; min-height: 43px; border: 0; border-radius: 9px; background: var(--green); color: white; font-weight: 700; font-size: 13px; transition: background .15s, transform .15s; }
.button:hover { background: var(--green-dark); transform: translateY(-1px); }
.button:disabled { opacity: .46; cursor: not-allowed; transform: none; }
.button.secondary { width: auto; padding: 0 16px; background: #e9eddf; color: var(--green-dark); }
.button.secondary:hover { background: #dfe7d1; }
.solo-button { width: 100% !important; min-height: 38px; margin-top: 8px; }
.fine-print { margin: 18px 0 0; color: #989c91; font-size: 11px; }
.screen { max-width: 920px; margin: 44px auto 20px; }
.screen-title { display: flex; align-items: flex-end; justify-content: space-between; gap: 20px; margin-bottom: 20px; }
.screen-title h1 { margin: 5px 0 0; font-size: 38px; letter-spacing: -2px; }
.code-chip { border: 1px dashed #b6c2a8; padding: 10px 14px; border-radius: 10px; background: #edf1e5; text-align: right; }
.code-chip span { display: block; color: var(--muted); text-transform: uppercase; letter-spacing: 1.2px; font-size: 9px; }
.code-chip strong { font: 700 19px "Space Grotesk", sans-serif; letter-spacing: 3px; }
.lobby-grid { display: grid; grid-template-columns: 1.1fr .9fr; gap: 16px; }
.lobby-card { padding: 22px; border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.lobby-card h2 { font: 600 17px "Space Grotesk", sans-serif; margin-bottom: 16px; }
.player-row { min-height: 47px; border-top: 1px solid #eff0e9; display: flex; align-items: center; justify-content: space-between; font-size: 13px; }
.player-row:first-of-type { border-top: 0; }
.player-name { display: flex; align-items: center; gap: 9px; }
.avatar { width: 28px; height: 28px; border-radius: 9px; display: grid; place-items: center; color: var(--green-dark); background: var(--lime); font-weight: 700; font-size: 11px; }
.host-tag { padding: 4px 7px; border-radius: 5px; background: #edf1e5; color: var(--green); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.waiting { color: var(--muted); font-size: 12px; line-height: 1.6; }
.rules { margin: 0; padding-left: 18px; color: var(--muted); font-size: 12px; line-height: 1.9; }
.lobby-actions { display: flex; align-items: center; gap: 13px; margin-top: 18px; }
.lobby-actions .button { width: auto; padding: 0 20px; }
.status-hint { color: var(--muted); font-size: 11px; }
.game-layout { display: grid; grid-template-columns: minmax(0, 1fr) 265px; gap: 19px; align-items: start; }
.game-main, .sidebar-card { border: 1px solid var(--line); border-radius: 16px; background: var(--card); }
.game-main { padding: 19px; }
.round-line { display: flex; justify-content: space-between; align-items: center; margin-bottom: 13px; }
.round-label { color: var(--muted); font-size: 11px; font-weight: 700; text-transform: uppercase; letter-spacing: 1px; }
.round-label strong { color: var(--ink); font: 600 17px "Space Grotesk", sans-serif; text-transform: none; letter-spacing: 0; margin-left: 5px; }
.empty-pill { border-radius: 99px; padding: 6px 10px; background: #f2f1e9; color: var(--muted); font-size: 11px; }
.board-wrap { width: min(100%, 555px); margin: 0 auto; }
.board { display: grid; grid-template-columns: repeat(9, minmax(0, 1fr)); aspect-ratio: 1; gap: 3px; padding: 5px; border: 1px solid #daddd1; border-radius: 9px; background: #e8eadd; touch-action: manipulation; }
.board.placement-board { touch-action: none; user-select: none; }
.placement-board .cell { cursor: grab; }
.placement-board:active .cell { cursor: grabbing; }
.cell { position: relative; min-width: 0; padding: 0; border: 0; border-radius: 3px; background: #fbfaf4; transition: background .08s; }
.cell.center-target::after { content: ""; position: absolute; top: 50%; left: 50%; width: 5px; height: 5px; border-radius: 50%; background: #9c9475; transform: translate(-50%, -50%); pointer-events: none; }
.cell.filled { background: hsl(var(--tile-hue, 125), 48%, 62%); box-shadow: inset 0 0 0 1px hsl(var(--tile-hue, 125), 38%, 45%); }
.cell.preview { background: hsl(var(--tile-hue, 125), 58%, 76%); }
.cell.invalid { background: #efb487; }
.cell:focus-visible { outline: 2px solid #3f6647; outline-offset: 1px; z-index: 1; }
.tile-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin: 14px 0 10px; }
.tile-choice { display: flex; align-items: center; gap: 12px; padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; background: #fbfaf4; text-align: left; color: var(--ink); }
.tile-choice.selected { border-color: var(--green); background: #f1f5e9; box-shadow: 0 0 0 2px #416b4a1c; }
.tile-choice:disabled { opacity: .5; cursor: default; }
.piece-preview { display: grid; gap: 2px; flex: none; }
.piece-cell { width: 12px; height: 12px; border-radius: 2px; background: hsl(var(--tile-hue, 125), 48%, 62%); }
.piece-name { font-size: 12px; font-weight: 700; }
.controls { display: flex; align-items: center; flex-wrap: wrap; gap: 7px; }
.placement-actions { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-top: 10px; }
.ready-button { width: auto; min-width: 105px; padding: 0 20px; }
.icon-button { min-height: 33px; padding: 0 10px; border: 1px solid var(--line); border-radius: 7px; background: #fbfaf4; color: #4b5548; font-size: 11px; font-weight: 600; }
.icon-button:hover, .icon-button.active { border-color: #a8b99b; background: #edf1e5; }
.instruction { min-height: 18px; margin: 10px 0 0; color: var(--muted); font-size: 11px; }
.instruction strong { color: var(--green-dark); }
.sidebar { display: grid; gap: 12px; }
.sidebar-card { padding: 16px; }
.sidebar-card h3 { margin: 0 0 12px; color: var(--muted); font-size: 10px; text-transform: uppercase; letter-spacing: 1.2px; }
.opponent-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 0; border-top: 1px solid #eff0e9; font-size: 12px; }
.opponent-row:first-of-type { border-top: 0; padding-top: 0; }
.opponent-state { color: var(--muted); font-size: 10px; }
.you-label { color: var(--green); font-size: 9px; font-weight: 700; text-transform: uppercase; }
.second-card { padding: 13px; border: 1px solid #d5e3b8; border-radius: 10px; background: #f3f7e9; }
.second-card strong { display: block; margin-bottom: 5px; color: var(--green-dark); font: 600 14px "Space Grotesk", sans-serif; }
.second-card p { margin: 0; color: var(--muted); font-size: 11px; line-height: 1.5; }
.text-button { padding: 3px; border: 0; background: transparent; color: var(--green); font-size: 11px; font-weight: 700; text-decoration: underline; }
.wait-banner { padding: 11px 13px; border-radius: 9px; background: #f2f1e9; color: #71776a; font-size: 11px; line-height: 1.5; }
.result { max-width: 620px; margin: 70px auto; padding: 38px; border: 1px solid var(--line); border-radius: 20px; background: var(--card); text-align: center; }
.result-icon { width: 57px; height: 57px; margin: 0 auto 15px; display: grid; place-items: center; border-radius: 18px; background: var(--lime); color: var(--green-dark); font-size: 25px; }
.result h1 { margin: 0 0 9px; font-size: 43px; letter-spacing: -2px; }
.result p { color: var(--muted); font-size: 13px; line-height: 1.6; }
.result-list { margin: 23px auto; max-width: 390px; text-align: left; }
.result .button { max-width: 200px; }
#toast { position: fixed; z-index: 5; left: 50%; bottom: 25px; max-width: calc(100% - 30px); padding: 11px 15px; transform: translate(-50%, 15px); opacity: 0; pointer-events: none; border-radius: 9px; background: #29362b; color: white; font-size: 12px; transition: all .2s; }
#toast.show { transform: translate(-50%, 0); opacity: 1; }
@media (max-width: 760px) {
  .app-shell { padding: 0 17px; }
  .topbar { height: 64px; }
  .hero { margin-top: 43px; }
  h1 { letter-spacing: -2.5px; }
  .join-panel { margin-top: 28px; }
  .screen { margin-top: 28px; }
  .game-layout { grid-template-columns: 1fr; }
  .sidebar { grid-template-columns: 1fr 1fr; }
  .sidebar-card:first-child { grid-column: 1 / -1; }
  .game-main { padding: 14px; }
  .board { gap: 2px; padding: 4px; }
}
@media (max-width: 520px) {
  .app-shell { padding: 0 13px; }
  .top-note { font-size: 10px; }
  .hero { margin-top: 35px; }
  .intro { font-size: 13px; }
  .join-panel { grid-template-columns: 1fr; gap: 10px; }
  .panel { padding: 17px; }
  .screen-title { align-items: center; }
  .screen-title h1 { font-size: 32px; }
  .lobby-grid { grid-template-columns: 1fr; }
  .lobby-card { padding: 17px; }
  .lobby-actions { align-items: flex-start; flex-direction: column; }
  .tile-choice { gap: 8px; padding: 8px; }
  .piece-cell { width: 10px; height: 10px; }
  .sidebar { grid-template-columns: 1fr; }
  .sidebar-card:first-child { grid-column: auto; }
  .result { margin: 40px auto; padding: 26px 18px; }
}
