:root {
  --bg: #1b3a4a;
  --bg-deep: #122830;
  --surface: #234858;
  --surface-2: #2d5a6c;
  --ink: #f4fafc;
  --muted: #9eb8c4;
  --primary: #3ec4d8;
  --primary-bright: #6ad8e8;
  --accent: #ffc44d;
  --coral: #ff6b5a;
  --danger: #ef4d3d;
  --ok: #5dce8a;
  --track: #525c72;
  --track-glow: #8a9bb8;
  --slot: #1a2e38;
  --shadow: rgba(8, 16, 24, 0.5);
  --radius: 20px;
  --font-display: "Trebuchet MS", "Segoe UI", system-ui, sans-serif;
  --font-ui: "Segoe UI", system-ui, sans-serif;
  --sticky-right: 0px;
  --dock-side: 0px;
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-t: env(safe-area-inset-top, 0px);
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: var(--bg-deep);
  color: var(--ink);
  font-family: var(--font-ui);
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  touch-action: none;
}

#app {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 480px;
  margin: 0 auto;
  background:
    radial-gradient(ellipse 90% 50% at 50% -5%, rgba(80, 170, 200, 0.35), transparent 55%),
    radial-gradient(ellipse 70% 40% at 100% 100%, rgba(255, 120, 80, 0.12), transparent),
    var(--bg);
  overflow: hidden;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 1;
}

#ui-root {
  position: absolute;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  padding-right: var(--sticky-right);
  box-sizing: border-box;
}

#screen-menu,
#screen-boot {
  left: 0;
  right: 0;
  width: 100%;
  margin: 0 auto;
  box-sizing: border-box;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  pointer-events: auto;
}

.screen.overlay { background: transparent; pointer-events: none; }
.screen.overlay > * { pointer-events: auto; }
.screen.overlay .hud-chrome-top,
.screen.overlay .hud-chrome-bottom { pointer-events: auto; }
.hidden { display: none !important; }
[hidden] { display: none !important; }

html.file-protocol #app { display: none !important; }

.file-protocol-panel {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: #0f1a2e;
  color: #eef6ff;
  font-family: Nunito, Segoe UI, sans-serif;
}
.file-protocol-panel h1 {
  font-family: Fredoka, Nunito, sans-serif;
  margin: 0 0 8px;
}
.file-protocol-panel pre {
  background: rgba(0,0,0,0.35);
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.95rem;
}
.file-protocol-panel a { color: #7ee8ff; }

.boot-hint {
  margin: 14px 0 0;
  max-width: 280px;
  font-size: 0.78rem;
  line-height: 1.35;
  color: var(--muted);
  text-align: center;
}

/* Boot */
#screen-boot {
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: var(--bg-deep);
  z-index: 20;
}

.boot-capy {
  animation: bob 1.2s ease-in-out infinite;
}
.boot-capy img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  filter: drop-shadow(0 8px 16px rgba(0,0,0,0.4));
  border-radius: 18px;
}

.boot-brand {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: clamp(1.8rem, 8vw, 2.4rem);
  letter-spacing: -0.03em;
  color: var(--ink);
}

.boot-sub {
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.1rem;
  letter-spacing: 0.35em;
  color: var(--primary-bright);
}

.boot-bar {
  width: min(220px, 60vw);
  height: 8px;
  margin-top: 20px;
  border-radius: 99px;
  background: var(--surface);
  overflow: hidden;
}

#boot-fill {
  height: 100%;
  width: 8%;
  border-radius: 99px;
  background: linear-gradient(90deg, var(--primary), var(--accent));
  transition: width 0.25s ease-out;
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-10px); }
}

/* Menu — clean readable stack */
#screen-menu {
  padding: calc(12px + var(--safe-t)) 20px calc(18px + var(--safe-b));
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(ellipse 90% 55% at 50% -10%, rgba(45, 110, 125, 0.55), transparent 60%),
    radial-gradient(ellipse 70% 40% at 80% 100%, rgba(120, 70, 55, 0.25), transparent),
    var(--bg);
}

