/* Sized for the car's touch screen: large targets, no hover-only affordances. */

:root {
  /* Close to the car's own UI: near-black, flat greys, one blue. */
  --bg: #0b0b0c;
  --surface: #1b1b1d;
  --surface-2: #2a2a2d;
  --surface-3: #3a3a3e;
  --text: #f4f4f5;
  --muted: #8d8d93;
  --line: rgba(255, 255, 255, 0.06);
  --accent: #3e6ae1;
  --accent-text: #ffffff;
  --star: #f5f5f5;
  --danger: #e82127;
  --radius: 14px;
  --radius-lg: 20px;
  --gap: 16px;
  --touch: 64px;
  --bar-h: 96px;
  /* Motion: quick to answer a touch, soft to settle. */
  --ease-out: cubic-bezier(0.22, 1, 0.36, 1);
  --ease-in: cubic-bezier(0.55, 0, 1, 0.45);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
  --t-fast: 160ms;
  --t-med: 320ms;
  --t-slow: 560ms;
  /* A hairline of light on the top edge gives flat surfaces some depth. */
  --edge: inset 0 1px 0 rgba(255, 255, 255, 0.05);
  --lift: 0 18px 50px rgba(0, 0, 0, 0.5);
  --skeleton-hi: var(--surface-2);
  color-scheme: dark;
}

@media (prefers-color-scheme: light) {
  :root {
    --bg: #eeeeef;
    --surface: #ffffff;
    --surface-2: #e4e4e6;
    --surface-3: #d4d4d7;
    --text: #171a20;
    --muted: #5c5e62;
    --line: rgba(0, 0, 0, 0.06);
    --star: #171a20;
    --edge: inset 0 1px 0 rgba(255, 255, 255, 0.8);
    --lift: 0 18px 50px rgba(0, 0, 0, 0.14);
    --skeleton-hi: #f6f6f7;
    color-scheme: light;
  }
}

* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 400 20px/1.35 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-tap-highlight-color: transparent;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

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

[hidden] { display: none !important; }

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


/* ---------- buttons ---------- */

