:root {
  --bg1: #0b1023;
  --bg2: #111b3a;
  --panel: #172448;
  --line: rgba(148, 163, 184, 0.3);
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --warn: #fb7185;
}

* { box-sizing: border-box; }

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: "Verdana", "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at 12% 10%, rgba(56, 189, 248, 0.2), transparent 30%),
    radial-gradient(circle at 86% 14%, rgba(99, 102, 241, 0.25), transparent 34%),
    linear-gradient(180deg, var(--bg2), var(--bg1));
}

.shell {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 12px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.topbar h1 { margin: 0; font-size: 1.35rem; }
.topbar p { margin: 4px 0 0; color: var(--muted); font-size: 0.9rem; }

#newBtn {
  border: 0;
  border-radius: 10px;
  background: linear-gradient(135deg, #06b6d4, #0284c7);
  color: #fff;
  font-weight: 700;
  padding: 9px 14px;
  cursor: pointer;
}

.toolbar {
  margin-top: 12px;
  display: grid;
  grid-template-columns: auto 150px repeat(3, auto);
  gap: 8px;
  align-items: center;
}

.toolbar label { color: var(--muted); font-size: 0.9rem; }

.toolbar select,
.toolbar button {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: #11203d;
  color: var(--text);
  padding: 8px 10px;
  font-weight: 600;
}

.toolbar button {
  cursor: pointer;
}

.reward-bar {
  margin-top: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

#rewardBtn {
  border: 1px solid rgba(125, 211, 252, 0.45);
  border-radius: 10px;
  background: linear-gradient(135deg, rgba(14, 165, 233, 0.28), rgba(56, 189, 248, 0.16));
  color: var(--text);
  padding: 9px 12px;
  font-weight: 700;
  cursor: pointer;
}

#rewardBtn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
}

.reward-note {
  margin: 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.status {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.chip {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #112646, #172f56);
  padding: 8px 10px;
  display: flex;
  justify-content: space-between;
}

.chip span { color: var(--muted); }

.board-wrap {
  margin-top: 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #0c1a32;
  padding: 10px;
}

.board {
  width: min(560px, 100%);
  margin: 0 auto;
  display: grid;
  grid-template-columns: repeat(9, 1fr);
}

.cell {
  width: 100%;
  aspect-ratio: 1;
  border: 1px solid rgba(148, 163, 184, 0.3);
  background: #0f203e;
  color: var(--text);
  text-align: center;
  font-size: clamp(1rem, 2.4vw, 1.35rem);
  font-weight: 700;
  outline: none;
}

.cell.given {
  background: #193259;
  color: #dbeafe;
}

.cell.peer-row {
  background: rgba(125, 211, 252, 0.24);
}

.cell.peer-col {
  background: rgba(134, 239, 172, 0.24);
}

.cell.selected {
  background: #1d4b77;
  box-shadow: inset 0 0 0 2px #7dd3fc;
}

.cell.given.peer-row {
  background: rgba(96, 165, 250, 0.33);
}

.cell.given.peer-col {
  background: rgba(74, 222, 128, 0.3);
}

.cell.given.selected {
  background: #2a4f7d;
}

.cell.conflict {
  background: rgba(251, 113, 133, 0.2);
  color: #fecdd3;
}

.cell:focus {
  box-shadow: inset 0 0 0 2px var(--accent);
}

.cell.box-right { border-right-width: 3px; border-right-color: rgba(125, 211, 252, 0.7); }
.cell.box-bottom { border-bottom-width: 3px; border-bottom-color: rgba(125, 211, 252, 0.7); }
.cell.box-left { border-left-width: 3px; border-left-color: rgba(125, 211, 252, 0.7); }
.cell.box-top { border-top-width: 3px; border-top-color: rgba(125, 211, 252, 0.7); }

.message {
  margin-top: 10px;
  text-align: center;
  color: var(--muted);
  min-height: 1.2em;
}

.message.good { color: #4ade80; }
.message.bad { color: var(--warn); }

.number-pad {
  margin-top: 12px;
  width: min(560px, 100%);
  margin-left: auto;
  margin-right: auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.num-btn {
  border: 1px solid var(--line);
  border-radius: 10px;
  background: linear-gradient(180deg, #122b4f, #0f2442);
  color: #e2e8f0;
  font-size: 1.05rem;
  font-weight: 800;
  padding: 10px;
  cursor: pointer;
}

.num-btn:hover {
  background: linear-gradient(180deg, #163762, #143154);
}

.num-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.num-btn.done {
  display: none;
}

@media (max-width: 760px) {
  .toolbar {
    grid-template-columns: 1fr 1fr;
  }

  .status {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}
