/* ==========================================================================
   Clark Saga — Warm Cozy Sunlit Parlor Styling
   100% Offline, Zero External Fonts/CDNs, Senior-Friendly iPhone-First PWA
   ========================================================================== */

:root {
  --bg-cream: #FAF6EE;
  --bg-paper: #FFFDF8;
  --bg-parchment: #F1E8D8;
  --bg-desk: #E6DFD1;

  --felt-green: #1E5643;
  --felt-green-deep: #153E30;
  --felt-green-light: #286E56;

  --walnut: #5A3B28;
  --walnut-dark: #3F281A;
  --walnut-light: #7A543B;

  --coral: #D85A3A;
  --coral-hover: #C24A2C;
  --gold: #E5A938;
  --gold-soft: #FBF0D6;

  --ink: #1F1B17;
  --ink-muted: #5C4F43;
  --ink-light: #7C6E61;
  --border-warm: #DED2BE;
  --shadow-soft: 0 8px 24px rgba(31, 27, 23, 0.12);
  --shadow-card: 0 16px 40px rgba(31, 27, 23, 0.22);

  --font-serif: Georgia, "Iowan Old Style", "Palatino Linotype", "Book Antiqua", serif;
  --font-sans: -apple-system, BlinkMacSystemFont, "SF Pro Rounded", "SF Pro Text", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
}

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

html,
body {
  margin: 0;
  padding: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-cream);
  color: var(--ink);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.35;
  -webkit-font-smoothing: antialiased;
  user-select: none;
  -webkit-user-select: none;
}

button {
  font-family: inherit;
  font-size: 16px;
  color: inherit;
  cursor: pointer;
  border: none;
  background: none;
  padding: 0;
  touch-action: manipulation;
}

button:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

[hidden] {
  display: none !important;
}

/* ---- Desktop Centered Phone-Card Feel ---- */

@media (min-width: 560px) {
  body {
    background:
      radial-gradient(circle at 20% 15%, rgba(229, 169, 56, 0.14), transparent 50%),
      radial-gradient(circle at 80% 85%, rgba(30, 86, 67, 0.14), transparent 52%),
      var(--bg-desk);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px;
  }

  .app-shell {
    max-width: 480px;
    max-height: 920px;
    height: calc(100dvh - 24px);
    border-radius: 28px;
    box-shadow: 0 24px 64px rgba(31, 27, 23, 0.24), 0 0 0 1px rgba(90, 59, 40, 0.14);
    overflow: hidden;
  }
}

/* ---- Main App Shell ---- */

.app-shell {
  position: relative;
  width: 100%;
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background-color: var(--bg-cream);
  overflow: hidden;
}

/* ---- Compact Safe-Area Header ---- */

.app-header {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(var(--safe-top) + 4px) 10px 4px 12px;
  min-height: calc(var(--safe-top) + 52px);
  background: linear-gradient(180deg, #FFFDF8 0%, #F7EFE0 100%);
  border-bottom: 1px solid var(--border-warm);
  z-index: 20;
}

.brand-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.brand-logo {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  object-fit: cover;
  background: #FFF9EE;
  border: 2px solid var(--gold);
  box-shadow: 0 2px 6px rgba(90, 59, 40, 0.18);
  flex-shrink: 0;
}

.app-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--walnut-dark);
  white-space: nowrap;
  cursor: pointer;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-paper);
  border: 1.5px solid var(--border-warm);
  color: var(--walnut-dark);
  box-shadow: 0 2px 4px rgba(31, 27, 23, 0.06);
  transition: transform 0.12s ease, background-color 0.15s ease;
}

.icon-btn:active {
  transform: scale(0.94);
  background: var(--bg-parchment);
}

.icon-svg {
  width: 22px;
  height: 22px;
  display: block;
}

#btn-mute .icon-sound-off {
  display: none;
}

#btn-mute.is-muted {
  background: #F4E4DF;
  border-color: #E2B8AC;
  color: #9A3B23;
}

#btn-mute.is-muted .icon-sound-on {
  display: none;
}

#btn-mute.is-muted .icon-sound-off {
  display: block;
}

/* ---- Main Views Container ---- */

.app-main {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.tab-view {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ==========================================================================
   TAB 1: MATCH-3 VIEW
   ========================================================================== */

#match3-view {
  background:
    radial-gradient(circle at 50% 0%, rgba(229, 169, 56, 0.12), transparent 55%),
    var(--bg-cream);
  padding: 6px 10px 6px;
  gap: 6px;
}

.m3-hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  background: var(--bg-paper);
  border: 1.5px solid var(--border-warm);
  border-radius: var(--radius-md);
  padding: 6px 8px;
  box-shadow: 0 3px 10px rgba(90, 59, 40, 0.08);
  min-height: 58px;
}