.btn {
  min-height: var(--touch);
  padding: 0 24px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-2);
  color: inherit;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  text-decoration: none;
  cursor: pointer;
  user-select: none;
  /* Springs back on release; the press itself is quick (see :active). */
  transition:
    transform var(--t-med) var(--ease-spring),
    background-color var(--t-fast) ease,
    filter var(--t-fast) ease,
    opacity var(--t-fast) ease;
}
.btn:active { filter: brightness(1.25); transform: scale(0.96); transition-duration: 90ms; }
.btn-round:active { transform: scale(0.88); }
.btn-primary { background: var(--accent); color: var(--accent-text); font-weight: 500; }
.btn-ghost { background: transparent; }
.btn-danger { background: var(--danger); color: #fff; font-weight: 500; }
.btn-danger.is-armed { animation: armed 1s ease-in-out infinite; }
@keyframes armed {
  50% { box-shadow: 0 0 0 8px color-mix(in srgb, var(--danger) 25%, transparent); }
}
.btn-icon { width: var(--touch); padding: 0; background: var(--surface); }
.btn-icon svg { width: 28px; height: 28px; transition: transform var(--t-med) var(--ease-spring); }
.btn-icon:active svg { transform: scale(1.15); }
.btn-round { width: var(--touch); padding: 0; border-radius: 50%; position: relative; }

/* CSS-drawn transport icons: no dependency on symbol fonts. */
.btn-round[data-icon]::before { content: ""; display: block; }
.btn-round[data-icon="play"]::before {
  border-style: solid;
  border-width: 12px 0 12px 20px;
  border-color: transparent transparent transparent currentColor;
  margin-left: 6px;
}
.btn-round[data-icon="pause"]::before {
  width: 20px;
  height: 24px;
  border-left: 7px solid currentColor;
  border-right: 7px solid currentColor;
}
.btn-round[data-icon="stop"]::before { width: 20px; height: 20px; background: currentColor; border-radius: 3px; }

/* ---------- top bar ---------- */

.topbar {
  flex: none;
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 12px 24px;
  min-height: 88px;
}
.topbar h1 { margin: 0; font-size: 28px; font-weight: 500; flex: 1; letter-spacing: 0.01em; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand-mark { width: 40px; height: 40px; flex: none; }
.brand-tray { fill: none; stroke: var(--text); stroke-width: 6; stroke-linecap: round; }
.brand-play { fill: var(--accent); stroke: var(--accent); stroke-width: 5; stroke-linejoin: round; }
.topbar #back { background: var(--surface); padding: 0 22px 0 16px; }
.clock { display: flex; flex-direction: column; align-items: flex-end; line-height: 1.1; }
.clock > span { display: block; }
.clock-time { font-size: 32px; font-weight: 300; font-variant-numeric: tabular-nums; }
.clock-date { font-size: 16px; color: var(--muted); }
.clock-date::first-letter { text-transform: uppercase; }

main {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 24px 24px;
  transition: padding-bottom var(--t-med) var(--ease-out);
}

/* Each view rises in when the route changes. */
#view > * { animation: rise var(--t-slow) var(--ease-out) both; }
body.radio-on main { padding-bottom: calc(var(--bar-h) + 40px); }

.loading, .empty { color: var(--muted); text-align: center; margin-top: 48px; }

/* ---------- home ---------- */

.home { display: flex; flex-direction: column; gap: var(--gap); min-height: 100%; }
.tiles {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: var(--gap);
}
.tile {
  position: relative;
  overflow: hidden;
  background: var(--surface);
  border-radius: var(--radius-lg);
  padding: 32px;
  min-height: max(300px, 44vh);
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 6px;
  color: inherit;
  text-decoration: none;
  box-shadow: var(--edge);
  transition:
    background-color var(--t-med) var(--ease-out),
    transform var(--t-slow) var(--ease-spring),
    box-shadow var(--t-med) var(--ease-out);
  /* Staggered entrance; --i is the tile's position. */
  animation: rise var(--t-slow) var(--ease-out) both;
  animation-delay: calc(var(--i, 0) * 60ms + 60ms);
}
.tile:active { background: var(--surface-2); transform: scale(0.975); transition-duration: 120ms; }
/* A soft light follows the corner of the tile, only visible on press/hover. */
a.tile::before {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(120% 90% at 100% 0%, rgba(255, 255, 255, 0.07), transparent 60%);
  opacity: 0;
  transition: opacity var(--t-med) var(--ease-out);
  pointer-events: none;
}
a.tile:active::before { opacity: 1; }
/* A chevron tells active tiles from the upcoming ones. */
a.tile::after {
  content: "";
  position: absolute;
  top: 42px;
  right: 38px;
  width: 14px;
  height: 14px;
  border: solid var(--muted);
  border-width: 2px 2px 0 0;
  transform: rotate(45deg);
  transition: transform var(--t-med) var(--ease-spring), border-color var(--t-med) ease;
}
a.tile:active::after { transform: translateX(6px) rotate(45deg); border-color: var(--text); }
.tile-icon { width: 60px; height: 60px; margin-bottom: auto; color: var(--text); transition: transform var(--t-slow) var(--ease-spring); }
a.tile:active .tile-icon { transform: scale(0.92); }
.tile-icon svg { width: 100%; height: 100%; display: block; stroke-width: 1.4; }
.tile-name { font-size: 36px; font-weight: 500; letter-spacing: -0.01em; }
.tile-note { color: var(--muted); font-size: 18px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tile-live { color: var(--text); }
.tile-live::before {
  content: "";
  display: inline-block;
  width: 8px;
  height: 8px;
  margin-right: 10px;
  border-radius: 50%;
  background: var(--accent);
  vertical-align: 3px;
  animation: ring 2s var(--ease-out) infinite;
}

.home-soon { margin: 16px 0 0; font-size: 15px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; }
.tiles-soon .tile {
  min-height: 0;
  padding: 18px 22px;
  flex-direction: row;
  align-items: center;
  justify-content: flex-start;
  gap: 18px;
  background: transparent;
  border: 1px solid var(--line);
  color: var(--muted);
}
.tiles-soon .tile-icon { width: 36px; height: 36px; margin: 0; flex: none; color: var(--muted); }
.tiles-soon .tile-name { font-size: 20px; flex: none; }
.tiles-soon .tile-note { font-size: 16px; }

@media (hover: hover) {
  a.tile:hover { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); box-shadow: var(--edge), var(--lift); transform: translateY(-3px); }
  a.tile:hover::before { opacity: 1; }
  a.tile:hover::after { transform: translateX(4px) rotate(45deg); border-color: var(--text); }
  .card-main:hover { background: color-mix(in srgb, var(--surface-2) 55%, var(--surface)); }
  .btn:hover { filter: brightness(1.12); }
}

@keyframes pulse {
  50% { opacity: 0.35; }
}
/* A ring that swells out of a dot, for "live" markers. */
@keyframes ring {
  0% { box-shadow: 0 0 0 0 color-mix(in srgb, var(--accent) 60%, transparent); }
  80%, 100% { box-shadow: 0 0 0 10px color-mix(in srgb, var(--accent) 0%, transparent); }
}
@keyframes rise {
  from { opacity: 0; transform: translateY(14px); }
  to { opacity: 1; transform: none; }
}
@keyframes fade-in {
  from { opacity: 0; }
}
@keyframes pop-in {
  from { opacity: 0; transform: scale(0.94); }
  to { opacity: 1; transform: none; }
}
@keyframes star-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.45) rotate(-12deg); }
  100% { transform: scale(1) rotate(0); }
}
@keyframes eq {
  0%, 100% { background-size: 4px 100%, 4px 40%, 4px 70%; }
  33% { background-size: 4px 45%, 4px 100%, 4px 35%; }
  66% { background-size: 4px 75%, 4px 55%, 4px 100%; }
}
@keyframes shimmer {
  from { background-position: 150% 0; }
  to { background-position: -50% 0; }
}

/* ---------- catalog ---------- */

.catalog { display: flex; flex-direction: column; gap: var(--gap); }

