:root {
  --bg-start: #06070e;
  --bg-end: #111629;
  --surface: #edf2fb;
  --line: #d1dae8;
  --text: #111827;
  --panel: rgba(18, 23, 39, 0.92);
  --panel-border: rgba(160, 198, 255, 0.16);
  --muted: #b9c6de;
  --accent: #7ac7ff;
  --accent-2: #8f78ff;
  --danger: #ff7f97;
  --success: #7cf1c4;
  --highlight: rgba(122, 199, 255, 0.14);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Noto Sans TC", "Segoe UI", "PingFang TC", "Microsoft JhengHei", sans-serif;
  background:
    radial-gradient(110% 140% at 85% 0%, rgba(122, 199, 255, 0.14), transparent 40%),
    radial-gradient(110% 140% at 10% 12%, rgba(143, 120, 255, 0.12), transparent 34%),
    linear-gradient(160deg, var(--bg-start) 0%, var(--bg-end) 100%);
  color: var(--text);
  min-height: 100vh;
}

.page-wrap {
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding-inline: 24px;
}

.top-strip {
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(8, 10, 23, 0.92);
  border-bottom: 1px solid rgba(122, 199, 255, 0.18);
  backdrop-filter: blur(8px);
}

.top-strip-inner {
  overflow-x: auto;
}

.top-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.25rem;
  min-height: 58px;
  width: max-content;
  min-width: 100%;
  padding: 0.5rem 0;
}

.icon-button {
  width: auto;
  height: auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 0;
  background: transparent;
  padding: 0;
  line-height: 0;
  flex-shrink: 0;
  transition: transform 0.2s ease, filter 0.2s ease;
}

.icon-button img {
  width: clamp(168px, 26vw, 280px);
  height: auto;
  display: block;
  pointer-events: none;
}

.icon-button:hover {
  transform: translateY(-1px);
  filter: brightness(1.06);
}

.top-nav-links {
  display: inline-flex;
  align-items: center;
  gap: 0.58rem;
  flex-shrink: 0;
  min-width: max-content;
  white-space: nowrap;
}

.top-nav-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 0.7rem 1.02rem;
  border-radius: 999px;
  border: 1px solid rgba(162, 197, 255, 0.2);
  background: rgba(19, 18, 28, 0.72);
  color: #f5f8ff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.25rem;
  letter-spacing: 0.01em;
  transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease,
    box-shadow 0.2s ease;
}

.top-nav-link:hover {
  transform: translateY(-1px);
  background: rgba(28, 39, 74, 0.92);
  border-color: rgba(158, 206, 255, 0.42);
  box-shadow: 0 10px 24px rgba(6, 12, 30, 0.28);
}

.top-nav-link.is-active {
  background: linear-gradient(135deg, rgba(122, 199, 255, 0.94), rgba(106, 127, 255, 0.94));
  border-color: rgba(221, 237, 255, 0.68);
  color: #fefeff;
  box-shadow: 0 12px 28px rgba(36, 52, 136, 0.28);
}

.game-page {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 1rem;
  align-items: start;
  padding: 1rem 0 2rem;
}

.game-stage,
.game-info {
  grid-column: 1;
}

.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 1rem;
  box-shadow: 0 10px 24px rgba(21, 17, 36, 0.08);
}

.game-shell-sudoku .game-shell__toolbar {
  background: rgba(18, 22, 35, 0.94);
}

.sudoku-surface {
  position: relative;
  overflow: hidden;
  border-radius: 18px;
  background:
    radial-gradient(circle at top, rgba(122, 199, 255, 0.1), transparent 32%),
    linear-gradient(180deg, rgba(12, 16, 27, 0.98), rgba(20, 18, 33, 0.96));
  box-shadow:
    inset 0 0 0 1px rgba(186, 215, 255, 0.12),
    inset 0 18px 44px rgba(122, 199, 255, 0.04),
    0 16px 36px rgba(5, 8, 22, 0.32);
  padding: 24px;
}

