/* ── Reset & base ─────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg-dark:    #1a1a2e;
  --bg-darker:  #16213e;
  --accent-yellow: #FFD700;
  --accent-green:  #00FF88;
  --accent-red:    #FF3344;
  --accent-gray:   #888;
  --font-pixel: 'Silkscreen', 'Silkscreen-Bold', monospace;
}

html, body {
  width: 100%; height: 100%;
  background: var(--bg-dark);
  color: #fff;
  font-family: var(--font-pixel);
  overflow: hidden;
  -webkit-font-smoothing: none;
}

#top-bar-host {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: 30;
  pointer-events: none;
}
#top-bar-host .top-bar { pointer-events: auto; }

#app, #popup {
  position: fixed;
  inset: 0;
}
#popup { pointer-events: none; }
#popup:not(:empty) { pointer-events: auto; }

/* ── Screens ──────────────────────────────────────────────────────────────── */
.screen {
  position: relative;
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  overflow: hidden;
}

.screen-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  z-index: 0;
}

/* ── Top bar ──────────────────────────────────────────────────────────────── */
.top-bar {
  position: relative; z-index: 10;
  display: flex; align-items: center; gap: 8px;
  padding: env(safe-area-inset-top, 4px) 12px 4px;
  min-height: 44px;
}
.top-menu-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: fill; z-index: 0;
}
.avatar {
  width: 36px; height: 36px;
  border-radius: 50%; object-fit: cover;
  position: relative; z-index: 1;
  margin-top: 4px;
  margin-left: -8px;
}
.username-label {
  font-family: var(--font-pixel); font-size: 0.8rem; font-weight: bold;
  color: var(--accent-yellow);
  text-shadow: 0 0 10px var(--accent-yellow);
  position: relative; z-index: 1;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 90px;
}
.top-bar-cash {
  position: absolute; z-index: 1;
  left: calc(50% + 4px);
  top: 50%; transform: translateY(-50%);
  font-family: var(--font-pixel); font-size: 0.8rem;
  color: var(--accent-yellow); text-shadow: 0 0 8px var(--accent-yellow);
  white-space: nowrap;
}
.top-bar-shlobuda {
  position: absolute; z-index: 1;
  left: calc(75% + 10px);
  top: 50%; transform: translateY(-50%);
  font-family: var(--font-pixel); font-size: 0.8rem;
  color: var(--accent-green); text-shadow: 0 0 8px var(--accent-green);
  white-space: nowrap;
}
.balance-label, .income-label {
  font-family: var(--font-pixel);
  font-size: 0.8rem;
  color: var(--accent-yellow);
  position: relative; z-index: 1;
  text-shadow: 0 0 8px var(--accent-yellow);
  white-space: nowrap;
}
.shlobuda-label { color: var(--accent-green); text-shadow: 0 0 8px var(--accent-green); }
.income-label   { color: var(--accent-green); margin-left: auto; text-shadow: 0 0 8px var(--accent-green); }
.notif-badge {
  width: 22px; height: 22px;
  background: #FF8C00; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.7rem; font-weight: bold;
  position: relative; z-index: 1; margin-left: 4px;
}

/* Daily badge — below top-bar, right side */
.daily-badge {
  position: absolute; top: 44px; right: 12px; z-index: 20;
  width: 40px; height: 40px;
  background: none; border: none; cursor: pointer; padding: 0;
}
.daily-badge img {
  width: 100%; height: 100%; object-fit: contain; image-rendering: pixelated;
}

/* Exchange badge — round stub under daily tasks */
.exchange-badge {
  position: absolute; top: 92px; right: 12px; z-index: 20;
  width: 40px; height: 40px; border-radius: 50%;
  background: #AD9300; border: 2px solid #ffd700;
  color: #fff; font-family: var(--font-pixel); font-size: 0.8rem; font-weight: bold;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  box-shadow: 0 0 8px rgba(173,147,0,0.6);
}
.exchange-badge:active { opacity: 0.75; }

