@font-face { font-family: "Pixel"; src: url(/fonts/pixel.ttf); font-display: swap; }
@font-face { font-family: "Orbitron"; src: url(/fonts/orbitron.ttf); font-display: swap; }
@font-face { font-family: "Cinzel"; src: url(/fonts/cinzel.ttf); font-display: swap; }
@font-face { font-family: "Bebas"; src: url(/fonts/bebas.ttf); font-display: swap; }
@font-face { font-family: "Inter"; src: url(/fonts/inter.ttf) format("truetype"); font-weight: 100 900; font-display: swap; }
@font-face { font-family: "Fredoka"; src: url(/fonts/fredoka.ttf) format("truetype"); font-weight: 300 700; font-display: swap; }
@font-face { font-family: "Antonio"; src: url(/fonts/antonio.ttf) format("truetype"); font-weight: 100 700; font-display: swap; }

/* Theme tokens are overwritten from themes.json by app.js */
:root {
  --bg0: #0E0F12; --bg1: #16181E; --surface: #1C1E24; --surface2: #262932;
  --text: #E8EAED; --muted: #8A8F98; --accent: #8AB4F8; --accent2: #C58AF9; --focus: #FFFFFF;
  --r: 14px; --rl: 22px;
  --sans: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, system-ui, sans-serif;
  --font: var(--sans); --display: var(--sans); --display-scale: 1;
  --upper: none; --track: 0;
  --glass: color-mix(in srgb, var(--surface) 70%, transparent);
  --line: color-mix(in srgb, var(--text) 10%, transparent);
  --ease: cubic-bezier(.2, .8, .2, 1);
  --spring: cubic-bezier(.34, 1.56, .64, 1);
  color-scheme: dark;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; min-height: 100%; }
