#app {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: var(--space);
  gap: var(--space);
}
.shell-header {
  display: flex; align-items: center; gap: var(--space);
  padding: calc(8px * var(--text-scale));
  background: var(--bg-2);
  border-radius: var(--radius);
  flex-wrap: wrap;
}

/* Handheld: slimmer app chrome so content gets the screen. */
@media (max-width: 700px) {
  #app { padding: 8px; gap: 8px; }
  .shell-header { padding: 6px 8px; gap: 8px; }
}

/* Short screens (landscape phones): one-row header, tight gaps — the
   game board needs the height more than the chrome does. */
@media (max-height: 500px) {
  #app { padding: 6px; gap: 6px; }
  .shell-header { padding: 4px 8px; gap: 8px; flex-wrap: nowrap; }
  .shell-header button { padding: 6px 10px; }
}
.shell-header .brand { font-weight: 700; }
.shell-header .spacer { flex: 1; }
.shell-header .coin-chip {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 6px 10px; border-radius: var(--radius);
  background: rgba(255,255,255,0.08);
  font-weight: 600;
  min-height: 40px;
}
.shell-header .coin-chip .coin-icon { width: 20px; height: 20px; display: inline-block; }
.shell-header .profile-chip {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 6px 10px; border-radius: var(--radius);
  background: rgba(255,255,255,0.08);
  min-height: 40px;
}
.avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-block;
}
.section-title {
  font-size: calc(14px * var(--text-scale));
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--fg-dim);
  margin: 0 0 8px;
}
.continue-rail {
  display: flex; gap: var(--space); overflow-x: auto;
  padding-bottom: 4px;
}
.continue-card {
  flex: 0 0 auto;
  min-width: calc(220px * var(--text-scale));
  min-height: calc(72px * var(--text-scale));
  padding: var(--space);
  background: var(--bg-2);
  border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 4px;
  text-align: left;
}
.daily-entry {
  padding: var(--space);
  background: var(--bg-2);
  border-radius: var(--radius);
  display: flex; align-items: center; gap: var(--space);
  flex-wrap: wrap;
}
.daily-entry .daily-info { flex: 1; min-width: 200px; }
.catalog {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(calc(160px * var(--text-scale)), 1fr));
  gap: var(--space);
}
.catalog-tile {
  padding: var(--space);
  background: var(--bg-2);
  border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 6px;
  min-height: calc(120px * var(--text-scale));
  text-align: left;
}
.catalog-tile[aria-disabled="true"] {
  opacity: 0.4; cursor: not-allowed;
}
.catalog-tile .tile-title { font-weight: 600; }
.catalog-tile .tile-meta { color: var(--fg-dim); font-size: 0.9em; }
.catalog-tile .tile-tag {
  align-self: flex-start;
  font-size: 0.8em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
}
.house-ad-slot { min-height: 0; }
.house-ad-slot:empty { display: none; }
.primary-btn, .secondary-btn, .danger-btn {
  min-height: var(--tap);
  min-width: var(--tap);
  padding: 10px 18px;
  border-radius: var(--radius);
  font-weight: 600;
  display: inline-flex; align-items: center; justify-content: center;
  gap: 8px;
}
.primary-btn { background: var(--accent); color: #fff; }
.secondary-btn { background: rgba(255,255,255,0.12); }
.danger-btn { background: var(--danger); color: #fff; }
.profile-picker {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: var(--space);
}
.profile-tile {
  padding: var(--space);
  background: var(--bg-2);
  border-radius: var(--radius);
  display: flex; flex-direction: column; align-items: center; gap: 10px;
  min-height: calc(140px * var(--text-scale));
}
.profile-tile .avatar { width: 56px; height: 56px; }
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex; align-items: center; justify-content: center;
  padding: var(--space);
  z-index: 100;
}
.modal {
  background: var(--bg-2);
  border-radius: var(--radius);
  padding: calc(var(--space) * 1.5);
  max-width: 600px;
  width: 100%;
  display: flex; flex-direction: column; gap: var(--space);
  max-height: 90vh; overflow: auto;
}
.modal h2 { margin: 0; }
.form-row { display: flex; flex-direction: column; gap: 6px; }
.form-row label { color: var(--fg-dim); font-size: 0.9em; }
.swatch-row { display: flex; gap: 10px; flex-wrap: wrap; }
.swatch { width: 44px; height: 44px; border-radius: 50%; border: 2px solid rgba(255,255,255,0.35); cursor: pointer; padding: 0; }
.swatch.is-chosen { border-color: #ffffff; box-shadow: 0 0 0 3px var(--focus); }
.form-row input, .form-row select {
  font: inherit; min-height: 48px; padding: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: var(--radius);
  color: var(--fg);
}
.modal-actions {
  display: flex; gap: var(--space); justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: var(--space);
}
.joy__grid {
  display: grid;
  grid-template-columns: repeat(var(--joy-cols, 4), 1fr);
  gap: 6px;
  /* The wrap is a centered flex row, so the grid must carry its own width —
     without one it shrink-wraps to the cards' intrinsic size (~0, their
     faces are absolutely positioned) and the board collapses to dots.
     Width is container-relative (100%), never vw: a vw width inside the
     padded #app can exceed the visible page and force side-scroll. */
  width: min(100%, 680px);
  margin: 0 auto;
}
@media (min-width: 1200px) {
  /* Wide screens are TVs/desktops. The height cap (whole board above the
     fold) is applied by game.js as an inline max-width: calc() with * and /
     is not supported by the older WebViews this suite targets. */
  .joy__grid { width: min(100%, 860px); }
}
.joy__card {
  aspect-ratio: 3/4;
  background: var(--card-bg);
  border-radius: 12px;
  display: flex; align-items: center; justify-content: center;
  color: var(--card-fg);
  font-weight: 700;
  font-size: calc(24px * var(--text-scale));
  position: relative;
  cursor: pointer;
  user-select: none;
  transition: transform 0.32s cubic-bezier(0.3, 0.6, 0.35, 1), opacity 0.25s ease-out, box-shadow 0.25s ease-out;
  perspective: 600px;
  transform-style: preserve-3d;
  border: 1px solid rgba(0,0,0,0.4);
  box-shadow: 0 6px 14px rgba(0,0,0,0.42);
}
.joy__card .joy__face {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  border-radius: 10px;
  overflow: hidden;
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.joy__card .joy__back {
  background: var(--card-back, var(--card-bg));
  background-size: cover; background-position: center;
  transform: rotateY(0deg);
  box-shadow: inset 0 0 0 2px rgba(245,197,66,0.55), inset 0 0 0 6px rgba(8,12,22,0.28), inset 0 2px 8px rgba(255,255,255,0.14);
}
.joy__card .joy__front {
  background: linear-gradient(160deg, #fffdf6 0%, #f7efdc 55%, #eee1c4 100%);
  color: #111;
  transform: rotateY(180deg);
  font-size: calc(32px * var(--text-scale));
  box-shadow: inset 0 0 0 1px rgba(120,90,20,0.28), inset 0 -3px 8px rgba(120,90,20,0.12);
}
.joy__card .joy__front svg { width: 64%; height: 64%; }
.joy__card.is-up { transform: rotateY(180deg); }
.joy__card.is-matched {
  pointer-events: none;
  box-shadow: 0 0 0 3px rgba(245,197,66,0.75), 0 0 20px rgba(245,197,66,0.4);
}
/* The dim goes on the faces, never on the card itself: opacity below 1 on a
   preserve-3d element flattens its 3D and the card shows its back. */
.joy__card.is-matched .joy__face { opacity: 0.55; }
.settings-group { margin-bottom: var(--space); }
.settings-row {
  display: flex; align-items: center; gap: var(--space);
  padding: 10px; border-radius: var(--radius);
  background: rgba(255,255,255,0.04);
  margin-bottom: 6px;
  min-height: var(--tap);
  flex-wrap: wrap;
}
.settings-row .settings-label { flex: 1; min-width: 160px; }
.settings-row .settings-control { display: flex; align-items: center; gap: 8px; }
.settings-row.is-locked { opacity: 0.6; }
.settings-row .settings-lock-note { color: var(--fg-dim); font-size: 0.85em; flex-basis: 100%; }
.balance-display {
  font-variant-numeric: tabular-nums;
  font-weight: 700;
}
.ledger-list {
  display: flex; flex-direction: column; gap: 4px;
  max-height: 60vh; overflow: auto;
}
.ledger-row {
  display: flex; gap: 10px; padding: 8px;
  background: rgba(255,255,255,0.04);
  border-radius: 8px;
  align-items: baseline;
}
.ledger-row .ledger-delta { font-variant-numeric: tabular-nums; min-width: 60px; font-weight: 700; }
.ledger-row .ledger-reason { flex: 1; }
.ledger-row .ledger-ts { color: var(--fg-dim); font-size: 0.85em; }
.booster-list {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: var(--space);
}
.booster-card {
  padding: var(--space); background: var(--bg-2); border-radius: var(--radius);
  display: flex; flex-direction: column; gap: 6px;
}
.kill-notice {
  padding: calc(var(--space) * 2);
  background: var(--bg-2); border-radius: var(--radius);
  text-align: center;
}
.win-panel {
  padding: calc(var(--space) * 2);
  background: var(--bg-2); border-radius: var(--radius);
  display: flex; flex-direction: column; gap: var(--space);
  text-align: center;
  max-width: 500px; margin: 0 auto;
}
.win-panel .stars-line { font-size: 2em; letter-spacing: 0.2em; color: var(--focus); }
.dpad-hint {
  color: var(--fg-dim); font-size: 0.85em; margin-top: 6px;
}
.offline-banner {
  background: #5c3d12; color: #ffe2b0;
  padding: 6px 10px; border-radius: var(--radius);
  font-size: 0.9em;
}

/* ---- Premium game tiles (Netflix-style) — Nov 17, 2026 ----
   Art comes from games.json tile data (one art file per game).
   Rails scroll inside their own box; the page never scrolls sideways. */
.tile-rail {
  display: flex; gap: var(--space);
  overflow-x: auto; overflow-y: hidden;
  max-width: 100%;
  padding: 8px 4px 12px;
  scrollbar-width: thin;
}
.catalog-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(min(290px, 100%), 1fr));
  gap: var(--space);
}
.game-tile {
  flex: 0 0 auto;
  width: calc(300px * var(--text-scale));
  padding: 0;
  background: var(--bg-2);
  border-radius: 14px;
  overflow: hidden;
  display: flex; flex-direction: column;
  text-align: left;
  box-shadow: 0 4px 14px rgba(0,0,0,0.35);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.catalog-tiles .game-tile { width: auto; }
.game-tile .tile-art {
  position: relative;
  aspect-ratio: 16 / 9;
  background-size: cover;
  background-position: center;
  transition: transform 0.4s ease;
}
.game-tile .tile-badge {
  position: absolute; top: 8px; left: 8px;
  background: rgba(9, 13, 22, 0.85);
  color: #ffd964;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.78em; font-weight: 700; letter-spacing: 0.4px;
  text-transform: uppercase;
}
.game-tile .tile-info {
  padding: 10px 12px 12px;
  display: flex; flex-direction: column; gap: 3px;
}
.game-tile .tile-name { font-weight: 700; font-size: 1.07em; }
.game-tile .tile-line { color: var(--fg-dim); font-size: 0.9em; }
.game-tile .tile-tagrow { display: flex; gap: 6px; margin-top: 4px; }
.game-tile .tile-tag {
  align-self: flex-start;
  font-size: 0.78em;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,0.1);
}
/* The living-tile feel: on focus (TV) or hover (pointer) the tile lifts
   and the art slowly pushes in, like a preview waking up. */
.game-tile.is-focused, .game-tile:hover {
  transform: translateY(-3px) scale(1.025);
  box-shadow: 0 12px 28px rgba(0,0,0,0.5);
}
.game-tile.is-focused .tile-art, .game-tile:hover .tile-art {
  transform: scale(1.07);
}
.game-tile[aria-disabled="true"] { opacity: 0.45; }
.game-tile.is-static { cursor: default; }
@media (max-width: 700px) {
  .game-tile { width: calc(238px * var(--text-scale)); }
}

/* FLUX-ART-2026-11-17: home hero backdrop */
.home-hero { height: 170px; border-radius: var(--radius-lg); background: url("../img/bg-home-hero.jpg") center 38% / cover no-repeat; margin: 2px 0 12px; box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 10px 28px rgba(0,0,0,0.35); }