.hud-pill {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  padding: 4px 8px;
  border-radius: 10px;
  background: var(--bg-parchment);
  border: 1px solid var(--border-warm);
}

.hud-level {
  background: #F6ECDA;
  border-color: #E2CFAF;
}

.hud-moves {
  background: #E9F4EF;
  border-color: #BBD8CB;
  color: #164434;
}

.hud-moves.is-low {
  background: #FCE8E2;
  border-color: #E8A695;
  color: #A63317;
}

.hud-label {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--ink-muted);
  line-height: 1.1;
}

.hud-moves.is-low .hud-label {
  color: #A63317;
}

.hud-value {
  font-size: 21px;
  font-weight: 800;
  line-height: 1.1;
}

.m3-goals {
  flex: 1 1 auto;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 6px 10px;
}

.goal-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  background: #FAF5EB;
  border: 1px solid #E3D6C0;
  border-radius: 10px;
  padding: 3px 8px 3px 5px;
  font-size: 15px;
  font-weight: 700;
  color: var(--ink);
}

.goal-chip.is-done {
  background: #E5F5EC;
  border-color: #A5D6BA;
  color: #1A5C3B;
}

.goal-icon {
  width: 30px;
  height: 30px;
  border-radius: 7px;
  object-fit: contain;
  background: #FFFDF8;
  border: 1px solid rgba(90, 59, 40, 0.16);
  flex-shrink: 0;
}

.goal-emoji {
  font-size: 22px;
  line-height: 1;
}

.goal-count {
  font-size: 16px;
  font-weight: 800;
  white-space: nowrap;
}

.goal-placeholder {
  font-size: 15px;
  font-weight: 600;
  color: var(--ink-muted);
}

.m3-stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.m3-board-frame {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 18px;
  background: linear-gradient(155deg, #6E4932 0%, var(--walnut) 52%, var(--walnut-dark) 100%);
  border: 2px solid #8D6247;
  box-shadow:
    inset 0 2px 3px rgba(255, 240, 215, 0.28),
    inset 0 -3px 8px rgba(25, 14, 7, 0.45),
    0 10px 24px rgba(45, 28, 16, 0.28);
}

.game-canvas {
  display: block;
  touch-action: none;
  border-radius: 11px;
}

.action-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
}

.tool-btn {
  flex: 1 1 0;
  min-height: 46px;
  min-width: 44px;
  padding: 6px 8px;
  border-radius: 13px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--bg-paper);
  border: 1.5px solid var(--border-warm);
  color: var(--walnut-dark);
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 3px 0 #D8C9B0, 0 4px 10px rgba(31, 27, 23, 0.08);
  transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.tool-btn:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 #D8C9B0;
}

.tool-btn-warm {
  background: #FFF6E3;
  border-color: #E2BE79;
  color: #5D3D0F;
  box-shadow: 0 3px 0 #D6AE60, 0 4px 10px rgba(90, 59, 40, 0.1);
}

.tool-icon {
  font-size: 17px;
  line-height: 1;
}

/* ==========================================================================
   TAB 2: MAHJONG SOLITAIRE VIEW (Cozy Emerald Parlor Felt)
   ========================================================================== */

#mahjong-view {
  background:
    radial-gradient(ellipse at 50% 35%, var(--felt-green-light) 0%, var(--felt-green) 58%, var(--felt-green-deep) 100%);
  padding: 6px 8px 6px;
  gap: 6px;
}

.mj-hud {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.mj-layout-pill {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 44px;
  padding: 6px 12px;
  border-radius: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  background: rgba(255, 250, 240, 0.94);
  border: 1.5px solid rgba(229, 169, 56, 0.75);
  color: var(--walnut-dark);
  font-size: 16px;
  font-weight: 700;
  box-shadow: 0 3px 8px rgba(10, 32, 24, 0.25);
}

.mj-layout-pill:active {
  transform: scale(0.98);
}

.mj-layout-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mj-layout-caret {
  font-size: 14px;
  color: var(--walnut);
  flex-shrink: 0;
}

.mj-stats {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.mj-stat-pill {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-width: 60px;
  min-height: 44px;
  padding: 3px 8px;
  border-radius: 11px;
  background: rgba(16, 48, 37, 0.62);
  border: 1px solid rgba(255, 248, 232, 0.24);
  color: #FFFBF2;
}

.mj-stat-lbl {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #CBE4D8;
  line-height: 1.1;
}

.mj-stat-val {
  font-size: 18px;
  font-weight: 800;
  line-height: 1.15;
}

.mj-stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  position: relative;
  border-radius: 14px;
  overflow: hidden;
  border: 1.5px solid rgba(255, 248, 232, 0.16);
  box-shadow: inset 0 4px 18px rgba(8, 28, 21, 0.42);
}

#mahjong-canvas {
  width: 100%;
  height: 100%;
  border-radius: 12px;
}

