/* ==========================================================================
   MYRA SUDOKU v3.0 · 麥麥數獨 — Dynamic 4-Season Sanctuary, Uncropped Art Stages,
   Vivaldi Mini-Player, Google Sign-In & Character Picker, Human-Only Rankings
   ========================================================================== */

:root {
  --bg-page: #fdf7f0;
  --bg-gradient: radial-gradient(circle at 18% 12%, #fffaf4 0%, #faeee2 52%, #f4e1cf 100%);
  --bg-card: rgba(255, 252, 248, 0.94);
  --bg-card-strong: #fffdf9;
  --border-soft: rgba(180, 132, 108, 0.24);
  --border-strong: #8d5b4c;
  --text-main: #3b2620;
  --text-muted: #7a5c51;
  --accent: #d97757;
  --accent-strong: #b85335;
  --accent-soft: rgba(217, 119, 87, 0.15);
  --gold-star: #d99326;
  --cell-bg: #fffefb;
  --cell-peer: #f9efe4;
  --cell-same: #f6d5c1;
  --cell-selected: #f4b393;
  --cell-monogram: #fdf0eb;
  --cell-order-box: #fcf4ea;
  --cell-hint: #fde68a;
  --cell-error: #fecdd3;
  --digit-given: #35221c;
  --digit-user: #b84a27;
  --fog-bg: linear-gradient(135deg, #efe2d3 0%, #e4d0bb 100%);
  --thermo-stroke: rgba(236, 114, 151, 0.44);
  --shadow-cozy: 0 12px 32px rgba(92, 55, 38, 0.10);
  --shadow-pop: 0 6px 18px rgba(92, 55, 38, 0.14);
}

body[data-theme="study"] {
  --bg-page: #f5f3ee;
  --bg-gradient: radial-gradient(circle at 20% 10%, #faf9f5 0%, #ebe7de 58%, #dfd9cc 100%);
  --bg-card: rgba(252, 251, 247, 0.95);
  --bg-card-strong: #fcfbf8;
  --border-soft: rgba(100, 92, 79, 0.24);
  --border-strong: #435249;
  --text-main: #2c2823;
  --text-muted: #665f54;
  --accent: #557062;
  --accent-strong: #395044;
  --accent-soft: rgba(85, 112, 98, 0.16);
  --gold-star: #c2852b;
  --cell-bg: #fcfbf7;
  --cell-peer: #efece3;
  --cell-same: #d4e3da;
  --cell-selected: #b5cfc0;
  --cell-monogram: #e6f0ea;
  --cell-order-box: #f2f5ef;
  --digit-given: #23201b;
  --digit-user: #2d5942;
  --fog-bg: linear-gradient(135deg, #e2ded4 0%, #d4cfc2 100%);
}

body[data-theme="cafe"] {
  --bg-page: #f9f2eb;
  --bg-gradient: radial-gradient(circle at 80% 12%, #fff8f1 0%, #f1e2d3 55%, #e5ceb8 100%);
  --bg-card: rgba(255, 250, 245, 0.94);
  --bg-card-strong: #fffcf8;
  --border-soft: rgba(138, 90, 62, 0.25);
  --border-strong: #693f27;
  --text-main: #382216;
  --text-muted: #785643;
  --accent: #b56546;
  --accent-strong: #8f472b;
  --accent-soft: rgba(181, 101, 70, 0.16);
  --gold-star: #cf8a25;
  --cell-bg: #fffdf9;
  --cell-peer: #f5eadf;
  --cell-same: #f3d1c4;
  --cell-selected: #eca894;
  --cell-monogram: #fce6e0;
  --cell-order-box: #fbf1e4;
  --digit-given: #331e13;
  --digit-user: #9e3d22;
  --fog-bg: linear-gradient(135deg, #ead9c9 0%, #dcc4ae 100%);
}

body[data-theme="sakura"] {
  --bg-page: #231f33;
  --bg-gradient: radial-gradient(circle at 22% 14%, #352c4d 0%, #241e38 56%, #191528 100%);
  --bg-card: rgba(44, 37, 66, 0.93);
  --bg-card-strong: #31294a;
  --border-soft: rgba(244, 180, 200, 0.26);
  --border-strong: #eab308;
  --text-main: #fdf4f7;
  --text-muted: #cbbdd6;
  --accent: #ec7ea3;
  --accent-strong: #d95d88;
  --accent-soft: rgba(236, 126, 163, 0.20);
  --gold-star: #fbbf24;
  --cell-bg: #2a2340;
  --cell-peer: #362d52;
  --cell-same: #57385c;
  --cell-selected: #78426d;
  --cell-monogram: #3b2b4a;
  --cell-order-box: #33274a;
  --cell-hint: #6b5324;
  --cell-error: #6e273d;
  --digit-given: #fff5f8;
  --digit-user: #ff9ebb;
  --fog-bg: linear-gradient(135deg, #393056 0%, #2b2342 100%);
  --thermo-stroke: rgba(249, 148, 184, 0.50);
  --shadow-cozy: 0 14px 36px rgba(8, 5, 18, 0.45);
}

/* ======================== BESPOKE PER-SEASON BOARD STYLES ======================== */
body[data-board-style="study-notebook"] .board-outer-frame {
  border: 3.5px solid #3c4d43;
  border-radius: 12px;
  box-shadow: 0 10px 0 rgba(60, 77, 67, 0.14), var(--shadow-cozy);
}
body[data-board-style="study-notebook"] .cell-digit {
  font-family: "Georgia", "Iowan Old Style", "Times New Roman", serif;
  letter-spacing: -0.02em;
}

body[data-board-style="cafe-walnut"] .board-outer-frame {
  border: 5px solid #6b422b;
  border-radius: 22px;
  box-shadow: inset 0 0 0 2px #d7b296, 0 14px 30px rgba(74, 42, 24, 0.18);
}

body[data-board-style="sakura-lacquer"] .board-outer-frame {
  border: 3.5px solid #f59e0b;
  border-radius: 20px;
  box-shadow: 0 0 28px rgba(236, 126, 163, 0.25), var(--shadow-cozy);
}

* {
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html,
body {
  margin: 0;
  padding: 0;
  min-height: 100dvh;
  font-family: "Nunito", "Quicksand", "PingFang TC", "PingFang SC", "Hiragino Sans", -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-page);
  background-image: var(--bg-gradient);
  color: var(--text-main);
  overflow-x: hidden;
}

button,
a {
  font-family: inherit;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}
button:active,
a:active {
  transform: scale(0.97);
}

.hidden {
  display: none !important;
}

.screen {
  display: none;
  min-height: 100dvh;
}
.screen.active {
  display: flex;
  flex-direction: column;
}

/* ==========================================================================
   UNIFORM 3:4 ALIGNED ARTWORK STAGE (.art-stage-uncropped)
   All 6 custom artworks are 750x1000 (exact 3:4) — zero crop, zero sidebars!
   ========================================================================== */
.art-stage-uncropped {
  position: relative;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  aspect-ratio: 3 / 4;
  background: rgba(246, 234, 222, 0.65);
}
.art-stage-uncropped::before {
  display: none;
}
.uncropped-fg-img {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  object-fit: cover !important;
  object-position: center center !important;
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

/* ======================== FLOATING CELEBRATION PETALS ======================== */
.celebration-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 160;
  overflow: hidden;
}
.petal-spark {
  position: absolute;
  top: -32px;
  font-size: 20px;
  animation: petalFall linear forwards;
  opacity: 0.92;
}
@keyframes petalFall {
  0% {
    transform: translateY(0) rotate(0deg) scale(0.9);
    opacity: 1;
  }
  100% {
    transform: translateY(106dvh) rotate(320deg) scale(1.15);
    opacity: 0;
  }
}

/* ======================== VIVALDI FOUR SEASONS MINI-PLAYER POPOVER ======================== */
.music-cluster {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}
.music-cluster .violin-pill {
  border-top-right-radius: 10px;
  border-bottom-right-radius: 10px;
  padding-right: 10px;
}
.music-caret-btn {
  border-top-left-radius: 10px;
  border-bottom-left-radius: 10px;
  padding: 8px 9px;
  font-size: 11px;
}
.vivaldi-popover {
  position: fixed;
  top: 64px;
  right: max(16px, calc((100vw - 1180px) / 2 + 16px));
  z-index: 130;
  width: min(370px, calc(100vw - 24px));
  background: var(--bg-card-strong);
  color: var(--text-main);
  border: 1.8px solid var(--border-soft);
  border-radius: 22px;
  padding: 14px 16px;
  box-shadow: 0 20px 48px rgba(24, 14, 10, 0.24);
  animation: popBannerIn 0.2s ease-out;
}
.vivaldi-pop-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.vivaldi-pop-header strong {
  display: block;
  font-size: 13.5px;
  line-height: 1.25;
}
.vivaldi-pop-header small {
  display: block;
  font-size: 11.5px;
  color: var(--text-muted);
  margin-top: 2px;
}
.vivaldi-play-btn {
  flex-shrink: 0;
  padding: 6px 12px;
  font-size: 12px;
}
.vivaldi-season-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 11px;
}
.season-chip {
  padding: 5px 10px;
  border-radius: 999px;
  border: 1.5px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 800;
}
.season-chip.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #ffffff;
}
.vivaldi-volume-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-muted);
}
.vivaldi-volume-row input[type="range"] {
  flex: 1;
  accent-color: var(--accent);
}

/* ======================== ANIMATED VIOLIN SOUNDWAVE EQUALIZER PILL ======================== */
.violin-pill {
  gap: 6px;
}
.eq-bars {
  display: inline-flex;
  align-items: flex-end;
  gap: 2px;
  height: 12px;
  width: 12px;
}
.eq-bars i {
  display: block;
  width: 2.5px;
  height: 4px;
  border-radius: 2px;
  background: var(--accent);
  transition: height 0.2s ease;
}
.violin-pill.playing .eq-bars i:nth-child(1) {
  animation: eqBounce 0.85s ease-in-out infinite alternate;
}
.violin-pill.playing .eq-bars i:nth-child(2) {
  animation: eqBounce 0.62s ease-in-out 0.18s infinite alternate;
}
.violin-pill.playing .eq-bars i:nth-child(3) {
  animation: eqBounce 0.95s ease-in-out 0.32s infinite alternate;
}
.violin-pill.muted {
  opacity: 0.68;
}
@keyframes eqBounce {
  0% { height: 3px; }
  100% { height: 12px; }
}

/* ======================== SHARED BUTTONS, GOOGLE BUTTONS & PILLS ======================== */
.pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 13px;
  border-radius: 999px;
  border: 1.5px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
  text-decoration: none;
}
.pill-btn:hover {
  border-color: var(--accent);
}
.leaderboard-pill {
  border-color: rgba(217, 147, 38, 0.45);
  background: linear-gradient(135deg, var(--bg-card-strong), rgba(253, 230, 138, 0.22));
}
.character-pill {
  padding: 5px 12px 5px 6px;
}
.pill-char-thumb {
  width: 26px;
  height: 26px;
  object-fit: contain;
  border-radius: 7px;
  background: var(--accent-soft);
}
.icon-pill {
  padding: 8px 11px;
}

.google-signin-pill,
.google-hero-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 999px;
  border: 1.5px solid rgba(60, 64, 67, 0.22);
  background: #ffffff;
  color: #1f1f1f;
  font-weight: 800;
  text-decoration: none;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.08);
}
.google-signin-pill {
  padding: 7px 13px;
  font-size: 12.5px;
}
.google-hero-btn {
  padding: 10px 17px;
  font-size: 13.5px;
}
.google-signin-pill:hover,
.google-hero-btn:hover {
  border-color: #4285f4;
  box-shadow: 0 5px 14px rgba(66, 133, 244, 0.20);
}
.google-g-svg {
  width: 17px;
  height: 17px;
  flex-shrink: 0;
}

.cta-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 11px 20px;
  border-radius: 999px;
  border: none;
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #ffffff;
  font-size: 14px;
  font-weight: 800;
  box-shadow: 0 6px 18px rgba(184, 83, 53, 0.28);
}
.cta-primary:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