/* Exchange popup */
.xch-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end;
  background: rgba(0,0,0,0.55);
}
.xch-sheet {
  width: 100%; max-height: 82vh;
  border-radius: 12px 12px 0 0; overflow: hidden;
  animation: slide-up 0.25s ease-out forwards;
}
.xch-sheet.closing {
  animation: slide-down 0.22s ease-in forwards;
}
@keyframes slide-down {
  from { transform: translateY(0); }
  to   { transform: translateY(100%); }
}
.xch-sheet-bg {
  background: url("../images/xony_bg.png") top center / 100% auto no-repeat, #1a1a2e;
  padding: 16px 12px 24px;
  display: flex; flex-direction: column; gap: 12px;
  max-height: 82vh; overflow-y: auto;
}

/* ── Shared HUD tab-switcher component ───────────────────────────────────── */
/* Parallelogram shape via skewX — single-height, slightly angled             */
.ui-tabs,
.xch-tabs,
.tasks-tabs {
  display: flex; gap: 4px; justify-content: center;
  margin: 10px 0 8px;
}

.ui-tab,
.xch-tab,
.tasks-tab {
  flex: 0 0 auto;
  padding: 8px 24px;
  background: #1a1200;
  border: 1.5px solid #3a2f00;
  border-radius: 0;
  color: #6a5600;
  font-family: var(--font-pixel); font-size: 0.62rem; font-weight: bold;
  letter-spacing: 0.1em;
  -webkit-text-stroke: 0.5px rgba(255, 200, 0, 0.4);
  cursor: pointer;
  transform: skewX(-12deg);
}

.ui-tab:hover:not(.active),
.xch-tab:hover:not(.active),
.tasks-tab:hover:not(.active) {
  background: #0e0b00;
  border-color: #AD9300;
  color: #AD9300;
}