.search {
  width: 100%;
  min-height: var(--touch);
  padding: 0 20px 0 60px;
  border: 1px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  outline: none;
  box-shadow: var(--edge);
  transition: border-color var(--t-fast) ease, box-shadow var(--t-med) var(--ease-out), background-color var(--t-med) ease;
}
.search:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 22%, transparent);
}
.catalog-tools::before, .catalog-tools::after { transition: color var(--t-fast) ease; }
.catalog-tools:focus-within::before, .catalog-tools:focus-within::after { color: var(--accent); }
.catalog-tools { position: relative; }
/* Magnifier drawn with CSS, like the transport icons. */
.catalog-tools::before, .catalog-tools::after { content: ""; position: absolute; pointer-events: none; color: var(--muted); }
.catalog-tools::before { left: 22px; top: 50%; width: 16px; height: 16px; margin-top: -11px; border: 2px solid; border-radius: 50%; }
.catalog-tools::after { left: 39px; top: 50%; width: 2px; height: 9px; margin-top: 3px; background: currentColor; border-radius: 2px; transform: rotate(-45deg); }

/* Segmented control, like the tabs in the car's settings. */
.chips {
  position: relative;
  display: flex;
  gap: 4px;
  padding: 5px;
  border-radius: var(--radius);
  background: var(--surface);
  overflow-x: auto;
  scrollbar-width: none;
  /* Fades the right edge so it is clear the row scrolls. */
  mask-image: linear-gradient(to right, #000 calc(100% - 64px), transparent);
}
.send .chips, .iptv-form .chips { mask-image: none; align-self: flex-start; }
.send .chips { align-self: stretch; }
.chip {
  flex: none;
  min-height: 54px;
  padding: 0 22px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--muted);
  white-space: nowrap;
  cursor: pointer;
  position: relative;
  z-index: 1;
  transition: color var(--t-med) var(--ease-out), transform var(--t-med) var(--ease-spring);
}
.chip:active { transform: scale(0.95); transition-duration: 90ms; }
.chip[aria-selected="true"] { background: var(--surface-3); color: var(--text); font-weight: 500; }
/* The selected tab's background is one pill that slides between chips (the
   chips themselves go transparent once the script adds it). */
.chips.has-indicator .chip[aria-selected="true"] { background: transparent; }
.chip-indicator {
  position: absolute;
  top: 5px;
  bottom: 5px;
  left: 0;
  border-radius: 10px;
  background: var(--surface-3);
  box-shadow: var(--edge), 0 2px 8px rgba(0, 0, 0, 0.25);
  transition:
    transform var(--t-slow) var(--ease-spring),
    width var(--t-slow) var(--ease-spring),
    opacity var(--t-med) ease;
}
.chip-indicator.is-idle { opacity: 0; }
.chips.no-anim .chip-indicator { transition: none; }

.grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: var(--gap);
}

.card { position: relative; }
/* Cards cascade in after a group change; --i is capped so it stays short. */
.grid.is-entering .card { animation: rise var(--t-med) var(--ease-out) both; animation-delay: calc(var(--i, 0) * 16ms); }
.card-main {
  position: relative;
  width: 100%;
  min-height: 170px;
  padding: 18px 12px 14px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  box-shadow: var(--edge);
  transition:
    transform var(--t-med) var(--ease-spring),
    background-color var(--t-med) var(--ease-out),
    border-color var(--t-med) var(--ease-out),
    box-shadow var(--t-slow) var(--ease-out);
}
.card-main:active { background: var(--surface-2); transform: scale(0.95); transition-duration: 90ms; }
.card.on-air .card-main {
  border-color: var(--accent);
  background: color-mix(in srgb, var(--accent) 8%, var(--surface));
  box-shadow: var(--edge), 0 10px 36px color-mix(in srgb, var(--accent) 28%, transparent);
}
/* Three bouncing bars on the station that is playing. */
.card.on-air .card-main::after {
  content: "";
  position: absolute;
  top: 16px;
  left: 16px;
  width: 18px;
  height: 16px;
  background:
    linear-gradient(var(--accent), var(--accent)) 0 100% / 4px 100% no-repeat,
    linear-gradient(var(--accent), var(--accent)) 7px 100% / 4px 60% no-repeat,
    linear-gradient(var(--accent), var(--accent)) 14px 100% / 4px 80% no-repeat;
  animation: eq 1.1s ease-in-out infinite, fade-in var(--t-med) ease;
}
.card-logo {
  width: 96px;
  height: 96px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  background: #fff;
  transition: transform var(--t-slow) var(--ease-spring);
}
.card.on-air .card-logo { transform: scale(1.04); }
/* Logos fade in as they arrive instead of popping. */
.card-logo img { width: 100%; height: 100%; object-fit: contain; opacity: 0; transition: opacity var(--t-slow) var(--ease-out); }
.card-logo img.is-loaded { opacity: 1; }
.card-initials { background: var(--surface-2); color: var(--muted); font-size: 30px; font-weight: 500; }
.card-name {
  font-size: 18px;
  text-align: center;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.star {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 56px;
  height: 56px;
  border: 0;
  background: transparent;
  color: var(--muted);
  font-size: 24px;
  opacity: 0.35;
  cursor: pointer;
  transition: opacity var(--t-med) ease, color var(--t-med) ease;
}
.star[aria-pressed="true"] { color: var(--star); opacity: 1; }
.star.is-popping { animation: star-pop 480ms var(--ease-out); }

.catalog-summary { margin: 0; color: var(--muted); font-size: 17px; }

/* Placeholder while a channel list loads. The fixed background keeps one
   shimmer sweeping across every block in step. */
.skeleton {
  background: linear-gradient(100deg, var(--surface) 30%, var(--skeleton-hi) 50%, var(--surface) 70%) fixed;
  background-size: 200% 100%;
  animation: shimmer 1.6s linear infinite;
  border-radius: var(--radius);
}
.skeleton-search { height: var(--touch); }
.skeleton-chips { height: 64px; width: min(720px, 100%); }
.skeleton-card { min-height: 170px; }
.more { align-self: center; min-width: 280px; }
.empty:not([hidden]) { animation: rise var(--t-med) var(--ease-out); }

/* ---------- IPTV lists ---------- */

.iptv { display: flex; flex-direction: column; gap: var(--gap); max-width: 900px; }
.iptv h2 { margin: 16px 0 0; font-size: 24px; font-weight: 500; }
.notice {
  margin: 0;
  padding: 16px 20px;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--muted);
  font-size: 17px;
}
.notice-error { color: var(--text); border-left: 6px solid var(--danger); }
.notice, .form-error, .receive-body, .backup-card .receive-body { animation: rise var(--t-med) var(--ease-out) both; }
.iptv-lists { display: flex; flex-direction: column; gap: 10px; }
.iptv-lists .empty { margin: 8px 0; text-align: left; }
.iptv-row { display: flex; gap: 10px; align-items: stretch; }
.iptv-open {
  flex: 1;
  min-height: 80px;
  padding: 12px 20px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 4px;
  text-align: left;
  cursor: pointer;
  box-shadow: var(--edge);
  transition: transform var(--t-med) var(--ease-spring), background-color var(--t-med) var(--ease-out);
}
.iptv-open:active { background: var(--surface-2); transform: scale(0.98); transition-duration: 90ms; }
.iptv-meta { color: var(--muted); font-size: 16px; }
.iptv-form { display: flex; flex-direction: column; gap: 14px; }
.iptv-form label { display: flex; flex-direction: column; gap: 6px; color: var(--muted); font-size: 17px; }
.iptv-form input {
  min-height: var(--touch);
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  border: 1px solid transparent;
  transition: border-color var(--t-fast) ease, box-shadow var(--t-med) var(--ease-out);
}
.iptv-form input:focus, .login input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 5px color-mix(in srgb, var(--accent) 22%, transparent);
}
.iptv-form input[type="file"] { padding: 16px 18px; }
.form-error { margin: 0; color: var(--danger); }
.muted { color: var(--muted); font-size: 17px; margin: 0; }