/* ======================== SCREEN 1: HOME SANCTUARY ======================== */
.home-topbar {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: max(12px, env(safe-area-inset-top)) 18px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.brand-lockup {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}
.brand-logo-box {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  border: 2px solid var(--accent);
  background: var(--bg-card-strong);
  box-shadow: var(--shadow-pop);
  padding: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.brand-logo-box img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.brand-kicker {
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.brand-title {
  margin: 1px 0 0;
  font-size: clamp(18px, 2.3vw, 24px);
  font-weight: 900;
  letter-spacing: -0.01em;
}
.brand-title span {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 0.86em;
}
.top-actions {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.home-main {
  max-width: 1180px;
  width: 100%;
  margin: 0 auto;
  padding: 6px 18px max(28px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.welcome-hero-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-radius: 26px;
  padding: 18px 22px;
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  gap: 22px;
  box-shadow: var(--shadow-cozy);
}
.hero-sticker-stage {
  border-radius: 20px;
  width: 150px;
  aspect-ratio: 3 / 4;
  padding: 0;
  border: 1.5px solid var(--border-soft);
  box-shadow: var(--shadow-pop);
}
.hero-chibi-img:hover {
  transform: scale(1.04);
}
.hero-top-pills {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 7px;
}
.hero-greeting-pill,
.hero-season-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 11px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 800;
}
.hero-greeting-pill {
  background: var(--accent-soft);
  color: var(--accent-strong);
}
.hero-season-pill {
  background: var(--bg-card-strong);
  border: 1px solid var(--border-soft);
  color: var(--text-main);
}
body[data-theme="sakura"] .hero-greeting-pill {
  color: #ffd1e1;
}
.hero-copy h2 {
  margin: 0 0 6px;
  font-size: clamp(18px, 2.3vw, 24px);
  line-height: 1.25;
}
.hero-copy p {
  margin: 0 0 14px;
  color: var(--text-muted);
  font-size: 13.8px;
  line-height: 1.52;
}
.hero-quick-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 10px;
}

.section-heading-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.section-heading-row h3 {
  margin: 0;
  font-size: 17px;
}
.solved-progress-pill {
  font-size: 12px;
  font-weight: 800;
  color: var(--accent);
  background: var(--accent-soft);
  padding: 4px 11px;
  border-radius: 999px;
}

/* 4-Season Chapter Cards with Full Uncropped Portrait Stages */
.chapters-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}
.chapter-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-radius: 22px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-cozy);
  cursor: pointer;
  text-align: left;
  padding: 0;
  color: var(--text-main);
}
.chapter-card:hover {
  transform: translateY(-3px);
  border-color: var(--accent);
}
.chapter-art-banner {
  position: relative;
  width: 100%;
  aspect-ratio: 3 / 4;
  padding: 0;
  border-bottom: 1px solid var(--border-soft);
}
.chapter-card:hover .chapter-art-banner .uncropped-fg-img {
  transform: scale(1.03);
}
.chapter-meta-pills-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 2px;
}
.chapter-season-tag {
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}
body[data-theme="sakura"] .chapter-season-tag {
  color: #ffd1e1;
}
.chapter-status-pill {
  padding: 3px 8px;
  border-radius: 999px;
  background: rgba(60, 42, 34, 0.10);
  color: var(--text-main);
  font-size: 10.5px;
  font-weight: 800;
  white-space: nowrap;
}
.chapter-status-pill.solved {
  background: rgba(22, 128, 75, 0.16);
  color: #15803d;
}
.chapter-card-body {
  padding: 13px 14px 15px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  flex: 1;
}
.chapter-kicker {
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
}
.chapter-card-body h4 {
  margin: 0;
  font-size: 16px;
}
.chapter-card-body p {
  margin: 2px 0 8px;
  font-size: 12.5px;
  color: var(--text-muted);
  line-height: 1.42;
  flex: 1;
}
.chapter-badge-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 11.5px;
  font-weight: 800;
  color: var(--accent-strong);
}
body[data-theme="sakura"] .chapter-badge-row {
  color: #ffb3cb;
}

