/* ─── CSS Variables ─────────────────────────── */
:root {
  --bg: #F5F8FC;
  --surface: #FFFFFF;
  --text: #344861;
  --text-secondary: #6B7B8D;
  --text-muted: #94A3B8;
  --primary: #325AAF;
  --primary-hover: #2A4E99;
  --border: #E2E8F0;
  --shadow: 0 2px 8px rgba(0,0,0,.08);
  --shadow-hover: 0 4px 16px rgba(0,0,0,.12);
  --radius: 8px;
  --radius-sm: 4px;
  --nav-height: 48px;
  --status-height: 44px;
  --control-height: 64px;
}

[data-theme="dark"] {
  --bg: #121212;
  --surface: #1E1E1E;
  --text: #E0E0E0;
  --text-secondary: #A0AEC0;
  --text-muted: #718096;
  --primary: #5B8DEF;
  --primary-hover: #4A7BD9;
  --border: #2D3748;
  --shadow: 0 2px 8px rgba(0,0,0,.3);
  --shadow-hover: 0 4px 16px rgba(0,0,0,.4);
}

/* ─── Base ──────────────────────────────────── */
html {
  overflow: hidden;
  height: 100dvh;
}
body {
  background: var(--bg);
  color: var(--text);
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  overflow: hidden;
  height: 100dvh;
}

/* ─── Navbar ───────────────────────────────── */
.nav-bar {
  background: transparent;
  position: relative;
  z-index: 100;
  height: 40px;
}

.nav-inner {
  max-width: 800px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 16px;
  height: 100%;
}

.nav-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-right {
  display: flex;
  align-items: center;
  gap: 8px;
}

.nav-back-btn, .nav-icon-btn {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 8px;
  display: flex;
  align-items: center;
  border-radius: 6px;
  min-width: 44px;
  min-height: 44px;
  justify-content: center;
}
.nav-back-btn:hover, .nav-icon-btn:hover {
  background: rgba(0,0,0,0.06);
}
[data-theme="dark"] .nav-back-btn:hover,
[data-theme="dark"] .nav-icon-btn:hover {
  background: rgba(255,255,255,0.08);
}

.nav-hamburger {
  display: none;
}
.nav-logo-text {
  display: none;
}
.btn-new-game {
  display: none;
  background: var(--primary);
  color: #fff;
  border: none;
  padding: 6px 16px;
  border-radius: var(--radius);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.15s;
}
.btn-new-game:hover { background: var(--primary-hover); }

/* ─── Side Menu ────────────────────────────── */
.side-menu-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.4);
  z-index: 200;
}
.side-menu-overlay.open { display: block; }

.side-menu {
  position: fixed;
  top: 0;
  left: -280px;
  width: 280px;
  height: 100%;
  background: var(--surface);
  z-index: 201;
  transition: left 0.25s ease;
  overflow-y: auto;
}
.side-menu.open { left: 0; }

.side-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border);
}

.side-menu-close {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
}

.side-menu-items { padding: 8px 0; }

.side-menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  background: none;
  border: none;
  width: 100%;
  font-size: 0.95rem;
  transition: background 0.15s;
}
.side-menu-item:hover { background: var(--bg); }
.side-menu-divider { height: 1px; background: var(--border); margin: 4px 16px; }
.side-menu-app { color: var(--primary); }
.side-menu-app:hover { background: rgba(50,90,175,0.08); }

/* ─── Game Status Bar ──────────────────────── */
.game-status-bar {
  display: none; /* Hidden - Android app doesn't show this */
}

.game-status-inner {
  max-width: 800px;
  margin: 0 auto;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 0 16px;
  height: 100%;
}
.game-status-inner > :first-child { justify-self: start; }
.game-status-inner > :nth-child(2) { justify-self: center; }
.game-status-inner > :last-child { justify-self: end; }

/* Difficulty selector (combobox style) */
.difficulty-selector {
  position: relative;
}

.difficulty-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  background: none;
  border: none;
  color: var(--text);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.difficulty-btn:hover { background: var(--bg); }
.difficulty-btn svg { opacity: 0.5; }

.difficulty-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-hover);
  z-index: 50;
  min-width: 140px;
  padding: 4px 0;
}
.difficulty-dropdown.open { display: block; }

.difficulty-dropdown button {
  display: block;
  width: 100%;
  padding: 10px 16px;
  text-align: left;
  background: none;
  border: none;
  color: var(--text);
  font-size: 0.9rem;
  cursor: pointer;
  transition: background 0.1s;
}
.difficulty-dropdown button:hover { background: var(--bg); }
.difficulty-dropdown button.active {
  color: var(--primary);
  font-weight: 700;
}

.game-stat {
  font-size: 0.85rem;
  color: var(--text-secondary);
}
.game-stat strong {
  color: var(--text);
  font-variant-numeric: tabular-nums;
}

.timer { display: flex; align-items: center; gap: 4px; }

/* ─── Main Layout ──────────────────────────── */
.main-layout {
  display: flex;
  justify-content: center;
  padding: 0 4px;
  height: calc(100dvh - 40px);
  overflow: hidden;
}

.game-area {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 600px;
  height: 100%;
  overflow: hidden;
}

.game-minimap {
  position: fixed;
  border: 1px solid #bbb;
  border-radius: 2px;
  background: #fff;
  z-index: 10;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  pointer-events: none;
}
[data-theme="dark"] .game-minimap {
  border-color: #555;
  background: #1E1E1E;
}

.board-container {
  flex: 1 1 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  width: 100%;
  min-height: 0;
  position: relative;
  overflow: hidden;
}

#gameCanvas {
  display: block;
  touch-action: none;
}