.receive { display: flex; flex-direction: column; gap: var(--gap); }
.receive > .btn { align-self: flex-start; }
.receive-body {
  display: flex;
  gap: 28px;
  align-items: center;
  flex-wrap: wrap;
  padding: 24px;
  border-radius: var(--radius);
  background: var(--surface);
}
.receive-body[hidden] { display: none; }
.qr { width: 300px; height: 300px; flex: none; background: #fff; border-radius: 12px; padding: 8px; animation: pop-in var(--t-slow) var(--ease-spring) both; }
.qr svg { width: 100%; height: 100%; display: block; }
.receive-text { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 12px; }
.receive-text p { margin: 0; }
.receive-status { font-weight: 600; }
.receive-text .btn { align-self: flex-start; }

/* ---------- backup ---------- */

.home-links { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 8px; }
.home-links .btn { color: var(--muted); }
.iptv-backup { align-self: flex-start; color: var(--muted); }
.backup { display: flex; flex-direction: column; gap: var(--gap); }
.backup-cards { display: grid; grid-template-columns: repeat(auto-fit, minmax(560px, 1fr)); gap: var(--gap); align-items: start; }
.backup-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--edge);
}
.backup-card h2 { margin: 0; font-size: 26px; font-weight: 500; }
.backup-card p { margin: 0; }
.backup-card > .btn { align-self: flex-start; }
.backup-card .receive-body { padding: 0; margin-top: 8px; }
.qr-large { width: min(460px, 100%); height: auto; aspect-ratio: 1; }
.backup-nav { display: flex; gap: 10px; flex-wrap: wrap; }
.backup-nav .btn:disabled { opacity: 0.35; }

/* ---------- help ---------- */

.help { display: flex; flex-direction: column; gap: var(--gap); max-width: 1000px; }
.help-card {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding: 28px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--edge);
}
.help-card h2 { margin: 0; font-size: 26px; font-weight: 500; }
.help-card h3 { margin: 12px 0 0; font-size: 15px; font-weight: 500; color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; }
.help-card p, .help-card ul { margin: 0; }
.help-card ul { padding-left: 1.2em; display: flex; flex-direction: column; gap: 8px; }
.help-list { margin: 0; display: grid; grid-template-columns: max-content 1fr; gap: 14px 28px; }
.help-list dt { font-weight: 600; }
.help-list dd { margin: 0; color: var(--muted); }
.help-author { flex-direction: row; align-items: center; gap: 28px; flex-wrap: wrap; }
.help-author-text { flex: 1; min-width: 260px; display: flex; flex-direction: column; gap: 12px; }
.help-links { display: flex; gap: 8px 24px; flex-wrap: wrap; }
.help-links a { color: var(--accent); text-decoration: none; }
.help-qr { width: 220px; height: 220px; }
/* The car scans nothing: there the QR is the way. A phone gets the button. */
.help-kofi { display: none; align-self: flex-start; }