.endless-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-radius: 22px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
  box-shadow: var(--shadow-cozy);
}
.endless-kicker {
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.endless-info h3 {
  margin: 3px 0 4px;
  font-size: 17px;
}
.endless-info p {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
  max-width: 520px;
}
.diff-buttons-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}
.diff-launch-btn {
  padding: 9px 15px;
  border-radius: 13px;
  border: 1.5px solid var(--border-soft);
  background: var(--bg-card-strong);
  color: var(--text-main);
  font-size: 13px;
  font-weight: 800;
}
.diff-launch-btn:hover {
  border-color: var(--accent);
  background: var(--accent-soft);
  transform: translateY(-2px);
}

/* ======================== SCREEN 2: ACTIVE PUZZLE SANCTUARY ======================== */
.game-topbar {
  max-width: 1220px;
  width: 100%;
  margin: 0 auto;
  padding: max(8px, env(safe-area-inset-top)) 14px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.game-title-cluster {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}
.puzzle-mode-pill {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 800;
  white-space: nowrap;
}
#hudPuzzleTitle {
  font-size: 15px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.game-meta-right {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}
.timer-pill {
  font-variant-numeric: tabular-nums;
  font-size: 13px;
  font-weight: 800;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1px solid var(--border-soft);
}
.tiny-toggle {
  padding: 5px 10px;
  font-size: 11.5px;
}

.game-workspace {
  max-width: 1220px;
  width: 100%;
  margin: 0 auto;
  flex: 1;
  padding: 6px 16px max(12px, env(safe-area-inset-bottom));
  display: grid;
  grid-template-columns: 280px minmax(300px, 520px) 278px;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

/* Uncropped Companion Mascot + Uncropped Framed Chapter Illustration */
.companion-panel {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.mascot-bubble-wrap {
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-radius: 22px;
  padding: 11px 12px;
  display: flex;
  align-items: center;
  gap: 11px;
  box-shadow: var(--shadow-cozy);
}
.mascot-portrait-box {
  width: 68px;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  padding: 0;
  flex-shrink: 0;
  border: 1.5px solid var(--border-soft);
}
.mascot-live-sticker {
  animation: none;
}
@keyframes mascotFloat {
  0%, 100% { transform: translateY(0px); }
  50% { transform: translateY(-2.5px); }
}
.mascot-speech-card {
  min-width: 0;
  flex: 1;
}
.speech-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  margin-bottom: 4px;
}
.speech-header strong {
  font-size: 12.5px;
  color: var(--accent);
}
.progress-mini-chip {
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--accent-soft);
  flex-shrink: 0;
}
#mascotSpeechText {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.42;
  color: var(--text-main);
}