.sudoku-layout {
  height: 100%;
  display: grid;
  grid-template-columns: 164px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 24px 28px;
  align-items: stretch;
  justify-content: stretch;
}

.sudoku-board-panel {
  grid-column: 2;
  grid-row: 2;
  min-width: 0;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sudoku-topbar {
  grid-column: 1 / -1;
  grid-row: 1;
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  align-items: center;
  justify-content: center;
}

.sudoku-input-sidepanel {
  grid-column: 1;
  grid-row: 2;
  display: grid;
  align-content: start;
  min-height: 0;
  padding-top: 4px;
  padding: 12px;
  border-radius: 18px;
  border: 1px solid rgba(171, 219, 255, 0.12);
  background: rgba(18, 24, 40, 0.72);
  box-shadow: 0 12px 24px rgba(5, 9, 20, 0.12);
}

.sudoku-board {
  width: min(100%, 660px);
  max-width: 100%;
  max-height: min(100%, 660px);
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  aspect-ratio: 1;
  border: 2px solid rgba(208, 227, 255, 0.44);
  border-radius: 18px;
  overflow: hidden;
  background: rgba(11, 17, 31, 0.92);
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.03),
    0 20px 36px rgba(7, 10, 22, 0.3);
}

.sudoku-cell {
  position: relative;
  border: 1px solid rgba(169, 198, 241, 0.12);
  background: rgba(15, 20, 34, 0.96);
  color: #eff6ff;
  padding: 0;
  cursor: pointer;
  transition: background-color 0.18s ease, box-shadow 0.18s ease, color 0.18s ease;
}

.sudoku-cell::before {
  content: "";
  display: block;
  padding-top: 100%;
}

.sudoku-cell[data-row="2"],
.sudoku-cell[data-row="5"] {
  border-bottom-width: 2px;
  border-bottom-color: rgba(219, 235, 255, 0.34);
}

.sudoku-cell[data-col="2"],
.sudoku-cell[data-col="5"] {
  border-right-width: 2px;
  border-right-color: rgba(219, 235, 255, 0.34);
}

.sudoku-cell__content,
.sudoku-cell__notes {
  position: absolute;
  inset: 0;
}

.sudoku-cell__content {
  display: grid;
  place-items: center;
  font-size: clamp(1.34rem, 3vw, 2rem);
  font-weight: 800;
  line-height: 1;
}

.sudoku-cell__notes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 8px;
  color: #98aed7;
  font-size: clamp(0.52rem, 1vw, 0.72rem);
  font-weight: 700;
}

.sudoku-cell__note {
  display: grid;
  place-items: center;
}

.sudoku-cell.is-given .sudoku-cell__content {
  color: #f8fbff;
}

.sudoku-cell.is-hinted .sudoku-cell__content {
  color: #9be7ca;
}

.sudoku-cell.is-editable .sudoku-cell__content {
  color: #9fd4ff;
}

.sudoku-cell.is-selected {
  background: rgba(74, 127, 255, 0.3);
  box-shadow: inset 0 0 0 2px rgba(196, 219, 255, 0.72);
}

.sudoku-cell.is-related {
  background: var(--highlight);
}

.sudoku-cell.is-same-value {
  background: rgba(143, 120, 255, 0.18);
}

.sudoku-cell.is-error {
  background: rgba(255, 127, 151, 0.16);
  color: #ffe8ed;
}

.sudoku-cell.is-error .sudoku-cell__content {
  color: #ffdbe3;
}

.sudoku-cell.is-check-empty {
  box-shadow: inset 0 0 0 1px rgba(122, 199, 255, 0.38);
}

.sudoku-cell.is-check-wrong {
  box-shadow: inset 0 0 0 2px rgba(255, 127, 151, 0.6);
}

.sudoku-cell.is-locked {
  cursor: default;
}

.sudoku-input-panel {
  display: grid;
  gap: 10px;
}

.sudoku-number-pad {
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  gap: 10px;
}