.mj-actions {
  gap: 6px;
}

.mj-tool-btn {
  flex: 1 1 0;
  min-width: 58px;
  min-height: 46px;
  padding: 4px 4px;
  border-radius: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: rgba(255, 251, 242, 0.94);
  border: 1.5px solid rgba(229, 212, 182, 0.9);
  color: var(--walnut-dark);
  font-size: 12px;
  font-weight: 700;
  box-shadow: 0 3px 0 rgba(12, 36, 27, 0.42);
  transition: transform 0.1s ease, opacity 0.15s ease, background-color 0.15s ease;
}

.mj-tool-btn .tool-icon {
  font-size: 16px;
}

.mj-tool-btn .tool-label {
  font-size: 12px;
  line-height: 1;
}

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

.mj-tool-btn:disabled {
  opacity: 0.48;
  cursor: default;
}

.mj-tool-btn.is-toggled {
  background: #FDECC2;
  border-color: var(--gold);
  color: #53360B;
}

/* ==========================================================================
   TAB 3: TILE ALBUM VIEW
   ========================================================================== */

.album-view {
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--bg-cream);
  padding: 12px 12px 18px;
}

.album-header {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 12px;
}

.album-heading {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 22px;
  color: var(--walnut-dark);
}

.album-sub {
  margin: 2px 0 0;
  font-size: 15px;
  color: var(--ink-muted);
}

.album-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.album-pill {
  min-height: 44px;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bg-paper);
  border: 1.5px solid var(--border-warm);
  color: var(--walnut-dark);
  font-size: 15px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  transition: background-color 0.15s ease, color 0.15s ease, border-color 0.15s ease;
}

.album-pill .pill-count {
  font-weight: 600;
  opacity: 0.8;
}

.album-pill.is-active {
  background: var(--felt-green);
  border-color: var(--felt-green-deep);
  color: #FFFFFF;
}

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

@media (min-width: 440px) {
  .album-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 12px;
  }
}

.album-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 8px 6px 10px;
  min-height: 124px;
  border-radius: 15px;
  background: var(--bg-paper);
  border: 1.5px solid #E4D7C3;
  box-shadow: 0 4px 0 #DDD0BA, 0 5px 12px rgba(90, 59, 40, 0.09);
  text-align: center;
  transition: transform 0.12s ease;
}

.album-card:active {
  transform: translateY(2px);
}