.chapter-art-frame {
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-radius: 22px;
  padding: 10px;
  box-shadow: var(--shadow-cozy);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.chapter-side-stage {
  width: 100%;
  max-width: 236px;
  aspect-ratio: 3 / 4;
  margin: 0 auto;
  border-radius: 16px;
  padding: 0;
  border: 1.5px solid var(--border-soft);
}
.art-frame-caption {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
  text-align: center;
  padding: 0 4px;
}

/* Dynamic Live Objective Strip + 9x9 Sudoku Grid */
.board-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-width: 0;
  width: 100%;
}
.dynamic-hud-strip {
  width: min(100%, 500px, 65dvh, 92vw);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  flex-wrap: wrap;
}
.dyn-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--bg-card);
  border: 1.2px solid var(--border-soft);
  font-size: 11.5px;
  font-weight: 800;
  color: var(--text-main);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}
.streak-chip.hot {
  border-color: #f59e0b;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.22), var(--bg-card-strong));
}
.objective-chip.complete {
  border-color: #16a34a;
  background: rgba(22, 163, 74, 0.14);
}

.board-outer-frame {
  position: relative;
  width: min(100%, 500px, 65dvh, 92vw);
  aspect-ratio: 1 / 1;
  background: var(--border-strong);
  border: 3px solid var(--border-strong);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: var(--shadow-cozy);
  transition: border-radius 0.25s ease, border-color 0.25s ease;
}
.thermo-svg-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 2;
  pointer-events: none;
}
.sudoku-grid {
  width: 100%;
  height: 100%;
  display: grid;
  grid-template-columns: repeat(9, minmax(0, 1fr));
  grid-template-rows: repeat(9, minmax(0, 1fr));
}

