:root {
  --bg: #f5f8ff;
  --card: #ffffff;
  --line: #d9e2f2;
  --text: #122033;
  --muted: #5c6f88;
  --primary: #1565c0;
  --primary-hover: #0f4e96;
  --danger: #c62828;
  --success: #2e7d32;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "PingFang SC", "Microsoft YaHei", sans-serif;
  color: var(--text);
  background: linear-gradient(180deg, #edf4ff 0%, #f9fbff 60%, #ffffff 100%);
}

h1,
h2,
h3,
p {
  margin: 0;
}

.hidden {
  display: none !important;
}

.container {
  max-width: 1120px;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 20px;
  border-bottom: 1px solid var(--line);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(8px);
}

.brand {
  display: flex;
  gap: 12px;
  align-items: center;
}

.logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  background: var(--primary);
  color: #fff;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.brand h1 {
  font-size: 20px;
}

.user-box {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
}

.card {
  border: 1px solid var(--line);
  background: var(--card);
  border-radius: 16px;
  padding: 16px;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
}

input,
select {
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 0 12px;
  font-size: 14px;
  color: var(--text);
  background: #fff;
}

input:focus,
select:focus {
  outline: 2px solid #a5c9ff;
  border-color: #8cb8ff;
}

.btn {
  height: 40px;
  border-radius: 10px;
  border: 1px solid transparent;
  padding: 0 14px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 600;
}

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

.btn.primary {
  background: var(--primary);
  color: #fff;
}

.btn.primary:hover:enabled {
  background: var(--primary-hover);
}

.btn.secondary {
  border-color: var(--line);
  background: #fff;
  color: var(--text);
}

.status {
  margin: 12px 0;
  min-height: 20px;
  color: var(--muted);
  font-size: 14px;
}

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

.status.success {
  color: var(--success);
}

.auth-shell {
  display: grid;
  grid-template-columns: minmax(260px, 0.9fr) minmax(360px, 1.1fr);
  gap: 16px;
  align-items: start;
}

.auth-hero {
  background: linear-gradient(160deg, #ffffff 0%, #f4f8ff 100%);
}

.auth-hero h2 {
  margin-bottom: 10px;
}

.auth-hero p {
  color: var(--muted);
  line-height: 1.6;
  margin-bottom: 12px;
}

.auth-points {
  margin: 0;
  padding-left: 18px;
  color: #31445e;
  line-height: 1.7;
  font-size: 14px;
}

.auth-panel {
  box-shadow: 0 8px 24px rgba(18, 32, 51, 0.08);
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-bottom: 14px;
}

.tab-btn {
  height: 38px;
  border: 1px solid #cfdaef;
  border-radius: 10px;
  background: #f5f8ff;
  color: #335071;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
}

.tab-btn.active {
  border-color: #1a63c7;
  background: #e8f1ff;
  color: #154f98;
}

.auth-form {
  margin-bottom: 10px;
}

#reset-card {
  border-color: #98b9ef;
  background: #f7fbff;
}

.form-split {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #d7e4fa;
}

.assist-box {
  margin-top: 10px;
  border: 1px dashed #cbdaf3;
  border-radius: 12px;
  background: #f9fbff;
}

.assist-box summary {
  cursor: pointer;
  font-weight: 600;
  color: #31557f;
  list-style: none;
  padding: 12px 14px;
}

.assist-box summary::-webkit-details-marker {
  display: none;
}

.assist-content {
  padding: 0 14px 12px;
}

.hint {
  margin-top: 8px;
  font-size: 13px;
  color: var(--muted);
}

.workspace-toolbar {
  margin-bottom: 12px;
  padding: 14px;
}

.workspace-heading {
  margin-bottom: 10px;
}

.workspace-heading h2 {
  font-size: 20px;
}

.selected-game-tip {
  margin-top: 4px;
  font-size: 14px;
  color: #3a5f8e;
  font-weight: 600;
}

.toolbar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.inline-field {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-direction: row;
  font-size: 13px;
  color: #4d6280;
  padding: 8px 10px;
  background: #f5f8ff;
  border: 1px solid #dae4f5;
  border-radius: 10px;
}

.inline-field select {
  height: 32px;
  min-width: 96px;
}

.inline-batch input {
  width: 72px;
  height: 32px;
}

.hint-card {
  margin-bottom: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  background: #f2f8ff;
  border-color: #d7e7fb;
}

.hint-copy {
  color: #2f4f74;
  font-size: 14px;
}

.hint-title {
  font-weight: 700;
  margin-bottom: 4px;
}

.pager {
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: #5a6e88;
}

.board-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.board-wrap {
  position: relative;
  padding: 8px;
  border-radius: 12px;
  background: #fff;
  border: 1px solid #d9e2f2;
  box-shadow: 0 10px 24px rgba(18, 32, 51, 0.08);
}

.loading-overlay {
  position: absolute;
  inset: 0;
  z-index: 20;
  background: rgba(255, 255, 255, 0.84);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 12px;
}