.help-inline { color: var(--accent); text-decoration: none; }
.help-card > .btn { align-self: flex-start; margin-top: 8px; }
.wipe-status { font-weight: 600; }

/* ---------- novedades ---------- */

.news-group { border-left: 6px solid var(--accent); }
.news-meta { display: flex; align-items: center; gap: 12px; color: var(--muted); font-size: 16px; }
.news-new {
  padding: 2px 10px;
  border-radius: 999px;
  background: var(--accent);
  color: var(--accent-text);
  font-size: 14px;
  font-weight: 600;
}
.news-text { color: var(--muted); }
.news-entry ul { color: var(--muted); }
.news-dot {
  width: 12px;
  height: 12px;
  margin-left: 10px;
  border-radius: 50%;
  background: var(--accent);
  animation: ring 2s ease-out infinite;
}

/* ---------- arcade ---------- */

.arcade { display: flex; flex-direction: column; gap: var(--gap); }
.tile-game { min-height: max(280px, 36vh); }
.tile-about { color: var(--muted); font-size: 18px; max-width: 34ch; min-height: calc(1.35em * 3); }
.tile-game .tile-note { color: var(--text); margin-top: 6px; }

/* A game fills the view; nothing behind it scrolls. */
body.game-on main { overflow: hidden; }
.game-root { height: 100%; }
.game { position: relative; height: 100%; display: flex; flex-direction: column; gap: 12px; }
.game-bar { flex: none; display: flex; align-items: center; gap: 10px 24px; flex-wrap: wrap; }
.game-bar .btn:disabled { opacity: 0.35; }
.game-stat { display: flex; flex-direction: column; min-width: 80px; line-height: 1.15; }
.game-stat span { font-size: 12px; color: var(--muted); text-transform: uppercase; letter-spacing: 0.14em; }
.game-stat strong { font-size: 26px; font-weight: 500; font-variant-numeric: tabular-nums; }
.game-spacer { flex: 1; }
.game-body { flex: 1; min-height: 0; display: flex; gap: var(--gap); }
.game-stage {
  flex: 1;
  min-width: 0;
  min-height: 0;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Swipes and drags belong to the game, not to scrolling or zoom. */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--bg) 55%, transparent);
  backdrop-filter: blur(6px);
  animation: fade-in var(--t-med) var(--ease-out);
}
.game-panel {
  width: min(560px, calc(100% - 32px));
  padding: 32px;
  border-radius: var(--radius-lg);
  background: var(--surface);
  box-shadow: var(--edge), var(--lift);
  display: flex;
  flex-direction: column;
  gap: 12px;
  animation: pop-in var(--t-slow) var(--ease-spring) both;
}
.game-panel h2 { margin: 0; font-size: 30px; font-weight: 500; }
.game-panel p:empty { display: none; }
.game-actions { display: flex; gap: 10px; flex-wrap: wrap; justify-content: flex-end; margin-top: 8px; }

/* Snake */
.snake-stage canvas { display: block; border-radius: var(--radius); }
.dpad {
  flex: none;
  align-self: center;
  display: grid;
  grid-template-columns: repeat(3, 96px);
  grid-template-rows: repeat(3, 96px);
  grid-template-areas: ". up ." "left . right" ". down .";
  gap: 8px;
  touch-action: none;
}
.dpad .btn { width: 100%; height: 100%; min-height: 0; padding: 0; background: var(--surface); box-shadow: var(--edge); }
.dpad .btn::before { content: ""; border: solid transparent; }
.dpad-up { grid-area: up; }
.dpad-down { grid-area: down; }
.dpad-left { grid-area: left; }
.dpad-right { grid-area: right; }
.dpad .dpad-up::before { border-width: 0 16px 22px; border-bottom-color: currentColor; }
.dpad .dpad-down::before { border-width: 22px 16px 0; border-top-color: currentColor; }
.dpad .dpad-left::before { border-width: 16px 22px 16px 0; border-right-color: currentColor; }
.dpad .dpad-right::before { border-width: 16px 0 16px 22px; border-left-color: currentColor; }

/* Autonomía */
.range-stage canvas { display: block; border-radius: var(--radius); }
.range-modes { mask-image: none; }
.lane-pad {
  flex: none;
  align-self: center;
  display: grid;
  grid-template-rows: repeat(2, 132px);
  grid-template-columns: 120px;
  gap: 8px;
  touch-action: none;
}
.lane-pad .btn { width: 100%; height: 100%; min-height: 0; padding: 0; background: var(--surface); box-shadow: var(--edge); }
.lane-pad .btn::before { content: ""; border: solid transparent; }
.lane-pad .lane-up::before { border-width: 0 18px 24px; border-bottom-color: currentColor; }
.lane-pad .lane-down::before { border-width: 24px 18px 0; border-top-color: currentColor; }
/* The battery reads like the car's: an outlined cell with a terminal nub,
   green fill, red when low. */