.sudoku-cell {
  position: relative;
  border-right: 1px solid var(--border-soft);
  border-bottom: 1px solid var(--border-soft);
  background: var(--cell-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  user-select: none;
  cursor: pointer;
  transition: background 0.14s ease;
}
.sudoku-cell[data-col="2"],
.sudoku-cell[data-col="5"] {
  border-right: 2.5px solid var(--border-strong);
}
.sudoku-cell[data-col="8"] {
  border-right: none;
}
.sudoku-cell[data-row="2"],
.sudoku-cell[data-row="5"] {
  border-bottom: 2.5px solid var(--border-strong);
}
.sudoku-cell[data-row="8"] {
  border-bottom: none;
}

.sudoku-cell.order-box-tint {
  background: var(--cell-order-box);
}
.sudoku-cell.monogram-tint {
  background: var(--cell-monogram);
}
.sudoku-cell.peer-hl {
  background: var(--cell-peer);
}
.sudoku-cell.same-digit-hl {
  background: var(--cell-same);
}
.sudoku-cell.hint-related-hl {
  background: var(--cell-hint);
}
.sudoku-cell.selected {
  background: var(--cell-selected) !important;
  box-shadow: inset 0 0 0 2.5px var(--accent-strong);
}
.sudoku-cell.conflict {
  background: var(--cell-error) !important;
  animation: gentleShake 0.26s ease;
}
@keyframes gentleShake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

/* Dynamic Bonus Cell Watermarks & Café Box Corner Badges */
.sudoku-cell.bonus-target:not(.fogged)::before {
  content: attr(data-bonus-icon);
  position: absolute;
  top: 2px;
  right: 3px;
  z-index: 2;
  font-size: clamp(9px, 1.25vmin, 12px);
  opacity: 0.65;
  pointer-events: none;
}
.sudoku-cell.order-box-anchor:not(.fogged)::before {
  content: "☕";
  position: absolute;
  bottom: 1px;
  right: 2px;
  z-index: 2;
  font-size: clamp(7.5px, 1vmin, 10px);
  opacity: 0.56;
  pointer-events: none;
}

.cell-digit {
  position: relative;
  z-index: 3;
  font-size: clamp(17px, 3.1vmin, 27px);
  font-weight: 800;
  line-height: 1;
  color: var(--digit-user);
}
.sudoku-cell.given .cell-digit {
  color: var(--digit-given);
  font-weight: 900;
}
.sudoku-cell.pop-anim .cell-digit {
  animation: digitPop 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes digitPop {
  0% { transform: scale(0.5); opacity: 0.4; }
  100% { transform: scale(1); opacity: 1; }
}

.cell-notes-grid {
  position: relative;
  z-index: 3;
  width: 90%;
  height: 90%;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  align-items: center;
  justify-items: center;
  pointer-events: none;
}
.cell-notes-grid span {
  font-size: clamp(7.5px, 1.15vmin, 10.5px);
  font-weight: 800;
  line-height: 1;
  color: var(--text-muted);
}

/* Morning Mist Fog-of-War Veil */
.sudoku-cell.fogged {
  background: var(--fog-bg) !important;
}
.sudoku-cell.fogged::after {
  content: "☁️";
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(12px, 2vmin, 17px);
  opacity: 0.42;
}
.sudoku-cell.fogged .cell-digit,
.sudoku-cell.fogged .cell-notes-grid {
  opacity: 0;
}

/* Controls & Keypad */
.controls-panel {
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-radius: 24px;
  padding: 15px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  box-shadow: var(--shadow-cozy);
}
.tool-actions-bar {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 6px;
}
.tool-btn {
  padding: 8px 4px;
  border-radius: 13px;
  border: 1.5px solid var(--border-soft);
  background: var(--bg-card-strong);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.tool-btn.active {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}
body[data-theme="sakura"] .tool-btn.active {
  color: #ffc2d6;
}
.hint-tool-btn {
  border-color: rgba(217, 147, 38, 0.45);
}
.tool-ic {
  font-size: 17px;
  line-height: 1;
}
.tool-btn small {
  font-size: 10px;
  font-weight: 800;
  white-space: nowrap;
}

.numpad-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}
.num-btn {
  position: relative;
  min-height: 54px;
  border-radius: 15px;
  border: 1.5px solid var(--border-soft);
  border-bottom-width: 3px;
  background: var(--bg-card-strong);
  color: var(--text-main);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 4px;
}
.num-btn:hover {
  border-color: var(--accent);
}
.num-btn.pinned {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 2px var(--accent-soft);
}
.num-btn.completed-digit {
  opacity: 0.42;
}
.num-main {
  font-size: 21px;
  font-weight: 900;
  line-height: 1.05;
}
.num-rem {
  font-size: 10px;
  font-weight: 800;
  color: var(--text-muted);
}

.fast-mode-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.fast-pin-pill {
  padding: 6px 11px;
  border-radius: 999px;
  border: 1px solid var(--border-soft);
  background: var(--bg-card-strong);
  color: var(--text-main);
  font-size: 11.5px;
  font-weight: 700;
}
.fast-pin-pill.active {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.link-subtle-btn {
  border: none;
  background: transparent;
  color: var(--text-muted);
  font-size: 11.5px;
  font-weight: 700;
  text-decoration: underline;
}

/* ======================== MODALS: CHARACTER PICKER, VICTORY & HUMAN LEADERBOARD ======================== */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(24, 16, 14, 0.64);
  backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 14px;
}
.modal-card {
  position: relative;
  width: min(560px, 95vw);
  max-height: calc(100dvh - 28px);
  overflow-y: auto;
  background: var(--bg-card-strong);
  color: var(--text-main);
  border: 2px solid var(--border-soft);
  border-radius: 26px;
  padding: 20px 22px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
}
.character-modal-card {
  width: min(760px, 96vw);
}
.leaderboard-modal-card {
  width: min(680px, 96vw);
}
.modal-close-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 15px;
  font-weight: 800;
  flex-shrink: 0;
}
.victory-card > .modal-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
}
.modal-top-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 12px;
}
.modal-top-row h2 {
  margin: 2px 0 0;
  font-size: 20px;
}

/* Google Auth + Uncropped 6-Character Picker Grid */
.char-auth-banner {
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-radius: 18px;
  padding: 12px 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 12px;
}
.char-auth-copy {
  flex: 1;
  min-width: 220px;
}
.char-auth-copy strong {
  display: block;
  font-size: 13.5px;
  margin-bottom: 2px;
}
.char-auth-copy small {
  font-size: 12px;
  color: var(--text-muted);
}
.char-name-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}
.char-name-bar label {
  font-size: 12.5px;
  font-weight: 800;
  color: var(--text-muted);
}
.wide-name-input {
  width: 220px !important;
}

.character-cards-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.character-choice-card {
  background: var(--bg-card);
  border: 2px solid var(--border-soft);
  border-radius: 20px;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 7px;
  text-align: center;
  color: var(--text-main);
}
.character-choice-card:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}
.character-choice-card.selected {
  border-color: var(--accent);
  background: var(--accent-soft);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.char-card-art {
  width: 100%;
  max-width: 144px;
  aspect-ratio: 3 / 4;
  margin: 0 auto;
  border-radius: 14px;
  padding: 0;
  border: 1px solid var(--border-soft);
}
.character-choice-card strong {
  font-size: 13px;
  line-height: 1.2;
}
.character-choice-card small {
  font-size: 11px;
  color: var(--text-muted);
  line-height: 1.25;
}

/* Victory Modal (Clean Score Breakdown — No Photobook) */
.victory-header {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 14px;
}
.victory-char-stage {
  width: 84px;
  aspect-ratio: 3 / 4;
  border-radius: 16px;
  padding: 0;
  flex-shrink: 0;
  border: 1.5px solid var(--border-soft);
}
.victory-kicker {
  font-size: 10.5px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--accent);
}
.victory-header h2 {
  margin: 2px 0 4px;
  font-size: 20px;
}
.victory-stats {
  margin: 0;
  font-size: 13px;
  color: var(--text-muted);
}
.victory-breakdown-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 12px;
}
.v-stat-box {
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-radius: 14px;
  padding: 9px 8px;
  text-align: center;
}
.v-stat-box.highlight {
  border-color: rgba(217, 147, 38, 0.5);
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.16), var(--bg-card));
}
.v-stat-box small {
  display: block;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 3px;
}
.v-stat-box strong {
  font-size: 15px;
  font-weight: 900;
  color: var(--text-main);
}

