:root {
  --bg: #eef8ff;
  --bg-strong: #d7efff;
  --surface: #ffffff;
  --surface-soft: #f6fbff;
  --surface-strong: #e6f4ff;
  --primary: #0f7cff;
  --primary-dark: #0a57b5;
  --primary-ink: #08356f;
  --accent: #ffb703;
  --accent-deep: #c77700;
  --success: #12a150;
  --success-bg: #ebfff3;
  --danger: #dc4b5f;
  --danger-bg: #fff0f2;
  --text: #10213a;
  --text-soft: #516177;
  --text-faint: #6f8097;
  --border: rgba(16, 33, 58, 0.12);
  --border-strong: rgba(15, 124, 255, 0.28);
  --shadow: 0 16px 44px rgba(16, 33, 58, 0.08);
  --shadow-strong: 0 24px 64px rgba(15, 124, 255, 0.18);
  --radius: 18px;
  --radius-lg: 28px;
  --sans: "Lexend", sans-serif;
  --mono: "JetBrains Mono", monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 18px;
  scroll-behavior: smooth;
}

body {
  min-height: 100vh;
  font-family: var(--sans);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
  background:
    radial-gradient(circle at top left, rgba(255, 183, 3, 0.18), transparent 32%),
    radial-gradient(circle at top right, rgba(15, 124, 255, 0.18), transparent 28%),
    linear-gradient(180deg, #fbfeff 0%, var(--bg) 100%);
}

body.modal-open {
  overflow: hidden;
}

button,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

code {
  font-family: var(--mono);
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  padding: 18px 28px;
  background: rgba(255, 255, 255, 0.96);
  border-bottom: 1px solid rgba(16, 33, 58, 0.12);
  backdrop-filter: blur(14px);
  box-shadow: 0 14px 34px rgba(16, 33, 58, 0.08);
  transition: filter 0.22s ease, opacity 0.22s ease, transform 0.22s ease;
}

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

.brand-badge {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  border-radius: 20px;
  background: linear-gradient(135deg, #0f7cff 0%, #13b5ff 100%);
  color: #fff;
  font-size: 1.9rem;
  font-weight: 900;
  box-shadow: 0 18px 34px rgba(15, 124, 255, 0.28);
}

.brand-kicker {
  font-size: 0.82rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 4px;
}

.brand-title {
  font-size: clamp(1.5rem, 2vw, 2rem);
  font-weight: 900;
  letter-spacing: -0.04em;
}

.brand-subtitle {
  font-size: 0.98rem;
  color: var(--text-soft);
  margin-top: 4px;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.secondary-link-btn,
.guide-link-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 999px;
  border: 2px solid rgba(15, 124, 255, 0.16);
  background: rgba(255, 255, 255, 0.82);
  color: var(--primary-ink);
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 10px 22px rgba(15, 124, 255, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.secondary-link-btn:hover,
.secondary-link-btn:focus-visible,
.guide-link-btn:hover,
.guide-link-btn:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(15, 124, 255, 0.34);
  background: #ffffff;
  box-shadow: 0 14px 24px rgba(15, 124, 255, 0.12);
  outline: none;
}

.stat-pill {
  min-width: 146px;
  padding: 12px 16px;
  border-radius: 999px;
  background: linear-gradient(180deg, #ffffff 0%, #f3f9ff 100%);
  border: 2px solid rgba(15, 124, 255, 0.18);
  box-shadow: 0 10px 22px rgba(16, 33, 58, 0.07);
}

.stat-label {
  display: block;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--text-faint);
  margin-bottom: 4px;
}

.stat-value {
  font-size: 1.25rem;
  font-weight: 900;
  color: var(--text);
}

.label-short {
  display: none;
}

.primary-btn,
.secondary-btn,
.reset-btn,
.ghost-btn,
.quick-btn,
.cell {
  border: none;
}

.primary-btn {
  padding: 16px 24px;
  border-radius: 999px;
  background: linear-gradient(135deg, var(--accent) 0%, #ff8c42 100%);
  color: #5c2f00;
  font-weight: 900;
  font-size: 1rem;
  box-shadow: 0 18px 32px rgba(255, 183, 3, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.primary-btn:hover,
.primary-btn:focus-visible {
  transform: translateY(-2px);
  box-shadow: 0 22px 38px rgba(255, 183, 3, 0.32);
}

.secondary-btn,
.reset-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 14px 20px;
  border-radius: 999px;
  font-weight: 900;
  font-size: 0.96rem;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.secondary-btn {
  background: linear-gradient(180deg, #ffffff 0%, #edf7ff 100%);
  color: var(--primary-ink);
  border: 2px solid rgba(15, 124, 255, 0.18);
  box-shadow: 0 14px 26px rgba(15, 124, 255, 0.1);
}

.reset-btn {
  background: linear-gradient(180deg, #fffdf8 0%, #fff3dc 100%);
  color: #7a4400;
  border: 2px solid rgba(255, 183, 3, 0.3);
  box-shadow: 0 14px 26px rgba(255, 183, 3, 0.16);
}

.secondary-btn:hover,
.secondary-btn:focus-visible,
.reset-btn:hover,
.reset-btn:focus-visible {
  transform: translateY(-2px);
  outline: none;
}

.secondary-btn:hover,
.secondary-btn:focus-visible {
  border-color: rgba(15, 124, 255, 0.34);
  box-shadow: 0 18px 30px rgba(15, 124, 255, 0.14);
}

.reset-btn:hover,
.reset-btn:focus-visible {
  border-color: rgba(255, 183, 3, 0.42);
  box-shadow: 0 18px 30px rgba(255, 183, 3, 0.22);
}

.secondary-link-btn:active,
.guide-link-btn:active,
.primary-btn:active,
.secondary-btn:active,
.reset-btn:active {
  transform: translateY(0) scale(0.985);
}

.page-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 24px;
  padding: 28px;
}

.content {
  display: grid;
  gap: 24px;
  align-content: start;
  transition: filter 0.22s ease, opacity 0.22s ease, transform 0.22s ease;
}

.panel {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(16, 33, 58, 0.08);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}

.hero-panel {
  display: grid;
  grid-template-columns: minmax(0, 1.3fr) minmax(320px, 0.7fr);
  gap: 22px;
  padding: 28px;
  overflow: hidden;
  position: relative;
}

.hero-panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at 85% 20%, rgba(19, 181, 255, 0.18), transparent 18%),
    radial-gradient(circle at 12% 88%, rgba(255, 183, 3, 0.2), transparent 22%);
  pointer-events: none;
}

.eyebrow {
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 10px;
}

.hero-title {
  font-size: clamp(2rem, 4vw, 3.3rem);
  line-height: 1.02;
  font-weight: 900;
  letter-spacing: -0.05em;
  max-width: 12ch;
}

.hero-copy p {
  margin-top: 14px;
  max-width: 48rem;
  font-size: 1.08rem;
  line-height: 1.7;
  color: var(--text-soft);
}

.hero-side {
  display: grid;
  gap: 16px;
  align-content: start;
}

.progress-card,
.status-card {
  padding: 22px;
  border-radius: 24px;
  background: var(--surface);
  border: 1px solid rgba(16, 33, 58, 0.08);
  box-shadow: 0 10px 28px rgba(16, 33, 58, 0.06);
}

.progress-label,
.status-label {
  font-size: 0.9rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--text-faint);
  margin-bottom: 12px;
}

.progress-track {
  height: 18px;
  border-radius: 999px;
  background: #dbeeff;
  overflow: hidden;
  margin-bottom: 14px;
}

.progress-fill {
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--primary) 0%, #1ed2ff 100%);
  transition: width 0.25s ease;
}

.progress-text {
  font-size: 1.22rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.status-message {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-soft);
}

.how-to-play {
  padding: 24px 26px;
}

.steps-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.step-card {
  padding: 20px;
  border-radius: 24px;
  background: linear-gradient(180deg, var(--surface-soft) 0%, var(--surface) 100%);
  border: 1px solid rgba(16, 33, 58, 0.08);
}

.step-number {
  width: 42px;
  height: 42px;
  display: grid;
  place-items: center;
  margin-bottom: 14px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, #13b5ff 100%);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 10px 24px rgba(15, 124, 255, 0.22);
}

.step-card strong {
  display: block;
  font-size: 1.1rem;
  font-weight: 800;
  margin-bottom: 8px;
}

.step-card p {
  color: var(--text-soft);
  line-height: 1.65;
}

.board-panel {
  padding: 24px;
}

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

.board-header h2 {
  font-size: clamp(1.5rem, 2.5vw, 2.2rem);
  font-weight: 900;
  letter-spacing: -0.04em;
}

.board-header p {
  margin-top: 10px;
  max-width: 38rem;
  color: var(--text-soft);
  line-height: 1.7;
}

.legend {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.legend-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  background: var(--surface-soft);
  border: 2px solid rgba(16, 33, 58, 0.08);
  box-shadow: 0 8px 20px rgba(16, 33, 58, 0.05);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
}

.legend-item.easy {
  background: #e7fff0;
  border-color: rgba(18, 161, 80, 0.26);
  color: #0f7c44;
}

.legend-item.medium {
  background: #fff0bf;
  border-color: rgba(255, 183, 3, 0.34);
  color: #8a5400;
}

.legend-item.hard {
  background: #ffe2e7;
  border-color: rgba(220, 75, 95, 0.3);
  color: #a5253d;
}

.legend-item.expert {
  background: #dceaff;
  border-color: rgba(8, 53, 111, 0.26);
  color: #08356f;
}

.legend-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  flex-shrink: 0;
}

.legend-dot.default {
  background: #cce6ff;
}

.legend-dot.success {
  background: #82dfaa;
}

.legend-dot.free {
  background: #ffd875;
}

.board-scroll {
  overflow-x: auto;
  padding: 8px 8px 12px;
  border-radius: 28px;
  border: 1px solid rgba(15, 124, 255, 0.12);
  background: linear-gradient(180deg, rgba(247, 251, 255, 0.95) 0%, rgba(235, 245, 255, 0.94) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.84);
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  scroll-padding-inline: 8px;
}

.bingo-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 14px;
  min-width: 860px;
}

.cell {
  width: 100%;
  min-height: 196px;
  padding: 18px 16px;
  border-radius: 24px;
  background: linear-gradient(180deg, #ffffff 0%, #f6fbff 100%);
  border: 3px solid rgba(15, 124, 255, 0.14);
  box-shadow: 0 18px 34px rgba(16, 33, 58, 0.08);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  text-align: left;
  color: var(--text);
  appearance: none;
  -webkit-appearance: none;
  position: relative;
  overflow: hidden;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, filter 0.18s ease;
}

.cell:hover,
.cell:focus-visible {
  transform: translateY(-4px);
  border-color: var(--primary);
  box-shadow: 0 24px 44px rgba(15, 124, 255, 0.2);
  outline: none;
}

.cell:active {
  transform: scale(0.985);
  box-shadow: 0 18px 30px rgba(15, 124, 255, 0.16);
}

.cell.free-cell {
  cursor: default;
}

.cell.solved {
  cursor: pointer;
}

.cell.solved {
  background: linear-gradient(180deg, #17b25f 0%, #10914a 100%);
  border-color: rgba(10, 104, 50, 0.8);
  box-shadow: 0 24px 42px rgba(18, 161, 80, 0.3);
  color: #f7fff9;
}

.cell.solved::after {
  content: "✓";
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: #10914a;
  color: #fff;
  font-size: 1rem;
  font-weight: 900;
  border: 2px solid rgba(255, 255, 255, 0.72);
  box-shadow: 0 10px 18px rgba(18, 161, 80, 0.28);
}

.cell.free-cell {
  align-items: center;
  justify-content: center;
  text-align: center;
  background: linear-gradient(180deg, #fff7d9 0%, #ffe6a8 100%);
  border-color: rgba(199, 119, 0, 0.28);
  box-shadow: 0 18px 34px rgba(255, 183, 3, 0.2);
}

.cell.active {
  border-color: #ff9800;
  box-shadow: 0 0 0 5px rgba(255, 183, 3, 0.18), 0 26px 44px rgba(255, 183, 3, 0.2);
}

.cell.bingo-line {
  animation: pulseCell 0.55s ease;
}

@keyframes pulseCell {
  0% { transform: scale(1); }
  40% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

.cell-top {
  width: 100%;
}

.cell-meta {
  width: 100%;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.cell-table {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  max-width: 100%;
  padding: 8px 12px;
  border-radius: 999px;
  background: #f1f8ff;
  color: var(--primary-ink);
  font-size: 0.88rem;
  font-weight: 800;
  border: 1px solid rgba(15, 124, 255, 0.18);
}

.difficulty-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  border-radius: 999px;
  font-size: 0.82rem;
  font-weight: 900;
  white-space: nowrap;
}

.cell-mobile-shell,
.cell-mobile-badge {
  display: none;
}

.difficulty-easy {
  background: #dff8ea;
  border: 2px solid rgba(18, 161, 80, 0.3);
  color: #0c6f3b;
}

.difficulty-medium {
  background: #ffe7a1;
  border: 2px solid rgba(255, 183, 3, 0.36);
  color: #7f4900;
}

.difficulty-hard {
  background: #ffd8df;
  border: 2px solid rgba(220, 75, 95, 0.3);
  color: #a6253d;
}

.difficulty-expert {
  background: #dce9ff;
  border: 2px solid rgba(8, 53, 111, 0.26);
  color: #08356f;
}

.cell.diff-lett {
  background: linear-gradient(180deg, #ffffff 0%, #f1fff6 100%);
  border-color: rgba(18, 161, 80, 0.34);
}

.cell.diff-middels {
  background: linear-gradient(180deg, #ffffff 0%, #fff7df 100%);
  border-color: rgba(255, 183, 3, 0.38);
}

.cell.diff-vanskelig {
  background: linear-gradient(180deg, #ffffff 0%, #fff0f3 100%);
  border-color: rgba(220, 75, 95, 0.34);
}

.cell.diff-ekspert {
  background: linear-gradient(180deg, #ffffff 0%, #eef5ff 100%);
  border-color: rgba(8, 53, 111, 0.32);
}

.cell.solved.diff-lett,
.cell.solved.diff-middels,
.cell.solved.diff-vanskelig,
.cell.solved.diff-ekspert {
  background: linear-gradient(180deg, #17b25f 0%, #10914a 100%);
  border-color: rgba(10, 104, 50, 0.8);
}

.cell-hint {
  margin-top: 14px;
  font-size: 1.12rem;
  line-height: 1.5;
  font-weight: 800;
}

.cell-bottom {
  width: 100%;
  display: grid;
  gap: 10px;
}

.cell-state {
  font-size: 0.9rem;
  font-weight: 800;
  color: var(--text-soft);
}

.cell.solved .cell-state {
  color: rgba(247, 255, 249, 0.92);
}

.cell-preview-wrap {
  width: 100%;
  padding: 12px 12px 10px;
  border-radius: 18px;
  background: rgba(16, 145, 74, 0.08);
  border: 1px solid rgba(18, 161, 80, 0.22);
}

.cell-solved-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.94);
  color: #0f7c44;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.cell-preview-label {
  margin-top: 10px;
  font-size: 0.78rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #0f7c44;
}

.cell-preview {
  display: block;
  margin-top: 6px;
  font-size: 0.84rem;
  line-height: 1.45;
  color: #17492d;
  white-space: normal;
  word-break: break-word;
}

.cell.solved .cell-table {
  background: rgba(255, 255, 255, 0.18);
  color: #f7fff9;
  border-color: rgba(255, 255, 255, 0.16);
}

.cell.solved .cell-hint,
.cell.solved .cell-preview-label,
.cell.solved .cell-preview {
  color: #f7fff9;
}

.cell.solved .cell-preview-wrap {
  background: rgba(255, 255, 255, 0.14);
  border-color: rgba(255, 255, 255, 0.18);
}

.cell.free-cell .cell-hint {
  font-size: 1.6rem;
  font-weight: 900;
}

.cell.free-cell .cell-state {
  color: #6e4900;
}

.sidebar {
  padding: 24px;
  align-self: start;
  position: sticky;
  top: 112px;
  height: calc(100vh - 136px);
  max-height: calc(100vh - 136px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: rgba(255, 255, 255, 0.94);
  transition: filter 0.22s ease, opacity 0.22s ease, box-shadow 0.22s ease, transform 0.22s ease;
}

body.modal-open .topbar,
body.modal-open .content {
  filter: blur(10px) saturate(0.8);
  opacity: 0.34;
  transform: scale(0.995);
  pointer-events: none;
  user-select: none;
}

body.modal-open .sidebar {
  position: fixed;
  top: 112px;
  right: 28px;
  bottom: 24px;
  width: 360px;
  height: calc(100vh - 136px);
  max-height: none;
  overflow: hidden;
  z-index: 260;
  opacity: 1;
  filter: none;
  transform: none;
  box-shadow: 0 22px 44px rgba(15, 124, 255, 0.12);
}

.sidebar h2 {
  font-size: 1.5rem;
  font-weight: 900;
  letter-spacing: -0.04em;
  margin-bottom: 0;
}

.sidebar p {
  color: var(--text-soft);
  line-height: 1.65;
  margin-bottom: 18px;
}

.sidebar-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 18px;
}

.sidebar-content {
  display: block;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 100%;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y;
  padding-right: 6px;
  margin-right: -6px;
  cursor: grab;
}

.sidebar-content.drag-scrolling,
.quick-actions.drag-scrolling {
  cursor: grabbing;
  user-select: none;
}

.sidebar-mobile-toggle,
.helper-mobile-toggle,
.modal-tables-toggle {
  display: none;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 2px solid rgba(15, 124, 255, 0.16);
  background: rgba(255, 255, 255, 0.88);
  color: var(--primary-ink);
  font-size: 0.88rem;
  font-weight: 800;
  box-shadow: 0 10px 22px rgba(15, 124, 255, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease, background 0.18s ease;
}

.sidebar-mobile-toggle:hover,
.sidebar-mobile-toggle:focus-visible,
.helper-mobile-toggle:hover,
.helper-mobile-toggle:focus-visible,
.modal-tables-toggle:hover,
.modal-tables-toggle:focus-visible {
  transform: translateY(-2px);
  border-color: rgba(15, 124, 255, 0.32);
  background: #ffffff;
  box-shadow: 0 12px 22px rgba(15, 124, 255, 0.12);
  outline: none;
}

.table-card {
  border-radius: 22px;
  border: 1px solid rgba(16, 33, 58, 0.09);
  background: var(--surface);
  overflow: hidden;
  margin-bottom: 12px;
  box-shadow: 0 10px 24px rgba(16, 33, 58, 0.05);
  transition: border-color 0.18s ease, box-shadow 0.18s ease, transform 0.18s ease;
}

.table-card.focused {
  border-color: var(--primary);
  box-shadow: 0 0 0 4px rgba(15, 124, 255, 0.12), 0 18px 32px rgba(15, 124, 255, 0.16);
}

.table-card.collapsed .table-body {
  display: none;
}

.table-card-header {
  width: 100%;
  padding: 18px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: transparent;
  text-align: left;
  touch-action: pan-y;
}

.table-card-header:hover,
.table-card-header:focus-visible {
  background: #f6fbff;
  outline: none;
}

.table-card-header:active {
  background: #eef6ff;
}

.table-card:hover {
  transform: translateY(-1px);
}

.table-name {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

.table-toggle {
  font-size: 1rem;
  color: var(--text-soft);
  transition: transform 0.18s ease;
}

.table-card.collapsed .table-toggle {
  transform: rotate(-90deg);
}

.table-body {
  padding: 0 14px 14px;
  touch-action: pan-y;
}

.col-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  padding: 10px 12px;
  border-radius: 14px;
  background: var(--surface-soft);
  margin-top: 8px;
  touch-action: pan-y;
}

.col-badge {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 28px;
  padding: 0 8px;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  font-family: var(--mono);
}

.col-badge.pk {
  background: #fff1c7;
  color: #7f4b00;
}

.col-badge.fk {
  background: #dff0ff;
  color: #0757b3;
}

.col-badge.col {
  opacity: 0;
}

.col-name {
  font-family: var(--mono);
  font-size: 0.86rem;
  font-weight: 700;
  color: var(--text);
  word-break: break-word;
}

.col-type {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--text-faint);
}

.memory-box {
  margin-top: 18px;
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fff7d9 0%, #fff2be 100%);
  border: 1px solid rgba(255, 183, 3, 0.34);
}

.memory-box h3 {
  font-size: 1rem;
  font-weight: 900;
  margin-bottom: 10px;
  color: #764300;
}

.memory-box p {
  margin: 0;
  color: #6b4b11;
  font-size: 0.96rem;
}

.memory-box code {
  display: inline-block;
  margin: 4px 6px 4px 0;
  padding: 6px 10px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.6);
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background:
    radial-gradient(circle at 28% 50%, rgba(15, 124, 255, 0.12), transparent 30%),
    linear-gradient(90deg, rgba(5, 18, 35, 0.34) 0%, rgba(5, 18, 35, 0.2) 56%, rgba(5, 18, 35, 0.04) 74%, transparent 88%);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 24px 440px 24px 24px;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.22s ease;
  z-index: 200;
}

.modal-overlay.open {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal {
  width: min(860px, 100%);
  max-height: min(92vh, 960px);
  overflow: auto;
  border-radius: 30px;
  background: #ffffff;
  box-shadow: 0 30px 90px rgba(0, 0, 0, 0.28);
  pointer-events: none;
  display: flex;
  flex-direction: column;
}

.modal-overlay.open .modal {
  pointer-events: auto;
}

.modal-top {
  position: sticky;
  top: 0;
  z-index: 5;
  padding: 28px 30px 18px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98) 0%, rgba(255, 255, 255, 0.98) 82%, rgba(255, 255, 255, 0.9) 100%);
  border-bottom: 1px solid rgba(16, 33, 58, 0.08);
  backdrop-filter: blur(18px);
}

.modal-kicker {
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--primary);
  margin-bottom: 12px;
}

.modal-question {
  font-size: clamp(1.7rem, 2.6vw, 2.5rem);
  font-weight: 900;
  line-height: 1.15;
  letter-spacing: -0.04em;
  margin-bottom: 16px;
}

.modal-context {
  padding: 18px;
  border-radius: 22px;
  background: #eff8ff;
  border: 1px solid rgba(15, 124, 255, 0.16);
  color: var(--primary-ink);
  line-height: 1.7;
}

.modal-context .context-block + .context-block {
  margin-top: 12px;
}

.modal-context strong {
  font-weight: 800;
}

.modal-context code {
  padding: 3px 8px;
  border-radius: 8px;
  background: #d9efff;
}

.competition-note {
  padding: 14px 16px;
  border-radius: 18px;
  background: rgba(255, 183, 3, 0.14);
  border: 1px solid rgba(255, 183, 3, 0.28);
  color: #6d4500;
}

.modal-context a {
  color: #0a57b5;
  font-weight: 800;
}

.modal-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.chip {
  padding: 9px 14px;
  border-radius: 999px;
  font-size: 0.92rem;
  font-weight: 800;
  background: #eef6ff;
  color: var(--primary-ink);
  border: 1px solid rgba(15, 124, 255, 0.16);
}

.chip.difficulty-easy,
.chip.difficulty-medium,
.chip.difficulty-hard,
.chip.difficulty-expert {
  font-weight: 900;
}

.modal-body {
  padding: 24px 30px 30px;
  display: grid;
  gap: 18px;
}

.helper-box {
  padding: 18px;
  border-radius: 22px;
  background: linear-gradient(180deg, #fff7d5 0%, #ffefb0 100%);
  border: 2px solid rgba(255, 183, 3, 0.26);
  margin-bottom: 0;
}

.helper-box h3 {
  font-size: 1rem;
  font-weight: 900;
  color: #7a4400;
  margin-bottom: 0;
}

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

.helper-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.68);
  color: #8a5400;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.helper-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.modal-mobile-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.helper-content {
  display: grid;
  gap: 14px;
}

.helper-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.quick-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  scrollbar-gutter: stable;
}

.hint-toggle {
  padding: 10px 14px;
  min-height: 46px;
  border-radius: 999px;
  border: 1px solid rgba(122, 68, 0, 0.18);
  background: rgba(255, 255, 255, 0.74);
  color: #7a4400;
  font-size: 0.88rem;
  font-weight: 800;
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.hint-toggle.active {
  background: #fff;
  border-color: rgba(15, 124, 255, 0.38);
  color: var(--primary-dark);
  box-shadow: 0 0 0 4px rgba(15, 124, 255, 0.12);
}

.quick-btn {
  padding: 12px 15px;
  min-height: 48px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.9);
  border: 2px solid rgba(199, 119, 0, 0.14);
  color: #7a4400;
  font-size: 0.92rem;
  font-weight: 800;
  transition: transform 0.18s ease, border-color 0.18s ease, box-shadow 0.18s ease;
}

.quick-btn.hint-match {
  background: #ffffff;
  border-color: rgba(15, 124, 255, 0.42);
  color: var(--primary-dark);
  box-shadow: 0 0 0 4px rgba(15, 124, 255, 0.12);
}

.editor-label {
  display: block;
  margin-bottom: -6px;
  font-size: 1rem;
  font-weight: 900;
}

.editor-shell {
  position: relative;
  margin-bottom: 14px;
  border-radius: 22px;
  border: 2px solid rgba(121, 141, 172, 0.28);
  background: #0d1830;
  overflow: hidden;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}

.editor-shell:focus-within {
  border-color: var(--primary);
  box-shadow: 0 0 0 5px rgba(15, 124, 255, 0.16);
}

.editor-shell.has-error {
  border-color: rgba(220, 75, 95, 0.5);
  box-shadow: 0 0 0 5px rgba(220, 75, 95, 0.12);
}

.editor-highlight,
.sql-textarea {
  width: 100%;
  padding: 18px;
  font-family: var(--mono);
  font-size: 1.08rem;
  line-height: 1.75;
  white-space: pre-wrap;
  word-break: break-word;
}

.editor-highlight {
  position: absolute;
  inset: 0;
  z-index: 1;
  color: #eaf2ff;
  pointer-events: none;
}

.sql-textarea {
  position: relative;
  z-index: 2;
  min-height: 110px;
  background: transparent;
  color: transparent;
  -webkit-text-fill-color: transparent;
  border: none;
  resize: none;
  outline: none;
  caret-color: #8fe7ff;
}

.sql-textarea::placeholder {
  color: rgba(189, 205, 230, 0.56);
  -webkit-text-fill-color: rgba(189, 205, 230, 0.56);
}

.sql-textarea::selection {
  background: rgba(143, 231, 255, 0.22);
}

.editor-note {
  margin-top: -6px;
  margin-bottom: 0;
  font-size: 0.92rem;
  color: var(--text-soft);
}

.analysis-strip {
  margin-bottom: 16px;
  display: none;
}

.analysis-label {
  display: block;
  margin-bottom: 10px;
  font-size: 0.84rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.clause-checklist {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.clause-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  border-radius: 999px;
  border: 1px solid rgba(16, 33, 58, 0.1);
  background: #f4f8fc;
  color: var(--text-soft);
  font-size: 0.88rem;
  font-weight: 800;
}

.clause-pill.ok {
  background: var(--success-bg);
  border-color: rgba(18, 161, 80, 0.22);
  color: var(--success);
}

.clause-pill.missing {
  background: var(--danger-bg);
  border-color: rgba(220, 75, 95, 0.22);
  color: var(--danger);
}

.clause-pill.idle {
  background: #f5f8fb;
  border-color: rgba(81, 97, 119, 0.12);
  color: var(--text-faint);
}

.feedback-row {
  min-height: 64px;
  display: flex;
  align-items: center;
  padding: 14px 16px;
  border-radius: 18px;
  font-size: 1rem;
  font-weight: 800;
  line-height: 1.55;
  margin-bottom: 0;
}

.feedback-row.hint {
  background: #ebf6ff;
  border: 2px solid rgba(15, 124, 255, 0.18);
  color: var(--primary-ink);
}

.feedback-row.ok {
  background: var(--success-bg);
  border: 2px solid rgba(18, 161, 80, 0.24);
  color: var(--success);
}

.feedback-row.err {
  background: var(--danger-bg);
  border: 2px solid rgba(220, 75, 95, 0.2);
  color: var(--danger);
}

.result-panel {
  display: none;
  margin-bottom: 0;
  padding: 16px;
  border-radius: 20px;
  border: 2px solid rgba(15, 124, 255, 0.16);
  background: #f5fbff;
  scroll-margin-block: 24px 140px;
}

.result-panel.show {
  display: block;
}

.result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}

.result-title {
  font-size: 0.94rem;
  font-weight: 900;
  color: var(--primary-ink);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.result-meta {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--text-soft);
}

.result-message {
  padding: 12px 14px;
  border-radius: 14px;
  background: #eef6ff;
  color: var(--primary-ink);
  font-size: 0.94rem;
  font-weight: 700;
}

.result-message.err {
  background: #fff0f2;
  color: var(--danger);
}

.result-scroll {
  overflow: auto;
  border-radius: 14px;
  border: 1px solid rgba(16, 33, 58, 0.08);
  background: #fff;
}

.result-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 420px;
}

.result-table th,
.result-table td {
  padding: 12px 14px;
  text-align: left;
  border-bottom: 1px solid rgba(16, 33, 58, 0.08);
  font-size: 0.92rem;
}

.result-table th {
  background: #f2f8ff;
  color: var(--primary-ink);
  font-weight: 900;
}

.result-table td {
  color: var(--text);
  font-family: var(--mono);
}

.result-table tr:last-child td {
  border-bottom: none;
}

.result-row-highlight td {
  background: #ebfff3;
  color: #0d6f39;
  font-weight: 800;
}

.result-section + .result-section {
  margin-top: 14px;
}

.result-section-title {
  margin-bottom: 10px;
  font-size: 0.82rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--primary-ink);
}

.result-empty {
  padding: 16px;
  border-radius: 14px;
  background: #f7fbff;
  color: var(--text-soft);
  font-weight: 700;
}

.result-schema-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.result-schema-pill {
  padding: 10px 12px;
  border-radius: 999px;
  background: #eef6ff;
  border: 1px solid rgba(15, 124, 255, 0.16);
  color: var(--primary-ink);
  font-family: var(--mono);
  font-size: 0.84rem;
  font-weight: 700;
}

.modal-footer {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 12px;
  position: sticky;
  bottom: 0;
  z-index: 4;
  margin-top: -2px;
  padding-top: 14px;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.76) 0%, rgba(255, 255, 255, 0.98) 30%);
  backdrop-filter: blur(16px);
}

