:root {
  --bg: #302e2b; --panel: #262421; --panel2: #1f1e1b; --text: #fff; --muted: #b0aea9;
  --green: #81b64c; --green-d: #45753c; --light: #ebecd0; --dark: #739552;
  --hl-light: #f5f682; --hl-dark: #b9ca43;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--bg); color: var(--text); font: 15px/1.4 "Segoe UI", system-ui, -apple-system, sans-serif; display: flex; min-height: 100vh; }
a { color: inherit; text-decoration: none; }
h1 { margin: 0 0 4px; font-size: 26px; }
h2 { margin: 0 0 12px; font-size: 17px; }
.muted { color: var(--muted); }
[hidden] { display: none !important; }

.side { width: 150px; background: var(--panel2); display: flex; flex-direction: column; padding: 10px 0; flex-shrink: 0; }
.logo { font-size: 24px; font-weight: 800; padding: 6px 16px 18px; color: var(--green); }
.logo span { color: #fff; }
.nav-item { padding: 10px 16px; font-weight: 600; }
.nav-item:hover { background: #ffffff10; }
main { flex: 1; padding: 24px; min-width: 0; }

.btn { background: var(--green); color: #fff; border: 0; border-radius: 8px; padding: 10px 18px; font-weight: 800; font-size: 15px; cursor: pointer; box-shadow: 0 4px 0 var(--green-d); display: inline-block; text-align: center; }
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--green-d); }
.btn.big { font-size: 20px; padding: 14px 28px; width: 100%; margin-top: 10px; }
.btn.small { padding: 7px 12px; font-size: 13px; }
.btn.ghost { background: #3c3a37; box-shadow: 0 4px 0 #22211f; }
.btn:disabled { opacity: .5; cursor: default; }

input, select, textarea { background: #3c3a37; color: #fff; border: 1px solid #4b4847; border-radius: 6px; padding: 9px 10px; font: inherit; }
textarea { width: 100%; resize: vertical; margin: 10px 0 6px; font-family: ui-monospace, monospace; font-size: 12px; }
label { display: block; margin: 12px 0; font-weight: 600; }
label input:not([type=file]), label select { display: block; width: 100%; margin-top: 6px; }
input[type=range] { accent-color: var(--green); padding: 0; }
.row { display: flex; gap: 8px; flex-wrap: wrap; }
.row input { flex: 1; min-width: 140px; }
.card { background: var(--panel); border-radius: 10px; padding: 20px; margin: 18px 0; max-width: 640px; }
.or { text-align: center; color: var(--muted); margin: 16px 0 10px; font-size: 13px; }
.drop { border: 2px dashed #555; border-radius: 10px; padding: 22px; text-align: center; cursor: pointer; font-weight: 400; margin: 0; }
.drop.over { border-color: var(--green); background: #81b64c18; }
.pfp-row { display: flex; align-items: center; gap: 14px; }
.progress { height: 8px; background: #3c3a37; border-radius: 4px; margin-top: 14px; overflow: hidden; }
.progress div { height: 100%; width: 0; background: var(--green); transition: width .15s; }

.avatar { width: 40px; height: 40px; border-radius: 4px; object-fit: cover; background: #555; flex-shrink: 0; }
.avatar.big { width: 88px; height: 88px; border-radius: 8px; }

.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 16px; margin-top: 20px; }
.bot-card { background: var(--panel); border-radius: 10px; padding: 18px; text-align: center; cursor: pointer; transition: transform .1s; }
.bot-card:hover { transform: translateY(-3px); background: #2d2b28; }
.bot-card .avatar { width: 110px; height: 110px; border-radius: 10px; margin-bottom: 10px; }
.bot-card .name { font-weight: 800; font-size: 17px; }
.bot-card.new { display: flex; flex-direction: column; justify-content: center; align-items: center; border: 2px dashed #4b4847; background: transparent; min-height: 200px; font-weight: 700; color: var(--muted); }
.bot-card.new span { font-size: 48px; color: var(--green); }

/* PLAY */
.play-wrap { display: flex; gap: 20px; justify-content: center; align-items: flex-start; }
.board-col { --size: min(calc(100vh - 140px), calc(100vw - 600px)); width: max(var(--size), 320px); }
.player-bar { display: flex; align-items: center; gap: 10px; padding: 8px 0; font-weight: 700; min-height: 56px; }
.player-bar .sub { color: var(--muted); font-weight: 400; font-size: 13px; }
.player-bar .captured { font-size: 18px; letter-spacing: -4px; color: #ccc; opacity: .85; }
.board { position: relative; display: grid; grid-template-columns: repeat(8, 1fr); aspect-ratio: 1; border-radius: 4px; overflow: hidden; user-select: none; touch-action: none; }
.sq { position: relative; aspect-ratio: 1; }
.sq.l { background: var(--light); } .sq.d { background: var(--dark); }
.sq.l.hl { background: var(--hl-light); } .sq.d.hl { background: var(--hl-dark); }
.sq.check { background: radial-gradient(circle, #ff0000 0%, #e7000080 40%, transparent 75%), var(--dark); }
.sq.l.check { background: radial-gradient(circle, #ff0000 0%, #e7000080 40%, transparent 75%), var(--light); }
.sq img { position: absolute; inset: 0; width: 100%; height: 100%; cursor: grab; z-index: 2; }
.sq img.dragging { opacity: .35; }
.sq .coord { position: absolute; font-size: calc(var(--size) / 48); font-weight: 700; z-index: 1; }
.sq .rank { top: 2px; left: 4px; } .sq .file { bottom: 1px; right: 4px; }
.sq.l .coord { color: var(--dark); } .sq.d .coord { color: var(--light); }
.sq .dot { position: absolute; inset: 34%; border-radius: 50%; background: #0000002a; z-index: 3; pointer-events: none; }
.sq .ring { position: absolute; inset: 0; border-radius: 50%; border: calc(var(--size) / 110) solid #0000002a; z-index: 3; pointer-events: none; }
.ghost-piece { position: fixed; pointer-events: none; z-index: 100; transform: translate(-50%, -50%); }

.panel { width: 360px; background: var(--panel); border-radius: 8px; display: flex; flex-direction: column; height: calc(var(--size, 600px) + 112px); max-height: calc(100vh - 48px); min-height: 420px; }
.panel-head { padding: 16px; display: flex; gap: 12px; align-items: center; border-bottom: 1px solid #3c3a37; }
.panel-head .avatar { width: 56px; height: 56px; }
.bubble { background: #fff; color: #222; padding: 8px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; position: relative; }
.status { padding: 10px 16px; font-size: 13px; color: var(--muted); min-height: 38px; border-bottom: 1px solid #3c3a37; }
.status b { color: var(--green); }
.moves { flex: 1; overflow-y: auto; font-size: 14px; }
.moves .mrow { display: grid; grid-template-columns: 44px 1fr 1fr; padding: 3px 12px; }
.moves .mrow:nth-child(odd) { background: #2a2926; }
.moves .num { color: var(--muted); }
.moves .mv { font-weight: 700; padding: 1px 6px; border-radius: 3px; }
.moves .mv.cur { background: #ffffff22; }
.moves .mv.book::after { content: " 📖"; font-size: 10px; }
.controls { display: flex; gap: 6px; padding: 12px; border-top: 1px solid #3c3a37; flex-wrap: wrap; }
.controls .btn { flex: 1; }

.modal { position: fixed; inset: 0; background: #000a; display: flex; align-items: center; justify-content: center; z-index: 200; padding: 16px; }
.modal-box { background: var(--panel); border-radius: 12px; padding: 24px; width: 420px; max-width: 100%; max-height: 90vh; overflow-y: auto; text-align: center; }
.modal-box .avatar { width: 96px; height: 96px; border-radius: 10px; }
.stats { text-align: left; font-size: 13px; margin: 14px 0; display: grid; grid-template-columns: auto 1fr; gap: 4px 14px; }
.stats dt { color: var(--muted); } .stats dd { margin: 0; font-weight: 600; }
.colors { display: flex; gap: 10px; justify-content: center; margin: 16px 0; }
.colors button { width: 64px; height: 64px; border-radius: 8px; border: 3px solid transparent; background: #3c3a37; cursor: pointer; font-size: 34px; }
.colors button.sel { border-color: var(--green); }
.promo { display: flex; gap: 8px; justify-content: center; }
.promo img { width: 72px; height: 72px; background: #3c3a37; border-radius: 8px; cursor: pointer; }
.promo img:hover { background: var(--green); }
.toast { position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%); background: #111; padding: 12px 20px; border-radius: 8px; font-weight: 600; z-index: 300; }
.link-danger { color: #e05656; background: none; border: 0; cursor: pointer; margin-top: 12px; font: inherit; }

@media (max-width: 900px) {
  body { flex-direction: column; }
  .side { width: 100%; flex-direction: row; padding: 0; }
  .logo { padding: 10px 16px; }
  main { padding: 12px 16px; }
  .play-wrap { flex-direction: column; align-items: stretch; }
  .board-col { --size: calc(100vw - 32px); width: 100%; }
  .panel { width: 100%; height: 360px; }
}

/* review */
.review { padding: 12px; border-bottom: 1px solid #3c3a37; }
#graph { width: 100%; height: 70px; border-radius: 4px; cursor: pointer; display: block; }
.acc { width: 100%; font-size: 13px; margin-top: 10px; border-collapse: collapse; }
.acc th { color: var(--muted); font-weight: 600; font-size: 12px; }
.acc th:first-child { text-align: right; } .acc th:last-child { text-align: left; }
.acc td { padding: 2px 6px; }
.acc tr.big td { font-size: 22px; font-weight: 800; padding-bottom: 6px; }
.moves .mv { cursor: pointer; }
.moves .mv:hover { background: #ffffff14; }
.controls .btn { flex: 1 1 28%; }
.tabs { display: flex; gap: 8px; margin-top: 16px; }
.tab { background: none; border: 0; color: var(--muted); font: inherit; font-weight: 700; font-size: 16px; padding: 6px 2px; cursor: pointer; border-bottom: 3px solid transparent; }
.tab.on { color: #fff; border-color: var(--green); }
.badge { display: inline-block; font-size: 11px; background: #81b64c33; color: var(--green); border-radius: 4px; padding: 1px 6px; margin-top: 4px; }
.nav-item.back { margin-top: auto; color: var(--muted); font-size: 13px; }
@media (max-width: 900px) { .nav-item.back { margin: 0 0 0 auto; } }
