/* =========================================================
   Picross · 像素画谜
   Retro Handheld Arcade & Stamp Workshop Theme
   ========================================================= */

:root {
  --bg-deep: #0b1120;
  --bg-mid: #1e1b4b;
  --bg-radial: radial-gradient(circle at 50% 30%, #1e1b4b 0%, #0f172a 65%, #050814 100%);

  --card-bg: rgba(30, 41, 59, 0.75);
  --card-border: rgba(99, 102, 241, 0.25);
  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.1);

  --console-body: #1e293b;
  --console-frame: #0f172a;
  --console-bevel: inset 0 2px 4px rgba(255, 255, 255, 0.1), inset 0 -2px 4px rgba(0, 0, 0, 0.5);

  --cell-empty-bg: #1e293b;
  --cell-empty-hover: #334155;
  --cell-border: #334155;
  --subgrid-divider: #6366f1;

  --cell-paint-bg: #38bdf8;
  --cell-paint-shadow: inset 0 -2px 0 #0284c7, 0 2px 4px rgba(0, 0, 0, 0.3);
  --cell-cross-color: #f87171;

  --accent-cyan: #38bdf8;
  --accent-pink: #f43f5e;
  --accent-gold: #f59e0b;
  --accent-indigo: #6366f1;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --radius-lg: 16px;
  --radius-md: 10px;
  --radius-sm: 6px;

  --font-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg-deep);
  background-image: var(--bg-radial);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  line-height: 1.5;
  overflow-x: hidden;
  position: relative;
}

/* Background floating particles */
body::before {
  content: "";
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1.5px 1.5px at 20px 30px, rgba(255, 255, 255, 0.25), rgba(0,0,0,0)),
    radial-gradient(2px 2px at 90px 140px, rgba(99, 102, 241, 0.3), rgba(0,0,0,0)),
    radial-gradient(1px 1px at 160px 80px, rgba(56, 189, 248, 0.3), rgba(0,0,0,0)),
    radial-gradient(2px 2px at 240px 220px, rgba(244, 63, 94, 0.25), rgba(0,0,0,0));
  background-repeat: repeat;
  background-size: 280px 280px;
  opacity: 0.6;
  z-index: 0;
}

/* =========================================================
   Layout & Container
   ========================================================= */

.game-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  position: relative;
  z-index: 1;
}

/* System Tray (Header) */
.system-tray {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px;
  background: rgba(15, 23, 42, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: sticky;
  top: 0;
  z-index: 20;
}

.tray-left, .tray-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.tray-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  height: 34px;
  padding: 0 12px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.tray-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  border-color: rgba(255, 255, 255, 0.25);
  transform: translateY(-1px);
}

.tray-btn:active {
  transform: translateY(1px);
  box-shadow: none;
}

.tray-btn.icon-btn {
  width: 34px;
  padding: 0;
  font-size: 15px;
}

.tray-btn.sound-muted {
  opacity: 0.5;
  filter: grayscale(1);
}

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

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