.sudoku-number-pad__button,
.sudoku-clear-button,
.sudoku-sidebar__button,
.sudoku-difficulty__button,
.sudoku-overlay button {
  border: 1px solid rgba(171, 202, 255, 0.18);
  background: rgba(22, 29, 50, 0.9);
  color: #f7fbff;
  border-radius: 16px;
  font: inherit;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.sudoku-number-pad__button:hover,
.sudoku-clear-button:hover,
.sudoku-sidebar__button:hover,
.sudoku-difficulty__button:hover,
.sudoku-overlay button:hover {
  transform: translateY(-1px);
  border-color: rgba(171, 219, 255, 0.38);
  box-shadow: 0 12px 24px rgba(6, 12, 32, 0.22);
}

.sudoku-number-pad__button {
  min-height: 56px;
  font-size: 1.2rem;
  font-weight: 800;
}

.sudoku-clear-button {
  min-height: 52px;
  font-weight: 700;
}

.sudoku-overlay {
  position: absolute;
  inset: 24px;
  display: grid;
  place-items: center;
  padding: 24px;
  border-radius: 20px;
  background: rgba(9, 13, 22, 0.54);
  z-index: 5;
}

.sudoku-overlay.is-hidden {
  display: none;
}

.sudoku-overlay__panel {
  width: min(100%, 420px);
  padding: 1.8rem;
  border-radius: 24px;
  border: 1px solid rgba(171, 220, 255, 0.18);
  background:
    linear-gradient(160deg, rgba(17, 24, 40, 0.96), rgba(24, 19, 43, 0.94)),
    radial-gradient(circle at top, rgba(122, 199, 255, 0.1), transparent 44%);
  color: #f7fbff;
  text-align: center;
  box-shadow: 0 28px 60px rgba(4, 9, 22, 0.34);
}

.sudoku-overlay__kicker {
  margin: 0 0 0.7rem;
  font-size: 1rem;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: #9fd4ff;
}

.sudoku-overlay h1 {
  margin: 0 0 0.8rem;
  font-size: clamp(2.3rem, 4vw, 3rem);
  line-height: 1.1;
}

.sudoku-overlay p {
  margin: 0;
  line-height: 1.7;
  color: #d7e7ff;
}

.sudoku-overlay__actions {
  margin-top: 1.5rem;
  display: flex;
  justify-content: center;
}

.sudoku-overlay button {
  min-width: 156px;
  min-height: 52px;
  padding: 0.9rem 1.3rem;
  background: linear-gradient(135deg, rgba(122, 199, 255, 0.96), rgba(106, 127, 255, 0.96));
  border-color: rgba(219, 232, 255, 0.36);
  color: #fefeff;
  font-weight: 800;
}

.sudoku-sidebar {
  background:
    linear-gradient(180deg, rgba(122, 199, 255, 0.08), transparent 20%),
    rgba(15, 19, 32, 0.98);
  color: #f7fbff;
  box-shadow: inset 0 0 0 1px rgba(171, 219, 255, 0.12);
}

.sudoku-topbar__item {
  min-height: 50px;
  padding: 0.8rem 1rem;
  border-radius: 999px;
  border: 1px solid rgba(171, 219, 255, 0.16);
  background: rgba(18, 24, 40, 0.82);
  color: #f7fbff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.28rem;
  line-height: 1;
  white-space: nowrap;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.02);
}

.sudoku-topbar__item--stat {
  min-width: 196px;
  font-weight: 700;
}

.sudoku-topbar__item--button {
  font: inherit;
  font-weight: 700;
  cursor: pointer;
  transition: transform 0.18s ease, border-color 0.18s ease, background-color 0.18s ease, box-shadow 0.18s ease;
}

.sudoku-topbar__item--button:hover {
  transform: translateY(-1px);
  border-color: rgba(171, 219, 255, 0.38);
  box-shadow: 0 12px 24px rgba(6, 12, 32, 0.22);
}

.sudoku-topbar__item--button.is-active {
  background: linear-gradient(135deg, rgba(122, 199, 255, 0.94), rgba(106, 127, 255, 0.94));
  border-color: rgba(221, 237, 255, 0.44);
  color: #fff;
}

