:root {
  --bg: #161d14; --panel: #222c1f; --panel2: #2c3829; --line: #3b4a37; --text: #eef1e8; --muted: #9fae98;
  --accent: #d8b64a; --mine: #2e6fbf; --mine2: #4b8ee0; --opp: #b8392b; --opp2: #de5a4a; --good: #6fcf7a; --bad: #ef7b6c;
  --grass: #5a7a45; --grass2: #66884f; --lake: #2b5f8c;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; background: var(--bg); color: var(--text); font: 16px/1.4 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif; }
body { min-height: 100dvh; padding: var(--site-bar, 0px) max(8px, env(safe-area-inset-right)) env(safe-area-inset-bottom) max(8px, env(safe-area-inset-left)); }
.hidden { display: none !important; }
button, input { font: inherit; color: inherit; }
.top { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 8px 2px; max-width: 640px; margin: 0 auto; }
.top h1 { margin: 0; font-size: 1.25rem; letter-spacing: .02em; color: var(--accent); }
.top-right { display: flex; align-items: center; gap: 6px; }
.langs { display: inline-flex; }
.chip { background: var(--panel); border: 1px solid var(--line); border-radius: 999px; padding: 5px 11px; font-size: .85rem; cursor: pointer; }
.langs .chip:first-child { border-radius: 999px 0 0 999px; }
.langs .chip:last-child { border-radius: 0 999px 999px 0; border-left: 0; }
.chip.active { background: var(--accent); color: #1a1a10; border-color: var(--accent); font-weight: 700; }
.conn { max-width: 640px; margin: 0 auto 6px; background: #5b3b12; border: 1px solid #a2701f; border-radius: 8px; padding: 6px 10px; font-size: .9rem; }
main { max-width: 640px; margin: 0 auto; padding-bottom: 24px; }

.tagline { color: var(--muted); margin: 4px 2px 10px; }
.card { background: var(--panel); border: 1px solid var(--line); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; }
.card h2 { margin: 0 0 2px; font-size: 1.05rem; }
.hint { color: var(--muted); font-size: .88rem; margin: 2px 0 8px; }
label { display: block; font-size: .88rem; color: var(--muted); margin-bottom: 4px; }
.check { display: flex; align-items: center; gap: 8px; margin: 4px 0 10px; color: var(--text); }
input[type=text], input[type=password], input[type=email] { width: 100%; background: #12180f; border: 1px solid var(--line); border-radius: 10px; padding: 10px 12px; }
input:focus-visible, button:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.row { display: flex; gap: 8px; }
.row > * { flex: 1; }
.row.join { margin-top: 10px; }
.row.join input { text-transform: uppercase; letter-spacing: .2em; text-align: center; font-weight: 700; }
.btn { background: var(--accent); color: #1c1a0c; border: 0; border-radius: 12px; padding: 12px 14px; font-weight: 700; cursor: pointer; min-height: 46px; }
.btn.ghost { background: var(--panel2); color: var(--text); border: 1px solid var(--line); font-weight: 600; }
.btn.wide { width: 100%; }
.btn:disabled { opacity: .45; cursor: default; }
.btn.danger { background: #7a2a22; color: #fff; }
.rooms { list-style: none; margin: 6px 0 0; padding: 0; display: grid; gap: 8px; }
.rooms .empty { color: var(--muted); font-size: .9rem; }
.rooms button { width: 100%; text-align: left; }

.status { font-weight: 700; font-size: 1.05rem; text-align: center; margin: 2px 0 6px; min-height: 1.5em; }
.status.win { color: var(--good); } .status.lose { color: var(--bad); }
.status .sub { display: block; font-weight: 400; font-size: .88rem; color: var(--muted); }
.bar { display: flex; justify-content: space-between; align-items: center; font-size: .9rem; color: var(--muted); padding: 2px 4px; gap: 8px; }
.bar b { color: var(--text); }
.bar .dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; margin-right: 6px; }
.bar .dot.mine { background: var(--mine2); } .bar .dot.opp { background: var(--opp2); }
.bar.turn b { color: var(--accent); }

#board-wrap { display: flex; justify-content: center; }
#board {
  --b: max(300px, min(100vw - 16px, 100dvh - 360px, 600px));
  width: var(--b); height: var(--b); display: grid; grid-template: repeat(10, 1fr) / repeat(10, 1fr); gap: 1px;
  background: #0d130b; border: 2px solid #0d130b; border-radius: 8px; overflow: hidden; touch-action: manipulation; user-select: none;
}
.cell { border: 0; border-radius: 0; position: relative; background: var(--grass); display: flex; align-items: center; justify-content: center; padding: 0; }
.cell:nth-child(2n) { background: var(--grass2); }
.cell.lake { background: var(--lake); background-image: repeating-linear-gradient(135deg, rgba(255,255,255,.08) 0 3px, transparent 3px 8px); }
.cell.zone { box-shadow: inset 0 0 0 2px rgba(75,142,224,.45); }
.cell.last::before { content: ""; position: absolute; inset: 0; box-shadow: inset 0 0 0 2px var(--accent); pointer-events: none; z-index: 2; }
.cell.sel { box-shadow: inset 0 0 0 3px #fff; z-index: 1; }
.cell.tgt::after { content: ""; position: absolute; width: 28%; height: 28%; border-radius: 50%; background: rgba(255,255,255,.7); pointer-events: none; z-index: 3; }
.cell.tgt.atk::after { width: 86%; height: 86%; background: transparent; border: 3px solid #ffd54a; border-radius: 8px; }
.cell.flash .pc { animation: flash .9s ease-out; }
@keyframes flash { 0% { transform: scale(1.25); filter: brightness(1.7); } 100% { transform: scale(1); filter: none; } }

.pc { width: 90%; height: 90%; border-radius: 22%; display: flex; align-items: center; justify-content: center; font-weight: 800;
  font-size: calc(var(--b) / 10 * .46); line-height: 1; color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); position: relative;
  box-shadow: 0 1px 2px rgba(0,0,0,.5), inset 0 0 0 1px rgba(255,255,255,.25); }
.pc.mine { background: linear-gradient(160deg, var(--mine2), var(--mine)); }
.pc.opp { background: linear-gradient(160deg, var(--opp2), var(--opp)); }
.pc.hid::before { content: "★"; font-size: .8em; opacity: .55; }
.pc.moved.opp::after { content: ""; position: absolute; right: 9%; top: 9%; width: 20%; height: 20%; border-radius: 50%; background: #ffe58a; }
.pc.emoji { font-size: calc(var(--b) / 10 * .5); }

.msg { min-height: 2.6em; text-align: center; font-size: .92rem; color: var(--muted); margin: 6px 4px 2px; }
.tray { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; margin: 6px 0; --b: 330px; }
.tray button { background: var(--panel); border: 2px solid var(--line); border-radius: 12px; padding: 4px 2px 3px; display: flex; flex-direction: column; align-items: center; gap: 1px; cursor: pointer; min-height: 62px; }
.tray button .pc { width: 38px; height: 38px; font-size: 1.15rem; }
.tray button small { font-size: .68rem; color: var(--muted); line-height: 1.1; text-align: center; }
.tray button.on { border-color: var(--accent); background: var(--panel2); }
.tray button:disabled { opacity: .3; cursor: default; }
.lost { display: grid; gap: 4px; margin: 6px 0; font-size: .82rem; color: var(--muted); }
.lost .l { display: flex; flex-wrap: wrap; align-items: center; gap: 3px; }
.lost .pc { width: 24px; height: 24px; font-size: .78rem; --b: 240px; }
.lost .pc.mine { opacity: .9; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 8px; }
.actions .btn { flex: 1 1 120px; }

.overlay { position: fixed; inset: 0; background: rgba(0,0,0,.65); z-index: 2147483001; display: flex; align-items: flex-end; justify-content: center; overflow-y: auto; padding: 12px; }
.sheet { background: var(--panel); border: 1px solid var(--line); border-radius: 16px; padding: 16px; width: 100%; max-width: 480px; margin: auto; display: grid; gap: 10px; }
.sheet h2 { margin: 0; }
.sheet p { margin: 0; }
.error { color: var(--bad); min-height: 1.2em; font-size: .9rem; }
.sheet .hint { margin: 0; }
.rules table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.rules td, .rules th { padding: 4px 6px; border-bottom: 1px solid var(--line); text-align: left; }
.rules .pc { width: 28px; height: 28px; font-size: .9rem; --b: 280px; }
.rules p { font-size: .92rem; }
@media (min-width: 700px) { .overlay { align-items: center; } }
@media (prefers-reduced-motion: reduce) { .cell.flash .pc { animation: none; } }
.msg:empty { display: none; }
.tray { gap: 5px; margin: 8px 0 4px; }
.tray button { min-height: 54px; padding: 3px 1px 2px; }
.tray button .pc { width: 32px; height: 32px; font-size: 1rem; }
.actions .btn { min-height: 42px; padding: 8px 12px; }
