/* ==========================================================================
   Design System — Mini Games Hub
   Tokens: Primitives -> Semantic Roles (OKLCH, Dark & Light)
   ========================================================================== */

:root {
  /* Neutral Primitives (Cool Slate, hue 245, low chroma) */
  --slate-50: oklch(0.985 0.004 245);
  --slate-100: oklch(0.96 0.006 245);
  --slate-200: oklch(0.915 0.009 245);
  --slate-300: oklch(0.84 0.012 245);
  --slate-400: oklch(0.71 0.014 245);
  --slate-500: oklch(0.56 0.015 245);
  --slate-600: oklch(0.45 0.015 245);
  --slate-700: oklch(0.35 0.016 245);
  --slate-800: oklch(0.25 0.016 245);
  --slate-850: oklch(0.205 0.016 245);
  --slate-900: oklch(0.165 0.015 245);
  --slate-950: oklch(0.125 0.014 245);

  /* Accent Primitives (Sky, hue 225) */
  --sky-100: oklch(0.94 0.04 225);
  --sky-400: oklch(0.76 0.14 222);
  --sky-500: oklch(0.67 0.16 225);
  --sky-600: oklch(0.54 0.16 228);
  --sky-700: oklch(0.45 0.14 230);
  --sky-950: oklch(0.16 0.04 230);

  /* Status Primitives (>15 deg OKLCH hue separation) */
  --green-400: oklch(0.76 0.16 150);
  --green-600: oklch(0.53 0.15 150);
  --amber-400: oklch(0.80 0.15 78);
  --amber-600: oklch(0.60 0.15 75);
  --red-400: oklch(0.70 0.19 25);
  --red-600: oklch(0.54 0.20 25);

  /* Layout & Type Metrics */
  --header-height: 60px;
  --nav-height: 68px;
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-xl: 24px;
  --ease-out-quint: cubic-bezier(0.2, 0, 0, 1);
}

/* Dark Theme (Default) */
:root,
[data-theme="dark"] {
  color-scheme: dark;
  --color-bg-canvas: var(--slate-950);
  --color-bg-surface: var(--slate-900);
  --color-bg-surface-2: var(--slate-850);
  --color-bg-elevated: var(--slate-800);
  --color-bg-chrome: oklch(0.145 0.015 245 / 0.88);
  --color-bg-game-stage: oklch(0.105 0.012 245);

  --color-text-primary: var(--slate-50);
  --color-text-secondary: var(--slate-300);
  --color-text-muted: var(--slate-400);

  --color-border-subtle: oklch(1 0 0 / 0.08);
  --color-border-strong: oklch(1 0 0 / 0.16);

  --color-accent-solid: var(--sky-400);
  --color-accent-hover: oklch(0.81 0.13 222);
  --color-accent-subtle: oklch(0.76 0.14 222 / 0.14);
  --color-accent-text: var(--sky-950);
  --color-accent-fg: var(--sky-400);

  --color-success-solid: var(--green-400);
  --color-success-subtle: oklch(0.76 0.16 150 / 0.15);
  --color-warning-solid: var(--amber-400);
  --color-warning-subtle: oklch(0.80 0.15 78 / 0.15);
  --color-danger-solid: var(--red-400);
  --color-danger-subtle: oklch(0.70 0.19 25 / 0.15);

  --color-focus-ring: var(--sky-400);
  --shadow-card: 0 0 0 1px oklch(1 0 0 / 0.08), 0 6px 20px -8px oklch(0 0 0 / 0.45);
  --shadow-card-hover: 0 0 0 1px oklch(1 0 0 / 0.16), 0 10px 24px -8px oklch(0 0 0 / 0.6);
  --shadow-elevated: 0 0 0 1px oklch(1 0 0 / 0.12), 0 18px 40px -10px oklch(0 0 0 / 0.7);
}

