:root {
  color-scheme: light;
  --bg: #eef3f6;
  --text: #17212b;
  --muted: #687783;
  --line: #22313d;
  --soft-line: #c9d6dd;
  --surface: #fbfdff;
  --surface-strong: #ffffff;
  --tile: #f2f8fb;
  --given: #e9edf2;
  --primary: #1687c4;
  --primary-dark: #075f91;
  --accent: #f4b44e;
  --danger: #d9503f;
  --shadow: rgb(23 33 43 / 16%);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background:
    radial-gradient(circle at 14% 8%, rgb(22 135 196 / 14%), transparent 28%),
    radial-gradient(circle at 84% 18%, rgb(244 180 78 / 16%), transparent 26%),
    linear-gradient(135deg, #f8fbfd 0%, var(--bg) 48%, #e7eff4 100%);
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button,
input {
  font: inherit;
}

button {
  border: 1px solid var(--soft-line);
  background: linear-gradient(180deg, var(--surface-strong), #f2f7fa);
  color: var(--text);
  min-height: 44px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 650;
  box-shadow: 0 6px 16px rgb(23 33 43 / 7%);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, background 140ms ease;
}

button:hover {
  border-color: color-mix(in srgb, var(--primary) 55%, var(--soft-line));
  box-shadow: 0 10px 22px rgb(23 33 43 / 10%);
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  box-shadow: none;
  transform: none;
}

button.primary,
button.active {
  background: linear-gradient(180deg, #22a0df, var(--primary));
  color: white;
  border-color: var(--primary);
  box-shadow: 0 10px 24px rgb(22 135 196 / 26%);
}

.app-shell {
  width: min(1400px, 100%);
  margin: 0 auto;
  padding: 24px;
  overflow-x: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  margin-bottom: 18px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(32px, 5vw, 54px);
  line-height: 1.05;
  letter-spacing: 0;
}

.topbar p {
  margin-top: 8px;
  color: var(--muted);
  font-weight: 500;
}

.badges {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.badges span {
  background: rgb(255 255 255 / 72%);
  color: var(--primary-dark);
  border-radius: 999px;
  padding: 8px 12px;
  white-space: nowrap;
  border: 1px solid rgb(255 255 255 / 72%);
  box-shadow: 0 8px 18px rgb(23 33 43 / 8%);
  backdrop-filter: blur(12px);
  font-weight: 700;
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 322px;
  gap: 28px;
  align-items: start;
}

.game-layout > * {
  min-width: 0;
}

.board-area {
  display: grid;
  justify-items: center;
  width: 100%;
  min-width: 0;
  padding: 12px;
  border-radius: 22px;
  background: rgb(255 255 255 / 54%);
  border: 1px solid rgb(255 255 255 / 76%);
  box-shadow: 0 24px 60px var(--shadow);
  backdrop-filter: blur(18px);
}

.board-mount {
  width: 100%;
  max-width: min(900px, calc(100vh - 150px));
  aspect-ratio: 1;
  min-width: 0;
  position: relative;
  border-radius: 0;
  overflow: hidden;
  box-shadow: 0 18px 42px rgb(23 33 43 / 12%);
}

.board-mount canvas {
  display: block;
  width: 100% !important;
  height: 100% !important;
  transition: filter 180ms ease, opacity 180ms ease;
}

.board-mount.is-waiting canvas {
  filter: blur(12px) saturate(0.82);
  opacity: 0.28;
}

.start-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    linear-gradient(145deg, rgb(255 255 255 / 74%), rgb(238 247 252 / 74%));
  border-radius: 0;
  z-index: 2;
  backdrop-filter: blur(4px);
}

.board-mount.is-playing .start-overlay,
.board-mount.is-finished .start-overlay {
  display: none;
}

.start-btn {
  min-width: 150px;
  min-height: 58px;
  background: linear-gradient(180deg, #27a8e5, var(--primary));
  border-color: var(--primary);
  color: white;
  font-weight: 800;
  font-size: 1.08rem;
  box-shadow: 0 16px 34px rgb(22 135 196 / 34%);
}

.side-panel {
  display: grid;
  gap: 16px;
  min-width: 0;
  padding: 18px;
  border-radius: 24px;
  background: rgb(255 255 255 / 64%);
  border: 1px solid rgb(255 255 255 / 78%);
  box-shadow: 0 20px 50px rgb(23 33 43 / 12%);
  backdrop-filter: blur(18px);
}

.difficulty-row,
.number-pad {
  display: grid;
  gap: 10px;
}

.difficulty-row {
  grid-template-columns: repeat(3, 1fr);
}

.number-pad {
  grid-template-columns: repeat(3, 1fr);
}

.number-pad button {
  min-height: 56px;
  font-weight: 800;
  font-size: 1.08rem;
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.name-field {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-weight: 700;
}

.name-field input {
  border: 1px solid var(--soft-line);
  background: rgb(255 255 255 / 78%);
  color: var(--text);
  min-height: 46px;
  border-radius: 12px;
  padding: 0 12px;
  box-shadow: inset 0 1px 2px rgb(23 33 43 / 5%);
}

.status {
  min-height: 44px;
  color: var(--muted);
  padding: 12px 14px;
  border-radius: 14px;
  background: rgb(255 255 255 / 56%);
  border: 1px solid rgb(255 255 255 / 70%);
  font-weight: 650;
}

.status.error {
  color: var(--danger);
}

.leaderboard {
  display: grid;
  gap: 12px;
}

.leaderboard h2 {
  font-size: 1.35rem;
}

.leaderboard ol {
  display: grid;
  gap: 10px;
  list-style-position: inside;
  margin: 0;
  padding: 0;
}

.leaderboard li {
  background: rgb(255 255 255 / 72%);
  border: 1px solid var(--soft-line);
  border-radius: 14px;
  padding: 11px 12px;
  box-shadow: 0 8px 18px rgb(23 33 43 / 6%);
}

.score-meta {
  color: var(--muted);
  font-size: 0.9rem;
}

@media (max-width: 800px) {
  .topbar,
  .game-layout {
    grid-template-columns: 1fr;
  }

  .topbar {
    display: grid;
  }

  .badges {
    justify-content: flex-start;
  }

  .board-area,
  .side-panel {
    border-radius: 20px;
    padding: 12px;
  }

  .board-mount {
    max-width: min(100%, calc(100vh - 210px));
  }
}

@media (max-width: 420px) {
  .app-shell {
    padding: 16px;
  }

  .actions {
    grid-template-columns: 1fr;
  }
}