.brand-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  background: linear-gradient(135deg, #f8fafc 20%, #38bdf8 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

/* =========================================================
   Game Stage & Dual Wings (Desktop layout)
   ========================================================= */

.game-stage {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 20px;
  padding: 24px 16px;
  max-width: 1260px;
  margin: 0 auto;
  width: 100%;
}

.side-wing {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wing-card {
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 16px;
  box-shadow: var(--card-shadow);
}

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

.wing-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: 0.5px;
}

.wing-action-btn {
  background: none;
  border: none;
  color: var(--accent-cyan);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.wing-action-btn:hover {
  text-decoration: underline;
}

.wing-stamps-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  margin-bottom: 14px;
}

.mini-stamp {
  width: 100%;
  aspect-ratio: 1;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 4px;
  position: relative;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.mini-stamp:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
}

.mini-stamp.stamp-unlocked {
  background: rgba(30, 41, 59, 0.9);
  border-color: rgba(56, 189, 248, 0.35);
}

.mini-stamp.stamp-locked {
  opacity: 0.4;
  cursor: default;
}

.mini-pixel-canvas canvas {
  image-rendering: pixelated;
  max-width: 100%;
  max-height: 32px;
}

.mini-stars {
  font-size: 8px;
  color: var(--accent-gold);
  line-height: 1;
  margin-top: 2px;
}

.lock-icon {
  font-size: 14px;
  color: var(--text-dim);
}

.chapter-badges-row {
  margin-top: 8px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.badge-label {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-bottom: 6px;
}

.badges-container {
  display: flex;
  gap: 8px;
}

.chapter-badge {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(15, 23, 42, 0.6);
}

.chapter-badge.badge-gold {
  background: radial-gradient(circle, #f59e0b, #b45309);
  border-color: #fde047;
  box-shadow: 0 0 10px rgba(245, 158, 11, 0.4);
}

.chapter-badge.badge-silver {
  background: radial-gradient(circle, #94a3b8, #475569);
  border-color: #cbd5e1;
}

.chapter-badge.badge-locked {
  opacity: 0.3;
  filter: grayscale(1);
}

.workshop-btn {
  width: 100%;
  margin-top: 14px;
  padding: 10px;
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.2), rgba(168, 85, 247, 0.2));
  border: 1px dashed rgba(168, 85, 247, 0.4);
  border-radius: var(--radius-sm);
  color: #c084fc;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.workshop-btn:hover {
  background: linear-gradient(135deg, rgba(99, 102, 241, 0.35), rgba(168, 85, 247, 0.35));
  border-color: #c084fc;
  transform: translateY(-1px);
}

/* Right Wing: Quick Guide */
.wing-guide-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text-main);
}

.guide-bullets {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 12px;
  color: var(--text-muted);
}

.guide-bullets li strong {
  color: var(--text-main);
}

.star-rating-hint {
  margin-top: 16px;
  padding: 10px;
  background: rgba(15, 23, 42, 0.5);
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 11px;
  color: var(--accent-gold);
}

/* =========================================================
   Center Console (Main Game Machine)
   ========================================================= */

.center-console {
  flex: 1;
  max-width: 720px;
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 18px;
}

.level-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  max-width: 700px;
  background: var(--card-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--card-border);
  border-radius: var(--radius-lg);
  padding: 10px 18px;
  box-shadow: var(--card-shadow);
}

.nav-arrow-btn {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.15s ease, background 0.15s ease;
}

.nav-arrow-btn:hover {
  background: rgba(51, 65, 85, 0.8);
  transform: scale(1.08);
}

.level-meta {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.chapter-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--accent-cyan);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.level-selector-trigger {
  background: none;
  border: none;
  color: var(--text-main);
  font-size: 16px;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px;
  border-radius: 4px;
}

.level-selector-trigger:hover {
  background: rgba(255, 255, 255, 0.06);
}

.down-arrow {
  font-size: 10px;
  color: var(--text-muted);
}

/* Handheld Board Frame */
.board-frame {
  background: var(--console-frame);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  box-shadow: var(--console-bevel), 0 20px 35px -10px rgba(0, 0, 0, 0.7);
  border: 2px solid rgba(255, 255, 255, 0.08);
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  max-width: 700px;
  overflow-x: auto;
}

.picross-board-layout {
  display: grid;
  grid-template-areas:
    "corner cols"
    "rows   cells";
  grid-template-columns: auto auto;
  grid-template-rows: auto auto;
  background: #141c2e;
  border: 2px solid #334155;
  border-radius: var(--radius-md);
  padding: 6px;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.6);
  width: fit-content;
  margin: 0 auto;
}

.board-corner {
  grid-area: corner;
  background: rgba(15, 23, 42, 0.4);
  border-right: 2px solid #334155;
  border-bottom: 2px solid #334155;
}

.board-col-clues {
  grid-area: cols;
  display: grid;
  border-bottom: 2px solid #334155;
}

.col-clue {
  width: var(--cell-size, 40px);
  min-width: 18px;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  align-items: center;
  padding: 8px 1px;
  gap: 3px;
  border-right: 1px solid rgba(51, 65, 85, 0.5);
  transition: opacity 0.2s ease;
}