.ui-tab.active,
.xch-tab.active,
.tasks-tab.active {
  background: linear-gradient(180deg, #ffd700 0%, #c8a000 45%, #7a6000 100%);
  border-color: #ffd700;
  color: #0a0800;
  box-shadow: 0 0 8px rgba(255, 200, 0, 0.45), inset 0 1px 0 rgba(255,255,255,0.2);
}

/* Tile grid: 3 per row */
.xch-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px;
}
.xch-tile {
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 4px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 8px; cursor: pointer;
  font-family: var(--font-pixel);
}
.xch-tile:hover  { border-color: #AD9300; background: rgba(173,147,0,0.12); }
.xch-tile:active { opacity: 0.7; }
.xch-tile:disabled { opacity: 0.4; cursor: default; }
.xch-cost  { font-size: 0.65rem; color: #fff; }
.xch-arrow { font-size: 0.5rem;  color: #888; }
.xch-gain  { font-size: 0.65rem; color: #44ff44; }

/* Coming soon */
.xch-soon {
  text-align: center; padding: 48px 0;
  font-family: var(--font-pixel); font-size: 1rem;
  color: #AD9300;
  text-shadow: 0 0 12px rgba(173,147,0,0.6);
}

/* TON Connect tab */
.xch-wallet-row {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; padding: 8px 0 12px;
}
.xch-connect-btn {
  background: #0088cc; color: #fff;
  border: none; border-radius: 8px;
  padding: 8px 18px; font-size: 0.8rem; font-weight: 700;
  cursor: pointer; letter-spacing: 0.03em;
}
.xch-connect-btn:active { opacity: 0.8; }
.xch-wallet-addr {
  font-size: 0.75rem; color: #aaa; font-family: monospace;
}
.xch-wallet-disconnect {
  background: none; border: 1px solid #555; border-radius: 6px;
  color: #888; font-size: 0.7rem; padding: 3px 8px; cursor: pointer;
}
.xch-wallet-disconnect:active { color: #f44336; border-color: #f44336; }
.xch-tile-ton.disabled { opacity: 0.35; cursor: not-allowed; }
.xch-ton-waiting {
  text-align: center; padding: 32px 16px;
  font-size: 0.85rem; color: #ccc; line-height: 1.8;
}
.xch-ton-hint { font-size: 0.7rem; color: #666; }
.xch-ton-spinner {
  width: 32px; height: 32px; margin: 0 auto 16px;
  border: 3px solid #333; border-top-color: #0088cc;
  border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.xch-ton-success {
  text-align: center; padding: 32px 16px;
  font-size: 1rem; color: #44ff44;
  font-family: var(--font-pixel);
  display: flex; flex-direction: column; align-items: center;
}

/* Daily tasks popup */
.daily-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end;
  background: rgba(0,0,0,0.5);
}
.daily-sheet {
  position: relative; width: 100%;
  border-radius: 12px 12px 0 0; overflow: hidden;
  animation: slide-up 0.25s ease-out forwards;
}
.daily-sheet-bg {
  position: absolute; inset: 0;
  width: 100%; height: 100%; object-fit: cover; z-index: 0;
}
.daily-content {
  position: relative; z-index: 1;
  padding: 16px 16px 24px;
}
.daily-header-img {
  width: 100%; display: block;
  image-rendering: pixelated; object-fit: contain;
  margin-bottom: 12px; border-radius: 8px;
}
.daily-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 16px; }
.daily-row {
  display: flex; align-items: center; gap: 8px;
  background: var(--accent-yellow); border-radius: 6px;
  padding: 8px 10px;
}
.daily-reward {
  font-family: var(--font-pixel); font-size: 0.8rem;
  color: #000; font-weight: bold; min-width: 54px; flex-shrink: 0;
}
.daily-text {
  font-family: var(--font-pixel); font-size: 0.6rem;
  color: #333; flex: 1; line-height: 1.3;
}
.daily-status {
  font-family: var(--font-pixel); font-size: 0.75rem; font-weight: bold;
  flex-shrink: 0;
}
.daily-status.get  { color: var(--accent-red); }
.daily-status.done { color: var(--accent-green); }
.xony-badge {
  margin-left: auto;
  background: var(--accent-green); color: #000;
  padding: 2px 8px; font-size: 0.75rem;
  position: relative; z-index: 1;
}

/* ── Garage screen ────────────────────────────────────────────────────────── */
.garage-bg-wrap {
  flex: 1; position: relative; overflow: hidden;
}
.car-stage {
  position: absolute; z-index: 2;
  display: flex; align-items: center; justify-content: center;
  width: 100%; padding: 0 8px;
  top: 60%;
  transform: translateY(-50%);
}
.car-img {
  width: 60%; max-width: 280px;
  object-fit: contain; image-rendering: pixelated;
  filter: drop-shadow(0 4px 24px rgba(0,255,136,0.25));
}
.car-name {
  text-align: center;
  font-family: var(--font-pixel);
  font-size: 1.1rem; letter-spacing: 2px;
  color: var(--accent-yellow);
  text-shadow: 0 0 12px var(--accent-yellow);
  margin-top: 8px;
}
.car-display { display: flex; flex-direction: column; align-items: center; flex: 1; position: relative; }

@keyframes car-exit-right {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}
@keyframes car-exit-left {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(-120%); opacity: 0; }
}
@keyframes car-enter-left {
  from { transform: translateX(-120%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes car-enter-right {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
.car-display.exit-right,
.car-img-sm.exit-right  { animation: car-exit-right 0.3s ease-in forwards; }
.car-display.exit-left  { animation: car-exit-left  0.3s ease-in forwards; }
.car-display.enter-left,
.car-img-sm.enter-left  { animation: car-enter-left  0.3s ease-out forwards; }
.car-display.enter-right{ animation: car-enter-right 0.3s ease-out forwards; }

.smoke-canvas {
  position: absolute;
  pointer-events: none; z-index: 3;
  image-rendering: pixelated;
}

.nav-btn { background: none; border: none; cursor: pointer; padding: 8px; }
.nav-btn img { width: 36px; object-fit: contain; image-rendering: pixelated; }
.nav-btn.hidden { visibility: hidden; }

/* ── Bottom buttons ───────────────────────────────────────────────────────── */
.bottom-buttons {
  position: absolute; z-index: 10;
  bottom: 80px; left: 0; right: 0;
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px;
  gap: 4px;
}
.hex-btn { background: none; border: none; cursor: pointer; }
.hex-btn img { width: 100px; object-fit: contain; image-rendering: pixelated; }

.race-btn {
  position: absolute; z-index: 10;
  bottom: 14px; left: 50%; transform: translateX(-50%);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  padding: 10px 32px;
  background: #0d0800;
  border: 3px solid #ffd700;
  border-radius: 0;
  color: #ffd700;
  font-family: var(--font-pixel); font-size: 0.84rem; font-weight: bold;
  letter-spacing: 0.1em; text-transform: uppercase;
  cursor: pointer; text-align: center; line-height: 1.4;
  white-space: nowrap;
  box-shadow: 5px 5px 0 #6a4f00, 0 0 16px rgba(255,200,0,0.2);
  -webkit-text-stroke: 0.4px rgba(255,200,0,0.5);
  text-shadow: 0 0 10px rgba(255,200,0,0.7);
}
.race-btn:active {
  box-shadow: 2px 2px 0 #6a4f00, 0 0 16px rgba(255,200,0,0.2);
  transform: translateX(calc(-50% + 3px)) translateY(3px);
}
.race-btn.disabled { opacity: 0.4; cursor: default; border-color: #555; color: #555; text-shadow: none; box-shadow: none; }

/* ── Auto Haus ────────────────────────────────────────────────────────────── */
.haus-car-area {
  position: relative; z-index: 2;
  display: flex; align-items: flex-end; justify-content: center; gap: 8px;
  flex: 1; padding: 4vh 4px 16px;
  overflow: hidden;
}
.haus-car-display {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.haus-car-area .car-img-sm {
  position: relative; top: auto; left: auto; transform: none;
  width: 70%; max-width: 240px; margin: 0 auto 4px;
}

/* ── Car card (shared Haus + Tune) ────────────────────────────────────────── */
@keyframes slide-up {
  from { transform: translateY(100%); }
  to   { transform: translateY(0); }
}
.car-card {
  position: relative; z-index: 2;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.15);
  border-radius: 8px; margin: 0 12px 12px;
  padding: 12px; flex: 1; overflow-y: auto;
}
.car-card.slide-up {
  background: url("../images/xony_bg.png") top center / 100% auto no-repeat;
  flex: none; height: 50vh;
  margin-top: auto; margin-bottom: 0; border-radius: 12px 12px 0 0;
  padding-top: 32px;
  animation: slide-up 0.25s ease-out forwards;
}
.car-card.slide-up.slide-down {
  animation: slide-down 0.18s ease-in forwards;
}
@keyframes slide-down {
  from { transform: translateY(0); }
  to   { transform: translateY(110%); }
}
.card-header { display: flex; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
.card-title-block { flex: 1; }
.car-title { display: block; font-size: 0.9rem; color: #fff; margin-bottom: 4px; }
.car-desc { display: block; font-size: 0.65rem; color: #aaa; font-style: italic; }
.price-box {
  border: 1px solid var(--accent-yellow); border-radius: 4px;
  padding: 4px 8px; text-align: center; min-width: 70px;
}
.price-label { display: block; font-size: 0.55rem; color: #aaa; }
.price-value { display: block; font-size: 0.8rem; color: var(--accent-yellow); }

.stats-grid { display: flex; gap: 8px; margin-bottom: 10px; }
.stats-col { flex: 1; }
.col-header {
  font-size: 0.7rem; color: #fff; margin-bottom: 8px; letter-spacing: 1px;
  text-align: center; background: rgba(0,0,0,0.35);
  border-radius: 4px; padding: 3px 0;
}

/* Segmented stat cell */
.stat-cell { display: flex; flex-direction: column; align-items: center; margin-bottom: 10px; gap: 3px; }
.seg-track { display: flex; gap: 3px; align-items: flex-end; }
.seg {
  width: 14px; height: 18px;
  background: #333; flex-shrink: 0;
  transform: skewX(-25deg);
}
.seg.filled { background: var(--accent-green); }
.stat-name { font-size: 0.6rem; color: #ccc; text-transform: capitalize; text-align: center; }

/* keep legacy for haus */
.stat-row { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }
.prog-track { flex: 1; height: 6px; background: #333; border-radius: 3px; min-width: 40px; }
.prog-fill  { height: 100%; background: var(--accent-green); border-radius: 3px; transition: width 0.3s; }

.card-actions { display: flex; gap: 8px; justify-content: space-between; margin-top: 8px; align-items: center; }
.card-actions .action-btn img { width: auto; height: 36px; }

/* ── Tune Garage ──────────────────────────────────────────────────────────── */
.tune-screen { display: flex; flex-direction: column; }
.car-img-sm {
  position: absolute; z-index: 2;
  width: 40%; max-width: 180px;
  top: 28%; left: 50%; transform: translateX(-50%);
  object-fit: contain; image-rendering: pixelated;
}
.stage-badge {
  font-family: var(--font-pixel);
  font-size: 0.5rem; color: var(--accent-green);
  border: 1px solid var(--accent-green);
  padding: 2px 6px; border-radius: 2px;
  white-space: nowrap; align-self: flex-start;
  letter-spacing: 0.05em;
}
.upg-btn {
  font-family: var(--font-pixel); font-size: 0.55rem;
  border: none; border-radius: 3px; padding: 3px 6px;
  cursor: pointer; white-space: nowrap;
}
.upg-btn.green { background: var(--accent-green); color: #000; }
.upg-btn.disabled { background: #444; color: #666; cursor: default; }
.upg-btn.loading {
  background: #2a2a2a; color: #AD9300; cursor: default;
  animation: upg-pulse 0.6s ease-in-out infinite alternate;
}
@keyframes upg-pulse {
  from { opacity: 0.4; }
  to   { opacity: 1; }
}

/* Stage upgrade button */
.stage-upgrade-wrap {
  padding: 8px 12px 0;
}
.stage-upgrade-btn {
  width: 100%; padding: 10px 12px;
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  border: 2px solid #AD9300; border-radius: 8px;
  background: rgba(173,147,0,0.15);
  cursor: pointer; font-family: var(--font-pixel);
  box-shadow: 0 0 10px rgba(173,147,0,0.3);
}
.stage-upgrade-btn:hover  { background: rgba(173,147,0,0.28); }
.stage-upgrade-btn:active { opacity: 0.75; }
.stage-upgrade-btn.disabled {
  border-color: #444; background: rgba(255,255,255,0.04);
  box-shadow: none; cursor: default;
}
.stage-upgrade-label {
  font-size: 0.75rem; color: #ffd700; letter-spacing: 1px;
}
.stage-upgrade-btn.disabled .stage-upgrade-label { color: #666; }
.stage-upgrade-cost  { font-size: 0.6rem; color: #AD9300; }
.stage-upgrade-hint  { font-size: 0.55rem; color: #555; }

/* ── Action buttons ───────────────────────────────────────────────────────── */
.action-btn {
  position: relative; display: inline-flex; align-items: center; gap: 6px;
  border: none; background: none; cursor: pointer;
  font-family: var(--font-pixel); font-size: 0.75rem; color: #fff;
  padding: 4px 8px;
}
.action-btn img { height: 36px; object-fit: contain; image-rendering: pixelated; }
.action-btn span { position: absolute; left: 50%; transform: translateX(-50%); white-space: nowrap; }
.action-btn.back-btn img { filter: grayscale(1); }
.action-btn.center { display: flex; margin: 8px auto 0; }
.action-btn.disabled { opacity: 0.4; pointer-events: none; }

/* ── Drossel daily reward overlay ─────────────────────────────────────────── */
.drossel-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end; justify-content: center;
  background: rgba(0,0,0,0.55);
}
.drossel-card {
  position: fixed; bottom: 0; right: 0;
  width: 80%; max-width: 320px;
}
.drossel-img {
  width: 100%; display: block;
  image-rendering: pixelated; object-fit: contain;
}
/* text sits inside the speech bubble area */
.drossel-text-block {
  position: absolute;
  top: 5%; left: 8%; right: 18%;
  height: 58%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  padding-top: 8%;
  gap: 0; text-align: center;
}
.drossel-msg {
  font-family: var(--font-pixel); font-size: 0.78rem; font-weight: bold;
  color: #000; line-height: 1.6;
  -webkit-text-stroke: 2px #fff;
  paint-order: stroke fill;
}
.drossel-reward-card {
  margin-top: 10px;
  background: #EE9E27; border-radius: 8px; padding: 10px 24px;
}
.drossel-reward {
  font-family: var(--font-pixel); font-size: 1.1rem; font-weight: bold;
  color: #000;
  -webkit-text-stroke: 2px #fff;
  paint-order: stroke fill;
}
.drossel-text-block .action-btn {
  margin-top: 20px;
}

/* ── Loader ───────────────────────────────────────────────────────────────── */
.loader-progress-wrap {
  position: absolute; bottom: 18%; left: 50%; transform: translateX(-50%);
  width: 75%; display: flex; flex-direction: column; align-items: center; gap: 10px;
  z-index: 10; image-rendering: pixelated;
}
.loader-pct {
  font-family: var(--font-pixel); font-size: 0.6rem; color: var(--accent-green);
  text-shadow: 0 0 8px var(--accent-green), 0 0 20px var(--accent-green);
  letter-spacing: 3px;
  animation: loader-blink 0.35s step-end infinite;
}
@keyframes loader-blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0; }
}

/* double-line arcade frame */
.loader-bar-track {
  display: flex; gap: 2px;
  padding: 5px;
  background: #050505;
  /* inner frame */
  border: 2px solid #eee;
  /* outer frame via outline */
  outline: 2px solid #000;
  outline-offset: 3px;
  box-shadow:
    0 0 0 5px #000,          /* black gap between outlines */
    0 0 0 7px #888,          /* outer dim ring */
    8px 8px 0 #000,          /* chunky pixel drop-shadow */
    inset 2px 2px 0 #aaa,    /* top-left bevel */
    inset -2px -2px 0 #333;  /* bottom-right bevel */
}

/* empty cell — dark slot with subtle grid lines */
.loader-cell {
  width: 16px; height: 26px;
  background:
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 12px,
      rgba(255,255,255,0.03) 12px,
      rgba(255,255,255,0.03) 13px
    ),
    #0c0c0c;
  box-shadow:
    inset 1px 1px 0 #1e1e1e,
    inset -1px -1px 0 #050505;
}

/* filled cell — green with distinct pixel lighting */
.loader-cell.filled {
  background: linear-gradient(
    to bottom,
    #aaffd0 0px, #aaffd0 3px,   /* bright top highlight strip */
    #00ff88 3px, #00cc66 80%,   /* main green */
    #007a3d 100%                 /* dark bottom edge */
  );
  box-shadow:
    inset 1px 0 0 rgba(255,255,255,0.25),  /* left edge shine */
    inset 0 -2px 0 rgba(0,0,0,0.5);        /* bottom shadow */
  animation: cell-pop 0.12s steps(2) forwards;
}

@keyframes cell-pop {
  0%   { filter: brightness(2.5); }
  100% { filter: brightness(1); }
}

/* ── Race Screen ──────────────────────────────────────────────────────────── */
.race-screen {
  position: relative; overflow: hidden;
  width: 100%; height: 100%;
  background: #1d1d2e;
}

/* Canvas fills the screen — all game-world layers drawn here by JS */
.race-canvas {
  position: absolute; inset: 0;
  display: block; width: 100%; height: 100%;
}

/* Traffic light DOM overlay */
.race-light {
  position: absolute;
  top: 28%; left: 50%; transform: translateX(-50%);
  height: 110px;
  image-rendering: pixelated;
  z-index: 10;
  transition: opacity 0.25s;
}

/* Race result card */
.race-result-overlay {
  position: absolute; inset: 0; z-index: 20;
  display: flex; align-items: flex-end;
}
.race-result-card {
  width: 100%; min-height: 52%;
  background: url("../images/xony_bg.png") top center / 100% auto no-repeat, #2a2a3e;
  border-radius: 12px 12px 0 0;
  padding: 32px 24px 24px;
  animation: slide-up 0.3s ease-out forwards;
  display: flex; flex-direction: column; align-items: center; gap: 20px;
}
.race-result-title {
  font-family: var(--font-pixel); font-size: 1.3rem;
  color: var(--accent-yellow);
  text-shadow: 0 0 16px var(--accent-yellow);
  letter-spacing: 4px;
}
.race-result-stats {
  width: 100%; display: flex; flex-direction: column; gap: 12px;
}
.race-result-row {
  display: flex; justify-content: space-between; align-items: center;
  font-family: var(--font-pixel); font-size: 0.85rem; color: #ccc;
  border-bottom: 1px solid rgba(255,255,255,0.1); padding-bottom: 8px;
}
.race-result-val {
  color: var(--accent-green);
  text-shadow: 0 0 8px var(--accent-green);
}

/* ── Error ────────────────────────────────────────────────────────────────── */
.error-screen {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; gap: 12px; padding: 24px; text-align: center;
  color: var(--accent-red); font-size: 0.9rem;
}

/* ── Tasks popup ─────────────────────────────────────────────────────────── */
.tasks-overlay {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: flex-end;
  background: rgba(0,0,0,0.55);
}
.tasks-sheet {
  width: 100%; height: 80vh;
  border-radius: 12px 12px 0 0; overflow: hidden;
  animation: slide-up 0.25s ease-out forwards;
}
.tasks-sheet.closing {
  animation: slide-down 0.22s ease-in forwards;
}
.tasks-sheet-bg {
  background: url("images/xony_bg.png") top center / 100% auto no-repeat, #1a1a2e;
  height: 100%;
  padding: 20px 12px 16px;
  display: flex; flex-direction: column; gap: 0;
  box-sizing: border-box;
}
.tasks-header-img {
  width: 100%; display: block;
  margin-bottom: 12px;
  border-radius: 6px;
}
/* tasks tabs — see shared .ui-tab / .tasks-tab alias in the Tabs section above */
.tasks-reset-hint { font-size: 11px; color: #888; text-align: center; margin: 0 0 6px; }
.tasks-content { overflow-y: auto; flex: 1; padding: 0 8px; }
.task-row { display: flex; justify-content: space-between; align-items: center; padding: 10px 4px; border-bottom: 1px solid #222; }
.task-info { display: flex; flex-direction: column; gap: 2px; flex: 1; }
.task-label { font-size: 13px; color: #e0e0e0; }
.task-reward { font-size: 11px; color: #4caf50; font-weight: bold; }
.task-action { min-width: 72px; text-align: right; }
.task-claim-btn { background: #4caf50; color: #000; border: none; border-radius: 6px; padding: 6px 12px; font-size: 12px; font-weight: bold; cursor: pointer; font-family: inherit; }
.task-claim-btn:disabled { opacity: 0.5; cursor: not-allowed; }
.task-done { color: #4caf50; font-size: 16px; font-weight: bold; }
.task-locked { color: #444; font-size: 14px; }