.loading-inner {
  text-align: center;
  color: #4f6280;
  font-size: 13px;
}

.spinner {
  border: 4px solid rgba(0, 0, 0, 0.1);
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border-left-color: #2563eb;
  margin: 0 auto 8px;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.batch-tip {
  margin-top: 12px;
  color: #5b6f88;
  font-size: 14px;
}

.symbol-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 8px;
}

.symbol-legend-label {
  font-size: 14px;
  color: #37506f;
  font-weight: 600;
}

.symbol-legend-item {
  min-width: 2.1rem;
  height: 2.1rem;
  padding: 0 0.35rem;
  border: 1px solid #9ca3af;
  border-radius: 0.45rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #fff;
  font-size: 1.15rem;
  font-weight: 700;
  line-height: 1;
}

.sudoku-grid {
  --cell-size: 2.5rem;
  --cell-size-print: 4rem;
  --cell-font: 1.25rem;
  --cell-font-print: 2rem;
  --grid-size: 9;
  display: grid;
  grid-template-columns: repeat(var(--grid-size), var(--cell-size));
  grid-auto-rows: var(--cell-size);
  gap: 1px;
  background-color: #111827;
  border: 4px solid #111827;
}

.sudoku-cell {
  width: var(--cell-size);
  height: var(--cell-size);
  font-size: var(--cell-font);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  line-height: 1;
  background-color: #fff;
}

.sudoku-cell.given {
  color: #111827;
}

.sudoku-cell.empty {
  color: #2563eb;
}

.sudoku-cell.solution {
  color: #d97706;
}

.sudoku-cell.border-right {
  border-right: 3px solid #111827;
}

.sudoku-cell.border-bottom {
  border-bottom: 3px solid #111827;
}

.print-area {
  display: none;
}

.print-page {
  width: 100%;
  min-height: 100%;
  border: 1px solid #2a3550;
  border-radius: 12px;
  padding: 10mm 8mm;
  break-after: page;
  page-break-after: always;
}

.print-page:last-child {
  break-after: auto;
  page-break-after: auto;
}

.print-head {
  border-bottom: 2px solid #2a3550;
  padding-bottom: 3mm;
  margin-bottom: 5mm;
}

.print-head h3 {
  margin: 0;
  font-size: 18pt;
}

.print-meta {
  font-size: 10.5pt;
  color: #49566f;
  margin-top: 2mm;
}

.print-sub-meta {
  font-size: 10pt;
  color: #5f6f86;
  margin-top: 1mm;
}

.print-body {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2mm;
}

.print-grid-wrap {
  display: flex;
  justify-content: center;
  margin: 2mm 0 4mm;
}

.print-foot {
  margin-top: 5mm;
  padding-top: 3mm;
  border-top: 1px solid #c7d0dd;
  color: #4e5d77;
  font-size: 10pt;
  display: flex;
  justify-content: space-between;
}

.print-legend {
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 2mm;
  margin-bottom: 2mm;
}

.print-legend-label {
  font-size: 9.5pt;
  color: #4b5563;
}

.print-legend-item {
  min-width: 7mm;
  height: 7mm;
  padding: 0 1.2mm;
  border: 1px solid #9ca3af;
  border-radius: 1.2mm;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 12pt;
  font-weight: 700;
  line-height: 1;
  background: #fff;
}

@media (max-width: 980px) {
  .auth-shell {
    grid-template-columns: 1fr;
  }

  .hint-card {
    flex-direction: column;
    align-items: flex-start;
  }
}

@media (max-width: 900px) {
  .toolbar-row {
    align-items: stretch;
  }

  .inline-field {
    width: 100%;
    justify-content: space-between;
  }

  .inline-field select,
  .inline-batch input {
    width: 58%;
  }

  .pager {
    flex-direction: column;
  }

  .sudoku-grid {
    --cell-size: 2.1rem;
    --cell-font: 1rem;
  }
}

@media print {
  @page {
    size: A4 portrait;
    margin: 6mm;
  }

  body {
    background: #fff;
    margin: 0;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
  }

  .no-print {
    display: none !important;
  }

  .container {
    max-width: none;
    padding: 0;
  }

  .print-area {
    display: block;
  }

  .sudoku-grid {
    margin: 0 auto;
    gap: 0 !important;
    grid-template-columns: repeat(var(--grid-size), var(--cell-size-print)) !important;
    grid-auto-rows: var(--cell-size-print) !important;
    border: 3px solid #111;
    background: #111;
  }

  .sudoku-cell {
    width: var(--cell-size-print) !important;
    height: var(--cell-size-print) !important;
    font-size: var(--cell-font-print) !important;
    border: 1px solid #9ca3af;
  }

  .sudoku-cell.border-right {
    border-right: 2.5px solid #000;
  }

  .sudoku-cell.border-bottom {
    border-bottom: 2.5px solid #000;
  }
}