.col-clue:last-child {
  border-right: none;
}

.col-clue.subgrid-border-col {
  border-right: 2px solid var(--subgrid-divider);
}

.col-clue.line-satisfied {
  opacity: 0.35;
}

.board-row-clues {
  grid-area: rows;
  display: grid;
  border-right: 2px solid #334155;
}

.row-clue {
  height: var(--cell-size, 40px);
  min-height: 18px;
  display: flex;
  flex-direction: row;
  justify-content: flex-end;
  align-items: center;
  padding: 2px 10px;
  gap: clamp(4px, calc(var(--cell-size, 40px) * 0.15), 10px);
  border-bottom: 1px solid rgba(51, 65, 85, 0.5);
  transition: opacity 0.2s ease;
}

.row-clue:last-child {
  border-bottom: none;
}

.row-clue.subgrid-border-row {
  border-bottom: 2px solid var(--subgrid-divider);
}

.row-clue.line-satisfied {
  opacity: 0.35;
}

.clue-num {
  font-family: var(--font-mono);
  font-size: clamp(10px, calc(var(--cell-size, 40px) * 0.38), 18px);
  font-weight: 700;
  color: #e2e8f0;
  text-align: center;
  line-height: 1.1;
}

.clue-zero {
  color: var(--text-dim);
}

.board-grid-cells {
  grid-area: cells;
  display: grid;
}

/* Individual Cell Button */
.picross-cell {
  width: var(--cell-size, 40px);
  height: var(--cell-size, 40px);
  min-width: 18px;
  min-height: 18px;
  background: var(--cell-empty-bg);
  border: 1px solid var(--cell-border);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(13px, calc(var(--cell-size, 40px) * 0.6), 34px);
  font-weight: 800;
  transition: background 0.1s ease, transform 0.08s ease;
  position: relative;
  outline: none;
}

.picross-cell:hover {
  background: var(--cell-empty-hover);
}

.picross-cell.subgrid-border-col {
  border-right: 2px solid var(--subgrid-divider);
}

.picross-cell.subgrid-border-row {
  border-bottom: 2px solid var(--subgrid-divider);
}

/* Painted state */
.picross-cell.cell-painted {
  background: var(--cell-paint-bg);
  box-shadow: var(--cell-paint-shadow);
  border-color: #0284c7;
  transform: scale(0.96);
  border-radius: 2px;
}

/* Crossed state */
.picross-cell.cell-crossed {
  background: #1e293b;
  color: var(--cell-cross-color);
  font-family: var(--font-mono);
}

/* Error flash */
.picross-cell.cell-error {
  animation: cellShake 0.3s cubic-bezier(0.36, 0.07, 0.19, 0.97) both;
  background: #ef4444 !important;
  border-color: #b91c1c !important;
}

/* Hint flash */
.picross-cell.cell-hint-flash {
  animation: cellPulse 0.5s ease-in-out infinite;
  box-shadow: 0 0 12px var(--accent-cyan);
}

@keyframes cellShake {
  10%, 90% { transform: translate3d(-1px, 0, 0); }
  20%, 80% { transform: translate3d(2px, 0, 0); }
  30%, 50%, 70% { transform: translate3d(-2px, 0, 0); }
  40%, 60% { transform: translate3d(2px, 0, 0); }
}

@keyframes cellPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

/* =========================================================
   Console Action Controls
   ========================================================= */

.console-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.tools-toggle-group {
  display: flex;
  gap: 12px;
  width: 100%;
}

.tool-btn {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 48px;
  background: rgba(30, 41, 59, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.2);
  transition: all 0.15s ease;
}

.tool-btn:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.25);
}

.tool-btn:active {
  transform: translateY(2px);
}

.tool-btn.tool-active {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.25), rgba(99, 102, 241, 0.25));
  border-color: var(--accent-cyan);
  color: #fff;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.3), inset 0 1px 0 rgba(255, 255, 255, 0.2);
}

.tool-icon {
  font-size: 18px;
}