.victory-rank-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 15px;
  background: linear-gradient(135deg, rgba(251, 191, 36, 0.20), var(--accent-soft));
  border: 1.5px solid rgba(217, 147, 38, 0.45);
  margin-bottom: 12px;
  font-size: 12.5px;
  font-weight: 800;
  animation: popBannerIn 0.45s cubic-bezier(0.34, 1.56, 0.64, 1);
}
@keyframes popBannerIn {
  0% { transform: scale(0.95); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}
.rank-sparkle-ic {
  font-size: 20px;
  animation: crownBob 1.8s ease-in-out infinite;
}
.modal-actions-row {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

/* ======================== HUMAN-ONLY LEADERBOARD STYLES ======================== */
.mini-kicker-lbl {
  display: block;
  font-size: 9.5px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--accent);
  margin-bottom: 3px;
}
.lb-name-input {
  border-radius: 10px;
  border: 1.5px solid var(--border-soft);
  background: var(--bg-card-strong);
  color: var(--text-main);
  padding: 6px 10px;
  font-size: 13px;
  font-weight: 800;
  width: 156px;
}
.lb-period-tabs {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 7px;
  margin-bottom: 10px;
}
.lb-tab {
  padding: 8px 10px;
  border-radius: 13px;
  border: 1.5px solid var(--border-soft);
  background: var(--bg-card);
  color: var(--text-main);
  font-size: 12.5px;
  font-weight: 800;
  text-align: center;
}
.lb-tab.active {
  border-color: var(--accent);
  background: linear-gradient(135deg, var(--accent), var(--accent-strong));
  color: #ffffff;
}
.lb-subbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 12px;
}
.lb-cozy-subtitle {
  font-size: 12px;
  font-weight: 700;
  color: var(--text-muted);
}

/* Top-3 Rising Animated Podium */
.lb-podium-stage {
  display: grid;
  grid-template-columns: 1fr 1.14fr 1fr;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 10px 0;
  margin-bottom: 14px;
  background: radial-gradient(circle at 50% 25%, rgba(251, 191, 36, 0.18), transparent 72%);
  border-radius: 22px;
}
.podium-column {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  transform-origin: bottom center;
  animation: podiumRise 0.62s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}