/* Light Theme */
[data-theme="light"] {
  color-scheme: light;
  --color-bg-canvas: var(--slate-100);
  --color-bg-surface: oklch(1 0 0);
  --color-bg-surface-2: var(--slate-50);
  --color-bg-elevated: var(--slate-200);
  --color-bg-chrome: oklch(1 0 0 / 0.88);
  --color-bg-game-stage: oklch(0.12 0.015 245);

  --color-text-primary: var(--slate-950);
  --color-text-secondary: var(--slate-700);
  --color-text-muted: var(--slate-600);

  --color-border-subtle: oklch(0 0 0 / 0.08);
  --color-border-strong: oklch(0 0 0 / 0.16);

  --color-accent-solid: var(--sky-600);
  --color-accent-hover: var(--sky-700);
  --color-accent-subtle: oklch(0.54 0.16 228 / 0.11);
  --color-accent-text: oklch(1 0 0);
  --color-accent-fg: var(--sky-600);

  --color-success-solid: var(--green-600);
  --color-success-subtle: oklch(0.53 0.15 150 / 0.12);
  --color-warning-solid: var(--amber-600);
  --color-warning-subtle: oklch(0.60 0.15 75 / 0.12);
  --color-danger-solid: var(--red-600);
  --color-danger-subtle: oklch(0.54 0.20 25 / 0.12);

  --color-focus-ring: var(--sky-600);
  --shadow-card:
    0 0 0 1px oklch(0 0 0 / 0.06),
    0 1px 2px -1px oklch(0 0 0 / 0.06),
    0 4px 10px 0 oklch(0 0 0 / 0.04);
  --shadow-card-hover:
    0 0 0 1px oklch(0 0 0 / 0.1),
    0 2px 4px -1px oklch(0 0 0 / 0.08),
    0 8px 18px 0 oklch(0 0 0 / 0.07);
  --shadow-elevated:
    0 0 0 1px oklch(0 0 0 / 0.08),
    0 16px 36px -8px oklch(0 0 0 / 0.18);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  scroll-padding-block-start: calc(var(--header-height) + 12px);
  scroll-padding-block-end: calc(var(--nav-height) + 16px);
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--color-bg-canvas);
  color: var(--color-text-primary);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Inter, system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.45;
  overflow-x: hidden;
  min-height: 100dvh;
}

:focus-visible {
  outline: 2px solid var(--color-focus-ring);
  outline-offset: 2px;
}

button,
input {
  font-family: inherit;
  color: inherit;
}