/* ─── Game Bottom (info bar + button bar) ──── */
.game-bottom {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 0;
  z-index: 5;
  visibility: hidden; /* hidden until positioned by JS */
}
.game-info-row {
  visibility: hidden; /* hidden until positioned by JS */
}

/* Info row below board — positioned by JS */
.game-info-row {
  position: absolute;
  left: 0;
  right: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 2px 8px;
  z-index: 5;
}
.game-errors {
  display: flex;
  gap: 3px;
}
.game-size-text {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.8rem;
  color: #aaa;
}
[data-theme="dark"] .game-size-text { color: #777; }

.error-x {
  font-size: 16px;
  font-weight: 700;
  color: #D0D0D0;
  line-height: 1;
}
.error-x.used {
  color: #FF4444;
}
[data-theme="dark"] .error-x { color: #444; }
[data-theme="dark"] .error-x.used { color: #FF6666; }

/* game-size-label removed — shown on board canvas */

/* Button bar row */
.game-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(24px, 7vw, 48px);
  padding: 0 16px;
}

/* Undo/Redo stack */
.game-btn-stack {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Base button style */
.game-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #B0B0B0;
  border: 3px solid transparent;
  color: #fff;
  cursor: pointer;
  border-radius: 18%;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 2px 2px 0 rgba(0,0,0,0.12);
}
.game-btn:active {
  transform: translate(1px, 1px);
  box-shadow: 0 0 0 transparent;
}
.game-btn:disabled {
  opacity: 0.35;
  cursor: default;
  pointer-events: none;
}

/* Small buttons (Undo, Redo) */
.game-btn--small {
  width: clamp(48px, 13vw, 66px);
  height: clamp(48px, 13vw, 66px);
}
.game-btn--small svg {
  width: clamp(22px, 6vw, 28px);
  height: clamp(22px, 6vw, 28px);
}

/* Large buttons (Pen, Cross, Hint) */
.game-btn--large {
  width: clamp(72px, 20vw, 96px);
  height: clamp(72px, 20vw, 96px);
}
.game-btn--large svg {
  width: clamp(30px, 9vw, 40px);
  height: clamp(30px, 9vw, 40px);
}

/* Active / selected state */
.game-btn.active {
  background: #4A94C0;
  border-color: #2E6A8F;
}

/* Hint button: same size as Pen/Cross, blue outline by default */
.game-btn--hint {
  background: #888;
  border: 3px solid transparent;
  color: #fff;
}
.game-btn--hint.active {
  background: #4A94C0;
  border-color: #2E6A8F;
}
[data-theme="dark"] .game-btn--hint {
  background: #555;
}
[data-theme="dark"] .game-btn--hint.active {
  background: #5B8DEF;
  border-color: #3A6BC0;
}
/* hint svg inherits from .game-btn--large svg */

/* Badge on hint button */
.game-btn-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  min-width: 22px;
  height: 22px;
  background: #4A94C0;
  color: #fff;
  font-size: 12px;
  font-weight: 700;
  border-radius: 11px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 3px;
  line-height: 1;
}
[data-theme="dark"] .game-btn-badge {
  background: #8AACBC;
  color: #121212;
}

/* Dark theme adjustments for game buttons */
[data-theme="dark"] .game-btn {
  background: #555;
}
[data-theme="dark"] .game-btn.active {
  background: #5B8DEF;
  border-color: #3A6BC0;
}

/* ─── Fullscreen mode ──────────────────────── */
body.fullscreen .nav-bar,
body.fullscreen .game-status-bar,
body.fullscreen .seo-content { display: none; }

body.fullscreen .main-layout {
  height: 100dvh;
  padding: 4px 4px 0;
}

body.fullscreen .game-btn.fullscreen-btn {
  color: var(--primary);
  border-color: var(--primary);
}

/* ─── Modals ───────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 300;
  align-items: center;
  justify-content: center;
}
.modal-overlay.open {
  display: flex;
}

.modal-box {
  background: var(--surface);
  border-radius: 16px;
  padding: 32px 28px;
  max-width: 380px;
  width: 90%;
  text-align: center;
  box-shadow: var(--shadow-hover);
}

.modal-box h2 {
  margin-bottom: 8px;
  font-size: 1.3rem;
}

.modal-box p {
  color: var(--text-secondary);
  margin-bottom: 20px;
  font-size: 0.95rem;
}

.clear-time {
  font-size: 1.1rem;
  margin-bottom: 20px;
}
.clear-time strong {
  font-size: 1.5rem;
  color: var(--primary);
}

.modal-buttons {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.modal-btn {
  padding: 10px 24px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-weight: 600;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.15s;
}
.modal-btn:hover { background: var(--bg); }
.modal-btn.primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}
.modal-btn.primary:hover { background: var(--primary-hover); }

/* Settings modal */
.modal-settings { text-align: left; }
.modal-settings h2 { text-align: center; }

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.setting-row:last-of-type { border-bottom: none; }

/* Toggle switch */
.toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  flex-shrink: 0;
}
.toggle input { opacity: 0; width: 0; height: 0; }
.slider {
  position: absolute;
  inset: 0;
  background: var(--border);
  border-radius: 24px;
  cursor: pointer;
  transition: 0.2s;
}
.slider::before {
  content: '';
  position: absolute;
  width: 18px;
  height: 18px;
  left: 3px;
  bottom: 3px;
  background: #fff;
  border-radius: 50%;
  transition: 0.2s;
}
.toggle input:checked + .slider { background: var(--primary); }
.toggle input:checked + .slider::before { transform: translateX(20px); }

/* ─── Platform Banner ─────────────────────── */
.platform-banner {
  width: 320px;
  height: 50px;
  margin: 8px auto 0;
  overflow: hidden;
}