.ghost-btn {
  padding: 14px 20px;
  border-radius: 16px;
  background: #f1f6fb;
  color: var(--text);
  font-weight: 800;
  border: 2px solid rgba(16, 33, 58, 0.08);
  transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.modal-primary {
  padding: 14px 22px;
  border-radius: 16px;
  background: linear-gradient(135deg, var(--primary) 0%, #13b5ff 100%);
  color: #fff;
  font-weight: 900;
  box-shadow: 0 16px 28px rgba(15, 124, 255, 0.2);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}

.quick-btn:hover,
.quick-btn:focus-visible,
.hint-toggle:hover,
.hint-toggle:focus-visible,
.ghost-btn:hover,
.ghost-btn:focus-visible,
.modal-primary:hover,
.modal-primary:focus-visible {
  transform: translateY(-2px);
  outline: none;
}

.quick-btn:hover,
.quick-btn:focus-visible,
.hint-toggle:hover,
.hint-toggle:focus-visible {
  border-color: rgba(15, 124, 255, 0.32);
  box-shadow: 0 10px 18px rgba(15, 124, 255, 0.12);
}

.ghost-btn:hover,
.ghost-btn:focus-visible {
  border-color: rgba(15, 124, 255, 0.22);
  box-shadow: 0 12px 20px rgba(16, 33, 58, 0.08);
}

.modal-primary:hover,
.modal-primary:focus-visible {
  box-shadow: 0 20px 32px rgba(15, 124, 255, 0.26);
}

.quick-btn:active,
.hint-toggle:active,
.ghost-btn:active,
.modal-primary:active {
  transform: scale(0.985);
}

.kw {
  color: #6fe7ff;
  font-weight: 700;
}

.kw-fn {
  color: #ffe289;
  font-weight: 700;
}

.kw-table {
  color: #9fd3ff;
  font-weight: 700;
}

.sql-column {
  color: #f4f8ff;
}

.kw-star {
  color: #ffbf52;
  font-weight: 800;
}

.sql-string {
  color: #9ef0a4;
  font-weight: 700;
}

.sql-number {
  color: #ffd27a;
  font-weight: 700;
}

.sql-operator {
  color: #ffb0bc;
  font-weight: 700;
}

.sql-symbol {
  color: #8ea8cb;
}

.sql-error {
  color: #ffd0d6;
  text-decoration: underline wavy #ff7e91 2px;
  text-underline-offset: 4px;
}

.sql-gap {
  display: inline-block;
  margin: 0 2px;
  padding: 1px 7px;
  border-radius: 8px;
  background: rgba(220, 75, 95, 0.2);
  color: #ffb5bf;
  border-bottom: 2px solid #ff7e91;
  font-size: 0.88em;
  font-weight: 700;
}

.bingo-toast {
  position: fixed;
  top: 92px;
  left: 50%;
  transform: translateX(-50%) translateY(-16px);
  padding: 16px 28px;
  border-radius: 999px;
  background: linear-gradient(135deg, #0f7cff 0%, #12a150 100%);
  color: #fff;
  font-size: 1.1rem;
  font-weight: 900;
  box-shadow: 0 24px 40px rgba(15, 124, 255, 0.22);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.22s ease, opacity 0.22s ease;
  z-index: 300;
}

.bingo-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

.correct-flash {
  position: fixed;
  inset: 0;
  background: rgba(18, 161, 80, 0.08);
  opacity: 0;
  pointer-events: none;
  z-index: 150;
}

.correct-flash.flash {
  animation: flash 0.38s ease;
}

@keyframes flash {
  0% { opacity: 0; }
  30% { opacity: 1; }
  100% { opacity: 0; }
}

.fullhouse-overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(5, 18, 35, 0.88);
  backdrop-filter: blur(12px);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.24s ease;
  z-index: 500;
}

.fullhouse-overlay.show {
  opacity: 1;
  pointer-events: auto;
}

.fullhouse-card {
  width: min(720px, 100%);
  padding: 42px 26px;
  border-radius: 34px;
  text-align: center;
  background: linear-gradient(180deg, #ffffff 0%, #edf8ff 68%, #e6fff0 100%);
  box-shadow: 0 32px 90px rgba(0, 0, 0, 0.22);
}

.fullhouse-emoji {
  font-size: 4.6rem;
  margin-bottom: 10px;
}

.fullhouse-title {
  font-size: clamp(2.2rem, 5vw, 4rem);
  font-weight: 900;
  letter-spacing: -0.05em;
}

.fullhouse-sub {
  margin-top: 14px;
  font-size: 1.12rem;
  line-height: 1.75;
  color: var(--text-soft);
}

.confetti-container {
  position: fixed;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
  z-index: 999;
}

.confetti-piece {
  position: absolute;
  top: -12px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  from {
    transform: translateY(0) rotate(0deg);
    opacity: 1;
  }
  to {
    transform: translateY(110vh) rotate(720deg);
    opacity: 0;
  }
}

.shake {
  animation: shake 0.36s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-5px); }
  40% { transform: translateX(5px); }
  60% { transform: translateX(-4px); }
  80% { transform: translateX(4px); }
}

::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-thumb {
  background: rgba(81, 97, 119, 0.3);
  border-radius: 999px;
}

@media (max-width: 1200px) {
  .page-shell {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .sidebar {
    position: static;
    height: auto;
    max-height: none;
  }

  .modal-overlay {
    padding: 24px;
  }

  body.modal-open .sidebar {
    position: static;
    width: auto;
    height: auto;
    max-height: none;
    z-index: auto;
  }
}

@media (max-width: 900px) {
  html {
    font-size: 17px;
  }

  .topbar,
  .page-shell {
    padding-left: 16px;
    padding-right: 16px;
  }

  .topbar {
    padding-top: 16px;
    padding-bottom: 16px;
    align-items: flex-start;
    flex-direction: column;
  }

  .topbar-actions {
    width: 100%;
    justify-content: stretch;
  }

  .hero-panel {
    grid-template-columns: 1fr;
    padding: 22px;
  }

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

  .board-header {
    flex-direction: column;
  }

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

  .board-panel,
  .how-to-play,
  .sidebar,
  .hero-panel {
    border-radius: 24px;
  }

  .bingo-grid {
    min-width: 720px;
  }

  .modal-top,
  .modal-body {
    padding-left: 18px;
    padding-right: 18px;
  }

  .board-scroll {
    padding: 8px 6px 12px;
  }

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

  .quick-btn,
  .guide-link-btn,
  .hint-toggle {
    width: 100%;
    justify-content: center;
  }
}

@media (max-width: 640px) {
  body.modal-open .topbar,
  body.modal-open .content {
    opacity: 0;
    filter: none;
    transform: none;
  }

  html {
    font-size: 16px;
  }

  .topbar {
    gap: 14px;
  }

  body {
    background:
      radial-gradient(circle at top left, rgba(255, 183, 3, 0.14), transparent 26%),
      radial-gradient(circle at top right, rgba(15, 124, 255, 0.14), transparent 22%),
      linear-gradient(180deg, #fbfeff 0%, #edf6ff 100%);
  }

  .brand-badge {
    width: 54px;
    height: 54px;
  }

  .brand {
    width: 100%;
  }

  .brand-subtitle {
    display: none;
  }

  .label-full {
    display: none;
  }

  .label-short {
    display: inline;
  }

  .stat-pill {
    min-width: 0;
    width: 100%;
    padding: 10px 14px;
  }

  .stat-label {
    font-size: 0.74rem;
  }

  .topbar-actions {
    width: 100%;
  }

  .secondary-link-btn,
  .primary-btn,
  .secondary-btn,
  .reset-btn {
    width: 100%;
    justify-content: center;
  }

  .page-shell {
    gap: 16px;
    padding-top: 16px;
    padding-bottom: 20px;
  }

  .topbar-actions {
    gap: 10px;
  }

  .board-panel,
  .sidebar {
    padding: 16px;
    border-radius: 22px;
  }

  .board-header {
    margin-bottom: 14px;
  }

  .board-header h2,
  .sidebar h2 {
    font-size: 1.2rem;
  }

  .legend {
    display: none;
  }

  .board-scroll {
    margin-inline: -2px;
    padding: 4px;
    border-radius: 20px;
    overflow: visible;
  }

  .bingo-grid {
    min-width: 0;
    gap: 8px;
  }

  .cell {
    aspect-ratio: 1 / 1;
    min-height: 0;
    display: grid;
    place-items: center;
    padding: 8px;
    border-width: 2px;
    border-radius: 18px;
    gap: 0;
  }

  .cell.free-cell {
    display: grid;
    place-items: center;
    padding: 8px;
  }

  .cell-table,
  .cell-hint,
  .cell-state,
  .cell-preview-wrap,
  .difficulty-badge,
  .cell-top,
  .cell-bottom {
    display: none;
  }

  .cell-mobile-shell {
    display: grid;
    place-items: center;
    width: 100%;
    height: 100%;
  }

  .cell-mobile-badge {
    display: inline-flex;
    min-width: 48px;
    min-height: 48px;
    padding: 0;
    border-radius: 14px;
    align-items: center;
    justify-content: center;
    font-size: 1.15rem;
    font-weight: 900;
    box-shadow: 0 8px 18px rgba(16, 33, 58, 0.12);
  }

  .cell.solved {
    box-shadow: 0 20px 28px rgba(18, 161, 80, 0.3), inset 0 0 0 2px rgba(255, 255, 255, 0.16);
  }

  .cell.solved .cell-mobile-badge {
    background: rgba(255, 255, 255, 0.16);
    border: 2px solid rgba(255, 255, 255, 0.26);
    color: #ffffff;
    box-shadow: none;
  }

  .cell.solved::after {
    display: none;
  }

  .cell.free-cell::before {
    content: "★";
    display: grid;
    place-items: center;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    background: rgba(255, 183, 3, 0.2);
    color: #8a5200;
    font-size: 1.25rem;
    font-weight: 900;
    box-shadow: 0 8px 18px rgba(255, 183, 3, 0.16);
  }

  .cell.free-cell .cell-hint {
    display: none;
  }

  .sidebar {
    height: auto;
    max-height: none;
  }

  body.modal-open .sidebar {
    position: fixed;
    left: 12px;
    right: 12px;
    bottom: 12px;
    top: auto;
    width: auto;
    height: min(46dvh, 420px);
    max-height: min(46dvh, 420px);
    padding: 14px;
    border-radius: 22px;
    overflow: hidden;
    z-index: 320;
    opacity: 0;
    filter: none;
    transform: translateY(18px);
    pointer-events: none;
    box-shadow: 0 22px 44px rgba(16, 33, 58, 0.22);
  }

  body.modal-open .sidebar.mobile-open {
    opacity: 1;
    transform: translateY(0);
    pointer-events: auto;
  }

  .sidebar-content {
    max-height: min(46vh, 420px);
    padding-right: 4px;
    margin-right: -4px;
  }

  .table-card-header {
    padding: 16px;
  }

  .col-row {
    grid-template-columns: 36px minmax(0, 1fr) auto;
    padding: 9px 10px;
  }

  .modal-overlay {
    padding: 0;
    align-items: stretch;
    justify-content: stretch;
    background: linear-gradient(180deg, rgba(248, 252, 255, 0.98) 0%, rgba(238, 247, 255, 0.99) 100%);
  }

  .modal {
    width: 100%;
    max-height: none;
    height: 100dvh;
    border-radius: 0;
    background: linear-gradient(180deg, #ffffff 0%, #f8fbff 100%);
  }

  .modal-top {
    position: static;
    top: auto;
    z-index: auto;
    padding: 18px 16px 14px;
  }

  .modal-body {
    padding: 16px;
    padding-bottom: calc(18px + env(safe-area-inset-bottom, 0));
    gap: 16px;
  }

  .modal-question {
    font-size: 1.45rem;
    line-height: 1.2;
    margin-bottom: 14px;
  }

  .modal-context {
    padding: 14px;
    border-radius: 18px;
    line-height: 1.5;
  }

  .competition-note {
    display: none;
  }

  .modal-chips {
    gap: 8px;
    margin-top: 12px;
  }

  .chip {
    padding: 7px 10px;
    font-size: 0.8rem;
  }

  .helper-header {
    flex-direction: column;
    align-items: stretch;
    margin-bottom: 0;
  }

  .modal-mobile-tools {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
  }

  .helper-actions {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    align-items: stretch;
  }

  .helper-box {
    padding: 14px;
    border-radius: 18px;
  }

  .helper-title-row {
    justify-content: space-between;
  }

  .helper-count {
    font-size: 0.7rem;
    letter-spacing: 0.04em;
  }

  .sidebar-head {
    margin-bottom: 0;
  }

  .sidebar-mobile-toggle,
  .helper-mobile-toggle,
  .modal-tables-toggle {
    display: inline-flex;
    width: 100%;
  }

  body.modal-open .sidebar.mobile-open .sidebar-mobile-toggle {
    display: none;
  }

  .sidebar-content {
    margin-top: 12px;
  }

  .helper-content {
    margin-top: 12px;
  }

  .quick-actions {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 8px;
    max-height: min(32vh, 220px);
    overflow: auto;
    padding-right: 4px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: none;
  }

  .quick-btn {
    min-width: 0;
    width: 100%;
    min-height: 44px;
    padding: 10px 8px;
    font-size: 0.82rem;
  }

  .sidebar:not(.mobile-open) .sidebar-content,
  .helper-box:not(.mobile-open) .helper-content {
    display: none;
  }

  .editor-highlight,
  .sql-textarea {
    padding: 14px;
    font-size: 1rem;
    line-height: 1.65;
  }

  .feedback-row {
    min-height: 0;
    padding: 12px 14px;
    font-size: 0.94rem;
  }

  .result-scroll {
    border-radius: 12px;
  }

  .result-table {
    min-width: 340px;
  }

  .modal-footer {
    position: static;
    margin-top: 2px;
    flex-direction: column-reverse;
    padding-top: 6px;
    padding-bottom: env(safe-area-inset-bottom, 0);
    background: transparent;
    backdrop-filter: none;
  }

  .modal-footer button {
    width: 100%;
    min-height: 50px;
  }

  .bingo-toast {
    top: 14px;
    width: calc(100vw - 24px);
    max-width: 360px;
    padding: 14px 18px;
    font-size: 0.98rem;
  }

  .legend {
    display: none;
  }
}

@media (max-width: 420px) {
  .modal-mobile-tools {
    grid-template-columns: 1fr;
  }

  .brand-subtitle {
    font-size: 0.88rem;
    line-height: 1.45;
  }

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

  .secondary-link-btn,
  .guide-link-btn {
    width: 100%;
  }

  .bingo-grid {
    gap: 6px;
  }

  .cell {
    padding: 7px;
    border-radius: 16px;
  }

  .cell-mobile-badge {
    min-width: 42px;
    min-height: 42px;
    border-radius: 10px;
    font-size: 1rem;
  }
}