.podium-column.rank-2 { animation-delay: 0.08s; }
.podium-column.rank-1 { animation-delay: 0.18s; }
.podium-column.rank-3 { animation-delay: 0.26s; }
@keyframes podiumRise {
  0% { opacity: 0; transform: translateY(28px) scale(0.88); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.podium-crown {
  font-size: 22px;
  line-height: 1;
  margin-bottom: 3px;
  animation: crownBob 2.1s ease-in-out infinite;
}
@keyframes crownBob {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-4px) rotate(3deg); }
}
.podium-avatar-wrap {
  position: relative;
  width: 60px;
  aspect-ratio: 3 / 4;
  border-radius: 14px;
  padding: 0;
  overflow: hidden;
  background: var(--bg-card-strong);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.14);
  margin-bottom: 6px;
}
.podium-column.rank-1 .podium-avatar-wrap {
  width: 70px;
  aspect-ratio: 3 / 4;
  border: 3px solid #f59e0b;
  box-shadow: 0 0 22px rgba(245, 158, 11, 0.36);
}
.podium-column.rank-2 .podium-avatar-wrap {
  border: 2.5px solid #cbd5e1;
}
.podium-column.rank-3 .podium-avatar-wrap {
  border: 2.5px solid #d97757;
}
.podium-avatar-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.podium-name {
  font-size: 12px;
  font-weight: 900;
  max-width: 138px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.podium-metric {
  font-size: 11px;
  font-weight: 800;
  color: var(--accent);
  margin: 2px 0 6px;
}
.podium-pedestal {
  width: 100%;
  border-radius: 16px 16px 10px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-weight: 900;
  color: #3d2822;
  box-shadow: inset 0 2px 0 rgba(255, 255, 255, 0.55);
}
.podium-column.rank-1 .podium-pedestal {
  height: 74px;
  background: linear-gradient(180deg, #fde68a 0%, #f59e0b 100%);
  font-size: 19px;
}
.podium-column.rank-2 .podium-pedestal {
  height: 54px;
  background: linear-gradient(180deg, #f1f5f9 0%, #cbd5e1 100%);
  font-size: 16px;
}
.podium-column.rank-3 .podium-pedestal {
  height: 44px;
  background: linear-gradient(180deg, #fed7aa 0%, #ea9a6c 100%);
  font-size: 15px;
}

.lb-empty-state {
  background: var(--bg-card);
  border: 1.5px dashed var(--border-soft);
  border-radius: 20px;
  padding: 22px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.lb-empty-state img {
  width: 84px;
  height: 98px;
  object-fit: contain;
}
.lb-empty-state strong {
  font-size: 15px;
}
.lb-empty-state p {
  margin: 0;
  font-size: 12.5px;
  color: var(--text-muted);
  max-width: 380px;
}

.lb-rows-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.lb-row-card {
  background: var(--bg-card);
  border: 1.5px solid var(--border-soft);
  border-radius: 16px;
  padding: 9px 12px;
  display: grid;
  grid-template-columns: 32px 44px 1fr auto;
  align-items: center;
  gap: 10px;
  animation: rowSlideIn 0.42s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(var(--row-idx, 0) * 55ms);
}
.lb-row-card.is-me {
  border-color: var(--accent);
  background: linear-gradient(90deg, var(--accent-soft), var(--bg-card-strong));
  box-shadow: 0 4px 14px rgba(217, 119, 87, 0.16);
}
@keyframes rowSlideIn {
  0% { opacity: 0; transform: translateX(-14px); }
  100% { opacity: 1; transform: translateX(0); }
}
.lb-rank-num {
  font-size: 14px;
  font-weight: 900;
  color: var(--text-muted);
  text-align: center;
}
.lb-row-avatar {
  width: 39px;
  aspect-ratio: 3 / 4;
  border-radius: 9px;
  object-fit: cover;
  background: var(--bg-card-strong);
  padding: 0;
}
.lb-row-info {
  min-width: 0;
}
.lb-row-title-line {
  display: flex;
  align-items: center;
  gap: 6px;
}
.lb-row-title-line strong {
  font-size: 13.5px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.me-badge-chip {
  padding: 1px 7px;
  border-radius: 999px;
  background: var(--accent);
  color: #ffffff;
  font-size: 10px;
  font-weight: 900;
}
.lb-bar-track {
  margin-top: 5px;
  height: 6px;
  border-radius: 999px;
  background: rgba(148, 130, 120, 0.18);
  overflow: hidden;
}
.lb-bar-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--accent), #f59e0b);
  transform-origin: left center;
  animation: barSweep 0.75s cubic-bezier(0.22, 1, 0.36, 1) backwards;
  animation-delay: calc(var(--row-idx, 0) * 55ms + 120ms);
}
@keyframes barSweep {
  0% { transform: scaleX(0); }
  100% { transform: scaleX(1); }
}
.lb-row-score {
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.lb-row-score strong {
  display: block;
  font-size: 14px;
  color: var(--accent-strong);
}
body[data-theme="sakura"] .lb-row-score strong {
  color: #ffb3cb;
}
.lb-row-score small {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 700;
}

/* ======================== RESPONSIVE 1: TABLET LANDSCAPE & MEDIUM SCREENS ======================== */
@media (max-width: 1160px) and (min-height: 541px) and (orientation: landscape) {
  .game-workspace {
    grid-template-columns: 224px minmax(320px, 1fr) 236px;
    gap: 14px;
    padding: 6px 14px 10px;
  }
  .chapter-side-stage {
    max-width: 184px;
  }
  .controls-panel {
    padding: 12px;
    gap: 9px;
  }
}

/* ======================== RESPONSIVE 1B: TABLET PORTRAIT ======================== */
@media (max-width: 1080px) and (orientation: portrait) {
  .chapters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .game-workspace {
    grid-template-columns: 1fr;
    max-width: 540px;
    gap: 8px;
  }
  .board-outer-frame,
  .dynamic-hud-strip {
    width: min(100%, 480px, 50dvh, 92vw);
  }
  .chapter-art-frame {
    display: none;
  }
}

/* ======================== RESPONSIVE 2: MOBILE PORTRAIT (360x740 .. 430x932) ======================== */
@media (max-width: 680px) and (orientation: portrait) {
  .hide-xs,
  .hide-mobile-portrait {
    display: none !important;
  }
  .home-topbar {
    padding: max(10px, env(safe-area-inset-top)) 12px 6px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  .top-actions {
    justify-content: space-between;
    flex-wrap: nowrap;
  }
  .brand-logo-box {
    width: 38px;
    height: 38px;
  }
  .brand-title {
    font-size: 17px;
  }
  .pill-btn {
    padding: 6px 10px;
    font-size: 12px;
  }
  .google-signin-pill {
    padding: 6px 10px;
    font-size: 11.5px;
  }
  .home-main {
    padding: 4px 12px 24px;
    gap: 14px;
  }
  .welcome-hero-card {
    grid-template-columns: 1fr;
    padding: 14px;
    gap: 12px;
    text-align: center;
  }
  .hero-sticker-stage {
    width: 132px;
    aspect-ratio: 3 / 4;
    height: auto;
    margin: 0 auto;
  }
  .hero-top-pills,
  .hero-quick-row {
    justify-content: center;
  }
  .chapters-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
  }
  .chapter-art-banner {
    width: 100%;
    aspect-ratio: 3 / 4;
    height: auto;
  }
  .chapter-card-body {
    padding: 10px 10px 12px;
  }
  .chapter-card-body h4 {
    font-size: 14px;
  }
  .chapter-card-body p {
    font-size: 11.5px;
  }
  .character-cards-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .victory-breakdown-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
  .lb-period-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  /* Zero-Scroll Mobile Portrait Game Layout */
  #gameScreen {
    height: 100dvh;
    overflow: hidden;
  }
  .game-topbar {
    padding: max(6px, env(safe-area-inset-top)) 10px 4px;
  }
  .puzzle-mode-pill {
    display: none;
  }
  #hudPuzzleTitle {
    font-size: 13.5px;
  }
  .game-workspace {
    padding: 2px 10px max(8px, env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 5px;
    min-height: 0;
  }
  .companion-panel {
    width: 100%;
  }
  .mascot-bubble-wrap {
    padding: 6px 10px;
    border-radius: 16px;
    gap: 8px;
  }
  .mascot-portrait-box {
    width: 48px;
    aspect-ratio: 3 / 4;
    height: auto;
    border-radius: 10px;
  }
  #mascotSpeechText {
    font-size: 11.5px;
    line-height: 1.28;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .dynamic-hud-strip {
    width: min(94vw, 46dvh);
  }
  .dyn-chip {
    padding: 3px 8px;
    font-size: 10.5px;
  }
  .board-outer-frame {
    width: min(94vw, 46dvh);
    border-radius: 14px;
  }
  .controls-panel {
    width: 100%;
    padding: 8px 10px;
    border-radius: 18px;
    gap: 6px;
  }
  .numpad-grid {
    grid-template-columns: repeat(9, minmax(0, 1fr));
    gap: 4px;
  }
  .num-btn {
    min-height: 44px;
    border-radius: 10px;
    padding: 2px 0;
  }
  .num-main {
    font-size: 17px;
  }
  .num-rem {
    font-size: 8.5px;
  }
  .tool-btn {
    padding: 5px 2px;
    border-radius: 10px;
  }
  .tool-ic {
    font-size: 14.5px;
  }
}

/* ======================== RESPONSIVE 3: MOBILE HORIZONTAL / LANDSCAPE (740x360 .. 932x430) ======================== */
@media (max-height: 540px) and (orientation: landscape) {
  .hide-compact-ls {
    display: none !important;
  }
  .home-topbar {
    padding: 6px 14px 4px;
  }
  .welcome-hero-card {
    grid-template-columns: 114px 1fr;
    padding: 10px 14px;
    gap: 14px;
  }
  .hero-sticker-stage {
    width: 114px;
    aspect-ratio: 3 / 4;
    height: auto;
  }
  .hero-copy h2 {
    font-size: 16px;
  }
  .hero-copy p {
    font-size: 12px;
    margin-bottom: 8px;
  }
  .chapters-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 10px;
  }
  .chapter-art-banner {
    width: 100%;
    aspect-ratio: 3 / 4;
    height: auto;
  }

  #gameScreen {
    height: 100dvh;
    max-height: 100dvh;
    overflow: hidden;
  }
  .game-topbar {
    padding: 4px max(12px, env(safe-area-inset-right)) 3px max(12px, env(safe-area-inset-left));
    min-height: 34px;
  }
  .game-topbar .pill-btn {
    padding: 4px 8px;
    font-size: 11px;
  }
  .timer-pill {
    padding: 3px 8px;
    font-size: 11px;
  }
  .game-workspace {
    height: calc(100dvh - 38px);
    max-height: calc(100dvh - 38px);
    padding: 3px max(12px, env(safe-area-inset-right)) 6px max(12px, env(safe-area-inset-left));
    display: grid;
    grid-template-columns: auto minmax(260px, 380px);
    grid-template-rows: auto 1fr;
    grid-template-areas:
      "board companion"
      "board controls";
    align-items: stretch;
    justify-content: center;
    column-gap: 14px;
    row-gap: 5px;
  }
  .board-stage {
    grid-area: board;
    gap: 4px;
  }
  .dynamic-hud-strip {
    width: min(calc(100dvh - 68px), 44vw);
    flex-wrap: nowrap;
    gap: 4px;
  }
  .dyn-chip {
    padding: 2px 6px;
    font-size: 9.5px;
    white-space: nowrap;
  }
  .board-outer-frame {
    width: min(calc(100dvh - 68px), 44vw);
    height: min(calc(100dvh - 68px), 44vw);
    border-radius: 13px;
    border-width: 2.5px;
  }
  .companion-panel {
    grid-area: companion;
  }
  .chapter-art-frame {
    display: none;
  }
  .mascot-bubble-wrap {
    padding: 5px 9px;
    border-radius: 14px;
    gap: 8px;
  }
  .mascot-portrait-box {
    width: 42px;
    aspect-ratio: 3 / 4;
    height: auto;
    border-radius: 10px;
  }
  .speech-header strong {
    font-size: 11.5px;
  }
  #mascotSpeechText {
    font-size: 11px;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }
  .controls-panel {
    grid-area: controls;
    padding: 7px 9px;
    border-radius: 16px;
    gap: 5px;
    justify-content: space-between;
    min-height: 0;
  }
  .tool-actions-bar {
    gap: 4px;
  }
  .tool-btn {
    padding: 4px 2px;
    border-radius: 9px;
    gap: 1px;
  }
  .tool-ic {
    font-size: 13.5px;
  }
  .tool-btn small {
    font-size: 9px;
  }
  .numpad-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 4px;
    flex: 1;
    min-height: 0;
  }
  .num-btn {
    min-height: 33px;
    border-radius: 10px;
    border-bottom-width: 2px;
    flex-direction: row;
    gap: 5px;
    padding: 2px 6px;
  }
  .num-main {
    font-size: 15.5px;
  }
  .num-rem {
    font-size: 9.5px;
  }
  .fast-pin-pill {
    padding: 3px 8px;
    font-size: 10px;
  }
  .link-subtle-btn {
    font-size: 10px;
  }
}

/* ======================== PRINTABLE PUZZLE CARD ======================== */
@media print {
  body {
    background: #ffffff !important;
    color: #111111 !important;
  }
  #homeScreen,
  .game-topbar button,
  .controls-panel,
  .modal-backdrop,
  .vivaldi-popover {
    display: none !important;
  }
  #gameScreen {
    display: block !important;
  }
  .game-workspace {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    gap: 18px !important;
  }
  .board-outer-frame {
    width: 460px !important;
    height: 460px !important;
    border: 3px solid #111 !important;
  }
  .sudoku-cell.fogged::after {
    display: none !important;
  }
  .sudoku-cell.fogged .cell-digit {
    opacity: 1 !important;
  }
}