/* ─── SEO Content ──────────────────────────── */
.seo-content {
  max-width: 800px;
  margin: 0 auto;
  padding: 40px 20px;
  color: var(--text-secondary);
  font-size: 0.9rem;
  line-height: 1.7;
}
.seo-content h1 {
  font-size: 1.5rem;
  color: var(--text);
  margin-bottom: 12px;
}
.seo-content h2 {
  font-size: 1.1rem;
  color: var(--text);
  margin: 20px 0 8px;
}

/* ─── App Banner ───────────────────────────── */
.app-banner {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  margin: 24px 0;
  background: var(--surface);
  border: 2px solid var(--primary);
  border-radius: 12px;
  box-shadow: 0 2px 8px rgba(50,90,175,0.1);
}
.app-banner-icon { flex-shrink: 0; }
.app-banner-text { flex: 1; }
.app-banner-text strong { display: block; color: var(--text); font-size: 0.95rem; }
.app-banner-text span { font-size: 0.8rem; color: var(--text-secondary); }
.app-banner-btn {
  flex-shrink: 0;
  padding: 8px 18px;
  background: var(--primary);
  color: #fff;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
}
.app-banner-btn:hover { background: var(--primary-hover); }

/* ─── Responsive ───────────────────────────── */
@media (max-width: 480px) {
  .nav-inner { padding: 0 12px; }
  .game-status-inner { padding: 0 12px; }
  .main-layout { padding: 4px 4px 0; }
  .btn-new-game { padding: 6px 12px; font-size: 0.8rem; }
  .game-btn--small { width: 46px; height: 46px; }
  .game-btn--large { width: 66px; height: 66px; }
  .game-buttons { gap: 16px; }
}

@media (min-width: 769px) {
  .board-container { max-width: 600px; max-height: 600px; }
  .seo-content { display: none; }
}

/* Collection fullscreen */
.collection-screen {
  display: none;
  position: fixed;
  inset: 0;
  background: var(--bg);
  z-index: 250;
  flex-direction: column;
  overflow: hidden;
}
.collection-screen.open {
  display: flex;
}

.collection-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.collection-back {
  background: none;
  border: none;
  color: var(--text);
  cursor: pointer;
  padding: 4px;
  display: flex;
}

.collection-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.collection-tabs {
  display: flex;
  gap: 0;
  padding: 0 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  overflow-x: auto;
}

.col-tab {
  padding: 8px 12px;
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.col-tab:hover { color: var(--text); }
.col-tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.collection-progress {
  padding: 12px 16px;
  flex-shrink: 0;
}

.collection-progress span {
  font-size: 0.85rem;
  color: var(--text-secondary);
  display: block;
  margin-bottom: 6px;
}

.progress-bar {
  width: 100%;
  height: 6px;
  background: var(--border);
  border-radius: 3px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--primary);
  border-radius: 3px;
  transition: width 0.3s;
}

.collection-grid {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
  gap: 8px;
  align-content: start;
}

.collection-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  cursor: pointer;
  padding: 6px 4px;
  border-radius: var(--radius-sm);
  transition: background 0.15s;
}
.collection-item:hover { background: var(--surface); }

.collection-item canvas {
  border: 1px solid var(--border);
  border-radius: 3px;
  display: block;
}

.collection-item .label {
  font-size: 0.65rem;
  color: var(--text-muted);
  text-align: center;
}

.collection-item.locked canvas {
  opacity: 0.3;
}
.collection-item.locked .label {
  color: var(--text-muted);
}

.empty-stats {
  text-align: center;
  color: var(--text-muted);
  padding: 20px;
}

/* ─── Title Screen ─────────────────────────── */
.title-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #FFFFFF 0%, #E8F0F8 100%);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: opacity 0.4s, transform 0.4s;
}
[data-theme="dark"] .title-screen {
  background: linear-gradient(180deg, #121212 0%, #1A1A1A 100%);
}
.title-screen.hiding {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
}
.title-screen.hidden { display: none; }

.title-particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.title-content {
  text-align: center;
  position: relative;
  z-index: 1;
  animation: titleFadeIn 0.6s ease-out;
}

@keyframes titleFadeIn {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}

.title-main {
  width: 70%;
  max-width: 400px;
  height: auto;
  image-rendering: pixelated;
  display: block;
  margin: 0 auto 0;
}
[data-theme="dark"] .title-main {
  filter: brightness(0) invert(0.88);
}

.title-sub {
  width: 35%;
  max-width: 200px;
  height: auto;
  image-rendering: pixelated;
  display: block;
  margin: 12px auto 0;
}
[data-theme="dark"] .title-sub {
  filter: brightness(0) saturate(100%) invert(72%) sepia(15%) saturate(500%) hue-rotate(165deg);
}

.title-touch {
  font-family: monospace;
  font-size: 0.85rem;
  color: #AAAAAA;
  position: fixed;
  bottom: 10%;
  left: 50%;
  transform: translateX(-50%);
  animation: touchBlink 1.2s ease-in-out infinite;
  letter-spacing: 1px;
}
[data-theme="dark"] .title-touch {
  color: #BDBDBD;
}

@keyframes touchBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* ─── Mode Select Screen ─────────────────── */
.mode-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #FFFFFF 0%, #E8F0F8 100%);
  z-index: 498;
  display: none;
  flex-direction: column;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  touch-action: auto;
}
[data-theme="dark"] .mode-screen {
  background: linear-gradient(180deg, #121212 0%, #1A1A1A 100%);
}
.mode-screen.open { display: flex; }
.mode-screen.hiding {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}

.mode-particles {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  touch-action: none;
}

/* App bar */
.mode-appbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 40px;
  padding: 0 12px;
  position: relative;
  z-index: 10;
}
.mode-appbar-title {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  color: #222222;
  letter-spacing: 1px;
}
[data-theme="dark"] .mode-appbar-title { color: #F0F0F0; }
.mode-appbar-actions {
  display: flex;
  gap: 8px;
}
.mode-appbar-btn {
  background: none;
  border: none;
  color: #222222;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  transition: background 0.2s;
}
[data-theme="dark"] .mode-appbar-btn { color: #F0F0F0; }
.mode-appbar-btn:hover { background: rgba(0,0,0,0.06); }
[data-theme="dark"] .mode-appbar-btn:hover { background: rgba(255,255,255,0.08); }

/* Show/hide sun/moon icons based on theme */
/* Light mode: show moon (tap to go dark), Dark mode: show sun (tap to go light) */
.icon-sun { display: none; }
[data-theme="dark"] .icon-sun { display: block; }
[data-theme="dark"] .icon-moon { display: none; }

/* Mode cards container */
.mode-cards-container {
  flex: 1 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 8px 16px;
  position: relative;
  z-index: 1;
  max-width: 480px;
  margin: 0 auto;
  min-height: 0;
  width: 100%;
  animation: titleFadeIn 0.4s ease-out;
}

/* Mode card — retro press style */
.mode-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 20px 16px;
  background: #FFFFFF;
  border: 2px solid #4A94C0;
  border-radius: 6px;
  cursor: pointer;
  text-align: left;
  width: 100%;
  font-family: monospace;
  color: #222222;
  position: relative;
  transition: transform 80ms;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.1);
}
[data-theme="dark"] .mode-card {
  background: #1E1E1E;
  color: #F0F0F0;
  box-shadow: 3px 3px 0 rgba(255,255,255,0.12);
}
.mode-card:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 rgba(0,0,0,0.1);
}