.hidden {
  display: none !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.tabular {
  font-variant-numeric: tabular-nums;
}

/* ==========================================================================
   Shell & Sticky Chrome
   ========================================================================== */

.app-shell {
  width: 100%;
  max-width: 520px;
  margin-inline: auto;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  min-height: var(--header-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-block: 10px;
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
  background: var(--color-bg-chrome);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid var(--color-border-subtle);
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}

.topbar-title-group {
  display: flex;
  flex-direction: column;
  min-width: 0;
  flex: 1;
}

.app-title {
  margin: 0;
  font-size: 1.0625rem;
  font-weight: 700;
  line-height: 1.25;
  text-wrap: balance;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-subtitle {
  font-size: 0.75rem;
  line-height: 1.3;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  display: grid;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition-property: transform, background-color, box-shadow;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.icon-btn:not(:disabled):active {
  transform: scale(0.96);
}

.icon-btn svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

@media (hover: hover) {
  .icon-btn:hover {
    background: var(--color-bg-surface-2);
    box-shadow: var(--shadow-card-hover);
  }
}

/* Main View Container */
.main-content {
  flex: 1;
  padding-block: 16px calc(var(--nav-height) + max(20px, env(safe-area-inset-bottom)));
  padding-inline: max(16px, env(safe-area-inset-left)) max(16px, env(safe-area-inset-right));
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.main-content.in-game {
  padding-block-end: max(24px, env(safe-area-inset-bottom));
}

/* ==========================================================================
   Hero Status & Daily Reward Card
   ========================================================================== */

.hero-card {
  background: var(--color-bg-surface);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-xl);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.hero-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.hero-user {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  flex: 1;
}

.badge-avatar {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-md);
  background: var(--color-accent-subtle);
  border: 1px solid var(--color-border-subtle);
  display: grid;
  place-items: center;
  font-size: 1.5rem;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition-property: transform;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.badge-avatar:not(:disabled):active {
  transform: scale(0.96);
}

.hero-meta {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.hero-name-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 0;
}

.hero-name {
  font-size: 1rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.level-pill {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  background: var(--color-accent-subtle);
  color: var(--color-accent-fg);
  white-space: nowrap;
}

.xp-track {
  width: 100%;
  height: 6px;
  border-radius: 999px;
  background: var(--color-bg-elevated);
  overflow: hidden;
}

.xp-fill {
  height: 100%;
  border-radius: 999px;
  background: var(--color-accent-solid);
  transition-property: width;
  transition-duration: 300ms;
  transition-timing-function: var(--ease-out-quint);
}

.xp-caption {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

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

.metric-box {
  background: var(--color-bg-surface-2);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-sm);
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.metric-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.metric-val {
  font-size: 1.0625rem;
  font-weight: 700;
  color: var(--color-text-primary);
}

.daily-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  background: var(--color-accent-subtle);
  border: 1px solid var(--color-border-subtle);
}

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

.daily-title {
  font-size: 0.875rem;
  font-weight: 700;
}

.daily-sub {
  font-size: 0.75rem;
  color: var(--color-text-secondary);
}

/* ==========================================================================
   Buttons
   ========================================================================== */

.btn {
  min-height: 44px;
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  padding-block: 10px;
  padding-inline: 16px;
  font-size: 0.875rem;
  font-weight: 700;
  line-height: 1.2;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--color-accent-solid);
  color: var(--color-accent-text);
  -webkit-tap-highlight-color: transparent;
  transition-property: transform, background-color, opacity;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.btn:not(:disabled):active {
  transform: scale(0.96);
}

.btn:disabled {
  opacity: 0.52;
  cursor: not-allowed;
}

.btn-with-icon-start {
  padding-inline-start: 14px;
  padding-inline-end: 16px;
}

.btn-secondary {
  background: var(--color-bg-surface-2);
  color: var(--color-text-primary);
  border-color: var(--color-border-strong);
}

.btn-sm {
  min-height: 38px;
  padding-block: 8px;
  padding-inline: 12px;
  font-size: 0.8125rem;
}

.btn-block {
  width: 100%;
}

@media (hover: hover) {
  .btn:not(:disabled):hover {
    background: var(--color-accent-hover);
  }
  .btn-secondary:not(:disabled):hover {
    background: var(--color-bg-elevated);
  }
}

/* ==========================================================================
   Search, Category Chips & Game Grid
   ========================================================================== */

.toolbar-stack {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.search-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.search-box {
  position: relative;
  flex: 1;
  min-width: 0;
}

.search-icon {
  position: absolute;
  inset-inline-start: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  color: var(--color-text-muted);
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
  pointer-events: none;
}

.search-input {
  width: 100%;
  min-height: 44px;
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border-strong);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  padding-block: 10px;
  padding-inline: 38px 14px;
  font-size: 1rem; /* 16px prevents iOS Safari auto-zoom */
  line-height: 1.3;
}

.search-input::placeholder {
  color: var(--color-text-muted);
}

.chips-strip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-block: 2px;
  padding-inline-end: 20px;
  scrollbar-width: none;
  -webkit-mask-image: linear-gradient(to right, #000 90%, transparent 100%);
  mask-image: linear-gradient(to right, #000 90%, transparent 100%);
}

.chips-strip::-webkit-scrollbar {
  display: none;
}

.chip-btn {
  min-height: 36px;
  border-radius: 999px;
  border: 1px solid var(--color-border-subtle);
  background: var(--color-bg-surface);
  color: var(--color-text-secondary);
  padding-block: 6px;
  padding-inline: 14px;
  font-size: 0.8125rem;
  font-weight: 600;
  white-space: nowrap;
  flex-shrink: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition-property: transform, background-color, color, border-color;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.chip-btn:not(:disabled):active {
  transform: scale(0.96);
}

.chip-btn.active {
  background: var(--color-accent-solid);
  color: var(--color-accent-text);
  border-color: transparent;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.section-header-left {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.section-heading {
  margin: 0;
  font-size: 0.8125rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--color-text-muted);
}

.section-count {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(156px, 1fr));
  gap: 12px;
}

.game-card-wrap {
  position: relative;
  min-width: 0;
}

.game-card {
  width: 100%;
  height: 100%;
  text-align: start;
  background: var(--color-bg-surface);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-lg); /* 20px = 12px padding + 8px inner radius */
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  cursor: pointer;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition-property: transform, box-shadow, background-color;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.game-card:not(:disabled):active {
  transform: scale(0.96);
}

@media (hover: hover) {
  .game-card:hover {
    box-shadow: var(--shadow-card-hover);
    background: var(--color-bg-surface-2);
  }
}

.game-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
  padding-inline-end: 32px;
}

.game-icon-box {
  width: 42px;
  height: 42px;
  border-radius: 8px; /* concentric: 20px outer - 12px padding = 8px */
  background: var(--color-bg-surface-2);
  border: 1px solid var(--color-border-subtle);
  display: grid;
  place-items: center;
  font-size: 1.375rem;
  flex-shrink: 0;
}

.game-tag {
  font-size: 0.6875rem;
  font-weight: 700;
  padding: 3px 7px;
  border-radius: 999px;
  background: var(--color-accent-subtle);
  color: var(--color-accent-fg);
  white-space: nowrap;
}

.fav-btn {
  position: absolute;
  top: 6px;
  inset-inline-end: 6px;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  display: grid;
  place-items: center;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition-property: transform, color;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.fav-btn.active {
  color: var(--color-warning-solid);
}

.fav-btn:not(:disabled):active {
  transform: scale(0.92);
}

.fav-btn svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-width: 1.85;
  fill: none;
}

.fav-btn.active svg {
  fill: currentColor;
}

.game-name {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
  line-height: 1.25;
  text-wrap: balance;
  overflow-wrap: break-word;
}

.game-desc {
  margin: 0;
  font-size: 0.8125rem;
  line-height: 1.4;
  color: var(--color-text-secondary);
  text-wrap: pretty;
  flex: 1;
}

.game-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding-top: 6px;
  border-top: 1px solid var(--color-border-subtle);
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.game-best-val {
  font-weight: 700;
  color: var(--color-accent-fg);
}

.empty-state {
  background: var(--color-bg-surface);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-lg);
  padding: 24px 16px;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.empty-title {
  margin: 0;
  font-size: 1rem;
  font-weight: 700;
}

.empty-desc {
  margin: 0;
  font-size: 0.875rem;
  color: var(--color-text-secondary);
  max-width: 32ch;
}

/* ==========================================================================
   Quests & Achievements Tab
   ========================================================================== */

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

.quest-card {
  background: var(--color-bg-surface);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-lg);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.quest-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.quest-title {
  margin: 0;
  font-size: 0.9375rem;
  font-weight: 700;
}

.quest-desc {
  margin: 2px 0 0;
  font-size: 0.8125rem;
  color: var(--color-text-secondary);
}

.quest-reward {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-accent-fg);
  white-space: nowrap;
}

.ach-card {
  background: var(--color-bg-surface);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  opacity: 0.65;
}

.ach-card.unlocked {
  opacity: 1;
  border-color: var(--color-success-subtle);
}

.ach-icon {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-sm);
  background: var(--color-bg-surface-2);
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  flex-shrink: 0;
}

.ach-card.unlocked .ach-icon {
  background: var(--color-success-subtle);
}

.ach-body {
  flex: 1;
  min-width: 0;
}

.ach-status {
  font-size: 0.75rem;
  font-weight: 700;
  color: var(--color-text-muted);
  white-space: nowrap;
}

.ach-card.unlocked .ach-status {
  color: var(--color-success-solid);
}

/* ==========================================================================
   Leaderboard View
   ========================================================================== */

.leader-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.leader-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: var(--color-bg-surface);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  min-width: 0;
}

.leader-item.is-me {
  background: var(--color-accent-subtle);
  border-color: var(--color-accent-fg);
}

.leader-left {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  flex: 1;
}

.leader-rank {
  min-width: 26px;
  font-weight: 700;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.leader-name {
  font-size: 0.9375rem;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.leader-lvl {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.leader-score {
  font-size: 0.9375rem;
  font-weight: 700;
  color: var(--color-accent-fg);
}

/* ==========================================================================
   Bottom Tab Bar
   ========================================================================== */

.bottom-nav {
  position: fixed;
  bottom: 0;
  inset-inline: 0;
  z-index: 25;
  display: flex;
  justify-content: center;
  padding-inline: max(12px, env(safe-area-inset-left)) max(12px, env(safe-area-inset-right));
  padding-bottom: max(8px, env(safe-area-inset-bottom));
  pointer-events: none;
}

.bottom-nav-inner {
  pointer-events: auto;
  width: 100%;
  max-width: 496px;
  background: var(--color-bg-chrome);
  backdrop-filter: blur(16px);
  border: 1px solid transparent;
  box-shadow: var(--shadow-elevated);
  border-radius: 22px; /* 16px inner + 6px padding */
  padding: 6px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.nav-tab {
  min-height: 48px;
  border-radius: 16px;
  border: none;
  background: transparent;
  color: var(--color-text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  position: relative;
  -webkit-tap-highlight-color: transparent;
  transition-property: transform, background-color, color;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.nav-tab:not(:disabled):active {
  transform: scale(0.96);
}

.nav-tab.active {
  background: var(--color-accent-subtle);
  color: var(--color-accent-fg);
}

.nav-tab svg {
  width: 20px;
  height: 20px;
  stroke: currentColor;
  fill: none;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.nav-dot {
  position: absolute;
  top: 6px;
  inset-inline-end: 24%;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-danger-solid);
}

/* ==========================================================================
   Game Stage & Embedded Game Controls
   ========================================================================== */

.game-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.difficulty-bar {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
  padding: 5px;
  border-radius: 16px;
  background: var(--color-bg-surface);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
}

.diff-btn {
  min-height: 36px;
  border-radius: 11px; /* concentric: 16px - 5px */
  border: none;
  background: transparent;
  color: var(--color-text-secondary);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition-property: transform, background-color, color;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.diff-btn:not(:disabled):active {
  transform: scale(0.96);
}

.diff-btn.active {
  background: var(--color-accent-solid);
  color: var(--color-accent-text);
  font-weight: 700;
}

.hud-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  background: var(--color-bg-surface);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
}

.hud-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.hud-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
}

.hud-val {
  font-size: 1.125rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.canvas-box {
  background: var(--color-bg-game-stage);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  border-radius: 22px; /* 14px inner canvas + 8px padding */
  padding: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
}

canvas {
  max-width: 100%;
  border-radius: 14px;
  touch-action: none;
  user-select: none;
}

.status-banner {
  text-align: center;
  font-size: 0.875rem;
  line-height: 1.4;
  color: var(--color-text-secondary);
  min-height: 20px;
  text-wrap: pretty;
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 60px);
  grid-template-rows: repeat(2, 50px);
  gap: 8px;
  justify-content: center;
  user-select: none;
}

.dpad-btn {
  border-radius: var(--radius-sm);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  font-size: 1.125rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition-property: transform, background-color;
  transition-duration: 120ms;
  transition-timing-function: ease-out;
}

.dpad-btn:not(:disabled):active {
  transform: scale(0.96);
  background: var(--color-accent-solid);
  color: var(--color-accent-text);
}

/* 2048 */
.board-2048 {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  background: var(--color-bg-surface);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  border-radius: 20px;
  padding: 10px;
  touch-action: none;
  user-select: none;
}

.tile-2048 {
  aspect-ratio: 1;
  border-radius: 10px;
  display: grid;
  place-items: center;
  font-size: 1.375rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
}

/* Clicker */
.clicker-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding-block: 8px;
}

.tap-orb {
  width: 184px;
  height: 184px;
  border-radius: 50%;
  border: 4px solid var(--color-accent-solid);
  background: radial-gradient(circle at 35% 30%, var(--sky-400), var(--sky-600) 65%, var(--sky-950));
  box-shadow: 0 0 36px oklch(0.76 0.14 222 / 0.35);
  color: #fff;
  font-size: 3.5rem;
  cursor: pointer;
  display: grid;
  place-items: center;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
  transition-property: transform;
  transition-duration: 100ms;
  transition-timing-function: ease-out;
}

.tap-orb:not(:disabled):active {
  transform: scale(0.94);
}

.energy-wrap {
  width: 100%;
  background: var(--color-bg-surface);
  border-radius: 999px;
  height: 14px;
  overflow: hidden;
  border: 1px solid var(--color-border-subtle);
}

.energy-fill {
  height: 100%;
  background: var(--color-accent-solid);
  transition-property: width;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.upgrades-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.upgrade-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  background: var(--color-bg-surface);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  border-radius: var(--radius-lg);
  padding: 12px 14px;
}

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

.upgrade-title {
  font-size: 0.9375rem;
  font-weight: 700;
}

.upgrade-sub {
  font-size: 0.8125rem;
  color: var(--color-text-muted);
  font-variant-numeric: tabular-nums;
}

/* Match-3 */
.match3-board {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 6px;
  background: var(--color-bg-surface);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  border-radius: 20px;
  padding: 10px;
  user-select: none;
}

.gem-cell {
  aspect-ratio: 1;
  border-radius: 10px;
  background: var(--color-bg-surface-2);
  border: 2px solid transparent;
  display: grid;
  place-items: center;
  font-size: 1.35rem;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition-property: transform, border-color, background-color;
  transition-duration: 120ms;
  transition-timing-function: ease-out;
}

.gem-cell.selected {
  border-color: var(--color-accent-solid);
  transform: scale(1.06);
  background: var(--color-accent-subtle);
}

/* Cipher & Greed Grids */
.cipher-grid {
  display: grid;
  gap: 8px;
  background: var(--color-bg-surface);
  border: 1px solid transparent;
  box-shadow: var(--shadow-card);
  border-radius: 22px;
  padding: 12px;
  user-select: none;
}

.cipher-cell {
  aspect-ratio: 1;
  min-height: 44px;
  border-radius: 10px; /* concentric: 22px - 12px */
  background: var(--color-bg-surface-2);
  border: 1px solid var(--color-border-subtle);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition-property: transform, background-color, box-shadow;
  transition-duration: 140ms;
  transition-timing-function: ease-out;
}

.cipher-cell:not(:disabled):active {
  transform: scale(0.96);
}

.cipher-cell.target {
  background: var(--color-accent-solid);
  color: var(--color-accent-text);
  box-shadow: 0 0 14px oklch(0.76 0.14 222 / 0.55);
}

.cipher-cell.noise {
  background: var(--color-warning-solid);
  box-shadow: 0 0 12px oklch(0.80 0.15 78 / 0.5);
}

.cipher-cell.correct {
  background: var(--color-success-solid);
  color: var(--sky-950);
}

.cipher-cell.wrong {
  background: var(--color-danger-solid);
  color: #fff;
}

/* ==========================================================================
   Native Dialogs & Toasts
   ========================================================================== */

dialog.modal-dialog {
  border: 1px solid transparent;
  box-shadow: var(--shadow-elevated);
  border-radius: var(--radius-xl);
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  width: min(92%, 420px);
  max-height: 82dvh;
  padding: 18px;
  margin: auto;
  overscroll-behavior: contain;
}

dialog.modal-dialog::backdrop {
  background: oklch(0 0 0 / 0.65);
  backdrop-filter: blur(4px);
}

@media (prefers-reduced-motion: no-preference) {
  dialog.modal-dialog[open] {
    animation: dialogEnter 240ms var(--ease-out-quint) both;
  }
}

@keyframes dialogEnter {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

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

.dialog-title {
  margin: 0;
  font-size: 1.125rem;
  font-weight: 700;
}

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

.faq-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}

.faq-item {
  background: var(--color-bg-surface-2);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
}

.badge-option {
  background: var(--color-bg-surface-2);
  border: 1px solid var(--color-border-subtle);
  border-radius: var(--radius-md);
  padding: 12px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition-property: transform, border-color, background-color;
  transition-duration: 150ms;
  transition-timing-function: ease-out;
}

.badge-option:not(:disabled):active {
  transform: scale(0.96);
}

.badge-option.equipped {
  border-color: var(--color-accent-solid);
  background: var(--color-accent-subtle);
}

.toast-stack {
  position: fixed;
  top: calc(var(--header-height) + 10px);
  inset-inline: 16px;
  z-index: 60;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.toast {
  pointer-events: auto;
  max-width: 420px;
  width: 100%;
  background: var(--color-bg-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border-strong);
  box-shadow: var(--shadow-elevated);
  border-radius: var(--radius-md);
  padding: 10px 14px;
  font-size: 0.875rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

@media (prefers-reduced-motion: no-preference) {
  .toast {
    animation: dialogEnter 220ms var(--ease-out-quint) both;
  }
}

.share-row {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
}
