:root {
  --bg: #f4f8fb;
  --surface: rgba(255, 255, 255, 0.86);
  --surface-solid: #ffffff;
  --surface-soft: #edf3f8;
  --text: #14233b;
  --muted: #607188;
  --line: #a9b8c8;
  --line-soft: #d9e2eb;
  --blue: #0869dc;
  --blue-dark: #064ba4;
  --blue-soft: #e8f2ff;
  --red: #d92d4f;
  --red-dark: #a91d39;
  --mint: #62d7aa;
  --mint-soft: #dff8ee;
  --warning: #b54708;
  --danger: #b42318;
  --shadow-raised: 0 16px 38px rgba(39, 67, 97, 0.12), 0 2px 8px rgba(39, 67, 97, 0.06);
  --shadow-overlay: 0 24px 64px rgba(20, 35, 59, 0.2);
  --radius-s: 10px;
  --radius-m: 18px;
  --radius-l: 28px;
  --space-xs: 8px;
  --space-s: 16px;
  --space-m: 24px;
  --space-l: 32px;
  --space-xl: 48px;
}

* { box-sizing: border-box; }
html { min-height: 100%; background: var(--bg); }
body {
  min-height: 100dvh;
  margin: 0;
  padding: 0 0 env(safe-area-inset-bottom);
  overflow-x: hidden;
  color: var(--text);
  background:
    linear-gradient(rgba(122, 152, 182, 0.055) 1px, transparent 1px),
    linear-gradient(90deg, rgba(122, 152, 182, 0.055) 1px, transparent 1px),
    var(--bg);
  background-size: 32px 32px;
  font-family: "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-text-size-adjust: 100%;
}
button, input { font: inherit; }
button { -webkit-tap-highlight-color: transparent; }
.hidden { display: none !important; }
.sr-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0; }

.ambient { position: fixed; z-index: -1; border-radius: 50%; filter: blur(2px); pointer-events: none; }
.ambient-a { width: 420px; height: 420px; top: -220px; right: -90px; background: radial-gradient(circle, rgba(25, 128, 236, 0.16), transparent 70%); }
.ambient-b { width: 360px; height: 360px; bottom: -220px; left: -120px; background: radial-gradient(circle, rgba(98, 215, 170, 0.16), transparent 70%); }
.app { width: min(1180px, calc(100% - 32px)); margin: 0 auto; padding: 20px 0 56px; }