/* Per-mode card borders */
.mode-card--daily { border-color: #4AC4A5; }
.mode-card--classic { border-color: #4A94C0; }
.mode-card--expert { border-color: #3A6AA8; }
[data-theme="dark"] .mode-card--daily { border-color: #7EDCC2; }
[data-theme="dark"] .mode-card--classic { border-color: #8AACBC; }
[data-theme="dark"] .mode-card--expert { border-color: #95A6BC; }

/* Mode card icon */
.mode-card-icon {
  flex-shrink: 0;
  width: 56px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  border: 3px solid;
}
.mode-card-icon--daily {
  background: #E8F8F2;
  border-color: #4AC4A5;
}
.mode-card-icon--classic {
  background: #E8F0F8;
  border-color: #4A94C0;
}
.mode-card-icon--expert {
  background: #E4E8F2;
  border-color: #3A6AA8;
}
[data-theme="dark"] .mode-card-icon--daily { background: #152820; border-color: #7EDCC2; }
[data-theme="dark"] .mode-card-icon--classic { background: #1A1A1A; border-color: #8AACBC; }
[data-theme="dark"] .mode-card-icon--expert { background: #1A1A1A; border-color: #95A6BC; }

/* Mode card text */
.mode-card-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.mode-card-name {
  font-size: 1rem;
  font-weight: 700;
  text-transform: uppercase;
}
.mode-card-desc {
  font-size: 0.75rem;
  color: #888888;
  margin-top: 2px;
}
[data-theme="dark"] .mode-card-desc { color: #9E9E9E; }

/* Progress bar */
.mode-card-progressbar {
  width: 100%;
  height: 8px;
  background: #D0D0D0;
  border-radius: 4px;
  border: 1px solid #AAAAAA;
  margin-top: 8px;
  overflow: hidden;
}
[data-theme="dark"] .mode-card-progressbar {
  background: #1A1A1A;
  border-color: #333333;
}
.mode-card-progressbar-fill {
  height: 100%;
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 0%;
}
.mode-card-progressbar-fill--daily { background: #00D1B2; }
.mode-card-progressbar-fill--classic { background: #0077B6; }
.mode-card-progressbar-fill--expert { background: #023E8A; }
[data-theme="dark"] .mode-card-progressbar-fill--daily { background: #7EDCC2; }
[data-theme="dark"] .mode-card-progressbar-fill--classic { background: #8AACBC; }
[data-theme="dark"] .mode-card-progressbar-fill--expert { background: #95A6BC; }

/* Continue button */
.mode-continue-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: monospace;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #FFFFFF;
  background: #0077B6;
  border: 2px solid #005A8C;
  border-radius: 6px;
  padding: 12px 32px;
  margin: 10px 0 0;
  cursor: pointer;
  position: relative;
  z-index: 1;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.15);
  transition: transform 80ms;
}
.mode-continue-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 rgba(0,0,0,0.15);
}
[data-theme="dark"] .mode-continue-btn {
  background: #8AACBC;
  border-color: #6B8FA0;
  color: #121212;
  box-shadow: 3px 3px 0 rgba(255,255,255,0.12);
}
.mode-continue-btn.hidden { display: none; }

/* Stats bar */
.mode-stats-bar {
  flex-shrink: 0;
  font-family: monospace;
  font-size: 0.65rem;
  color: #00997A;
  text-align: center;
  padding: 12px;
  margin: 0 16px 40px;
  background: #E8E8E8;
  border: 1px solid #C0C0C0;
  border-radius: 10px;
  position: relative;
  z-index: 1;
  letter-spacing: 1px;
}
[data-theme="dark"] .mode-stats-bar {
  color: #7EDCC2;
  background: #1A1A1A;
  border-color: #333333;
}

/* ─── Daily Calendar Screen ───────────────── */
.daily-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #FFFFFF 0%, #E8F0F8 100%);
  z-index: 496;
  display: none;
  flex-direction: column;
  overflow-y: auto;
}
[data-theme="dark"] .daily-screen {
  background: linear-gradient(180deg, #121212 0%, #1A1A1A 100%);
}
.daily-screen.open { display: flex; }
.daily-screen.hiding {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}

/* Daily app bar */
.daily-appbar {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 12px;
  gap: 8px;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.daily-appbar-title {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  color: #222222;
  letter-spacing: 1px;
}
[data-theme="dark"] .daily-appbar-title { color: #F0F0F0; }
.daily-back-btn {
  background: none;
  border: none;
  color: #222222;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  transition: background 0.2s;
}
[data-theme="dark"] .daily-back-btn { color: #F0F0F0; }
.daily-back-btn:hover { background: rgba(0,0,0,0.06); }
[data-theme="dark"] .daily-back-btn:hover { background: rgba(255,255,255,0.08); }

/* Today's card */
.daily-today-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 16px;
  margin: 8px 16px;
  background: #FFFFFF;
  border: 2px solid #4AC4A5;
  border-radius: 6px;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.1);
  position: relative;
  z-index: 1;
}
[data-theme="dark"] .daily-today-card {
  background: #1E1E1E;
  border-color: #7EDCC2;
  box-shadow: 3px 3px 0 rgba(255,255,255,0.12);
}
.daily-today-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.daily-today-label {
  font-family: monospace;
  font-size: 10px;
  color: #888888;
}
[data-theme="dark"] .daily-today-label { color: #9E9E9E; }
.daily-today-date {
  font-family: monospace;
  font-size: 18px;
  font-weight: 700;
  color: #222222;
}
[data-theme="dark"] .daily-today-date { color: #F0F0F0; }
.daily-today-progress {
  width: 100%;
  height: 6px;
  background: #D0D0D0;
  border-radius: 3px;
  overflow: hidden;
  margin-top: 4px;
}
[data-theme="dark"] .daily-today-progress {
  background: #333333;
}
.daily-today-progress-fill {
  height: 100%;
  background: #00D1B2;
  border-radius: 3px;
  transition: width 0.4s ease;
  width: 0%;
}
[data-theme="dark"] .daily-today-progress-fill {
  background: #7EDCC2;
}
.daily-today-gauge {
  font-family: monospace;
  font-size: 7px;
  color: #4AC4A5;
  text-align: right;
}
[data-theme="dark"] .daily-today-gauge { color: #7EDCC2; }

/* Start button in today card */
.daily-start-btn {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #FFFFFF;
  background: #4AC4A5;
  border: 2px solid #3AAA8F;
  border-radius: 6px;
  padding: 10px 20px;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.1);
  transition: transform 80ms;
  flex-shrink: 0;
}
.daily-start-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 rgba(0,0,0,0.1);
}
[data-theme="dark"] .daily-start-btn {
  background: #7EDCC2;
  border-color: #5CC0A5;
  color: #121212;
  box-shadow: 3px 3px 0 rgba(255,255,255,0.12);
}

/* Calendar */
.daily-calendar {
  flex: 1;
  margin: 8px 16px;
  position: relative;
  z-index: 1;
}
.daily-cal-header {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  margin-bottom: 12px;
}
.daily-cal-title {
  font-family: monospace;
  font-weight: 700;
  font-size: 1rem;
  color: #222222;
  min-width: 140px;
  text-align: center;
}
[data-theme="dark"] .daily-cal-title { color: #F0F0F0; }
.daily-cal-nav {
  background: none;
  border: none;
  color: #222222;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  transition: background 0.2s;
}
[data-theme="dark"] .daily-cal-nav { color: #F0F0F0; }
.daily-cal-nav:hover { background: rgba(0,0,0,0.06); }
[data-theme="dark"] .daily-cal-nav:hover { background: rgba(255,255,255,0.08); }
.daily-cal-nav:disabled {
  opacity: 0.3;
  cursor: default;
}
.daily-cal-weekdays {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  text-align: center;
  margin-bottom: 4px;
}
.daily-cal-weekday {
  font-family: monospace;
  font-size: 0.65rem;
  font-weight: 700;
  color: #888888;
  padding: 4px 0;
}
[data-theme="dark"] .daily-cal-weekday { color: #9E9E9E; }
.daily-cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}
.daily-cal-day {
  font-family: monospace;
  font-size: 0.85rem;
  font-weight: 600;
  color: #222222;
  background: #FFFFFF;
  border: 2px solid transparent;
  border-radius: 6px;
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  transition: all 0.15s;
  overflow: hidden;
}
.daily-cal-preview {
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
  object-fit: contain;
}
[data-theme="dark"] .daily-cal-day {
  color: #F0F0F0;
  background: #1E1E1E;
}
.daily-cal-day:hover:not(.daily-cal-day--disabled):not(.daily-cal-day--empty) {
  border-color: #4AC4A5;
}
.daily-cal-day--today {
  border-color: #4AC4A5 !important;
  font-weight: 700;
}
[data-theme="dark"] .daily-cal-day--today {
  border-color: #7EDCC2 !important;
}
.daily-cal-day--cleared {
  background: #E0F7F0 !important;
  color: #2D8A6E;
}
[data-theme="dark"] .daily-cal-day--cleared {
  background: #1A3A2E !important;
  color: #7EDCC2;
}
.daily-cal-day--selected {
  border-color: #4AC4A5 !important;
  border-width: 3px;
  font-weight: 700;
}
[data-theme="dark"] .daily-cal-day--selected {
  border-color: #7EDCC2 !important;
}
.daily-cal-day--disabled {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}
.daily-cal-day--empty {
  visibility: hidden;
  pointer-events: none;
}
.daily-cal-day--outside {
  opacity: 0.3;
  cursor: default;
  pointer-events: none;
}

/* Play button */
.daily-play-btn {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: #4AC4A5;
  background: #FFFFFF;
  border: 2px solid #4AC4A5;
  border-radius: 6px;
  padding: 14px 32px;
  margin: 8px 16px 24px;
  cursor: pointer;
  width: calc(100% - 32px);
  box-shadow: 3px 3px 0 rgba(0,0,0,0.1);
  transition: transform 80ms;
  position: relative;
  z-index: 1;
  flex-shrink: 0;
}
.daily-play-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 rgba(0,0,0,0.1);
}
[data-theme="dark"] .daily-play-btn {
  color: #7EDCC2;
  background: #1E1E1E;
  border-color: #7EDCC2;
  box-shadow: 3px 3px 0 rgba(255,255,255,0.12);
}

/* ─── Puzzle Select Screen ────────────────── */
.select-screen {
  position: fixed;
  inset: 0;
  background: linear-gradient(180deg, #FFFFFF 0%, #E8F0F8 100%);
  z-index: 497;
  display: none;
  flex-direction: column;
  touch-action: auto;
}
[data-theme="dark"] .select-screen {
  background: linear-gradient(180deg, #121212 0%, #1A1A1A 100%);
}
.select-screen.open {
  display: flex;
}
.select-screen.hiding {
  opacity: 0;
  transform: scale(1.05);
  pointer-events: none;
  transition: opacity 0.3s, transform 0.3s;
}

/* Select app bar */
.select-appbar {
  display: flex;
  align-items: center;
  height: 40px;
  padding: 0 12px;
  gap: 8px;
  flex-shrink: 0;
}
.select-appbar-title {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.9rem;
  text-transform: uppercase;
  color: #222222;
  letter-spacing: 1px;
  flex: 1;
}
[data-theme="dark"] .select-appbar-title { color: #F0F0F0; }
.select-back-btn {
  background: none;
  border: none;
  color: #222222;
  cursor: pointer;
  padding: 8px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 44px;
  min-height: 44px;
  transition: background 0.2s;
}
[data-theme="dark"] .select-back-btn { color: #F0F0F0; }
.select-back-btn:hover { background: rgba(0,0,0,0.06); }
[data-theme="dark"] .select-back-btn:hover { background: rgba(255,255,255,0.08); }

/* Select tabs */
.select-tabs {
  display: flex;
  flex-shrink: 0;
  padding: 0 12px;
}
.select-tab {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 0;
  background: none;
  border: none;
  font-family: monospace;
  font-weight: 700;
  font-size: 0.75rem;
  color: #888888;
  cursor: pointer;
  transition: color 0.2s;
  letter-spacing: 0.5px;
}
[data-theme="dark"] .select-tab { color: #9E9E9E; }
.select-tab.active { color: #222222; }
[data-theme="dark"] .select-tab.active { color: #F0F0F0; }
.select-tab svg { opacity: 0.6; }
.select-tab.active svg { opacity: 1; }

/* Tab indicator */
.select-tab-indicator {
  height: 4px;
  background: #4A94C0;
  border-radius: 2px;
  width: 33.333%;
  transition: transform 0.25s ease, width 0.25s ease, background 0.25s ease;
  flex-shrink: 0;
}
[data-theme="dark"] .select-tab-indicator { background: #8AACBC; }
.select-screen[data-mode="expert"] .select-tab-indicator { background: #3A6AA8; }
[data-theme="dark"] .select-screen[data-mode="expert"] .select-tab-indicator { background: #95A6BC; }

/* Puzzle grid */
.select-grid {
  flex: 1;
  overflow-y: scroll;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y !important;
  overscroll-behavior: contain;
  padding: 8px 12px;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  align-content: start;
  min-height: 0;
  -webkit-overflow-scrolling: touch;
  max-width: 480px;
  margin: 0 auto;
  width: 100%;
}

@keyframes gridSlideLeft {
  from { opacity: 0; transform: translateX(60px); }
  to { opacity: 1; transform: translateX(0); }
}
@keyframes gridSlideRight {
  from { opacity: 0; transform: translateX(-60px); }
  to { opacity: 1; transform: translateX(0); }
}

.select-grid.slide-left {
  animation: gridSlideLeft 0.25s ease-out;
}
.select-grid.slide-right {
  animation: gridSlideRight 0.25s ease-out;
}

/* Puzzle item - use padding-bottom trick for guaranteed square */
.select-puzzle-item {
  position: relative;
  width: 100%;
  padding-bottom: 100%; /* forces square */
  background: #FFFFFF;
  border: 3px solid #888888;
  border-radius: 4px;
  cursor: pointer;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.15);
  transition: transform 80ms, box-shadow 80ms;
  overflow: hidden;
}
[data-theme="dark"] .select-puzzle-item {
  background: #2A2A2A;
  border-color: #555555;
  box-shadow: 3px 3px 0 rgba(255,255,255,0.08);
}
.select-puzzle-item:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 transparent;
}

/* Cleared state */
.select-puzzle-item.cleared {
  border-color: #4A94C0;
}
[data-theme="dark"] .select-puzzle-item.cleared {
  border-color: #8AACBC;
}
.select-screen[data-mode="expert"] .select-puzzle-item.cleared {
  border-color: #3A6AA8;
}
[data-theme="dark"] .select-screen[data-mode="expert"] .select-puzzle-item.cleared {
  border-color: #95A6BC;
}

/* ─── Big Picture Dialog ──────────────────── */
.bigpic-overlay {
  display: none;
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 10;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.bigpic-overlay.open {
  display: flex;
}

.bigpic-dialog {
  background: #FFFFFF;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  max-width: 360px;
  width: 100%;
  animation: titleFadeIn 0.2s ease-out;
}
[data-theme="dark"] .bigpic-dialog {
  background: #1E1E1E;
}

.bigpic-size {
  display: block;
  font-family: monospace;
  font-weight: 700;
  font-size: 0.8rem;
  color: #888;
  text-align: right;
  margin-bottom: 4px;
}

.bigpic-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 2px;
  border: 2px solid #888;
  padding: 2px;
  background: #888;
}

.bigpic-cell {
  aspect-ratio: 1;
  position: relative;
  cursor: pointer;
  background: #FFFFFF;
  overflow: hidden;
  transition: transform 80ms;
}
.bigpic-cell:active {
  transform: scale(0.92);
}
[data-theme="dark"] .bigpic-cell {
  background: #2A2A2A;
}

.bigpic-cell canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  pointer-events: none;
}

/* Canvas inside puzzle item */
.select-puzzle-item canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
  touch-action: pan-y;
  pointer-events: none;
}

/* ─── Game Clear Screen ───────────────────── */
.gameclear-screen {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 600;
  background: linear-gradient(180deg, #FFFFFF 0%, #E8F0F8 100%);
  flex-direction: column;
  align-items: center;
  overflow: hidden;
}
.gameclear-screen.open {
  display: flex;
}
[data-theme="dark"] .gameclear-screen {
  background: linear-gradient(180deg, #121212 0%, #1A2230 100%);
}

.gameclear-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.gameclear-content {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  flex: 1;
  justify-content: center;
  padding-bottom: 100px;
  animation: gameclearEntry 0.6s ease-out;
}

@keyframes gameclearEntry {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.gameclear-title {
  position: relative;
  z-index: 1;
  width: 60%;
  max-width: 360px;
  height: auto;
  margin-top: max(20px, env(safe-area-inset-top, 20px));
  image-rendering: pixelated;
  animation: gameclearBounce 0.8s cubic-bezier(0.34, 1.56, 0.64, 1) 0.2s both;
}
[data-theme="dark"] .gameclear-title {
  filter: brightness(0) invert(0.88);
}

@keyframes gameclearBounce {
  0% { opacity: 0; transform: scale(0.3) translateY(-40px); }
  60% { opacity: 1; transform: scale(1.08) translateY(4px); }
  80% { transform: scale(0.96) translateY(-2px); }
  100% { transform: scale(1) translateY(0); }
}

.gameclear-preview {
  display: block;
  border: 3px solid #4A94C0;
  border-radius: 8px;
  background: #fff;
  box-shadow: 0 4px 20px rgba(74, 148, 192, 0.25);
}
[data-theme="dark"] .gameclear-preview {
  border-color: #8AACBC;
  background: #1E1E1E;
  box-shadow: 0 4px 20px rgba(138, 172, 188, 0.2);
}

.gameclear-stats {
  display: flex;
  gap: 32px;
}

.gameclear-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-family: monospace;
  font-size: 1.2rem;
  font-weight: 700;
  color: #344861;
}
[data-theme="dark"] .gameclear-stat {
  color: #E0E0E0;
}

.gameclear-stat-label {
  font-size: 0.7rem;
  font-weight: 400;
  color: #94A3B8;
  text-transform: uppercase;
  letter-spacing: 1px;
}
[data-theme="dark"] .gameclear-stat-label {
  color: #718096;
}

.gameclear-buttons {
  position: absolute;
  bottom: max(24px, env(safe-area-inset-bottom, 24px));
  left: 0;
  right: 0;
  z-index: 1;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 10px;
  padding: 0 16px;
}

.gameclear-btn {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
  height: 44px;
  min-width: 100px;
  padding: 0 16px;
  border-radius: 6px;
  cursor: pointer;
  transition: transform 80ms;
  /* HOME: white bg, blue border */
  background: #FFFFFF;
  color: #4A94C0;
  border: 2px solid #4A94C0;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.1);
}
.gameclear-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 rgba(0,0,0,0.1);
}
[data-theme="dark"] .gameclear-btn {
  background: #1E1E1E;
  color: #8AACBC;
  border-color: #8AACBC;
  box-shadow: 3px 3px 0 rgba(255,255,255,0.12);
}

.gameclear-btn--primary {
  background: #4A94C0;
  color: #FFFFFF;
  border-color: #3A7BA8;
}
[data-theme="dark"] .gameclear-btn--primary {
  background: #8AACBC;
  color: #121212;
  border-color: #6B8FA0;
}

.gameclear-btn--reward {
  background: #FF9800;
  color: #FFFFFF;
  border-color: #E68900;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.gameclear-btn--reward svg { flex-shrink: 0; stroke: #fff; }
.gameclear-btn--reward:hover { background: #F57C00; }
[data-theme="dark"] .gameclear-btn--reward {
  background: #FF9800;
  color: #FFFFFF;
  border-color: #E68900;
}

/* ─── Improved Game Over Modal ─────────────── */
.modal-gameover { position: relative; }

.gameover-icon {
  margin-bottom: 8px;
  animation: gameoverShake 0.5s ease-in-out;
}

@keyframes gameoverShake {
  0%, 100% { transform: rotate(0deg); }
  20% { transform: rotate(-8deg); }
  40% { transform: rotate(8deg); }
  60% { transform: rotate(-4deg); }
  80% { transform: rotate(4deg); }
}

.gameover-msg {
  color: var(--text-secondary);
  margin-bottom: 16px;
}

.rewarded-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 12px 20px;
  margin-bottom: 12px;
  background: #FF9800;
  color: #fff;
  border: none;
  border-radius: var(--radius);
  font-weight: 700;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.15s;
}
.rewarded-btn:hover { background: #F57C00; }
.rewarded-btn svg { flex-shrink: 0; stroke: #fff; }

/* ─── How to Play Tutorial ────────────────── */
.tutorial-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 700;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
}
.tutorial-overlay.open { display: flex; }

.tutorial-dialog {
  background: #FFFFFF;
  border: 2px solid #4A94C0;
  border-radius: 6px;
  box-shadow: 4px 4px 0 rgba(0,0,0,0.15);
  max-width: 400px;
  width: 100%;
  padding: 16px;
  animation: titleFadeIn 0.2s ease-out;
  max-height: 90vh;
  overflow-y: auto;
}
[data-theme="dark"] .tutorial-dialog {
  background: #1E1E1E;
  border-color: #8AACBC;
}

.tutorial-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}
.tutorial-title {
  font-family: monospace;
  font-weight: 700;
  font-size: 1rem;
  color: #222;
}
[data-theme="dark"] .tutorial-title { color: #F0F0F0; }
.tutorial-step {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.8rem;
  color: #4A94C0;
}

.tutorial-image-wrap {
  background: #F5F5F5;
  border: 1px solid #DDD;
  border-radius: 4px;
  padding: 8px;
  margin-bottom: 12px;
  display: flex;
  justify-content: center;
}
[data-theme="dark"] .tutorial-image-wrap {
  background: #2A2A2A;
  border-color: #444;
}
.tutorial-image {
  width: 100%;
  max-height: 50vh;
  object-fit: contain;
  image-rendering: pixelated;
}

.tutorial-desc {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.8rem;
  line-height: 1.5;
  color: #222;
  margin-bottom: 16px;
  white-space: pre-line;
}
[data-theme="dark"] .tutorial-desc { color: #E0E0E0; }

.tutorial-dots {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-bottom: 14px;
}
.tutorial-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #D0D0D0;
}
.tutorial-dot.active {
  background: #4A94C0;
}
[data-theme="dark"] .tutorial-dot { background: #444; }
[data-theme="dark"] .tutorial-dot.active { background: #8AACBC; }

.tutorial-buttons {
  display: flex;
  gap: 8px;
}
.tutorial-btn {
  flex: 1;
  height: 44px;
  font-family: monospace;
  font-weight: 700;
  font-size: 0.75rem;
  text-transform: uppercase;
  border-radius: 4px;
  cursor: pointer;
  border: 2px solid;
  box-shadow: 3px 3px 0 rgba(0,0,0,0.12);
  transition: transform 80ms;
}
.tutorial-btn:active {
  transform: translate(2px, 2px);
  box-shadow: 0 0 0 transparent;
}
.tutorial-btn--skip {
  background: #FFF;
  color: #607D8B;
  border-color: #B0BEC5;
}
[data-theme="dark"] .tutorial-btn--skip {
  background: #2A2A2A;
  color: #9E9E9E;
  border-color: #555;
}
.tutorial-btn--next {
  background: #FFF;
  color: #4A94C0;
  border-color: #4A94C0;
}
[data-theme="dark"] .tutorial-btn--next {
  background: #2A2A2A;
  color: #8AACBC;
  border-color: #8AACBC;
}

/* ─── Interactive Tutorial Board ──────────── */
.tutorial-board-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}
#tutorialCanvas {
  display: block;
  max-width: 100%;
  touch-action: none;
  border-radius: 4px;
}

.tutorial-mode-toggle {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin-bottom: 12px;
}
.tutorial-mode-btn {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.7rem;
  padding: 6px 16px;
  border: 2px solid #CCC;
  border-radius: 4px;
  background: #FFF;
  color: #666;
  cursor: pointer;
}
.tutorial-mode-btn.active {
  border-color: #4A94C0;
  color: #4A94C0;
  background: #EBF5FB;
}
[data-theme="dark"] .tutorial-mode-btn { background: #2A2A2A; color: #999; border-color: #555; }
[data-theme="dark"] .tutorial-mode-btn.active { background: #1A3050; color: #8AACBC; border-color: #8AACBC; }

/* (old hint-btn styles removed, now using .game-btn--hint) */

/* ─── In-Game Tutorial Guide Bubble ──────── */
.tutorial-dialog-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 600;
  background: rgba(0,0,0,0.45);
  align-items: center;
  justify-content: center;
}
.tutorial-dialog-overlay.visible {
  display: flex;
}
.tutorial-dialog-box {
  background: #fff;
  border-radius: 12px;
  padding: 24px 20px 16px;
  margin: 0 24px;
  max-width: 320px;
  width: 100%;
  box-shadow: 0 8px 32px rgba(0,0,0,0.25);
  text-align: center;
  animation: titleFadeIn 0.25s ease-out;
}
[data-theme="dark"] .tutorial-dialog-box {
  background: #1E2A3A;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}
.tutorial-dialog-text {
  font-family: monospace;
  font-weight: 700;
  font-size: 0.85rem;
  line-height: 1.6;
  color: #303030;
  margin: 0 0 16px;
  white-space: pre-line;
}
[data-theme="dark"] .tutorial-dialog-text {
  color: #E0E0E0;
}
.tutorial-dialog-btn {
  display: inline-block;
  background: #4A94C0;
  color: #fff;
  border: none;
  border-radius: 6px;
  padding: 10px 40px;
  font-family: monospace;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
  letter-spacing: 1px;
}
.tutorial-dialog-btn:active {
  transform: scale(0.95);
}
[data-theme="dark"] .tutorial-dialog-btn {
  background: #5B8DEF;
}
/* Tutorial button highlight pulse */
@keyframes tutorialPulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(74, 148, 192, 0.6); }
  50% { box-shadow: 0 0 0 8px rgba(74, 148, 192, 0); }
}
.tutorial-highlight {
  animation: tutorialPulse 1s ease-in-out infinite;
  position: relative;
  z-index: 10;
}
/* Big picture progress label */
.bigpic-progress {
  display: block;
  font-family: monospace;
  font-size: 0.6rem;
  font-weight: 700;
  color: #4A94C0;
  margin-top: 2px;
  text-align: center;
}
[data-theme="dark"] .bigpic-progress {
  color: #5B8DEF;
}