.stat-pills {
  display: flex;
  justify-content: space-around;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-md);
  padding: 8px 16px;
}

.stat-pill {
  display: flex;
  align-items: center;
  gap: 8px;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
}

.stat-value {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
}

.aux-actions {
  display: flex;
  gap: 10px;
}

.aux-btn {
  flex: 1;
  height: 40px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  transition: all 0.15s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.aux-btn:hover {
  background: rgba(51, 65, 85, 0.9);
  transform: translateY(-1px);
}

.aux-btn:active {
  transform: translateY(1px);
}

/* =========================================================
   Modals & Dialogs
   ========================================================= */

.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(5, 8, 20, 0.85);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

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

.modal-content {
  background: #1e293b;
  border: 1px solid rgba(99, 102, 241, 0.35);
  border-radius: var(--radius-lg);
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  max-width: 520px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  padding: 24px;
  position: relative;
  transform: scale(0.94);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.modal-open .modal-content {
  transform: scale(1);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 700;
}

.modal-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 16px;
}

.modal-close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
}

.modal-close-btn:hover {
  color: #fff;
}

.modal-primary-btn {
  background: linear-gradient(135deg, #38bdf8, #6366f1);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  font-size: 14px;
  font-weight: 600;
  padding: 10px 20px;
  cursor: pointer;
  box-shadow: 0 4px 12px rgba(56, 189, 248, 0.3);
  transition: all 0.15s ease;
}

.modal-primary-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(56, 189, 248, 0.4);
}

.modal-secondary-btn {
  background: rgba(51, 65, 85, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 600;
  padding: 10px 16px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-secondary-btn:hover {
  background: rgba(71, 85, 105, 0.9);
}

/* Win Fanfare Card */
.win-card {
  text-align: center;
  align-items: center;
}

.win-sparkles {
  font-size: 28px;
  margin-bottom: 4px;
}

.win-heading {
  font-size: 22px;
  font-weight: 800;
  background: linear-gradient(135deg, #38bdf8, #ec4899);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  margin-bottom: 12px;
}

.win-stamp-box {
  width: 200px;
  height: 200px;
  background: rgba(15, 23, 42, 0.8);
  border: 2px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
  box-shadow: inset 0 2px 10px rgba(0, 0, 0, 0.5), 0 0 25px rgba(56, 189, 248, 0.2);
}

.win-stamp-canvas {
  image-rendering: pixelated;
}

.stamp-drop-anim {
  animation: stampDrop 0.45s cubic-bezier(0.175, 0.885, 0.32, 1.275) both;
}

@keyframes stampDrop {
  0% { transform: scale(2.5) rotate(-15deg); opacity: 0; }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.win-level-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-main);
  margin-bottom: 6px;
}

.win-stars-row {
  display: flex;
  gap: 6px;
  font-size: 26px;
  margin-bottom: 8px;
}

.star-earned {
  color: var(--accent-gold);
  text-shadow: 0 0 12px rgba(245, 158, 11, 0.6);
}

.star-empty {
  color: rgba(255, 255, 255, 0.15);
}

.win-rating-summary {
  font-size: 13px;
  color: var(--accent-cyan);
  margin-bottom: 16px;
}

.win-stats-grid {
  display: flex;
  gap: 20px;
  margin-bottom: 20px;
  background: rgba(15, 23, 42, 0.5);
  padding: 8px 24px;
  border-radius: var(--radius-md);
}

.win-stat-item {
  display: flex;
  flex-direction: column;
}

.win-stat-lbl {
  font-size: 11px;
  color: var(--text-muted);
}

.win-stat-val {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 700;
}

.win-btn-row {
  display: flex;
  gap: 10px;
  width: 100%;
}

.win-btn-row button {
  flex: 1;
}

/* Album Dialog */
.album-content-scroll, .levels-content-scroll, .help-scroll-content {
  overflow-y: auto;
  max-height: 60vh;
  padding-right: 6px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.album-chapter-header, .levels-chapter-header {
  font-size: 14px;
  font-weight: 700;
  color: var(--accent-cyan);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 6px;
}

.album-chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  gap: 10px;
}

.album-stamp-card {
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 8px 4px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: transform 0.15s ease, border-color 0.15s ease;
}

.album-stamp-card:hover {
  transform: translateY(-2px);
  border-color: var(--accent-cyan);
}

.album-stamp-card canvas {
  image-rendering: pixelated;
  max-height: 50px;
}

.album-card-title {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-main);
  text-align: center;
}

.album-card-stars {
  font-size: 9px;
  color: var(--accent-gold);
}

.lock-placeholder {
  font-size: 20px;
  opacity: 0.3;
}

/* Levels Select Grid */
.levels-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(130px, 1fr));
  gap: 8px;
}