.album-plaque {
  width: 78px;
  height: 78px;
  border-radius: 12px;
  background: linear-gradient(180deg, #FFFDF9 0%, #F7EFE2 100%);
  border: 1.5px solid #E5D7C0;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.album-plaque img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.album-card-name {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink);
  line-height: 1.2;
}

/* ---- Album Zoom Modal ---- */

.album-zoom-card {
  max-width: 400px;
  padding: 16px;
  gap: 12px;
}

.album-zoom-topbar {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.album-zoom-badge {
  display: inline-flex;
  align-items: center;
  padding: 5px 12px;
  border-radius: 999px;
  background: var(--gold-soft);
  border: 1px solid #E4C37A;
  color: #5C3D0E;
  font-size: 14px;
  font-weight: 700;
}

.album-zoom-counter {
  font-size: 14px;
  font-weight: 700;
  color: var(--ink-muted);
}

.album-zoom-stage {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px 0;
}

.album-zoom-plaque {
  width: min(240px, 64vw);
  height: min(240px, 64vw);
  border-radius: 24px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F6EDDC 100%);
  border: 3px solid #E4D4BA;
  box-shadow:
    0 8px 0 #D8C5A5,
    0 16px 32px rgba(90, 59, 40, 0.2);
  padding: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.album-zoom-plaque img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.album-zoom-info {
  text-align: center;
}

.album-zoom-title {
  margin: 0 0 6px;
  font-family: var(--font-serif);
  font-size: 24px;
  color: var(--walnut-dark);
}

.album-zoom-caption {
  margin: 0;
  font-size: 17px;
  line-height: 1.4;
  color: var(--ink);
}

.album-zoom-nav {
  width: 100%;
  display: flex;
  gap: 10px;
}

.album-nav-btn {
  flex: 1 1 0;
}

/* ==========================================================================
   BOTTOM NAVIGATION TAB BAR
   ========================================================================== */

.tab-bar {
  flex: 0 0 auto;
  display: flex;
  align-items: stretch;
  gap: 6px;
  padding: 5px 8px calc(var(--safe-bottom) + 5px);
  background: linear-gradient(180deg, #FFFDF8 0%, #F4EBDC 100%);
  border-top: 1.5px solid var(--border-warm);
  z-index: 20;
}

.tab-btn {
  flex: 1 1 0;
  min-height: 52px;
  min-width: 48px;
  border-radius: 13px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--ink-muted);
  font-weight: 700;
  transition: background-color 0.15s ease, color 0.15s ease, transform 0.1s ease;
}

.tab-btn:active {
  transform: scale(0.96);
}

.tab-btn.is-active {
  background: var(--felt-green);
  color: #FFFFFF;
  box-shadow: 0 3px 10px rgba(30, 86, 67, 0.28);
}

.tab-svg {
  width: 22px;
  height: 22px;
  display: block;
}

.tab-label {
  font-size: 13px;
  line-height: 1.1;
}

/* ==========================================================================
   MODALS, SHEETS & BUTTONS
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(24, 19, 15, 0.56);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.modal-card {
  width: 100%;
  max-width: 390px;
  max-height: calc(100dvh - 32px);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 22px 20px;
  border-radius: 24px;
  background: var(--bg-paper);
  border: 2px solid #E5D7C0;
  box-shadow: var(--shadow-card);
  text-align: center;
}

.celebration-card {
  background:
    radial-gradient(circle at 50% 0%, rgba(229, 169, 56, 0.24), transparent 55%),
    var(--bg-paper);
}

.modal-emblem {
  font-size: 48px;
  line-height: 1;
}

.modal-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 26px;
  color: var(--walnut-dark);
}

.modal-subtitle {
  margin: 0;
  font-size: 17px;
  color: var(--ink);
  line-height: 1.4;
}

.modal-meta {
  margin: 0;
  font-size: 15px;
  font-weight: 700;
  color: var(--felt-green);
}

.modal-actions {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 4px;
}

.btn {
  min-height: 48px;
  min-width: 48px;
  padding: 10px 18px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.btn:active {
  transform: scale(0.97);
}

.btn-lg {
  min-height: 54px;
  font-size: 18px;
}

.btn-primary {
  background: var(--coral);
  color: #FFFFFF;
  box-shadow: 0 4px 0 #A73D22, 0 8px 18px rgba(216, 90, 58, 0.3);
}

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

.btn-secondary {
  background: var(--bg-parchment);
  color: var(--walnut-dark);
  border: 1.5px solid var(--border-warm);
}

.btn-gold {
  background: linear-gradient(180deg, #F0B84B 0%, #DF9D26 100%);
  color: #362205;
  box-shadow: 0 4px 0 #B67D15;
}

/* ---- Layout Picker Sheet ---- */

.modal-sheet {
  text-align: left;
  align-items: stretch;
  padding: 18px 16px;
}

.sheet-header {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.sheet-header .modal-title {
  font-size: 22px;
}

.surprise-btn {
  width: 100%;
}

.layouts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 54dvh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 2px;
}

.layout-option-btn {
  width: 100%;
  min-height: 68px;
  padding: 12px 14px;
  border-radius: 14px;
  background: #FAF5EB;
  border: 1.5px solid #E3D6C0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  text-align: left;
}

.layout-option-btn.is-current {
  background: #E8F4EE;
  border-color: var(--felt-green);
}

.layout-opt-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.layout-opt-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.layout-opt-desc {
  font-size: 13px;
  color: var(--ink-muted);
}

.layout-opt-right {
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 3px;
}

.diff-badge {
  font-size: 12px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--gold-soft);
  color: #69450E;
}

.win-star {
  font-size: 13px;
  font-weight: 700;
  color: #1E6A49;
}

/* ---- Settings Modal ---- */

.settings-card {
  text-align: left;
  align-items: stretch;
  padding: 18px 18px 20px;
}

.settings-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: 14px;
  background: #FAF5EB;
  border: 1px solid #E4D7C2;
}

.setting-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.setting-name {
  font-size: 16px;
  font-weight: 700;
  color: var(--ink);
}

.setting-desc {
  font-size: 13px;
  color: var(--ink-muted);
}