body {
  background: var(--bg0); color: var(--text); font-family: var(--font);
  font-size: 15.5px; line-height: 1.45; overflow-x: hidden; letter-spacing: -0.006em;
  -webkit-font-smoothing: antialiased; transition: background .4s;
  font-feature-settings: "cv11", "ss01", "tnum";
}
#fx { position: fixed; inset: 0; z-index: -1; display: block; }
[hidden] { display: none !important; }
button, input, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; }
.muted { color: var(--muted); }
.small { font-size: 13px; }
.display { font-family: var(--display); text-transform: var(--upper); letter-spacing: var(--track); font-weight: 600; }
i[data-icon], [data-icon] svg { display: inline-flex; }
svg { width: 1.25em; height: 1.25em; stroke: currentColor; fill: none; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* Glass card */
.card {
  background: var(--glass);
  backdrop-filter: blur(28px) saturate(170%); -webkit-backdrop-filter: blur(28px) saturate(170%);
  border: 1px solid var(--line); border-radius: max(var(--rl), 20px);
  box-shadow: 0 18px 50px rgba(0, 0, 0, .30), inset 0 1px 0 color-mix(in srgb, #fff 9%, transparent);
}

/* Apple theme: Liquid Glass — clearer, brighter glass over the wallpaper */
:root[data-glass] { --glass: rgba(255, 255, 255, .13); --line: rgba(255, 255, 255, .26); }
:root[data-glass] .card, :root[data-glass] .tile-btn, :root[data-glass] .tabs, :root[data-glass] .profile-chip {
  background: linear-gradient(180deg, rgba(255,255,255,.20), rgba(255,255,255,.08));
  border: 1px solid rgba(255, 255, 255, .28);
  box-shadow: 0 20px 50px rgba(0,0,0,.25), inset 0 1px 0 rgba(255,255,255,.35), inset 0 -1px 0 rgba(255,255,255,.08);
}
:root[data-glass] .icon-btn { background: rgba(255,255,255,.16); border-color: rgba(255,255,255,.3); }
:root[data-glass] .tab-ind { background: rgba(255,255,255,.22); }
:root[data-glass] .tab.active svg { color: #fff; }
:root[data-glass] .btn.primary { background: #fff; color: #0B1220; box-shadow: 0 8px 24px rgba(0,0,0,.25); }

/* Lock-screen clock (Apple theme) */
.lock { display: none; text-align: center; margin: -6px 0 18px; pointer-events: none; }
:root[data-theme="apple"] .lock { display: block; animation: viewIn .8s var(--ease); }
.lock .ld { font-weight: 620; font-size: 17px; color: rgba(255,255,255,.92); text-shadow: 0 1px 8px rgba(0,0,0,.35); }
.lock .lc {
  font-family: "Antonio", var(--sans); font-weight: 300; font-size: 128px; line-height: 1; letter-spacing: -0.02em;
  color: transparent; -webkit-text-stroke: 1.6px rgba(255,255,255,.9);
  filter: drop-shadow(0 6px 18px rgba(0,0,0,.28));
  background: linear-gradient(180deg, rgba(255,255,255,.92), rgba(255,255,255,.5));
  -webkit-background-clip: text; background-clip: text;
}

/* ---------------- Layout */
.app {
  max-width: 620px; margin: 0 auto;
  padding: calc(14px + env(safe-area-inset-top)) 16px calc(104px + env(safe-area-inset-bottom));
}
.top { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.brand { display: flex; align-items: center; gap: 12px; }
.brand-name { font-size: calc(19px * var(--display-scale)); }
.now { display: flex; align-items: center; gap: 7px; font-size: 13px; color: var(--muted); }
.dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); transition: background .3s; }
.dot.on { background: #4ADE80; box-shadow: 0 0 10px #4ADE80; animation: pulse 2.4s infinite; }
.dot.off { background: #F87171; }
@keyframes pulse { 50% { box-shadow: 0 0 2px #4ADE80; } }

.logo-big { width: 112px; height: 112px; display: block; margin: -10px auto 6px; animation: logoIn 1.2s var(--ease) both; }
.logo-small { width: 44px; height: 44px; animation: logoIn .9s var(--ease) both; }
@keyframes logoIn { from { opacity: 0; transform: scale(.6) rotate(-40deg); filter: blur(6px); } }
.top-actions { display: flex; align-items: center; gap: 10px; }
.profile-chip {
  display: flex; align-items: center; gap: 8px; padding: 4px 14px 4px 4px; border-radius: 99px;
  background: var(--glass); border: 1px solid var(--line); font-weight: 600; font-size: 14px;
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  transition: transform .2s var(--spring); animation: viewIn .6s var(--ease) both;
}
.profile-chip:active { transform: scale(.94); }
.av {
  width: 36px; height: 36px; border-radius: 50%; display: grid; place-items: center; font-size: 19px;
  background: radial-gradient(circle at 35% 30%, color-mix(in srgb, var(--c, #3B82F6) 100%, #fff 25%), var(--c, #3B82F6) 55%, color-mix(in srgb, var(--c, #3B82F6) 55%, #000));
  box-shadow: 0 4px 14px color-mix(in srgb, var(--c, #3B82F6) 45%, transparent);
}

.view { display: none; }
.view.active { display: block; animation: viewIn .45s var(--ease); }
@keyframes viewIn { from { opacity: 0; transform: translateY(14px); } }
.view-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 4px 0 14px; }
.view h2.display { font-size: calc(34px * var(--display-scale)); margin: 0; letter-spacing: calc(var(--track) - 0.025em); font-weight: 750; }
.section-title {
  font-size: 12px; font-weight: 700; letter-spacing: .14em; text-transform: uppercase;
  color: var(--muted); margin: 22px 4px 10px;
}

/* ---------------- Buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  height: 46px; padding: 0 20px; border-radius: 999px; font-weight: 620; white-space: nowrap;
  transition: transform .15s var(--ease), background .2s, box-shadow .2s;
}
.btn:active { transform: scale(.96); }
.btn.primary {
  background: linear-gradient(135deg, var(--accent), color-mix(in srgb, var(--accent) 70%, var(--accent2)));
  color: var(--bg0); box-shadow: 0 6px 24px color-mix(in srgb, var(--accent) 35%, transparent);
}
.btn.ghost { background: color-mix(in srgb, var(--surface2) 80%, transparent); border: 1px solid var(--line); }
.btn.ghost:hover { background: var(--surface2); }
.btn.wide { width: 100%; height: 52px; font-size: 16px; }
.btn-row { display: flex; flex-wrap: wrap; gap: 10px; margin: 12px 0; }
.icon-btn {
  width: 52px; height: 52px; border-radius: 50%; display: grid; place-items: center;
  background: color-mix(in srgb, var(--surface2) 85%, transparent); border: 1px solid var(--line);
  transition: transform .15s var(--spring), background .2s;
}
.icon-btn:active, .tile-btn:active, .dp:active { transform: scale(.9); }
.icon-btn.big { width: 64px; height: 64px; background: var(--accent); color: var(--bg0); border: 0;
  box-shadow: 0 8px 26px color-mix(in srgb, var(--accent) 45%, transparent); }
.icon-btn.sm { width: 42px; height: 42px; }
.icon-btn svg { width: 22px; height: 22px; }
.power { color: #F87171; }

/* ---------------- Segmented control */
.seg {
  position: relative; display: grid; grid-template-columns: 1fr 1fr; padding: 4px; margin-bottom: 14px;
  border-radius: 14px; background: color-mix(in srgb, var(--surface) 60%, transparent); border: 1px solid var(--line);
}
.seg-btn { position: relative; z-index: 1; height: 36px; border-radius: 10px; font-weight: 600; color: var(--muted); transition: color .2s; }
.seg-btn.active { color: var(--text); }
.seg-ind {
  position: absolute; top: 4px; bottom: 4px; left: 4px; width: calc(50% - 4px); border-radius: 10px;
  background: var(--surface2); box-shadow: 0 2px 10px rgba(0,0,0,.25); transition: transform .35s var(--spring);
}
.seg[data-mode="dpad"] .seg-ind { transform: translateX(100%); }

/* ---------------- Touchpad */
.pad {
  position: relative; height: min(56vh, 340px); overflow: hidden; touch-action: none; user-select: none;
  background:
    radial-gradient(circle at 50% 40%, color-mix(in srgb, var(--accent) 16%, transparent), transparent 65%),
    var(--glass);
}
.pad::before {
  content: ""; position: absolute; inset: 0;
  background-image: radial-gradient(color-mix(in srgb, var(--text) 14%, transparent) 1px, transparent 1px);
  background-size: 22px 22px; opacity: .5;
  mask-image: radial-gradient(circle at 50% 50%, #000 30%, transparent 75%);
}
.pad-hint { position: absolute; bottom: 14px; width: 100%; text-align: center; font-size: 12px; color: var(--muted); }
.ripple {
  position: absolute; width: 16px; height: 16px; margin: -8px 0 0 -8px; border-radius: 50%;
  border: 2px solid var(--accent); pointer-events: none; animation: ripple .6s var(--ease) forwards;
}
.ripple.hold { border-color: var(--accent2); animation-duration: .9s; }
@keyframes ripple { to { transform: scale(9); opacity: 0; } }
.trail {
  position: absolute; width: 10px; height: 10px; margin: -5px 0 0 -5px; border-radius: 50%;
  background: var(--accent); pointer-events: none; opacity: .5; animation: fade .5s forwards;
}
@keyframes fade { to { opacity: 0; transform: scale(.3); } }
.pad-arrow {
  position: absolute; left: 50%; top: 45%; width: 76px; height: 76px; margin: -38px 0 0 -38px;
  display: grid; place-items: center; color: var(--accent); opacity: 0; pointer-events: none;
}
.pad-arrow svg { width: 60px; height: 60px; stroke-width: 2.5; filter: drop-shadow(0 0 12px var(--accent)); }
.pad-arrow.show { animation: arrow .45s var(--ease); }
@keyframes arrow { 0% { opacity: 0; transform: scale(.6); } 30% { opacity: 1; transform: scale(1.1); } 100% { opacity: 0; transform: scale(1); } }

/* ---------------- D-pad */
.dpad-wrap { display: grid; place-items: center; padding: 4px 0; }
.dpad { position: relative; width: min(78vw, 300px); aspect-ratio: 1; border-radius: 50%; }
.dp {
  position: absolute; width: 33%; height: 33%; display: grid; place-items: center; border-radius: 50%;
  color: var(--text); transition: background .2s, transform .15s var(--spring);
}
.dp:hover { background: color-mix(in srgb, var(--text) 6%, transparent); }
.dp svg { width: 30px; height: 30px; }
.dp.up { top: 2%; left: 33.5%; } .dp.down { bottom: 2%; left: 33.5%; }
.dp.left { left: 2%; top: 33.5%; } .dp.right { right: 2%; top: 33.5%; }
.dp.ok {
  top: 31%; left: 31%; width: 38%; height: 38%; font-weight: 800; font-size: 18px; letter-spacing: .05em;
  background: linear-gradient(145deg, var(--surface2), var(--surface)); border: 1px solid var(--line);
  box-shadow: 0 8px 24px rgba(0,0,0,.35), 0 0 0 6px color-mix(in srgb, var(--accent) 12%, transparent);
}

/* ---------------- Remote rows */
.row4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 10px; margin: 14px 0; }
.tile-btn {
  display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 14px 4px 12px;
  border-radius: 18px; font-size: 12px; color: var(--muted);
  background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  transition: transform .15s var(--spring), color .2s;
}
.tile-btn svg { width: 24px; height: 24px; color: var(--text); }
.tile-btn:hover { color: var(--text); }
.media { display: flex; justify-content: center; align-items: center; gap: 26px; padding: 14px; }
.volume { display: flex; align-items: center; gap: 14px; padding: 12px 14px; margin-top: 12px; }
.slider-wrap { flex: 1; position: relative; }
.vol-val { position: absolute; right: 0; top: -20px; font-size: 12px; color: var(--muted); font-variant-numeric: tabular-nums; }
.vol-steps { display: flex; gap: 8px; }
input[type=range] {
  -webkit-appearance: none; appearance: none; width: 100%; height: 36px; background: transparent;
  --pct: 10%;
}
input[type=range]::-webkit-slider-runnable-track {
  height: 10px; border-radius: 99px;
  background: linear-gradient(90deg, var(--accent), var(--accent2)) 0 / var(--pct) 100% no-repeat,
              color-mix(in srgb, var(--text) 12%, transparent);
}
input[type=range]::-moz-range-track { height: 10px; border-radius: 99px; background: color-mix(in srgb, var(--text) 12%, transparent); }
input[type=range]::-moz-range-progress { height: 10px; border-radius: 99px; background: linear-gradient(90deg, var(--accent), var(--accent2)); }
input[type=range]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 26px; height: 26px; margin-top: -8px; border-radius: 50%;
  background: var(--text); box-shadow: 0 2px 10px rgba(0,0,0,.4), 0 0 0 6px color-mix(in srgb, var(--accent) 25%, transparent);
  transition: transform .15s var(--spring);
}
input[type=range]:active::-webkit-slider-thumb { transform: scale(1.15); }
input[type=range]::-moz-range-thumb { width: 24px; height: 24px; border: 0; border-radius: 50%; background: var(--text); }

.strip { display: flex; gap: 12px; overflow-x: auto; padding: 4px 4px 12px; scroll-snap-type: x mandatory; scrollbar-width: none; }
.strip::-webkit-scrollbar { display: none; }
.strip .app-tile { flex: 0 0 150px; scroll-snap-align: start; }

/* ---------------- App tiles */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 14px; }
.app-tile {
  position: relative; aspect-ratio: 16 / 9; border-radius: var(--r); overflow: hidden;
  background: var(--surface); border: 1px solid var(--line);
  box-shadow: 0 6px 20px rgba(0,0,0,.3);
  transition: transform .25s var(--spring), box-shadow .25s, opacity .25s;
  animation: tileIn .5s var(--ease) both; animation-delay: calc(var(--i, 0) * 30ms);
}
@keyframes tileIn { from { opacity: 0; transform: translateY(16px) scale(.96); } }
.app-tile img { width: 100%; height: 100%; object-fit: cover; display: block; pointer-events: none; }
.app-tile .label {
  position: absolute; inset: 0; display: grid; place-items: center; padding: 8px; text-align: center;
  font-weight: 700; font-size: 15px;
}
.app-tile.input .label { font-size: 26px; letter-spacing: .14em; color: #fff; }
.app-tile.input .sub { position: absolute; bottom: 8px; width: 100%; text-align: center; font-size: 11px; color: rgba(255,255,255,.75); }
.app-tile:hover { transform: translateY(-3px) scale(1.03); box-shadow: 0 12px 30px color-mix(in srgb, var(--glow, #000) 45%, transparent); }
.app-tile:active { transform: scale(.95); }
.app-tile.launching { animation: launch .5s var(--ease) forwards; }
@keyframes launch { 40% { transform: scale(1.08); } 100% { transform: scale(1.18); opacity: 0; } }
.app-tile .shine {
  position: absolute; top: -50%; left: -60%; width: 40%; height: 200%; transform: rotate(18deg);
  background: linear-gradient(90deg, transparent, rgba(255,255,255,.35), transparent); pointer-events: none;
}
.app-tile:hover .shine { animation: shine .9s var(--ease); }
@keyframes shine { to { left: 130%; } }

/* Arrange mode */
.grid.editing .app-tile { animation: wiggle .35s ease-in-out infinite alternate; cursor: grab; touch-action: none; }
.grid.editing .app-tile:nth-child(2n) { animation-delay: -.17s; }
@keyframes wiggle { from { transform: rotate(-1deg); } to { transform: rotate(1deg); } }
.app-tile.is-hidden { opacity: .35; filter: grayscale(1); }
.app-tile.dragging { z-index: 5; animation: none !important; transform: scale(1.08); box-shadow: 0 20px 50px rgba(0,0,0,.5); opacity: .95; }
.eye {
  position: absolute; top: 6px; right: 6px; width: 32px; height: 32px; border-radius: 50%;
  display: grid; place-items: center; background: rgba(0,0,0,.6); color: #fff; z-index: 2;
}
.eye svg { width: 18px; height: 18px; }
.edit-help { margin: -6px 2px 14px; }
.edit-bar {
  position: fixed; left: 50%; bottom: calc(96px + env(safe-area-inset-bottom)); transform: translateX(-50%);
  display: flex; gap: 8px; padding: 8px; z-index: 20; animation: rise .35s var(--spring);
  max-width: calc(100% - 24px); flex-wrap: wrap; justify-content: center;
}
@keyframes rise { from { transform: translate(-50%, 30px); opacity: 0; } }

.install { margin-top: 22px; padding: 18px; display: grid; grid-template-columns: auto 1fr; gap: 6px 14px; align-items: center; transition: border-color .2s, transform .2s; }
.install.drag { border-color: var(--accent); transform: scale(1.01); }
.install-icon { grid-row: span 2; width: 48px; height: 48px; border-radius: 14px; display: grid; place-items: center; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); }
.install-text { display: flex; flex-direction: column; }
.install .btn { grid-column: 2; justify-self: start; }
.progress { grid-column: 1 / -1; height: 8px; border-radius: 99px; background: color-mix(in srgb, var(--text) 10%, transparent); overflow: hidden; margin-top: 8px; }
.progress span { display: block; height: 100%; width: 0; background: linear-gradient(90deg, var(--accent), var(--accent2)); transition: width .2s; }
.install .small { grid-column: 1 / -1; margin: 4px 0 0; }

/* ---------------- Folders */
.app-tile.folder { background: linear-gradient(135deg, var(--surface2), color-mix(in srgb, var(--surface2) 60%, #000)); }
.app-tile .mini4 { position: absolute; inset: 6px 6px 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 4px; }
.app-tile .mini4 img, .app-tile .mini4 span { width: 100%; height: 100%; object-fit: cover; border-radius: 5px; background: var(--surface); }
.app-tile .fname {
  position: absolute; left: 0; right: 0; bottom: 0; padding: 4px 10px 6px; font-size: 13px; font-weight: 700;
  background: linear-gradient(transparent, rgba(0,0,0,.75)); color: #fff; text-align: left;
}
.tile-tools { position: absolute; top: 6px; right: 6px; display: flex; gap: 6px; z-index: 2; }
.tool {
  width: 32px; height: 32px; border-radius: 50%; display: grid; place-items: center;
  background: rgba(0,0,0,.62); color: #fff; transition: transform .15s var(--spring);
}
.tool:active { transform: scale(.85); }
.tool svg { width: 17px; height: 17px; }
.app-tile .badge {
  position: absolute; left: 6px; top: 6px; padding: 2px 8px; border-radius: 99px; font-size: 11px; font-weight: 700;
  background: rgba(0,0,0,.6); color: #fff; z-index: 2;
}

/* ---------------- Profiles */
.profiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 18px; margin-top: 18px; }
.profile {
  position: relative; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 18px 8px 16px;
  border-radius: 24px; background: var(--glass); border: 1px solid var(--line);
  backdrop-filter: blur(18px); -webkit-backdrop-filter: blur(18px);
  transition: transform .3s var(--spring), border-color .2s;
  animation: popIn .55s var(--spring) both; animation-delay: calc(var(--i, 0) * 70ms);
}
@keyframes popIn { from { opacity: 0; transform: scale(.6) translateY(20px); } }
.profile:active { transform: scale(.95); }
.profile .av { width: 92px; height: 92px; font-size: 46px; transition: transform .3s var(--spring); }
.profile:hover .av { transform: scale(1.06) rotate(-4deg); }
.profile.active { border-color: var(--accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent); }
.profile .pname { font-weight: 700; font-size: 16px; }
.profile .ptheme { font-size: 12px; color: var(--muted); margin-top: -6px; }
.profile .tool { position: absolute; top: 10px; right: 10px; }
.profile.add .av { background: color-mix(in srgb, var(--text) 10%, transparent); box-shadow: none; font-size: 40px; color: var(--muted); }

/* ---------------- Sheet forms */
.sheet h3 { margin: 8px 0 12px; }
.sheet .field input { width: 100%; }
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 6px; margin: 8px 0 14px; }
.emoji-grid button { aspect-ratio: 1; border-radius: 12px; font-size: 22px; background: color-mix(in srgb, var(--text) 6%, transparent); transition: transform .15s var(--spring); }
.emoji-grid button.on { background: color-mix(in srgb, var(--accent) 35%, transparent); transform: scale(1.1); }
.swatches { display: flex; flex-wrap: wrap; gap: 10px; margin: 8px 0 16px; }
.swatches button { width: 36px; height: 36px; border-radius: 50%; border: 3px solid transparent; transition: transform .15s var(--spring); }
.swatches button.on { border-color: var(--text); transform: scale(1.15); }
.list-btn {
  display: flex; align-items: center; gap: 12px; width: 100%; padding: 14px; margin-bottom: 8px; border-radius: 14px;
  background: color-mix(in srgb, var(--text) 6%, transparent); text-align: left; font-weight: 600;
  animation: viewIn .35s var(--ease) both; animation-delay: calc(var(--i, 0) * 40ms);
}
.list-btn .e { font-size: 22px; }
.sheet .grid { margin: 6px 0 4px; }
.btn.danger { background: color-mix(in srgb, #EF4444 22%, transparent); color: #FCA5A5; border: 1px solid color-mix(in srgb, #EF4444 40%, transparent); }

/* ---------------- Theme intro */
.intro {
  position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; text-align: center; padding: 24px;
  background: linear-gradient(var(--i-angle, 135deg), var(--i-bg)); color: var(--i-text); overflow: hidden;
  animation: introOut .5s var(--ease) 1.9s forwards;
}
@keyframes introOut { to { opacity: 0; visibility: hidden; } }
.intro .i-title { font-family: var(--i-font); font-weight: 700; font-size: calc(40px * var(--i-scale)); text-transform: var(--i-upper);
  letter-spacing: .04em; animation: introText .9s var(--spring) .35s both; text-shadow: 0 4px 30px rgba(0,0,0,.5); }
.intro .i-sub { margin-top: 10px; color: var(--i-muted); font-family: var(--i-font); font-size: calc(15px * var(--i-scale)); animation: introText .8s var(--ease) .7s both; }
@keyframes introText { from { opacity: 0; transform: translateY(24px) scale(.9); letter-spacing: .4em; filter: blur(6px); } }
.intro .i-photo { position: absolute; inset: 0; background-size: cover; background-position: center; animation: kenburns 2.6s ease-out both; }
.intro .i-photo::after { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 40%, rgba(0,0,0,.75)); }
@keyframes kenburns { from { transform: scale(1.18); opacity: 0; } 30% { opacity: 1; } }
.intro .i-fx { position: absolute; inset: 0; pointer-events: none; }
.intro.fx-stars .i-fx { background-image: radial-gradient(#fff 1px, transparent 1.5px), radial-gradient(#bfd9ff 1px, transparent 1.5px);
  background-size: 41px 37px, 67px 53px; animation: warp 2s ease-in both; }
@keyframes warp { to { transform: scale(3); opacity: 0; } }
.intro.fx-dungeon .i-fx { background: radial-gradient(circle at 50% 0, color-mix(in srgb, var(--i-accent) 50%, transparent), transparent 60%); animation: flicker 1s infinite; }
.intro.fx-court .i-fx { background: radial-gradient(circle at 50% 50%, transparent 30%, rgba(255,255,255,.18) 30.5%, transparent 31.5%), linear-gradient(90deg, transparent 49.8%, rgba(255,255,255,.18) 50%, transparent 50.2%); }
.intro.fx-scanlines .i-fx { background: repeating-linear-gradient(0deg, rgba(0,0,0,.3) 0 2px, transparent 2px 4px); }
.intro.fx-grid .i-fx { background: repeating-linear-gradient(90deg, transparent 0 30px, color-mix(in srgb, var(--i-accent2) 30%, transparent) 30px 31px); mask: linear-gradient(transparent 55%, #000); animation: glitch .3s steps(2) 4; }
@keyframes glitch { 50% { transform: translateX(6px); filter: hue-rotate(90deg); } }
.intro.fx-sun .i-fx { background: radial-gradient(circle at 50% 100%, var(--i-accent) 0 25%, transparent 26%); animation: sunrise 1.6s var(--ease) both; }
@keyframes sunrise { from { transform: translateY(40%); } }
.intro.fx-aurora .i-fx, .intro.fx-none .i-fx, .intro.fx-waves .i-fx {
  background: radial-gradient(ellipse at 30% 30%, color-mix(in srgb, var(--i-accent) 45%, transparent), transparent 60%),
              radial-gradient(ellipse at 70% 60%, color-mix(in srgb, var(--i-accent2) 40%, transparent), transparent 60%);
  animation: bloom 1.8s var(--ease) both;
}
@keyframes bloom { from { opacity: 0; transform: scale(.6); } }
/* Apple intro: colour blooms and a glowing "hello" */
.intro.fx-depth { background: #000; }
.intro.fx-depth .i-fx {
  background: radial-gradient(circle at 20% 60%, rgba(10,132,255,.55), transparent 40%),
              radial-gradient(circle at 45% 50%, rgba(191,90,242,.5), transparent 40%),
              radial-gradient(circle at 70% 55%, rgba(255,55,95,.45), transparent 40%),
              radial-gradient(circle at 90% 65%, rgba(48,209,88,.4), transparent 40%);
  filter: blur(20px); animation: bloom 1.8s var(--ease) both;
}
.intro.fx-depth .i-title {
  font-family: "Inter", var(--sans); font-weight: 250; font-size: 76px; letter-spacing: -0.03em; text-transform: none;
  background: linear-gradient(90deg, #fff, #b7d5ff, #ffd3f0, #fff); background-size: 200% 100%;
  -webkit-background-clip: text; background-clip: text; color: transparent; animation: introText .9s var(--spring) .3s both, sheen 2.4s linear infinite;
}
@keyframes sheen { to { background-position: -200% 0; } }

/* ---------------- Themes */
.themes { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 12px; }
.theme-card {
  position: relative; aspect-ratio: 4 / 3; border-radius: 20px; overflow: hidden; text-align: left; padding: 14px;
  display: flex; flex-direction: column; justify-content: flex-end; color: var(--t-text);
  background: linear-gradient(var(--t-angle, 135deg), var(--t-bg));
  border: 2px solid transparent; box-shadow: 0 8px 26px rgba(0,0,0,.35);
  transition: transform .3s var(--spring), border-color .2s;
  animation: tileIn .5s var(--ease) both; animation-delay: calc(var(--i) * 40ms);
}
.theme-card:hover { transform: translateY(-4px) rotate(-.6deg); }
.theme-card:active { transform: scale(.96); }
.theme-card.selected { border-color: var(--t-focus); box-shadow: 0 0 0 4px color-mix(in srgb, var(--t-accent) 35%, transparent), 0 14px 34px rgba(0,0,0,.4); }
.theme-card .mini { position: absolute; top: 14px; left: 14px; display: flex; gap: 6px; }
.theme-card .mini span { width: 34px; height: 20px; border-radius: min(var(--t-r), 6px); background: var(--t-surface); }
.theme-card .mini span:first-child { outline: 2px solid var(--t-focus); }
.theme-card .orb { position: absolute; top: 12px; right: 12px; width: 24px; height: 24px; border-radius: 50%; background: linear-gradient(135deg, var(--t-accent), var(--t-accent2)); box-shadow: 0 0 16px var(--t-accent); }
.theme-card .name { font-family: var(--t-font); font-weight: 700; font-size: calc(17px * var(--t-scale)); text-transform: var(--t-upper); line-height: 1.2; }
.theme-card .tag { font-size: 12px; color: var(--t-muted); }
.theme-card .check {
  position: absolute; top: 44px; right: 12px; width: 26px; height: 26px; border-radius: 50%;
  background: var(--t-focus); color: var(--t-bg0); display: grid; place-items: center; transform: scale(0); transition: transform .3s var(--spring);
}
.theme-card.selected .check { transform: scale(1); }
.theme-card .check svg { width: 15px; height: 15px; stroke-width: 3; }
.theme-card.fx-stars::before, .theme-card.fx-scanlines::before, .theme-card.fx-dungeon::before, .theme-card.fx-court::before, .theme-card.fx-sun::before, .theme-card.fx-grid::before, .theme-card.fx-aurora::before, .theme-card.fx-waves::before {
  content: ""; position: absolute; inset: 0; pointer-events: none;
}
.theme-card.fx-stars::before { background-image: radial-gradient(#fff 1px, transparent 1.5px), radial-gradient(#bfd9ff 1px, transparent 1.5px); background-size: 37px 41px, 53px 29px; background-position: 0 0, 17px 11px; opacity: .6; }
.theme-card.fx-scanlines::before { background: repeating-linear-gradient(0deg, rgba(0,0,0,.25) 0 2px, transparent 2px 4px); }
.theme-card.fx-dungeon::before { background: radial-gradient(circle at 0 20%, rgba(245,158,11,.45), transparent 55%), radial-gradient(circle at 100% 20%, rgba(245,158,11,.35), transparent 50%); animation: flicker 1.8s infinite; }
@keyframes flicker { 30% { opacity: .8; } 60% { opacity: 1; } 80% { opacity: .9; } }
.theme-card.fx-court::before { background: repeating-linear-gradient(0deg, rgba(176,112,58,.35) 0 14px, rgba(132,78,36,.35) 14px 15px), radial-gradient(circle at 50% 120%, transparent 38%, rgba(255,255,255,.3) 39%, transparent 40%); }
.theme-card.fx-sun::before { background: radial-gradient(circle at 72% 78%, var(--t-accent) 0 22%, transparent 23%); mask: linear-gradient(#000 70%, transparent 70%); }
.theme-card.fx-grid::before { background: linear-gradient(transparent 62%, rgba(0,240,255,.25) 63%, transparent 64%), repeating-linear-gradient(90deg, transparent 0 18px, rgba(0,240,255,.2) 18px 19px); mask: linear-gradient(transparent 60%, #000 62%); }
.theme-card.fx-aurora::before { background: radial-gradient(ellipse at 30% 20%, color-mix(in srgb, var(--t-accent) 40%, transparent), transparent 60%), radial-gradient(ellipse at 80% 30%, color-mix(in srgb, var(--t-accent2) 40%, transparent), transparent 60%); animation: drift 6s ease-in-out infinite alternate; }
@keyframes drift { to { transform: translateX(-8%); } }
.theme-card.fx-waves::before { background: radial-gradient(ellipse at 50% 120%, color-mix(in srgb, var(--t-accent) 35%, transparent), transparent 60%); }
.theme-card.fx-photo, .theme-card.fx-depth { background: center / cover var(--t-photo, none); }
.theme-card.fx-photo::before, .theme-card.fx-depth::before { content: ""; position: absolute; inset: 0; background: linear-gradient(transparent 35%, rgba(0,0,0,.7)); }
.theme-card .mini, .theme-card .orb, .theme-card .check { z-index: 1; }
.theme-card .name, .theme-card .tag { position: relative; z-index: 1; }

/* ---------------- More */
.panel { padding: 18px; margin-bottom: 14px; animation: viewIn .5s var(--ease) both; }
.panel:nth-of-type(2) { animation-delay: .06s; } .panel:nth-of-type(3) { animation-delay: .12s; }
.panel:nth-of-type(4) { animation-delay: .18s; } .panel:nth-of-type(5) { animation-delay: .24s; }
.panel h3 { display: flex; align-items: center; gap: 8px; margin: 0 0 6px; font-size: 17px; }
.panel h3 svg { color: var(--accent); }
.panel p { margin: 6px 0; }
.field { display: flex; flex-direction: column; gap: 4px; margin: 12px 0; }
.label { font-size: 11px; text-transform: uppercase; letter-spacing: .12em; color: var(--muted); font-weight: 700; }
code { font-family: ui-monospace, "Cascadia Mono", Consolas, monospace; padding: 10px 12px; border-radius: 12px; background: color-mix(in srgb, var(--bg0) 60%, transparent); border: 1px solid var(--line); word-break: break-all; }
.code-big { font-size: 22px; letter-spacing: .2em; color: var(--accent); }
.inline-form { display: flex; gap: 8px; margin: 10px 0; }
.inline-form input, .sheet input, .code-input {
  flex: 1; min-width: 0; height: 46px; padding: 0 14px; border-radius: 14px; outline: 0;
  background: color-mix(in srgb, var(--bg0) 55%, transparent); border: 1px solid var(--line); transition: border-color .2s, box-shadow .2s;
}
.inline-form input:focus, .sheet input:focus, .code-input:focus { border-color: var(--accent); box-shadow: 0 0 0 4px color-mix(in srgb, var(--accent) 20%, transparent); }
.switch { display: inline-flex; align-items: center; gap: 10px; cursor: pointer; font-size: 14px; color: var(--muted); margin-top: 6px; }
.switch input { display: none; }
.switch span { position: relative; width: 44px; height: 26px; border-radius: 99px; background: color-mix(in srgb, var(--text) 18%, transparent); transition: background .25s; flex: none; }
.switch span::after { content: ""; position: absolute; top: 3px; left: 3px; width: 20px; height: 20px; border-radius: 50%; background: #fff; transition: transform .3s var(--spring); }
.switch input:checked + span { background: var(--accent); }
.switch input:checked + span::after { transform: translateX(18px); }

/* ---------------- Bottom tabs */
.tabs {
  position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(12px + env(safe-area-inset-bottom));
  width: min(588px, calc(100% - 24px)); display: grid; grid-template-columns: repeat(5, 1fr); padding: 6px; z-index: 30;
  border-radius: 24px;
}
.tab { position: relative; z-index: 1; display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 0 6px; font-size: 11px; font-weight: 600; color: var(--muted); transition: color .25s; }
.tab svg { width: 22px; height: 22px; transition: transform .3s var(--spring); }
.tab.active { color: var(--text); }
.tab.active svg { transform: translateY(-2px) scale(1.1); color: var(--accent); }
.tab-ind {
  position: absolute; top: 6px; bottom: 6px; left: 6px; width: calc((100% - 12px) / 5); border-radius: 18px;
  background: color-mix(in srgb, var(--accent) 16%, transparent); transition: transform .4s var(--spring);
}

/* ---------------- Sheet, toast, login */
.sheet-backdrop { position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: 40; animation: fadeIn .25s; }
@keyframes fadeIn { from { opacity: 0; } }
.sheet {
  position: fixed; left: 50%; bottom: 0; transform: translateX(-50%); width: min(620px, 100%); z-index: 41;
  padding: 10px 18px calc(22px + env(safe-area-inset-bottom)); border-radius: 26px 26px 0 0; animation: sheetUp .4s var(--spring);
}
@keyframes sheetUp { from { transform: translate(-50%, 100%); } }
.sheet h3 { margin: 8px 0 12px; }
.sheet input { width: 100%; }
.grabber { width: 40px; height: 5px; border-radius: 99px; background: var(--line); margin: 0 auto 6px; }
.toast {
  position: fixed; left: 50%; top: calc(14px + env(safe-area-inset-top)); transform: translate(-50%, -140%); z-index: 50;
  padding: 11px 18px; border-radius: 99px; font-size: 14px; font-weight: 600; max-width: calc(100% - 32px);
  background: var(--surface2); border: 1px solid var(--line); box-shadow: 0 10px 30px rgba(0,0,0,.4);
  transition: transform .45s var(--spring);
}
.toast.show { transform: translate(-50%, 0); }
.login { min-height: 100dvh; display: grid; place-items: center; padding: 24px; }
.login-card { width: min(400px, 100%); padding: 32px 26px; text-align: center; animation: viewIn .6s var(--ease); }
.login-card h1 { margin: 0 0 6px; font-size: calc(30px * var(--display-scale)); }
.code-input { width: 100%; margin: 18px 0 12px; text-align: center; font-size: 22px; letter-spacing: .25em; text-transform: uppercase; height: 56px; }
.error { color: #FCA5A5; min-height: 20px; margin: 10px 0 0; font-size: 14px; }
.shake { animation: shake .45s; }
@keyframes shake { 20%, 60% { transform: translateX(-8px); } 40%, 80% { transform: translateX(8px); } }

/* Retro arcade wants square corners everywhere */
:root[data-square] .card, :root[data-square] .btn, :root[data-square] .tile-btn, :root[data-square] .app-tile,
:root[data-square] .chip, :root[data-square] .msg, :root[data-square] .tabs, :root[data-square] .tab-ind,
:root[data-square] .seg, :root[data-square] .seg-ind { border-radius: 2px; }

@media (min-width: 760px) {
  .grid { grid-template-columns: repeat(3, 1fr); }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; transition-duration: .01ms !important; }
}