.level-select-btn {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: rgba(15, 23, 42, 0.6);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
}

.level-select-btn:hover {
  background: rgba(51, 65, 85, 0.8);
  border-color: var(--accent-cyan);
}

.level-select-btn.level-active {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.15);
}

.level-select-btn.level-cleared .lvl-stars {
  color: var(--accent-gold);
}

.lvl-num {
  font-family: var(--font-mono);
  font-weight: 700;
  color: var(--text-muted);
}

.lvl-stars {
  font-size: 10px;
  color: var(--text-dim);
}

/* Custom Workshop */
.custom-toolbar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 14px;
}

.custom-select {
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 6px 12px;
  font-size: 13px;
  outline: none;
}

.custom-grid-wrapper {
  display: flex;
  justify-content: center;
  align-items: center;
  margin: 10px 0;
}

.custom-editor-grid {
  display: grid;
  background: #141c2e;
  border: 2px solid #334155;
  border-radius: var(--radius-sm);
  padding: 4px;
}

.custom-cell {
  width: 28px;
  height: 28px;
  background: #1e293b;
  border: 1px solid #334155;
  cursor: pointer;
  padding: 0;
}

.custom-cell.custom-filled {
  background: var(--accent-cyan);
}

.custom-msg {
  font-size: 12px;
  text-align: center;
  min-height: 20px;
  margin-top: 6px;
}

.custom-msg.error {
  color: #f87171;
}

.custom-msg.success {
  color: #4ade80;
}

.custom-footer {
  margin-top: 14px;
  display: flex;
  justify-content: flex-end;
}

/* Help Dialog Content */
.help-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.help-section h3 {
  font-size: 14px;
  color: var(--accent-cyan);
}

.help-section p {
  font-size: 12px;
  color: var(--text-muted);
}

/* =========================================================
   Mobile Responsiveness & Ad Safety Buffer (Mandatory Rule)
   ========================================================= */

.ad-safe-buffer {
  display: none;
}

@media (max-width: 900px) {
  .side-wing {
    display: none;
  }

  .game-stage {
    padding: 16px 12px;
    gap: 16px;
  }

  .center-console {
    max-width: 100%;
  }
}

@media (max-width: 768px) {
  /* Mobile Bottom Safety Buffer for Banner Ads */
  body {
    padding-bottom: max(68px, calc(16px + env(safe-area-inset-bottom)));
  }

  .ad-safe-buffer {
    display: block;
    height: max(68px, calc(16px + env(safe-area-inset-bottom)));
    width: 100%;
    pointer-events: none;
  }

  .system-tray {
    padding: 8px 12px;
  }

  .brand-title {
    font-size: 16px;
  }

  .level-banner {
    padding: 8px 12px;
  }

  .level-selector-trigger {
    font-size: 14px;
  }

  .board-frame {
    padding: 10px 8px;
    border-radius: var(--radius-md);
  }

  .tool-btn {
    height: 44px;
    font-size: 14px;
  }

  .aux-btn {
    height: 38px;
    font-size: 13px;
  }
}

/* Small mobile optimizations */
@media (max-width: 480px) {
  .board-frame {
    padding: 8px 4px;
  }

  .modal-content {
    padding: 16px;
  }

  .win-stamp-box {
    width: 150px;
    height: 150px;
  }
}

/* =========================================================
   Accessibility & Reduced Motion
   ========================================================= */

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
    scroll-behavior: auto !important;
  }
}