/* 58x44 hit target switch with crisp visual pill track */
.switch-btn {
  position: relative;
  flex-shrink: 0;
  width: 58px;
  height: 44px;
  min-width: 58px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.switch-btn::before {
  content: "";
  width: 54px;
  height: 32px;
  border-radius: 999px;
  background: #C9BDAA;
  transition: background-color 0.18s ease;
}

.switch-btn[aria-checked="true"]::before {
  background: var(--felt-green);
}

.switch-knob {
  position: absolute;
  left: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.25);
  transition: transform 0.18s ease;
}

.switch-btn[aria-checked="true"] .switch-knob {
  transform: translateX(22px);
}

.offline-box {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 13px;
  border-radius: 13px;
  background: #E8F5EE;
  border: 1.5px solid #AED6BF;
  color: #154A33;
  font-size: 14px;
  font-weight: 700;
}

.offline-dot {
  font-size: 18px;
  flex-shrink: 0;
}

.homescreen-tip {
  padding: 11px 13px;
  border-radius: 13px;
  background: var(--gold-soft);
  border: 1px solid #E5C989;
  color: #4D3510;
  font-size: 14px;
  line-height: 1.4;
}

.progress-summary {
  margin: 0;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--ink-muted);
}

/* ---- Floating Warm Toast ---- */

.toast-banner {
  position: absolute;
  left: 50%;
  top: calc(var(--safe-top) + 124px);
  transform: translateX(-50%);
  pointer-events: none;
  max-width: calc(100% - 28px);
  padding: 10px 18px;
  border-radius: 999px;
  background: rgba(31, 27, 23, 0.92);
  color: #FFFBF2;
  font-size: 15px;
  font-weight: 700;
  text-align: center;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.25);
  z-index: 420;
  pointer-events: none;
}

/* ---- Loading Splash ---- */

.loading-splash {
  position: absolute;
  inset: 0;
  z-index: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-cream);
  transition: opacity 0.25s ease;
}

.loading-splash.is-fading {
  opacity: 0;
  pointer-events: none;
}

.splash-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  text-align: center;
}

.splash-img {
  width: 108px;
  height: 108px;
  border-radius: 24px;
  border: 3px solid var(--gold);
  background: #FFFDF8;
  box-shadow: 0 12px 26px rgba(90, 59, 40, 0.18);
}

.splash-title {
  margin: 0;
  font-family: var(--font-serif);
  font-size: 28px;
  color: var(--walnut-dark);
}

.splash-sub {
  margin: 0;
  font-size: 16px;
  color: var(--ink-muted);
}

/* ==========================================================================
   HIDDEN DEVELOPER QA BAR (Only visible with ?dev=1 or 5 taps on title)
   ========================================================================== */

.dev-qa-bar {
  position: fixed;
  top: calc(var(--safe-top) + 60px);
  left: 50%;
  transform: translateX(-50%);
  width: min(440px, calc(100vw - 16px));
  z-index: 450;
  background: rgba(20, 22, 26, 0.95);
  color: #F4F5F7;
  border: 1.5px solid #49505C;
  border-radius: 12px;
  padding: 6px 8px;
  font-size: 12px;
  box-shadow: 0 12px 28px rgba(0, 0, 0, 0.45);
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.dev-qa-bar.is-collapsed {
  top: calc(var(--safe-top) + 10px);
  width: auto;
  left: auto;
  right: 108px;
  transform: none;
  padding: 3px 6px;
}

.dev-qa-bar.is-collapsed .dev-qa-status {
  display: none;
}

.dev-qa-bar.is-collapsed .dev-qa-body {
  display: none;
}

.dev-qa-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
}

.dev-qa-head {
  justify-content: space-between;
}

.dev-qa-title {
  color: #F7C948;
  font-size: 11px;
  letter-spacing: 0.06em;
}

.dev-qa-status {
  flex: 1 1 auto;
  text-align: center;
  color: #A7F3D0;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.dev-qa-lbl {
  font-size: 11px;
  color: #CBD5E1;
  margin-right: 2px;
}

.dev-qa-bar button {
  padding: 4px 8px;
  min-height: 28px;
  border-radius: 6px;
  background: #2C313A;
  color: #F8FAFC;
  border: 1px solid #4B5563;
  font-size: 11px;
  font-weight: 700;
}

.dev-qa-bar button.is-active {
  background: #16A34A;
  border-color: #22C55E;
  color: #FFFFFF;
}

.dev-qa-bar button.dev-btn-accent {
  background: #D85A3A;
  border-color: #F27B5C;
}
