:root {
  --bg: #14181d;
  --panel: #1b2128;
  --card: #232b33;
  --line: #34404c;
  --text: #e6e9ec;
  --muted: #9aa5b1;
  --accent: #ffd84a;
  --good: #5ee08a;
  --bad: #ff5a4f;
  --blue: #7aa7ff;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--bg); color: var(--text);
  font: 14px/1.45 system-ui, -apple-system, "Segoe UI", sans-serif; }
#app { display: flex; height: 100vh; }

#side { width: 380px; flex: none; overflow-y: auto; padding: 14px; background: var(--panel);
  border-right: 1px solid var(--line); display: flex; flex-direction: column; gap: 10px; }
h1 { font-size: 17px; margin: 0; letter-spacing: .2px; }
h2 { font-size: 15px; margin: 0 0 6px; }
h3 { font-size: 14px; margin: 14px 0 4px; }

#modes { display: flex; flex-wrap: wrap; gap: 4px; }
#modes button.active, .tools button.active { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; }

.card { background: var(--card); border-radius: 8px; padding: 10px 12px; }
.card p { margin: 6px 0; }
.card.small { font-size: 12.5px; color: var(--muted); min-height: 38px; }
.hidden { display: none !important; }
.row { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; }
.row.spread { justify-content: space-between; }
#settings label { display: flex; gap: 6px; align-items: center; color: var(--muted); font-size: 13px; }
label.check { cursor: pointer; }

.verdict { font-weight: 700; font-size: 16px; margin-bottom: 4px; }
.verdict.ok { color: var(--good); }
.verdict.bad { color: var(--bad); }
.tip { color: var(--muted); font-size: 12.5px; border-left: 3px solid var(--line); padding-left: 8px; }
.hint { color: var(--muted); font-size: 12.5px; }
.meta { color: var(--muted); font-size: 12px; }
.y { color: var(--accent); }
.r { color: var(--bad); }

table { width: 100%; border-collapse: collapse; font-size: 12.5px; margin: 6px 0; }
th, td { padding: 2px 5px; text-align: left; }
th { color: var(--muted); font-weight: 600; border-bottom: 1px solid var(--line); }
tr.win td { color: var(--good); }
tr.you td { color: var(--blue); }
tr.win.you td { font-weight: 700; color: var(--good); }
tr.total td { border-top: 1px solid var(--line); font-weight: 600; }

button { background: #2d3742; color: var(--text); border: 1px solid #3d4955; border-radius: 6px;
  padding: 5px 10px; font: inherit; font-size: 13px; cursor: pointer; }
button:hover { background: #36424f; }
button.primary { background: var(--accent); color: #111; border-color: var(--accent); font-weight: 600; }
button.small { font-size: 12px; padding: 3px 8px; }
select { background: #2d3742; color: var(--text); border: 1px solid #3d4955; border-radius: 6px;
  padding: 3px 6px; font: inherit; font-size: 13px; }
select:disabled { opacity: .45; }
kbd { background: #2d3742; border: 1px solid #3d4955; border-bottom-width: 2px; border-radius: 4px;
  padding: 0 4px; font: 11px ui-monospace, Consolas, monospace; color: var(--text); }
.keys { color: var(--muted); font-size: 12px; line-height: 1.9; }

#board { flex: 1; display: flex; align-items: center; justify-content: center; position: relative; overflow: hidden; }
canvas { border-radius: 4px; box-shadow: 0 6px 30px rgba(0, 0, 0, .45); cursor: pointer; touch-action: none; }

/* Phones / narrow windows: board on top, panel scrolls underneath. */
@media (max-width: 900px) {
  #app { flex-direction: column; height: auto; min-height: 100vh; }
  #board { order: -1; flex: none; height: min(100vw, 72vh); }
  #side { width: 100%; border-right: none; overflow: visible; padding: 10px; }
  .keys { display: none; }
}
#toast { position: absolute; bottom: 18px; left: 50%; transform: translateX(-50%); background: #000d;
  padding: 6px 12px; border-radius: 6px; opacity: 0; transition: opacity .2s; pointer-events: none; }
#toast.show { opacity: 1; }

.modal { position: fixed; inset: 0; background: #000b; display: flex; align-items: center; justify-content: center; z-index: 10; }
.modal .box { background: var(--panel); max-width: 720px; max-height: 88vh; overflow-y: auto; padding: 18px 24px;
  border-radius: 10px; border: 1px solid var(--line); }
.modal li { margin: 6px 0; }

.hpbar { position: relative; height: 18px; background: #5a1410; border-radius: 4px; overflow: hidden; margin: 4px 0; }
.hpbar div { height: 100%; background: #2fae3a; transition: width .2s; }
.hpbar span { position: absolute; inset: 0; text-align: center; font-size: 12px; font-weight: 700; line-height: 18px; }