.menu-bg { position: absolute; inset: 0; pointer-events: none; z-index: 0; }
.menu-blob { position: absolute; border-radius: 50%; filter: blur(48px); opacity: 0.4; }
.menu-blob.b1 { width: 220px; height: 220px; background: #4a9aaa; top: -50px; left: -70px; }
.menu-blob.b2 { width: 180px; height: 180px; background: #a86850; bottom: 30px; right: -60px; }

.menu-top { display: flex; justify-content: space-between; align-items: center; position: relative; z-index: 2; }

.icon-btn {
  width: 44px; height: 44px; border: none; border-radius: 14px;
  background: linear-gradient(180deg, var(--surface-2), var(--surface));
  color: var(--ink); font-size: 1.15rem; cursor: pointer; box-shadow: 0 4px 0 var(--shadow);
}
.icon-btn:active { transform: translateY(2px); box-shadow: 0 2px 0 var(--shadow); }

.coins-badge {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 8px 14px 8px 10px; border-radius: 99px;
  background: linear-gradient(180deg, #8a7550, #655840);
  font-weight: 800; font-size: 1.05rem; box-shadow: 0 4px 0 #453c28;
  border: 2px solid rgba(210, 180, 80, 0.35); color: inherit; font: inherit; cursor: pointer;
}
.coins-badge.compact { padding: 6px 12px 6px 8px; font-size: 0.95rem; }
.coin-icon {
  width: 22px; height: 22px; border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #f5f0d0, var(--accent));
  box-shadow: inset 0 -2px 0 #a89050, 0 2px 0 #756840;
}
.plus-chip {
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 50%; background: var(--coral);
  color: #fff; font-weight: 900; font-size: 0.85rem;
}

.menu-main {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
  min-height: 0;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
}

.menu-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  width: 100%;
  max-width: 360px;
  margin: 0 auto;
  position: relative;
  z-index: 2;
}
.menu-mascot {
  width: min(132px, 34vw); height: auto;
  filter: drop-shadow(0 10px 18px rgba(0,0,0,0.45));
  animation: bob 2.4s ease-in-out infinite;
}
.streak-chip {
  margin: 2px 0 0; padding: 4px 12px; border-radius: 99px;
  background: rgba(245, 208, 80, 0.15); color: var(--accent);
  font-weight: 800; font-size: 0.78rem; border: 1px solid rgba(245, 208, 80, 0.35);
}
.btn-daily {
  background: linear-gradient(180deg, #9a5088, #804878);
  color: #fff; box-shadow: 0 5px 0 #503050;
  display: flex; justify-content: space-between; align-items: center;
}
.btn-daily.daily-ready {
  animation: dailyPulse 1.8s ease-in-out infinite;
}
@keyframes dailyPulse {
  0%, 100% { box-shadow: 0 5px 0 #503050, 0 0 0 0 rgba(245, 208, 80, 0.35); }
  50% { box-shadow: 0 5px 0 #503050, 0 0 0 6px rgba(245, 208, 80, 0); }
}
.daily-tag {
  background: var(--accent); color: #3a3220; padding: 2px 10px;
  border-radius: 99px; font-size: 0.75rem; font-weight: 900; white-space: nowrap;
}
.trail-row {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; margin-bottom: 6px;
}
.shop-section-label {
  margin: 8px 0 4px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  align-self: flex-start;
}
.shop-section-label {
  margin: 8px 0 4px;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
  align-self: flex-start;
}
.shop-hint {
  margin: 0 0 8px; font-size: 0.75rem; color: var(--muted); font-weight: 700;
}
#screen-shop {
  align-items: center;
  justify-content: center;
  background: rgba(15, 18, 35, 0.72);
  backdrop-filter: blur(6px);
  padding: 16px;
  z-index: 15;
  overflow-y: auto;
}
.panel-shop {
  width: min(400px, 100%);
  max-height: min(92vh, 720px);
  overflow-y: auto;
}
.shop-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  margin: 4px 0 8px;
}
.shop-item {
  appearance: none;
  border: 2px solid rgba(255,255,255,0.1);
  background: linear-gradient(165deg, #2a4a58, #1a303c);
  color: var(--ink);
  border-radius: 18px;
  padding: 10px 12px;
  display: grid;
  grid-template-columns: 64px 1fr auto;
  align-items: center;
  gap: 12px;
  cursor: pointer;
  text-align: left;
  box-shadow: 0 4px 0 #0d2430;
  transition: transform 0.08s ease-out;
  font-family: var(--font-ui);
}
.shop-item:active { transform: translateY(2px); box-shadow: 0 2px 0 #0d2430; }
.shop-icon-wrap {
  position: relative;
  width: 56px; height: 56px;
  border-radius: 14px;
  overflow: hidden;
  background: transparent;
  flex-shrink: 0;
  box-shadow: 0 2px 0 rgba(0,0,0,0.25);
}
.shop-icon {
  width: 56px; height: 56px;
  object-fit: fill;
  display: block;
}
.shop-badge {
  position: absolute;
  right: 2px; bottom: 2px;
  z-index: 1;
  background: var(--accent);
  color: #3a3220;
  font-size: 0.65rem;
  font-weight: 900;
  padding: 1px 5px;
  border-radius: 99px;
  box-shadow: 0 1px 0 #908050;
}
.shop-copy {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
.shop-title {
  font-weight: 900;
  font-size: 0.98rem;
  line-height: 1.2;
}
.shop-desc {
  font-size: 0.78rem;
  color: var(--muted);
  font-weight: 700;
  line-height: 1.25;
}
.shop-price {
  font-weight: 900;
  font-size: 0.95rem;
  color: var(--accent);
  background: rgba(245, 208, 80, 0.14);
  border: 1px solid rgba(245, 208, 80, 0.35);
  border-radius: 12px;
  padding: 8px 10px;
  white-space: nowrap;
}
.trail-chip {
  appearance: none; border: 2px solid rgba(255,255,255,0.12);
  background: var(--surface-2); color: var(--ink); border-radius: 14px;
  padding: 8px 10px; display: flex; flex-direction: column; align-items: center;
  gap: 4px; font-weight: 800; font-size: 0.72rem; cursor: pointer; min-width: 68px;
}
.trail-chip.equipped { border-color: var(--accent); }
.trail-chip small { color: var(--muted); font-weight: 700; }
.trail-swatch {
  width: 36px; height: 10px; border-radius: 99px;
  background: linear-gradient(90deg, transparent, #ccc);
}
.trail-swatch[data-trail="none"] { background: rgba(255,255,255,0.15); }
.trail-swatch[data-trail="spark"] { background: linear-gradient(90deg, transparent, #ffe066, #fff); }
.trail-swatch[data-trail="aqua"] { background: linear-gradient(90deg, transparent, #7ec8e8, #dff6ff); }
.trail-swatch[data-trail="sunset"] { background: linear-gradient(90deg, transparent, #ff9a6a, #e85880); }
.trail-swatch[data-trail="rainbow"] { background: linear-gradient(90deg, #ff6b6b, #f5d050, #90d890, #7ec8e8, #c090e0); }

.tips-overlay {
  position: absolute; inset: 0; z-index: 12;
  display: flex; align-items: flex-end; justify-content: center;
  padding: 16px 16px 38%; pointer-events: auto;
  background: rgba(10, 16, 28, 0.35);
}
.tips-overlay.hidden { display: none !important; }
.tip-card {
  width: min(340px, 100%);
  background: var(--surface);
  border-radius: 18px;
  padding: 16px 16px 14px;
  box-shadow: 0 12px 28px rgba(0,0,0,0.4);
  display: flex; flex-direction: column; gap: 12px; text-align: center;
}
.tip-card p {
  margin: 0;
  font-weight: 700;
  line-height: 1.35;
  color: var(--ink);
  font-size: clamp(0.88rem, 3.2vw, 1rem);
}
.how-list {
  text-align: left;
  padding-left: 1.2em;
  color: var(--muted);
  font-size: clamp(0.8rem, 2.7vw, 0.95rem);
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.brand-eyebrow {
  font-size: clamp(0.58rem, 2.2vw, 0.7rem);
  letter-spacing: 0.08em;
  color: var(--accent);
  font-weight: 800;
  margin: 0;
  text-align: center;
  max-width: 96%;
}
.brand {
  font-family: var(--font-display); font-weight: 700;
  font-size: clamp(1.9rem, 8vw, 2.6rem); letter-spacing: -0.02em; line-height: 1.1; margin: 0;
}
.brand-rush {
  font-family: var(--font-display); font-weight: 700; font-size: 1.1rem;
  letter-spacing: 0.16em; color: var(--coral); margin: 0;
}
.tagline {
  color: var(--muted);
  font-size: clamp(0.82rem, 2.8vw, 0.95rem);
  max-width: min(290px, 92%);
  line-height: 1.35;
  margin: 0;
  text-wrap: balance;
}
.btn-challenge > span:first-child {
  flex: 1;
  text-align: left;
  padding-right: 8px;
  font-size: clamp(0.82rem, 3vw, 1.05rem);
  line-height: 1.15;
}
.pass-chip {
  margin: 0;
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--accent);
  text-align: center;
  line-height: 1.3;
  padding: 0 6px;
}
.level-chip {
  margin: 4px 0 0; padding: 6px 16px; border-radius: 99px; background: var(--surface-2);
  font-weight: 800; font-size: 0.9rem; border: 2px solid rgba(70, 130, 145, 0.35);
}
.menu-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.btn-play {
  position: relative; overflow: hidden; font-size: 1.25rem !important; padding: 16px 20px !important;
  background: linear-gradient(180deg, #f5d050, #e8a030) !important;
  color: #453820 !important;
  box-shadow: 0 6px 0 #a87830, 0 12px 24px rgba(160, 120, 48, 0.35) !important;
}
.btn-play .btn-shine {
  position: absolute; inset: 0;
  background: linear-gradient(105deg, transparent 40%, rgba(255,255,255,0.4) 50%, transparent 60%);
  transform: translateX(-120%); animation: shine 2.8s ease-in-out infinite;
}
@keyframes shine { 0%, 55% { transform: translateX(-120%); } 75%, 100% { transform: translateX(120%); } }

.btn-challenge {
  background: linear-gradient(180deg, #c06050, #a04840);
  color: #fff; box-shadow: 0 5px 0 #603028;
  display: flex; justify-content: space-between; align-items: center;
  gap: 8px;
}
.btn-challenge.challenge-done {
  background: linear-gradient(180deg, #4a7a58, #3a6048);
  box-shadow: 0 5px 0 #2a4030;
}
.challenge-tag {
  background: rgba(0,0,0,0.25); padding: 2px 10px; border-radius: 99px;
  font-size: 0.75rem; font-weight: 900;
}
.btn-chest {
  background: linear-gradient(180deg, #c9a050, #a87830);
  color: #3a3220; box-shadow: 0 5px 0 #6a5020; font-size: 1rem !important;
}
.btn-chest.chest-ready {
  animation: dailyPulse 1.8s ease-in-out infinite;
}
.toast {
  position: absolute; left: 50%; bottom: calc(18% + var(--safe-b));
  transform: translateX(-50%);
  z-index: 40; max-width: min(320px, 90vw);
  padding: 12px 18px; border-radius: 14px;
  background: rgba(20, 28, 40, 0.94); color: #fff;
  font-weight: 800; font-size: 0.95rem; text-align: center;
  box-shadow: 0 8px 24px rgba(0,0,0,0.4);
  pointer-events: none;
}
.toast.hidden { display: none !important; }

.btn {
  appearance: none;
  border: none;
  border-radius: 18px;
  padding: 16px 20px;
  font-family: var(--font-ui);
  font-weight: 800;
  font-size: 1.15rem;
  line-height: 1.2;
  white-space: normal;
  cursor: pointer;
  transition: transform 0.08s ease-out, box-shadow 0.08s ease-out;
}

.btn:active { transform: translateY(3px); }

.btn-primary {
  background: linear-gradient(180deg, var(--primary-bright), var(--primary));
  color: white;
  box-shadow: 0 6px 0 #4060a0, 0 10px 24px rgba(64, 96, 160, 0.35);
}

.btn-primary:active { box-shadow: 0 3px 0 #4060a0; }

.btn-secondary {
  background: var(--surface-2);
  color: var(--ink);
  box-shadow: 0 5px 0 var(--shadow);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  box-shadow: none;
}

/* Panels */
#screen-how, #screen-pause, #screen-win, #screen-lose {
  align-items: center;
  justify-content: center;
  background: rgba(15, 18, 35, 0.72);
  backdrop-filter: blur(6px);
  padding: 24px;
  z-index: 15;
}

.panel {
  width: min(360px, 100%);
  background: var(--surface);
  border-radius: 24px;
  padding: 28px 22px;
  text-align: center;
  box-shadow: 0 16px 40px var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel h2 {
  font-family: var(--font-display);
  font-size: 1.7rem;
  letter-spacing: -0.02em;
}

.how-list b { color: var(--ink); }

.over-sub { color: var(--muted); }
.over-coins {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--accent);
}
.over-actions { display: flex; flex-direction: column; gap: 8px; margin-top: 8px; }

.panel-win { border: 2px solid rgba(100, 210, 140, 0.5); }
.panel-lose { border: 2px solid rgba(220, 80, 60, 0.45); }
.win-burst { font-size: 2.4rem; animation: bob 1s ease-in-out infinite; }

/* HUD */
#screen-hud {
  padding: calc(8px + var(--safe-t)) 10px calc(8px + var(--safe-b));
  justify-content: space-between;
  pointer-events: none;
}

.hud-chrome-top {
  flex-shrink: 0;
  pointer-events: auto;
}

.hud-chrome-bottom {
  flex-shrink: 0;
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  pointer-events: auto;
  background: #122830;
  border-top: 1px solid rgba(255,255,255,0.1);
  box-shadow: 0 -8px 24px rgba(0,0,0,0.35);
  padding: 8px 10px calc(10px + var(--safe-b));
  width: 100%;
  box-sizing: border-box;
  z-index: 5;
  overflow: visible;
}

/* Short Yandex iframe / landscape phone: keep dock fully on-screen */
@media (max-height: 700px) {
  .hud-chrome-bottom {
    gap: 4px;
    padding: 6px 8px calc(8px + var(--safe-b));
  }
  .lane-unit.front {
    width: 48px;
    height: 48px;
  }
  .deck-slot {
    width: 36px;
    height: 36px;
  }
  .boost-btn {
    width: 46px;
    height: 46px;
  }
  .queue-front {
    padding: 4px 2px 0;
  }
}

.boost-btn {
  width: 54px;
  height: 54px;
  border-radius: 16px;
  border: none;
  background: linear-gradient(180deg, #2a5a6c, #1e4452);
  color: white;
  cursor: pointer;
  position: relative;
  box-shadow: 0 4px 0 #0d2430;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 6px;
  overflow: visible;
}

.boost-btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #0d2430; }

.boost-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.35));
}

.boost-ico {
  font-size: 1.25rem;
  font-weight: 900;
  line-height: 1;
}

.queue-front {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 10px;
  width: 100%;
  flex-wrap: nowrap;
  overflow-x: auto;
  padding: 8px 4px 2px;
  -webkit-overflow-scrolling: touch;
}

.lane-col {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.lane-peek {
  display: flex;
  gap: 3px;
  min-height: 8px;
}

.lane-peek-chip {
  width: 14px;
  height: 8px;
  border-radius: 4px;
  box-shadow: 0 1px 0 rgba(0,0,0,0.35);
  opacity: 0.9;
}

.lane-unit.front {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  z-index: 2;
}

.lane-unit.wait {
  width: 36px;
  height: 36px;
  border-radius: 10px;
}

.deck-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.deck-slots {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.deck-slot {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  background: var(--slot);
  border: 2px dashed rgba(255,255,255,0.22);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 0;
  cursor: pointer;
}

.deck-slot.filled {
  border-style: solid;
  border-color: var(--primary);
  background: var(--surface-2);
}

.deck-label {
  font-weight: 800;
  font-size: 0.72rem;
  color: var(--muted);
  letter-spacing: 0.04em;
}

.hud-chrome-bottom .boosters {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.queue-empty {
  margin: 0;
  font-size: 0.78rem;
  color: var(--muted);
  padding: 8px;
}

.hud-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.level-pill {
  padding: 8px 18px;
  border-radius: 99px;
  background: linear-gradient(180deg, var(--primary-bright), var(--primary));
  font-weight: 800;
  font-size: 0.95rem;
  box-shadow: 0 4px 0 #4060a0;
}

.color-stats {
  display: flex;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
  min-height: 28px;
  pointer-events: none;
}

.color-stat {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 99px;
  background: rgba(30, 35, 55, 0.75);
  font-weight: 800;
  font-size: 0.8rem;
  border: 2px solid transparent;
}

.color-stat .swatch {
  width: 12px;
  height: 12px;
  border-radius: 3px;
  border: 1px solid rgba(40, 35, 30, 0.5);
}

.deck-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  pointer-events: auto;
  flex-shrink: 0;
}

.deck-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 196, 80, 0.15);
}

.deck-entry-mark {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0;
  line-height: 1;
  color: #ffc44d;
  font-weight: 800;
  font-size: 0.68rem;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.deck-entry-arrow {
  font-size: 1.35rem;
  animation: deck-bounce 1.1s ease-in-out infinite;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,0.4));
}

@keyframes deck-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(4px); }
}

.deck-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}

.queue-section {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.queue-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding: 0 4px;
}

.queue-title {
  font-weight: 800;
  font-size: 0.78rem;
  color: var(--ink);
}

.queue-sub {
  font-size: 0.62rem;
  color: var(--muted);
  text-align: right;
}

.queue-board {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 108px;
  padding: 2px 0;
}

.queue-wait-row,
.queue-front-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  flex-wrap: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.queue-wait-row {
  min-height: 38px;
  opacity: 0.92;
}

.queue-front-row {
  min-height: 62px;
}

.queue-lane-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.queue-lane-arrow {
  font-size: 0.65rem;
  color: var(--accent);
  font-weight: 900;
  line-height: 1;
}

.queue-empty {
  margin: 0;
  font-size: 0.75rem;
  color: var(--muted);
  text-align: center;
  width: 100%;
  padding: 12px 0;
}

.queue-lane {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  flex-shrink: 0;
}

.queue-arrow {
  color: var(--accent);
  font-size: 0.72rem;
  font-weight: 900;
  line-height: 1;
  opacity: 0.9;
  text-shadow: 0 1px 0 rgba(0,0,0,0.5);
}

.queue-zig {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  width: 22px;
  margin-bottom: 22px;
  flex-shrink: 0;
  opacity: 0.75;
}

.queue-zig .zig-line {
  display: block;
  width: 2px;
  height: 18px;
  background: linear-gradient(var(--accent), transparent);
  border-radius: 2px;
}

.queue-zig .zig-icon {
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 900;
}

.queue-to-deck {
  display: none;
}

.color-badge {
  position: absolute;
  top: 3px;
  left: 3px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 1.5px solid rgba(255,255,255,0.85);
  box-shadow: 0 1px 2px rgba(0,0,0,0.45);
  pointer-events: none;
}

.lane-tag {
  position: absolute;
  top: -7px;
  right: -4px;
  background: var(--accent);
  color: #2a1808;
  font-size: 0.55rem;
  font-weight: 900;
  padding: 2px 5px;
  border-radius: 6px;
  line-height: 1;
  z-index: 3;
  box-shadow: 0 2px 0 rgba(0,0,0,0.35);
}

.lane-unit.deploy-ready {
  animation: ready-pulse 1.6s ease-in-out infinite;
}

@keyframes ready-pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.12); }
}

.hud-chrome-bottom .boosters {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 4px 0 2px;
  flex-shrink: 0;
}

.deck-label {
  font-weight: 800;
  font-size: 0.75rem;
  color: var(--muted);
}

.deck-slots {
  display: flex;
  gap: 6px;
  justify-content: center;
}

.deck-slot {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--slot);
  border: 2px dashed #4a6270;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
  padding: 0;
  cursor: pointer;
}

.deck-slot.filled {
  border-style: solid;
  border-color: rgba(70, 130, 145, 0.85);
  background: var(--surface-2);
}

.deck-slot.danger {
  border-color: var(--danger);
  animation: shake 0.4s ease;
}

.unit-spr {
  width: 92%;
  height: 92%;
  object-fit: contain;
  object-position: center 40%;
  pointer-events: none;
}

.queue-front {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}

.dock-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: 48px;
  padding: 0 4px;
}

.queue-wait {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  flex: 1;
  min-width: 0;
}

.lane-unit {
  border: none;
  border-radius: 12px;
  cursor: pointer;
  position: relative;
  box-shadow: 0 3px 0 var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  overflow: visible;
}

.lane-unit.front {
  width: 56px;
  height: 56px;
  border-radius: 14px;
  z-index: 2;
}

.lane-unit.wait {
  width: 36px;
  height: 36px;
  opacity: 0.88;
  box-shadow: 0 2px 0 var(--shadow);
}

.lane-unit.hand-pick:not(:disabled) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lane-unit:active:not(:disabled) {
  transform: translateY(2px);
  box-shadow: 0 1px 0 var(--shadow);
}

.lane-unit:disabled {
  cursor: default;
}

.queue-ammo {
  position: absolute;
  bottom: 2px;
  right: 3px;
  font-weight: 900;
  font-size: 0.65rem;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.75);
  pointer-events: none;
}

.boosters {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  pointer-events: auto;
  flex-shrink: 0;
}

.deck-label {
  align-self: flex-start;
  margin-left: 8%;
  font-weight: 800;
  font-size: 0.85rem;
  color: var(--muted);
}

.deck-slots {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.deck-slot {
  width: 48px;
  height: 48px;
  border-radius: 12px;
  background: var(--slot);
  border: 2px dashed #505868;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}

.deck-slot.filled {
  border-style: solid;
  border-color: #6078a8;
  background: var(--surface-2);
}

.deck-slot.danger {
  border-color: var(--danger);
  animation: shake 0.4s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-3px); }
  75% { transform: translateX(3px); }
}

.queue-wrap {
  margin-top: 6px;
  pointer-events: auto;
  max-height: 130px;
  overflow: visible;
}

.queue-grid,
.lanes-row {
  display: flex;
  justify-content: center;
  align-items: flex-end;
  gap: 10px;
  max-width: 360px;
  margin: 0 auto;
  min-height: 70px;
}

.lane {
  display: flex;
  flex-direction: column-reverse;
  gap: 3px;
  align-items: center;
  width: 62px;
}

.lane-unit {
  width: 56px;
  height: 56px;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  position: relative;
  box-shadow: 0 4px 0 var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  flex-shrink: 0;
  overflow: visible;
}

.lane-unit canvas {
  object-fit: contain;
}

.lane-unit.back {
  width: 48px;
  height: 48px;
  opacity: 0.72;
  transform: scale(0.92);
}

.lane-unit.front {
  z-index: 2;
}

.lane-unit.hand-pick:not(:disabled) {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.lane-unit:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--shadow);
}

.lane-unit:disabled {
  cursor: default;
}

.queue-item {
  aspect-ratio: 1;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  position: relative;
  background: var(--surface);
  box-shadow: 0 4px 0 var(--shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.08s ease-out;
  padding: 0;
}

.queue-item:active:not(:disabled) {
  transform: translateY(3px);
  box-shadow: 0 1px 0 var(--shadow);
}

.queue-item:disabled {
  opacity: 0.35;
  cursor: default;
}

.queue-item.hint {
  outline: 3px solid var(--accent);
  outline-offset: 2px;
  animation: hint-pulse 0.8s ease-in-out infinite;
}

@keyframes hint-pulse {
  50% { outline-color: #f0e060; }
}

.queue-ammo {
  position: absolute;
  bottom: 3px;
  right: 5px;
  font-weight: 900;
  font-size: 0.72rem;
  color: white;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.7);
}

.boosters {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 4px;
  padding-bottom: 2px;
  pointer-events: auto;
  flex-shrink: 0;
}

.boost-cost {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 20px;
  height: 20px;
  padding: 0 4px;
  border-radius: 99px;
  background: var(--accent);
  color: #3a3220;
  font-size: 0.7rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 0 #908050;
  z-index: 2;
}

body.hand-mode .lane-unit:not(:disabled) {
  box-shadow: 0 0 0 2px var(--accent), 0 4px 0 var(--shadow);
}

#ad-overlay {
  position: absolute;
  inset: 0;
  z-index: 50;
  background: rgba(15, 18, 35, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: auto;
}

.ad-spinner {
  width: 42px;
  height: 42px;
  border: 4px solid var(--surface-2);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

@media (prefers-reduced-motion: reduce) {
  .boot-capy, .hero-capy-img, .hero-ring, .menu-blob, .menu-spark,
  .hero-art .px, .btn-play .btn-shine, .win-burst, .queue-item.hint,
  .menu-mascot, .btn-daily.daily-ready {
    animation: none !important;
  }
}

/* —— Desktop / landscape: playfield left, dock right —— */
body.layout-wide #app {
  max-width: min(1180px, 100%);
}

body.layout-wide #screen-hud {
  padding: calc(8px + var(--safe-t)) 0 calc(8px + var(--safe-b));
  display: block;
}

body.layout-wide .hud-chrome-top {
  position: absolute;
  top: 0;
  left: 0;
  right: var(--dock-side);
  z-index: 6;
  padding: calc(8px + var(--safe-t)) 12px 0;
}

body.layout-wide .hud-chrome-bottom {
  position: absolute;
  top: 0;
  right: 0;
  bottom: 0;
  width: var(--dock-side);
  margin-top: 0;
  border-top: none;
  border-left: 1px solid rgba(255,255,255,0.1);
  box-shadow: -10px 0 28px rgba(0,0,0,0.35);
  padding: calc(56px + var(--safe-t)) 12px calc(12px + var(--safe-b));
  justify-content: flex-start;
  align-items: stretch;
  gap: 12px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.layout-wide .queue-front {
  flex-direction: column;
  align-items: stretch;
  justify-content: flex-start;
  overflow-x: hidden;
  overflow-y: auto;
  max-height: none;
  flex: 1 1 auto;
  gap: 8px;
  padding: 4px 0;
}

body.layout-wide .lane-col {
  flex-direction: row;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
  width: 100%;
}

body.layout-wide .lane-peek {
  flex-direction: column;
  min-width: 10px;
}

body.layout-wide .lane-unit.front {
  width: 58px;
  height: 58px;
}

body.layout-wide .deck-bar {
  width: 100%;
  align-items: stretch;
}

body.layout-wide .deck-slots {
  flex-wrap: wrap;
  justify-content: flex-start;
}

body.layout-wide .hud-chrome-bottom .boosters {
  flex-wrap: wrap;
  justify-content: flex-start;
  gap: 8px;
}

body.layout-wide .tips-overlay {
  right: var(--dock-side);
  padding: 16px 16px 20%;
  align-items: center;
}

body.layout-wide .toast {
  left: calc((100% - var(--dock-side)) / 2);
}

/* Wide menu breathes a bit on desktop */
body.layout-wide #screen-menu .menu-main,
body.layout-wide #screen-menu .menu-actions {
  max-width: 420px;
}