.sudoku-topbar__label {
  color: #c9daf4;
}

.sudoku-topbar__value {
  color: #ffffff;
  font-weight: 800;
}

.sudoku-sidebar {
  display: flex;
  flex-direction: column;
  gap: 14px;
  padding: 18px;
}

.sudoku-sidebar__card {
  border-radius: 18px;
  border: 1px solid rgba(171, 219, 255, 0.12);
  background: rgba(18, 24, 40, 0.9);
  padding: 14px;
  box-shadow: 0 12px 24px rgba(5, 9, 20, 0.18);
}

.sudoku-sidebar__header h2,
.sudoku-difficulty,
.sudoku-action-list {
  display: grid;
}

.sudoku-sidebar__header h2 {
  margin: 0 0 0.9rem;
  font-size: 1rem;
  color: #cddfff;
}

.sudoku-difficulty,
.sudoku-action-list {
  gap: 10px;
}

.sudoku-difficulty__button,
.sudoku-sidebar__button {
  min-height: 46px;
  padding: 0.82rem 0.9rem;
  text-align: left;
  font-weight: 700;
}

.sudoku-number-pad--side {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 56px));
  grid-auto-flow: column;
}

.sudoku-difficulty__button.is-active,
.sudoku-sidebar__button.is-active {
  background: linear-gradient(135deg, rgba(122, 199, 255, 0.94), rgba(106, 127, 255, 0.94));
  border-color: rgba(221, 237, 255, 0.44);
  color: #fff;
}

.sudoku-sidebar__button--primary {
  background: rgba(143, 120, 255, 0.2);
}

.sudoku-stat-list {
  display: grid;
  gap: 12px;
}

.sudoku-stat {
  padding: 0.86rem 0.95rem;
  border-radius: 14px;
  background: rgba(12, 17, 31, 0.82);
  border: 1px solid rgba(171, 219, 255, 0.1);
}

.sudoku-stat__label {
  display: block;
  color: #aac3e7;
  font-size: 0.92rem;
}

.sudoku-stat__value {
  display: block;
  margin-top: 0.35rem;
  font-size: 1.6rem;
  line-height: 1.1;
  color: #f7fbff;
  text-shadow: 0 0 18px rgba(122, 199, 255, 0.14);
}

.sudoku-status-text {
  margin: 12px 0 0;
  min-height: 42px;
  color: #b9cbe5;
  line-height: 1.55;
  font-size: 0.94rem;
}

.sudoku-status-text--hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  border: 0;
}

.sudoku-status-text.is-danger {
  color: #ffc3cf;
}

.sudoku-status-text.is-success {
  color: #b7f6de;
}

.game-info__panel h2 {
  margin: 0 0 0.6rem;
}

.game-info__panel p {
  margin: 0.42rem 0;
  line-height: 1.7;
}

.game-info__panel h3 {
  margin: 1.2rem 0 0.45rem;
}

@media (max-width: 768px) {
  .page-wrap {
    padding-inline: 16px;
  }

  .top-bar {
    gap: 0.9rem;
  }

  .sudoku-surface {
    padding: 14px;
  }

  .sudoku-layout {
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: auto;
    gap: 12px;
  }

  .sudoku-topbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    grid-column: 1;
    grid-row: auto;
    gap: 12px;
  }

  .sudoku-board-panel {
    grid-column: 1;
    grid-row: auto;
    width: 100%;
  }

  .sudoku-input-sidepanel {
    grid-column: 1;
    grid-row: auto;
    padding-top: 12px;
  }

  .sudoku-number-pad {
    grid-template-columns: repeat(5, minmax(0, 1fr));
  }

  .sudoku-number-pad--side {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    grid-template-rows: none;
    grid-auto-flow: row;
  }

  .sudoku-overlay {
    inset: 14px;
    padding: 12px;
  }

  .sudoku-overlay__panel {
    padding: 1.35rem;
  }
}