.r-battery { display: flex; align-items: center; gap: 10px; }
.r-cell {
  position: relative;
  width: 46px;
  height: 22px;
  padding: 3px;
  border: 2px solid var(--muted);
  border-radius: 6px;
}
.r-cell::after { content: ""; position: absolute; right: -6px; top: 5px; width: 3px; height: 8px; border-radius: 0 2px 2px 0; background: var(--muted); }
.r-level { display: block; height: 100%; border-radius: 2px; background: #3fb950; transition: width var(--t-fast) linear; }
.r-battery.is-low .r-level { background: var(--danger); }
.r-battery.is-low .r-pct { color: var(--danger); }
.r-pct { font-weight: 500; }
/* FSD saves left, as pips. */
.r-fsd { display: flex; align-items: center; gap: 6px; height: 1.15em; }
.r-fsd i { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--muted); transition: background-color var(--t-fast) ease, border-color var(--t-fast) ease; }
.r-fsd i.is-on { background: #3e8bff; border-color: #3e8bff; box-shadow: 0 0 8px rgba(62, 139, 255, 0.6); }

/* Parejas: cards flip in 3D; the back matches the solitaire deck. */
.memory-sizes { mask-image: none; }
.memory-board { display: grid; grid-template-columns: repeat(var(--cols), var(--card-w)); gap: 12px; }
.memory-card {
  width: var(--card-w);
  aspect-ratio: 3 / 4;
  padding: 0;
  border: 0;
  background: none;
  cursor: pointer;
  perspective: 900px;
  -webkit-touch-callout: none;
  animation: pop-in var(--t-slow) var(--ease-spring) both;
  animation-delay: calc(var(--i, 0) * 25ms);
}
.memory-inner {
  position: relative;
  display: block;
  width: 100%;
  height: 100%;
  transform-style: preserve-3d;
  transition: transform 420ms var(--ease-out);
}
.memory-card.is-up .memory-inner { transform: rotateY(180deg); }
.memory-card:active:not(.is-up) .memory-inner { transform: scale(0.94); transition-duration: 90ms; }
.memory-back, .memory-face {
  position: absolute;
  inset: 0;
  border-radius: calc(var(--card-w) * 0.08);
  backface-visibility: hidden;
  -webkit-backface-visibility: hidden;
}
.memory-back {
  background:
    radial-gradient(circle at 50% 50%, rgba(62, 106, 225, 0.45), transparent 60%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0 2px, transparent 2px 7px),
    #16181d;
  box-shadow:
    0 2px 6px rgba(0, 0, 0, 0.35),
    inset 0 0 0 calc(var(--card-w) * 0.05) #16181d,
    inset 0 0 0 calc(var(--card-w) * 0.05 + 1.5px) rgba(255, 255, 255, 0.28);
}
.memory-back::after {
  content: "";
  position: absolute;
  inset: 34% 30%;
  background: #fff;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M13 2 3 14h9l-1 8 10-12h-9l1-8z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M13 2 3 14h9l-1 8 10-12h-9l1-8z'/%3E%3C/svg%3E") center / contain no-repeat;
  filter: drop-shadow(0 0 6px rgba(62, 106, 225, 0.9));
}
.memory-face {
  transform: rotateY(180deg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4%;
  padding: 8%;
  background: #fff;
  color: #1b1b1d;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}
.memory-face svg { width: 78%; height: auto; }
.memory-face b { font-size: calc(var(--card-w) * 0.1); font-weight: 600; text-align: center; line-height: 1.1; }
.memory-card.is-matched .memory-face { box-shadow: 0 0 0 4px #3fb950, 0 0 18px rgba(63, 185, 80, 0.55); }
.memory-card.is-matched .memory-face svg { animation: pop-in var(--t-slow) var(--ease-spring); }

/* Minesweeper */
.mines-levels { mask-image: none; }
.m-mode svg { width: 26px; height: 26px; }
.m-mode[aria-pressed="true"] { background: var(--accent); color: var(--accent-text); }
/* The board is a stretch of road: a dashed lane line runs around it. */
.mines-board {
  display: grid;
  grid-template-columns: repeat(var(--cols), var(--cell));
  grid-auto-rows: var(--cell);
  gap: 4px;
  outline: 3px dashed color-mix(in srgb, var(--text) 30%, transparent);
  outline-offset: 8px;
  border-radius: 6px;
}
.mine-cell {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: 0;
  border-radius: calc(var(--cell) * 0.16);
  background: var(--surface-2);
  box-shadow: var(--edge);
  color: var(--text);
  font-size: calc(var(--cell) * 0.5);
  font-weight: 600;
  cursor: pointer;
  -webkit-touch-callout: none;
  transition: background-color var(--t-fast) ease, transform var(--t-med) var(--ease-spring);
}
.mine-cell:active:not(.is-open) { transform: scale(0.9); transition-duration: 90ms; }
.mine-cell.is-open { background: var(--surface); box-shadow: none; cursor: default; }
.mine-cell svg { width: 62%; height: 62%; }
.mine-cell.is-flag svg { animation: pop-in var(--t-med) var(--ease-spring); }
.mine-cell.is-exploded { background: var(--danger); color: #fff; }
.mine-cell.is-wrong { background: color-mix(in srgb, var(--danger) 35%, var(--surface-2)); }
.mine-cell[data-n="1"] { color: #5b8def; }
.mine-cell[data-n="2"] { color: #3fae6a; }
.mine-cell[data-n="3"] { color: #e5484d; }
.mine-cell[data-n="4"] { color: #9b7bf2; }
.mine-cell[data-n="5"] { color: #d9822b; }
.mine-cell[data-n="6"] { color: #2bb3c0; }
.mine-cell[data-n="8"] { color: var(--muted); }

/* Solitaire */
.sol-stage { align-items: stretch; justify-content: stretch; }
.sol-board { position: relative; width: 100%; height: 100%; }
.sol-slot, .sol-card {
  position: absolute;
  top: 0;
  left: 0;
  width: var(--cw);
  height: var(--ch);
  border-radius: calc(var(--cw) * 0.08);
}
.sol-slot {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--surface-2);
  color: var(--surface-3);
}
.sol-slot svg { width: 42%; height: 42%; }
.sol-stock { cursor: pointer; }
.sol-stock.is-empty svg { opacity: 0.3; }
.sol-card {
  background: #fff;
  color: #1b1b1d;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.35), inset 0 0 0 1px rgba(0, 0, 0, 0.08);
  cursor: pointer;
  overflow: hidden;
  will-change: transform;
  transition: transform 260ms var(--ease-out);
}
.sol-card.is-red { color: #d0202a; }
.sol-corner {
  position: absolute;
  top: 4%;
  left: 8%;
  right: 8%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: calc(var(--cw) * 0.24);
  line-height: 1;
}
.sol-corner b { font-weight: 600; letter-spacing: -0.04em; }
.sol-corner svg { width: calc(var(--cw) * 0.2); height: calc(var(--cw) * 0.2); }
.sol-pip { position: absolute; right: 9%; bottom: 8%; width: 50%; height: 50%; }
.sol-court { width: 56%; height: 56%; right: 7%; bottom: 6%; }
/* Back: graphite with a blue glow, a thin pinstripe frame and a bolt, like a
   charge port lit up. */
.sol-card.is-down {
  background:
    radial-gradient(circle at 50% 50%, rgba(62, 106, 225, 0.45), transparent 58%),
    repeating-linear-gradient(135deg, rgba(255, 255, 255, 0.04) 0 2px, transparent 2px 7px),
    #16181d;
  box-shadow:
    0 1px 3px rgba(0, 0, 0, 0.35),
    inset 0 0 0 calc(var(--cw) * 0.06) #16181d,
    inset 0 0 0 calc(var(--cw) * 0.06 + 1.5px) rgba(255, 255, 255, 0.28);
}
.sol-card.is-down::after {
  content: "";
  position: absolute;
  inset: 32% 30%;
  background: #fff;
  -webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M13 2 3 14h9l-1 8 10-12h-9l1-8z'/%3E%3C/svg%3E") center / contain no-repeat;
  mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24'%3E%3Cpath d='M13 2 3 14h9l-1 8 10-12h-9l1-8z'/%3E%3C/svg%3E") center / contain no-repeat;
  filter: drop-shadow(0 0 6px rgba(62, 106, 225, 0.9));
}
.sol-card.is-down > * { visibility: hidden; }
.sol-card.is-dragging { transition: none; box-shadow: 0 16px 36px rgba(0, 0, 0, 0.45); }
.sol-board.no-anim .sol-card { transition: none; }

/* ---------- phone send page ---------- */

.send-page { overflow: auto; }
.send { width: min(640px, 100%); margin: 0 auto; padding: 24px 16px 48px; display: flex; flex-direction: column; gap: var(--gap); }
.send h1 { margin: 0; font-size: 28px; font-weight: 500; }
.send #send-body { display: flex; flex-direction: column; gap: var(--gap); }
.send .chips { flex-wrap: wrap; }

/* ---------- TV player ---------- */

.tv-player {
  position: fixed;
  inset: 0;
  z-index: 10;
  background: #000;
  color: #fff;
  display: flex;
  flex-direction: column;
  animation: tv-in var(--t-slow) var(--ease-out) both;
}
.tv-player.is-leaving { animation: tv-out 260ms var(--ease-in) forwards; pointer-events: none; }
.tv-player .tv-bar { animation: slide-down var(--t-slow) var(--ease-out) 120ms both; }
@keyframes tv-in {
  from { opacity: 0; transform: scale(1.03); }
  to { opacity: 1; transform: none; }
}
@keyframes tv-out {
  to { opacity: 0; transform: scale(0.98); }
}
@keyframes slide-down {
  from { opacity: 0; transform: translateY(-16px); }
}
.tv-bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  background: #0b0b0b;
}
.tv-bar h2 {
  flex: 1;
  margin: 0 8px;
  font-size: 24px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.tv-bar .btn-ghost { color: #fff; }
.tv-stage { flex: 1; min-height: 0; position: relative; display: flex; }
.tv-stage video, .tv-stage iframe { flex: 1; width: 100%; height: 100%; border: 0; background: #000; }
.tv-status {
  position: absolute;
  inset: auto 0 0;
  margin: 0;
  padding: 24px;
  text-align: center;
  font-size: 22px;
  background: linear-gradient(transparent, rgba(0, 0, 0, 0.85));
  animation: rise var(--t-med) var(--ease-out) both;
}
body.tv-open .radio-bar { display: none; }
.tv-bar .btn-ghost[aria-pressed="true"] { background: rgba(255, 255, 255, 0.15); }
.tv-stats {
  position: absolute;
  top: 16px;
  right: 16px;
  margin: 0;
  padding: 16px 20px;
  min-width: 320px;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.78);
  display: grid;
  grid-template-columns: auto auto;
  gap: 6px 20px;
  font-size: 17px;
  font-variant-numeric: tabular-nums;
  backdrop-filter: blur(16px);
  transform-origin: top right;
  animation: pop-in var(--t-med) var(--ease-spring) both;
}
.tv-stats dt { color: #b8bec9; }
.tv-stats dd { margin: 0; text-align: right; }
.tv-verdict { grid-column: 1 / -1; margin: 8px 0 0; color: #ffd166; }

/* ---------- radio bar ---------- */

/* Floating media card, like the player at the bottom of the car's screen. */
.radio-bar {
  position: fixed;
  left: 24px;
  right: 24px;
  bottom: 16px;
  height: var(--bar-h);
  display: flex;
  align-items: center;
  gap: var(--gap);
  padding: 0 16px;
  border-radius: var(--radius-lg);
  background: color-mix(in srgb, var(--surface-2) 88%, transparent);
  backdrop-filter: blur(20px);
  box-shadow: var(--edge), 0 12px 40px rgba(0, 0, 0, 0.45);
  z-index: 5;
  animation: bar-in var(--t-slow) var(--ease-spring) both;
}
.radio-bar.is-leaving { animation: bar-out 280ms var(--ease-in) forwards; pointer-events: none; }
@keyframes bar-in {
  from { opacity: 0; transform: translateY(calc(100% + 24px)) scale(0.96); }
  to { opacity: 1; transform: none; }
}
@keyframes bar-out {
  to { opacity: 0; transform: translateY(calc(100% + 24px)) scale(0.96); }
}
.radio-bar .btn-round { background: transparent; }
.radio-bar .btn-round:first-of-type { background: var(--text); color: var(--bg); box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); }
.radio-bar .btn-round[data-icon]::before { animation: pop-in var(--t-med) var(--ease-spring); }
.radio-bar img { width: 64px; height: 64px; border-radius: 12px; object-fit: contain; background: #fff; transition: transform var(--t-slow) var(--ease-spring); }
/* The artwork shrinks a little while paused, as in the car's media player. */
.radio-bar.is-paused img { transform: scale(0.88); }
.radio-info { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.radio-info strong { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 22px; font-weight: 500; }
.radio-label, .radio-status { font-size: 16px; color: var(--muted); }
.radio-label { text-transform: uppercase; letter-spacing: 0.14em; font-size: 12px; font-weight: 500; }
.radio-status { display: flex; align-items: center; gap: 8px; }
.live-dot { display: none; width: 8px; height: 8px; border-radius: 50%; background: var(--danger); animation: pulse 1.6s ease-in-out infinite; }
.radio-bar.is-live .live-dot { animation: pulse 1.6s ease-in-out infinite, pop-in var(--t-med) var(--ease-spring); }
.radio-bar.is-live .live-dot { display: inline-block; }

/* ---------- login ---------- */

.login-page { align-items: center; justify-content: center; }
.login {
  width: min(520px, 100% - 32px);
  background: var(--surface);
  border-radius: var(--radius);
  padding: 40px;
  box-shadow: var(--edge), var(--lift);
  animation: rise var(--t-slow) var(--ease-out) both;
}
.login h1 { margin: 0 0 24px; font-weight: 500; }
.login .brand-mark { width: 64px; height: 64px; margin-bottom: 12px; }
.login form { display: flex; flex-direction: column; gap: 14px; }
.login input {
  min-height: var(--touch);
  padding: 0 18px;
  border: 0;
  border-radius: var(--radius);
  background: var(--surface-2);
  border: 1px solid transparent;
  transition: border-color var(--t-fast) ease, box-shadow var(--t-med) var(--ease-out);
}
.login-error { margin: 0; color: var(--danger); }
.login-hint { color: var(--muted); font-size: 16px; margin: 20px 0 0; }

@media (max-width: 700px) {
  body { font-size: 18px; }
  .topbar, main { padding-left: 16px; padding-right: 16px; }
  .grid { grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); }
  .tile { min-height: 200px; padding: 24px; }
  .tile-name { font-size: 30px; }
  .radio-bar { left: 12px; right: 12px; bottom: 12px; }
  .backup-cards { grid-template-columns: 1fr; }
  .help-list { grid-template-columns: 1fr; gap: 4px; }
  .help-list dd { margin-bottom: 10px; }
  .help-qr, .help-scan { display: none; }
  .help-kofi { display: inline-flex; }
  .game-body { flex-direction: column; }
  .dpad { grid-template-columns: repeat(3, 64px); grid-template-rows: repeat(3, 64px); }
  .lane-pad { grid-template-rows: 72px; grid-template-columns: repeat(2, 1fr); width: 100%; }
  .game-stat strong { font-size: 20px; }
  .clock > .clock-date { display: none; }
  #fullscreen { display: none; }
  .tv-bar #tv-full, .tv-bar #tv-alt { display: none; }
}

/* Motion is decoration only: with reduced motion everything still works,
   it just snaps into place. */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    animation-delay: 0s !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