/* Header */
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; min-height: 56px; margin-bottom: 32px; }
.brand { display: inline-flex; align-items: center; gap: 12px; padding: 4px; border: 0; color: inherit; background: transparent; cursor: pointer; text-align: left; border-radius: 12px; }
.brand:focus-visible, .btn:focus-visible, .action-btn:focus-visible, .piece-choice:focus-visible, .roomlist li:focus-visible, summary:focus-visible { outline: 3px solid rgba(8, 105, 220, 0.34); outline-offset: 3px; }
.brand-logo { width: 42px; height: 42px; object-fit: contain; filter: drop-shadow(0 7px 10px rgba(8, 105, 220, 0.18)); }
.brandtext { display: grid; gap: 1px; }
.brandtext strong { font-size: 18px; letter-spacing: 0.08em; }
.brandtext small { font-size: 11px; color: var(--muted); letter-spacing: 0.12em; text-transform: uppercase; }
.conn { display: inline-flex; min-height: 40px; align-items: center; gap: 8px; padding: 8px 13px; border: 1px solid var(--line-soft); border-radius: 999px; background: rgba(255,255,255,.72); color: var(--muted); font-size: 13px; font-weight: 700; box-shadow: 0 3px 12px rgba(39,67,97,.06); }
.conn i { width: 9px; height: 9px; border-radius: 50%; background: #8a99aa; box-shadow: 0 0 0 4px rgba(138,153,170,.12); }
.conn[data-state="open"] i { background: #14845f; box-shadow: 0 0 0 4px rgba(20,132,95,.14); }
.conn[data-state="connecting"] i { background: #d97706; box-shadow: 0 0 0 4px rgba(217,119,6,.14); animation: softPulse 1.2s infinite; }
.conn[data-state="off"] i { background: #8a99aa; }

/* Lobby hero */
.hero { display: grid; grid-template-columns: minmax(0, 1.04fr) minmax(340px, .72fr); align-items: center; gap: clamp(32px, 7vw, 88px); padding: 24px 0 56px; }
.eyebrow, .step { margin: 0 0 8px; color: var(--blue-dark); font-size: 12px; font-weight: 800; letter-spacing: .16em; text-transform: uppercase; }
.hero h1 { max-width: 700px; margin: 0; font-size: clamp(40px, 6.6vw, 76px); line-height: 1.08; letter-spacing: -.055em; }
.hero h1 span { color: var(--blue); }
.lead { max-width: 560px; margin: 24px 0 0; color: var(--muted); font-size: 17px; line-height: 1.7; }
.feature-line { display: flex; flex-wrap: wrap; gap: 12px 24px; margin-top: 28px; color: var(--muted); font-size: 13px; }
.feature-line span { display: inline-flex; align-items: baseline; gap: 5px; }
.feature-line b { color: var(--text); font-size: 18px; }
.hero-board { position: relative; width: min(100%, 390px); justify-self: end; padding: 16px; border: 1px solid rgba(150,171,192,.75); border-radius: 26px; background: linear-gradient(145deg, rgba(255,255,255,.96), rgba(230,238,246,.9)); box-shadow: var(--shadow-raised), inset 0 1px 0 #fff; transform: rotate(2deg); }
.finish { display: flex; align-items: center; gap: 9px; color: #16815d; font-size: 9px; font-weight: 900; letter-spacing: .24em; }
.finish i { height: 1px; flex: 1; background: linear-gradient(90deg, transparent, rgba(22,129,93,.55), transparent); }
.demo-grid { position: relative; margin-top: 9px; aspect-ratio: 1; border: 8px solid #d2dce6; border-radius: 18px; overflow: hidden; background: linear-gradient(rgba(130,153,178,.25) 1px, transparent 1px), linear-gradient(90deg, rgba(130,153,178,.25) 1px, transparent 1px), linear-gradient(180deg, rgba(98,215,170,.27), rgba(255,255,255,.96) 16%); background-size: 11.111% 11.111%; box-shadow: inset 0 4px 12px rgba(20,35,59,.08); }
.hero-board > p { margin: 11px 0 0; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .2em; text-align: center; text-transform: uppercase; }
.demo-wall { position: absolute; height: 5px; width: 30%; border-radius: 999px; box-shadow: 0 2px 6px currentColor; }
.demo-wall.blue { color: rgba(8,105,220,.28); background: var(--blue); }
.demo-wall.red { color: rgba(217,45,79,.28); background: var(--red); }
.demo-wall.w1 { left: 9%; top: 58%; transform: rotate(90deg); }
.demo-wall.w2 { left: 47%; top: 47%; }
.demo-wall.w3 { right: 2%; top: 69%; transform: rotate(90deg); }
.demo-pawn { position: absolute !important; width: 7.5%; aspect-ratio: 1; }
.demo-pawn.p1 { left: 21%; bottom: 8%; --piece-main: #0b75e8; --piece-dark: #06499b; --piece-light: #b9e3ff; }
.demo-pawn.p2 { right: 21%; bottom: 8%; --piece-main: #df3456; --piece-dark: #9e1733; --piece-light: #ffd4dc; }

/* Surfaces and forms */
.lobby-grid { display: grid; grid-template-columns: 1.08fr .92fr; gap: 24px; align-items: start; }
.panel { padding: 24px; border: 1px solid rgba(169,184,200,.82); border-radius: var(--radius-m); background: var(--surface); box-shadow: var(--shadow-raised); backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px); }
.section-head, .rooms-heading { display: flex; align-items: flex-start; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.section-head.compact { margin-bottom: 18px; }
.section-head h2, .rooms-heading h2, .chat h2 { margin: 0; font-size: 23px; line-height: 1.3; letter-spacing: -.025em; }
.quick-tag { padding: 7px 10px; border-radius: 8px; background: var(--mint-soft); color: #126449; font-size: 12px; font-weight: 800; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: grid; gap: 7px; margin-bottom: 20px; color: var(--text); font-size: 13px; font-weight: 700; }
.field > span, .choice-field legend { color: #41536a; font-size: 13px; font-weight: 800; }
input { width: 100%; min-width: 0; min-height: 48px; padding: 11px 13px; border: 1px solid #879aaf; border-radius: var(--radius-s); outline: none; background: rgba(255,255,255,.94); color: var(--text); font-size: 15px; transition: border-color .15s, box-shadow .15s, background .15s; }
input::placeholder { color: #6f8095; }
input:hover { border-color: #5d748d; }
input:focus { border-color: var(--blue); box-shadow: 0 0 0 4px rgba(8,105,220,.13); background: #fff; }
#codeInput { max-width: 230px; text-transform: uppercase; letter-spacing: .22em; font-size: 18px; font-weight: 800; }
.choice-field { min-width: 0; margin: 0 0 22px; padding: 0; border: 0; }
.choice-field legend { margin-bottom: 9px; }
.piece-picker { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; }
.piece-choice { position: relative; display: flex; min-width: 0; min-height: 64px; align-items: center; justify-content: center; gap: 9px; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.74); color: var(--muted); cursor: pointer; transition: transform .12s, border-color .12s, background .12s, box-shadow .12s; }
.piece-choice:hover { transform: translateY(-1px); border-color: var(--blue); }
.piece-choice.active { border: 2px solid var(--blue); background: var(--blue-soft); color: var(--blue-dark); box-shadow: 0 5px 14px rgba(8,105,220,.12); }
.piece-choice b { overflow: hidden; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }
.piece-token { --piece-main: #0b75e8; --piece-dark: #06499b; --piece-light: #b9e3ff; position: relative; display: block; flex: none; width: 28px; aspect-ratio: 1; filter: drop-shadow(0 4px 4px rgba(20,35,59,.2)); }
.piece-token.pulse, .pawn[data-piece="pulse"], .dot[data-piece="pulse"] { border-radius: 50%; background: radial-gradient(circle at 34% 26%, var(--piece-light) 0 9%, var(--piece-main) 28% 62%, var(--piece-dark) 100%); }
.piece-token.nova, .pawn[data-piece="nova"], .dot[data-piece="nova"] { border-radius: 28% 55% 30% 55%; background: linear-gradient(135deg, var(--piece-light), var(--piece-main) 42%, var(--piece-dark)); transform: rotate(45deg); }
.piece-token.prism, .pawn[data-piece="prism"], .dot[data-piece="prism"] { border-radius: 25%; clip-path: polygon(50% 0, 96% 25%, 88% 80%, 50% 100%, 12% 80%, 4% 25%); background: linear-gradient(145deg, var(--piece-light), var(--piece-main) 48%, var(--piece-dark)); }
.piece-token.orbit, .pawn[data-piece="orbit"], .dot[data-piece="orbit"] { border: 5px solid var(--piece-main); border-radius: 50%; background: radial-gradient(circle, var(--piece-light) 0 24%, var(--piece-dark) 27% 39%, transparent 42%); box-shadow: inset 0 0 0 2px var(--piece-light); }
.option-cards { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; }
.option-cards label { position: relative; cursor: pointer; }
.option-cards input { position: absolute; width: 1px; height: 1px; opacity: 0; }
.option-cards span { display: grid; min-height: 62px; place-content: center; padding: 8px; border: 1px solid var(--line); border-radius: 12px; background: rgba(255,255,255,.72); text-align: center; transition: border-color .12s, background .12s, box-shadow .12s; }
.option-cards b { font-size: 18px; }
.option-cards small { margin-top: 1px; color: var(--muted); font-size: 11px; }
.option-cards input:checked + span { border: 2px solid var(--blue); background: var(--blue-soft); color: var(--blue-dark); box-shadow: 0 5px 14px rgba(8,105,220,.1); }
.option-cards input:focus-visible + span { outline: 3px solid rgba(8,105,220,.3); outline-offset: 3px; }
.inline-field { display: flex; gap: 10px; }
.btn { display: inline-flex; min-height: 48px; align-items: center; justify-content: center; padding: 11px 17px; border: 1px solid #7890aa; border-radius: var(--radius-s); background: #fff; color: var(--blue-dark); font-size: 14px; font-weight: 800; cursor: pointer; transition: transform .1s, border-color .14s, background .14s, box-shadow .14s; white-space: nowrap; }
.btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--blue); background: var(--blue-soft); }
.btn:active:not(:disabled) { transform: translateY(1px); box-shadow: none; }
.btn:disabled { opacity: .46; cursor: not-allowed; }
.btn.primary { border-color: var(--blue-dark); background: linear-gradient(180deg, #167deb, var(--blue)); color: #fff; box-shadow: 0 8px 18px rgba(8,105,220,.24), inset 0 1px 0 rgba(255,255,255,.32); }
.btn.primary:hover:not(:disabled) { background: linear-gradient(180deg, #0d70df, #055cbd); box-shadow: 0 10px 22px rgba(8,105,220,.28); }
.btn.secondary { background: rgba(255,255,255,.78); }
.btn.quiet { border-color: var(--line-soft); background: var(--surface-soft); color: #41536a; }
.btn.danger { border-color: #d29a95; background: #fff; color: var(--danger); }
.btn.danger:hover:not(:disabled) { border-color: var(--danger); background: #fff0ef; }
.btn.wide { width: 100%; }
.btn.small { min-height: 48px; padding: 9px 14px; font-size: 13px; }
.form-message { min-height: 20px; margin: 9px 0 0; color: var(--danger); font-size: 13px; font-weight: 700; }
.divider { display: flex; align-items: center; gap: 12px; margin: 22px 0; color: var(--muted); font-size: 12px; }
.divider::before, .divider::after { content: ""; flex: 1; height: 1px; background: var(--line-soft); }
.adv { margin-top: 24px; border-top: 1px solid var(--line-soft); padding-top: 16px; }
.adv summary, .profile-panel summary { min-height: 48px; display: flex; align-items: center; color: #41536a; font-size: 13px; font-weight: 800; cursor: pointer; }
.adv .field { margin: 10px 0 0; }
.rooms-section { margin-top: 48px; padding-top: 32px; border-top: 1px solid var(--line-soft); }
.rooms-heading { align-items: center; margin-bottom: 6px; }
.hint { margin: 0; color: var(--muted); font-size: 13px; line-height: 1.6; }

/* Room list */
.roomlist { display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin: 18px 0 0; padding: 0; list-style: none; }
.roomlist li { display: grid; min-height: 92px; grid-template-columns: 1fr auto; align-items: center; gap: 8px 14px; padding: 16px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.76); cursor: pointer; transition: transform .12s, border-color .12s, box-shadow .12s; }
.roomlist li:hover { transform: translateY(-2px); border-color: var(--blue); box-shadow: 0 10px 24px rgba(39,67,97,.1); }
.roomlist .room-title { overflow: hidden; font-size: 15px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.roomlist .rcode { justify-self: end; color: var(--blue-dark); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; font-size: 14px; font-weight: 900; letter-spacing: .14em; }
.roomlist .rmeta { grid-column: 1 / -1; color: var(--muted); font-size: 12px; }
.roomlist .empty { grid-column: 1 / -1; display: flex; justify-content: center; min-height: 86px; color: var(--muted); cursor: default; }
.roomlist .empty:hover { transform: none; border-color: var(--line); box-shadow: none; }

/* Game room */
.room-titlebar { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 16px; margin-bottom: 24px; }
.room-titlebar > div { text-align: center; }
.room-titlebar p { margin: 0 0 3px; color: var(--muted); font-size: 13px; font-weight: 700; }
.room-titlebar h1 { margin: 0; font-size: 22px; }
.room-titlebar #btnBack { justify-self: start; }
.room-titlebar #btnCopy { justify-self: end; }
.code { color: var(--blue-dark); font-family: ui-monospace, "SFMono-Regular", Consolas, monospace; letter-spacing: .16em; }
.roomgrid { display: grid; grid-template-columns: minmax(0, 1fr) 320px; gap: 24px; align-items: start; }
.game-column { min-width: 0; }
.turn-banner { display: flex; width: min(100%, 620px); min-height: 68px; align-items: center; gap: 14px; margin: 0 auto 12px; padding: 10px 16px; border: 1px solid var(--line); border-radius: 16px; background: rgba(255,255,255,.78); color: var(--text); box-shadow: 0 8px 20px rgba(39,67,97,.08); transition: border-color .2s, background .2s, transform .2s, box-shadow .2s; }
.turn-symbol { display: grid; width: 42px; height: 42px; place-items: center; flex: none; border-radius: 12px; background: var(--surface-soft); color: var(--muted); font-size: 23px; font-weight: 900; }
.turn-copy { display: grid; gap: 2px; }
.turn-copy b { font-size: 17px; }
.turn-copy small { color: var(--muted); font-size: 12px; line-height: 1.4; }
.turn-banner[data-kind="mine"] { border: 2px solid var(--blue); background: linear-gradient(90deg, var(--blue-soft), rgba(255,255,255,.96)); box-shadow: 0 10px 28px rgba(8,105,220,.18); animation: turnNudge .5s ease-out; }
.turn-banner[data-kind="mine"] .turn-symbol { background: var(--blue); color: #fff; box-shadow: 0 6px 14px rgba(8,105,220,.28); }
.turn-banner[data-kind="win"] { border-color: #3a9f7a; background: var(--mint-soft); }
.turn-banner[data-kind="win"] .turn-symbol { background: #14845f; color: #fff; }
.turn-banner[data-kind="warn"] { border-color: #d7a36c; background: #fff8ed; }
.playersrow { display: grid; width: min(100%, 620px); grid-template-columns: 1fr 1fr; gap: 10px; margin: 0 auto 12px; }
.pcard { display: flex; min-width: 0; min-height: 56px; align-items: center; gap: 10px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.75); transition: border-color .18s, background .18s, box-shadow .18s; }
.pcard.active { border: 2px solid currentColor; background: #fff; box-shadow: 0 6px 18px rgba(39,67,97,.12); }
.pcard.p1 { color: var(--blue); }
.pcard.p2 { color: var(--red); }
.pcard .dot { --piece-main: currentColor; --piece-dark: color-mix(in srgb, currentColor 70%, #102542); --piece-light: color-mix(in srgb, currentColor 24%, #fff); width: 24px; height: 24px; flex: none; }
.pcard .pname { min-width: 0; overflow: hidden; color: var(--text); font-size: 13px; font-weight: 800; text-overflow: ellipsis; white-space: nowrap; }
.pcard .tag { padding: 3px 6px; border-radius: 6px; background: var(--surface-soft); color: #41536a; font-size: 10px; font-weight: 800; }
.pcard .tag.me { background: var(--blue-soft); color: var(--blue-dark); }
.pcard .tag.off { background: #eef0f3; color: #5f6873; }
.pcard .walls { display: inline-flex; align-items: center; gap: 4px; margin-left: auto; color: var(--muted); font-size: 12px; font-variant-numeric: tabular-nums; }
.pcard .wico { width: 15px; height: 5px; border-radius: 2px; background: #72869b; }
.pcard .release { min-height: 40px; padding: 6px 9px; }
.board-shell { width: min(100%, 620px); margin: 0 auto; padding: 9px 10px 10px; border: 1px solid #a3b2c2; border-radius: 24px; background: linear-gradient(145deg, #f8fbfe, #dce6ef); box-shadow: var(--shadow-raised), inset 0 1px 0 #fff; transition: box-shadow .2s, border-color .2s; }
.game-column.is-my-turn .board-shell { border-color: rgba(8,105,220,.68); box-shadow: 0 0 0 4px rgba(8,105,220,.1), 0 18px 40px rgba(39,67,97,.16), inset 0 1px 0 #fff; }
.board-finish { height: 22px; padding: 0 5px; }
.board { --turn-color: var(--blue); position: relative; display: grid; width: 100%; aspect-ratio: 1; border: 1px solid #9cabbc; border-radius: 16px; overflow: hidden; background: #d6e0ea; touch-action: manipulation; user-select: none; -webkit-tap-highlight-color: transparent; box-shadow: inset 0 5px 16px rgba(20,35,59,.1); }
.board.turn-p2 { --turn-color: var(--red); }
.cell { grid-area: var(--area); position: relative; z-index: 1; border: 1px solid rgba(132,151,173,.45); background: linear-gradient(145deg, #fbfdff, #edf2f7); }
.cell.dark { background: linear-gradient(145deg, #f6f9fc, #e9eff5); }
.cell.goal { background: linear-gradient(180deg, #baf1dc, #ecfaf5); }
.cell.last { box-shadow: inset 0 0 0 3px rgba(20,35,59,.3); }
.board[data-mode="move"] .cell.legal { cursor: pointer; }
.board[data-mode="move"] .cell.legal::after { content: ""; position: absolute; inset: 31%; border: 2px solid #fff; border-radius: 50%; background: var(--turn-color); box-shadow: 0 0 0 3px color-mix(in srgb, var(--turn-color) 24%, transparent), 0 3px 9px color-mix(in srgb, var(--turn-color) 28%, transparent); animation: legalBreathe 1.35s ease-in-out infinite; }
.board[data-mode="move"] .cell.legal:hover { z-index: 2; filter: brightness(.97); box-shadow: inset 0 0 0 3px color-mix(in srgb, var(--turn-color) 56%, transparent); }
.slot { grid-area: var(--area); z-index: 3; border-radius: 4px; pointer-events: none; background: transparent; transition: background .12s, box-shadow .12s, opacity .12s; }
.board[data-mode="wall"] .slot { pointer-events: auto; cursor: pointer; }
.slot.h { align-self: center; height: 210%; }
.slot.v { justify-self: center; width: 210%; }
.board[data-mode="wall"] .cell { pointer-events: none; }
.board[data-mode="wall"][data-orient="h"] .slot.v, .board[data-mode="wall"][data-orient="v"] .slot.h { pointer-events: none; }
.board[data-mode="wall"] .slot:hover, .board[data-mode="wall"] .slot.preview { z-index: 5; background: color-mix(in srgb, var(--turn-color) 78%, #fff); box-shadow: 0 0 0 2px #fff, 0 3px 12px color-mix(in srgb, var(--turn-color) 34%, transparent); }
.board[data-mode="wall"] .slot.bad:hover, .board[data-mode="wall"] .slot.bad.preview { background: repeating-linear-gradient(45deg, #c52436 0 6px, #f8a6af 6px 11px); box-shadow: 0 0 0 2px #fff, 0 3px 12px rgba(197,36,54,.3); }
.wall { grid-area: var(--area); z-index: 4; align-self: center; height: 165%; border: 1px solid #526b84; border-radius: 4px; background: linear-gradient(180deg, #a9bacb, #6d8196); box-shadow: 0 2px 5px rgba(20,35,59,.35), inset 0 1px 0 rgba(255,255,255,.65); pointer-events: none; }
.wall.v { width: 165%; height: auto; justify-self: center; align-self: stretch; background: linear-gradient(90deg, #a9bacb, #6d8196); }
.wall.last { border-color: var(--turn-color); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--turn-color), 0 3px 8px rgba(20,35,59,.28); }
.pawn { --piece-main: var(--blue); --piece-dark: #06499b; --piece-light: #b9e3ff; grid-area: var(--area); z-index: 6; margin: 13%; border: 2px solid rgba(255,255,255,.86); pointer-events: none; box-shadow: 0 5px 9px rgba(20,35,59,.34), inset 0 2px 3px rgba(255,255,255,.35); transition: grid-area .2s ease, transform .2s ease; }
.pawn.p2 { --piece-main: var(--red); --piece-dark: #98152f; --piece-light: #ffd2da; }
.pawn.turn { animation: pawnTurn 1.2s ease-in-out infinite; }
.action-dock { display: grid; width: min(100%, 620px); grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 14px auto 0; }
.action-btn { display: grid; min-height: 70px; grid-template-columns: 30px 1fr; grid-template-rows: auto auto; align-items: center; gap: 0 8px; padding: 9px 12px; border: 1px solid var(--line); border-radius: 14px; background: rgba(255,255,255,.78); color: var(--text); text-align: left; cursor: pointer; transition: transform .1s, border-color .12s, background .12s, box-shadow .12s; }
.action-btn:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--blue); }
.action-btn.active { border: 2px solid var(--blue); background: var(--blue-soft); box-shadow: 0 6px 16px rgba(8,105,220,.13); }
.action-btn:disabled { opacity: .48; cursor: not-allowed; }
.action-btn b { align-self: end; font-size: 13px; }
.action-btn small { align-self: start; color: var(--muted); font-size: 10px; }
.action-icon { grid-row: 1 / 3; display: block; justify-self: center; }
.pawn-icon { width: 22px; height: 22px; border: 2px solid #fff; border-radius: 50%; background: radial-gradient(circle at 35% 28%, #bde3ff 0 8%, var(--blue) 32% 65%, var(--blue-dark)); box-shadow: 0 3px 6px rgba(8,105,220,.28); }
.wall-icon { width: 28px; height: 7px; border-radius: 3px; background: linear-gradient(180deg, #aab9c9, #5e748a); box-shadow: 0 2px 4px rgba(20,35,59,.24); }
.wall-icon.vertical { transform: rotate(90deg); }
.operation-hint { min-height: 20px; margin: 9px 0 0; color: var(--muted); font-size: 12px; text-align: center; }
.side { display: grid; gap: 14px; }
.side .panel { padding: 18px; }
.info-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 14px; color: var(--muted); font-size: 12px; }
.info-row strong { color: var(--text); text-align: right; }
.room-actions { display: grid; grid-template-columns: 1fr 1fr; gap: 9px; }
.profile-panel { padding-top: 5px !important; }
.profile-panel summary { font-size: 15px; }
.profile-panel[open] summary { margin-bottom: 10px; }
.profile-panel .field { margin-bottom: 12px; }
.compact-picker { gap: 7px; margin-bottom: 12px; }
.compact-picker .piece-choice { min-height: 50px; padding: 6px; }
.compact-picker .piece-choice b { display: none; }
.chat .section-head { margin-bottom: 12px; }
.chatlog { display: flex; min-height: 148px; max-height: 220px; flex-direction: column; gap: 6px; overflow-y: auto; padding: 12px; border: 1px solid #879aaf; border-radius: 12px; background: rgba(246,249,252,.9); font-size: 13px; line-height: 1.55; }
.chatlog:empty::before { content: "消息会显示在这里"; margin: auto; color: var(--muted); }
.chatlog .c-name { margin-right: 5px; color: var(--blue-dark); font-weight: 800; }
.chatlog .c-sys { color: var(--muted); font-size: 12px; }
.chatform { display: flex; gap: 8px; margin-top: 10px; }
.chatform .btn { padding-inline: 14px; }

/* Feedback */
.toast { position: fixed; left: 50%; bottom: max(24px, env(safe-area-inset-bottom)); z-index: 99; max-width: min(88vw, 520px); padding: 12px 17px; border: 1px solid #29445f; border-radius: 12px; background: rgba(20,35,59,.94); color: #fff; box-shadow: var(--shadow-overlay); font-size: 13px; font-weight: 700; text-align: center; opacity: 0; pointer-events: none; transform: translate(-50%, 18px); transition: opacity .18s, transform .18s; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }

@keyframes softPulse { 50% { opacity: .36; } }
@keyframes legalBreathe { 50% { transform: scale(.78); opacity: .78; } }
@keyframes pawnTurn { 50% { transform: translateY(-5px) scale(1.06); filter: drop-shadow(0 7px 7px color-mix(in srgb, var(--piece-main) 30%, transparent)); } }
@keyframes turnNudge { 0% { transform: translateY(-4px); opacity: .7; } 100% { transform: translateY(0); opacity: 1; } }

@media (max-width: 900px) {
  .hero { grid-template-columns: 1fr minmax(280px, .65fr); gap: 28px; }
  .lobby-grid, .roomgrid { grid-template-columns: 1fr; }
  .roomgrid { gap: 20px; }
  .side { width: min(100%, 620px); margin: 0 auto; grid-template-columns: 1fr 1fr; }
  .side .chat { grid-column: 1 / -1; }
  .roomlist { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 660px) {
  .app { width: min(100% - 24px, 620px); padding-top: 12px; }
  .topbar { margin-bottom: 18px; }
  .brandtext small { display: none; }
  .hero { grid-template-columns: 1fr; padding: 14px 0 36px; }
  .hero h1 { font-size: clamp(38px, 12vw, 56px); }
  .lead { margin-top: 18px; font-size: 15px; }
  .hero-board { display: none; }
  .lobby-grid { gap: 14px; }
  .panel { padding: 19px; }
  .form-grid { grid-template-columns: 1fr; gap: 0; }
  .piece-choice { min-height: 58px; flex-direction: column; gap: 3px; }
  .piece-choice b { font-size: 10px; }
  .option-cards span { min-height: 66px; }
  .inline-field { flex-direction: column; }
  #codeInput { max-width: none; }
  .rooms-section { margin-top: 36px; }
  .roomlist { grid-template-columns: 1fr; }
  .room-titlebar { grid-template-columns: 1fr 1fr; }
  .room-titlebar > div { grid-column: 1 / -1; grid-row: 1; }
  .room-titlebar #btnBack { grid-row: 2; width: 100%; }
  .room-titlebar #btnCopy { grid-row: 2; width: 100%; }
  .playersrow { gap: 7px; }
  .pcard { min-height: 52px; padding: 7px 8px; gap: 6px; }
  .pcard .dot { width: 20px; height: 20px; }
  .pcard .tag { display: none; }
  .pcard .walls { gap: 2px; }
  .board-shell { border-radius: 18px; padding: 7px; }
  .board { border-radius: 12px; }
  .action-dock { gap: 7px; }
  .action-btn { min-height: 64px; grid-template-columns: 1fr; grid-template-rows: 28px auto; gap: 2px; padding: 7px 5px; text-align: center; }
  .action-btn .action-icon { grid-row: 1; }
  .action-btn b { font-size: 12px; }
  .action-btn small { display: none; }
  .side { grid-template-columns: 1fr; }
  .side .chat { grid-column: auto; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

@media (prefers-reduced-transparency: reduce) {
  .panel, .conn, .turn-banner { background: var(--surface-solid); backdrop-filter: none; -webkit-backdrop-filter: none; }
}
