:root {
  /* Isekai Gacha light-purple + yellow */
  --bg0: #0f0a1f;
  --bg1: #241a4a;
  --bg2: #3a2c7a;
  --glass: rgba(255,255,255,0.08);
  --glass-strong: rgba(255,255,255,0.14);
  --border: rgba(220,200,255,0.28);
  --primary: #c8a7ff;    /* light purple */
  --primary-strong: #b68cff;
  --secondary: #8aa7ff;  /* soft blue accent */
  --accent: #ffd561;     /* gacha yellow */
  --danger: #ff6b6b;
  --text: #f3eeff;
}

html, body { height: 100%; }
* { box-sizing: border-box; }
body {
  margin: 0; color: var(--text);
  background:
    radial-gradient(1200px 800px at 50% 10%, var(--bg2), var(--bg0)),
    linear-gradient(180deg, var(--bg1), var(--bg0));
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  overscroll-behavior: none;
}

/* Fullscreen app wrapper */
.app {
  width: 100vw;
  height: 100svh;
  position: relative;
  overflow: hidden;
  display: flex; align-items: center; justify-content: center;
}

/* HUD overlay */
.hud {
  position: absolute;
  top: env(safe-area-inset-top, 10px);
  left: 50%; transform: translateX(-50%);
  width: min(92vw, 440px);
  display: flex; gap: 10px; justify-content: space-between; align-items: center;
  background: var(--glass);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 8px 12px;
  backdrop-filter: blur(8px);
  z-index: 5;
  font-size: 14px;
}
.hearts { display: inline-flex; gap: 4px; align-items: center; }
.heart-img { width: 18px; height: 18px; image-rendering: auto; }

.status { color: var(--danger); font-weight: 800; }
.hud-btn {
  background: linear-gradient(135deg, var(--primary), #e1d3ff);
  border: 1px solid var(--border);
  color: #1e133b;
  font-weight: 900;
  border-radius: 10px;
  padding: 6px 10px;
  cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
}

/* Stage scaling */
.stage-wrap { position: absolute; inset: 0; display: grid; place-items: center; }

/* Game world */
.game-card {
  position: relative; width: 320px; height: 480px;
  border-radius: 18px; overflow: hidden;
  border: 1px solid var(--border);
  background: #120e23;
  box-shadow: 0 20px 50px rgba(0,0,0,0.5);
  touch-action: none; user-select: none;
}

/* Smooth tiling layers for road/clouds */
.scroll-layer {
  position: absolute; inset: 0; overflow: hidden;
  z-index: 0; pointer-events: none;
}
.scroll-layer .tile {
  position: absolute; left: 0; width: 100%; height: 100%;
  background-repeat: repeat-y;
  background-position: center top;
  background-size: 100% auto;
  will-change: transform;
  transform: translate3d(0, 0, 0);
}

/* Images */
.scroll-layer.road  .tile { background-image: url('assets/road.png'); }

/* Clouds become late-game vision blocker */
.scroll-layer.clouds {
  z-index: 3;       /* above truck/targets (z-index 2) */
  opacity: 0;       /* hidden until activated by JS */
  transition: opacity 0.6s ease;
}
.scroll-layer.clouds .tile { background-image: url('assets/clouds.png'); }
.scroll-layer.clouds.active { opacity: 0.9; } /* tweak 0.7–0.9 */

/* Playfield */
#lanes { position: absolute; inset: 0; display: grid; grid-template-columns: repeat(3,1fr); z-index: 1; }

/* Truck & targets */
.truck {
  position: absolute; bottom: 8px; width: calc(100%/3 - 16px); height: 64px; margin: 0 8px;
  display: flex; align-items: flex-end; justify-content: center;
  transition: left .18s ease, filter .18s ease; z-index: 2;
  will-change: transform; transform: translate3d(0, 0, 0);
}
.truck img { height: 64px; pointer-events: none; }
.truck.damaged { filter: brightness(0.7); }

/* Damage blink while 'hit' */
@keyframes hitBlink {
  0%, 50%, 100% { opacity: 1; }
  25%, 75% { opacity: 0.25; }
}
.truck.hit { animation: hitBlink 0.18s linear infinite; }

.target {
  position: absolute; width: calc(100%/3 - 16px); height: 56px; margin: 0 8px;
  display: flex; align-items: center; justify-content: center; z-index: 2;
  will-change: transform; transform: translate3d(0, 0, 0);
}
.target img { height: 56px; pointer-events: none; }
.target img[alt="megavip"] { filter: drop-shadow(0 0 6px #ffd700) drop-shadow(0 0 12px #ffed9a); }

/* Floating point popups (always above everything) */
.popup {
  position: absolute;
  left: 50%; top: 0;           /* we position via transform in JS */
  transform: translate3d(-50%, 0, 0);
  font-weight: 900;
  font-size: 16px;
  pointer-events: none;
  z-index: 4;                  /* above clouds */
  text-shadow: 0 0 8px rgba(255,255,255,0.35);
  opacity: 0;
  animation: floatUp 900ms ease-out forwards;
}
.popup.good { color: var(--primary); }
.popup.bad  { color: var(--danger); }

@keyframes floatUp {
  0%   { opacity: 0; transform: translate3d(-50%, 8px, 0) scale(0.9); }
  10%  { opacity: 1; transform: translate3d(-50%, 0px, 0) scale(1); }
  100% { opacity: 0; transform: translate3d(-50%, -36px, 0) scale(0.95); }
}

/* Modals */
.modal { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; background: linear-gradient(180deg, rgba(0,0,0,0.25), rgba(0,0,0,0.55)); z-index: 10; }
.modal.hidden { display: none; }

.menu-inner, .panel-inner {
  width: min(92vw, 440px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
  backdrop-filter: blur(12px);
  padding: 18px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55), inset 0 1px 0 rgba(255,255,255,0.06);
}

/* MENU */
.menu-header { text-align: center; margin-bottom: 12px; }
.menu-header .brand { font-size: 12px; letter-spacing: .18em; color: #ddd0ff; opacity: .85; }
.menu-header .title { font-size: 22px; font-weight: 900; margin-top: 6px; color: var(--primary); text-shadow: 0 0 10px rgba(200,167,255,.45); }
.menu-header .sponsor { margin-top: 6px; font-size: 12px; color: #ffe891; text-shadow: 0 0 10px rgba(255,216,106,.35); }

.menu-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 10px; }
.menu-btn {
  border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  color: var(--text);
  border-radius: 12px;
  padding: 12px 10px;
  font-size: 14px; font-weight: 800; cursor: pointer;
  box-shadow: 0 6px 16px rgba(0,0,0,0.25);
  transition: transform .08s ease, box-shadow .08s ease, background .2s;
}
.menu-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(0,0,0,0.35); }

.menu-cta { margin-top: 16px; text-align: center; }
.play-btn {
  width: 100%;
  border: 2px solid rgba(255,255,255,0.22);
  border-radius: 14px;
  padding: 14px 16px;
  font-size: 22px; font-weight: 900; letter-spacing: .04em;
  background: linear-gradient(135deg, var(--accent), #ffe6a6 60%);
  color: #24184a; text-shadow: none; cursor: pointer;
  box-shadow: 0 12px 30px rgba(255,213,97,0.35), inset 0 2px 0 rgba(255,255,255,0.6);
}
.play-btn:disabled { opacity: .6; cursor: not-allowed; box-shadow: none; color: #24184a; }
.play-btn:hover { filter: brightness(0.98); }
.play-btn:active { transform: translateY(1px); }

.muted { display: block; margin-top: 6px; font-size: 12px; color: #eae2ff9c; }

.footer-note { margin-top: 10px; text-align: center; opacity: .7; font-size: 12px; }

/* PANELS */
.panel .panel-inner h2 { margin: 0 0 10px 0; color: var(--primary); }
.compact { padding-left: 16px; }
.compact li { margin: 6px 0; }

.primary-btn, .secondary-btn, .ghost-btn {
  border-radius: 10px; padding: 10px 14px; cursor: pointer; border: 1px solid var(--border);
  font-weight: 800; color: var(--text);
}
.primary-btn   { background: linear-gradient(135deg, var(--primary), #efe6ff); color: #1b1238; }
.secondary-btn { background: linear-gradient(135deg, #b7c9ff, var(--secondary)); color: #0d1638; }
.ghost-btn     { background: transparent; }

.panel .row { display: flex; gap: 8px; margin-top: 10px; }

/* Leaderboard table */
/* ===== Menu button variants ===== */
.menu-btn.tutorial {
  /* Subtle purple background + stronger on hover */
  background: linear-gradient(180deg, rgba(155,113,255,0.32), rgba(155,113,255,0.18));
  border-color: rgba(155,113,255,0.45);
  box-shadow: 0 6px 16px rgba(155,113,255,0.25);
}
.menu-btn.tutorial:hover {
  transform: translateY(-1px);
  box-shadow: 0 12px 26px rgba(155,113,255,0.38);
}

/* ===== Leaderboard: glassy card table ===== */
table.lb {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  overflow: hidden;
  border-radius: 12px;
  background: rgba(255,255,255,0.06);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.05), 0 12px 28px rgba(0,0,0,0.35);
}
table.lb thead th {
  background: linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.04));
  color: var(--primary);
  text-shadow: 0 0 8px rgba(200,167,255,0.3);
  border: none;
  padding: 10px 10px;
  font-weight: 900;
  letter-spacing: .02em;
}
table.lb th:first-child { border-top-left-radius: 12px; }
table.lb th:last-child  { border-top-right-radius: 12px; }

table.lb tbody td {
  border-top: 1px solid rgba(220,200,255,0.15);
  padding: 10px 10px;
}

/* Zebra + hover */
table.lb tbody tr:nth-child(odd)  td { background: rgba(255,255,255,0.04); }
table.lb tbody tr:nth-child(even) td { background: rgba(255,255,255,0.02); }
table.lb tbody tr:hover td {
  background: rgba(155,113,255,0.12);
}

/* Alignments */
table.lb td:nth-child(1) { width: 44px; text-align: center; font-weight: 900; color: var(--accent); }
table.lb td:nth-child(3) { text-align: right; font-weight: 800; }
table.lb td:nth-child(4) { text-align: right; opacity: .85; }

/* Top 3 highlight */
table.lb tbody tr:nth-child(1) td { box-shadow: inset 0 0 0 9999px rgba(255,215,128,0.06); }
table.lb tbody tr:nth-child(2) td { box-shadow: inset 0 0 0 9999px rgba(200,167,255,0.05); }
table.lb tbody tr:nth-child(3) td { box-shadow: inset 0 0 0 9999px rgba(138,167,255,0.05); }


/* Toast notification */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--primary);
  color: #1b1238;
  font-weight: 800;
  padding: 10px 16px;
  border-radius: 12px;
  border: 1px solid var(--border);
  box-shadow: 0 6px 16px rgba(0,0,0,0.35);
  z-index: 999;
  opacity: 0;
  transition: opacity 0.3s ease;
}
.toast.show { opacity: 1; }
.toast.hidden { display: none; }

/* Ability splash modal */
.ability-modal .ability-inner{
  width: min(92vw, 520px);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: linear-gradient(180deg, rgba(255,255,255,0.09), rgba(255,255,255,0.04));
  padding: 16px;
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 14px;
  box-shadow: 0 24px 60px rgba(0,0,0,0.55);
}
.ability-modal img{
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.06);
}
.ability-info h3{ margin: 0 0 6px 0; color: var(--primary); }
.ability-info p{ margin: 0 0 10px 0; }

/* Invincibility visual (Special Boost) */
.truck.invincible {
  filter: drop-shadow(0 0 6px #ffe66a) drop-shadow(0 0 14px #fff2a0) saturate(1.4);
  animation: starSpin 0.6s linear infinite;
}
@keyframes starSpin {
  0% { transform: translate3d(0,0,0) rotate(0deg); }
  100% { transform: translate3d(0,0,0) rotate(360deg); }
}

/* ========= Ability Splash (full-screen slide-in from left) ========= */
/* ===== Ability Splash (centered + smooth fade in/out) ===== */
.ability-splash {
  position: fixed;
  inset: 0;
  z-index: 999;                 /* above HUD & panels */
  pointer-events: none;         /* no clicks needed */
  display: grid;
  place-items: center;          /* center image + caption */
  background: radial-gradient(60% 60% at 50% 50%, rgba(255,255,255,0.07), rgba(0,0,0,0.55));
  opacity: 0;
}

.ability-splash.show {
  animation: splashFade 2.2s ease forwards;  /* fade in → hold → fade out */
}

@keyframes splashFade {
  0%   { opacity: 0; }
  15%  { opacity: 1; }   /* fade in */
  80%  { opacity: 1; }   /* hold */
  100% { opacity: 0; }   /* fade out */
}

.ability-splash img {
  max-height: 80vh;
  max-width: 90vw;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.55));
  animation: splashZoom 0.5s cubic-bezier(.2,.9,.2,1.1) forwards;
}

@keyframes splashZoom {
  from { transform: scale(0.85); opacity: 0; }
  to   { transform: scale(1);    opacity: 1; }
}

.ability-caption {
  margin-top: 12px;
  text-align: center;
  color: #fff;
  text-shadow: 0 2px 10px rgba(0,0,0,0.6);
  font-weight: 800;
}
.ability-caption div { font-size: 22px; line-height: 1.15; }
.ability-caption small { display: block; opacity: .9; }

/* Big centered tutorial text */
.tutorial-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(0,0,0,0.45);
  z-index: 999;
  pointer-events: none; /* don't block gameplay controls */
}

.tutorial-overlay.hidden { display: none; }

.tutorial-overlay-text {
  font-size: 28px;
  font-weight: 900;
  color: #fff;
  text-align: center;
  text-shadow: 0 0 12px rgba(0,0,0,0.85);
  max-width: 80%;
  line-height: 1.3;
}


/* ===== Hearts UI: red for current HP, yellow for max buffer ===== */
.heart.red    { color: #ff3b3b; }
.heart.black  { color: #2b2b2b; opacity: .75; }  /* lost base hearts */
.heart.yellow { color: #ffd43b; }                /* extra (Rina) hearts */


/* ===== Ability Splash (good): centered, fade in/hold/out) ===== */
.ability-splash {
  position: fixed;
  inset: 0;
  z-index: 999;
  pointer-events: none;
  display: grid;
  place-items: center;
  background: radial-gradient(60% 60% at 50% 50%, rgba(255,255,255,0.07), rgba(0,0,0,0.55));
  opacity: 0;
}
.ability-splash.show { animation: splashFade 2.2s ease forwards; }
@keyframes splashFade {
  0% {opacity:0;} 15% {opacity:1;} 80% {opacity:1;} 100% {opacity:0;}
}
.ability-splash img {
  max-height: 80vh;
  max-width: 90vw;
  object-fit: contain;
  filter: drop-shadow(0 8px 24px rgba(0,0,0,0.55));
  animation: splashZoom .5s cubic-bezier(.2,.9,.2,1.1) forwards;
}
@keyframes splashZoom { from {transform:scale(.85);opacity:0;} to {transform:scale(1);opacity:1;} }
.ability-caption { margin-top:12px; text-align:center; color:#fff; text-shadow:0 2px 10px rgba(0,0,0,.6); font-weight:800; }
.ability-caption div { font-size:22px; line-height:1.15; }
.ability-caption small { display:block; opacity:.9; }

/* ===== EVIL Splash (enemy): slide in from RIGHT, red tint) ===== */
.ability-splash.evil {
  background: radial-gradient(60% 60% at 50% 50%, rgba(255,80,80,0.15), rgba(0,0,0,0.65));
}
.ability-splash.evil img {
  transform: translateX(20%) scale(.98);
  animation: evilSlide .5s cubic-bezier(.2,.9,.2,1.1) forwards;
}
@keyframes evilSlide { to { transform: translateX(0) scale(1); } }

/* Environment clouds (soft, vague) */
.clouds.env { opacity: .35 !important; filter: contrast(1.0) brightness(1.0); }

/* Lilith curse: dense, fully blocking */
.clouds.dense { opacity: 1 !important; filter: contrast(1.25) brightness(.9) saturate(1.05); }

/* Red screen tint during Lilith curse */
.app.omen::after{
  content:"";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(60% 60% at 50% 50%, rgba(180,0,0,0.10), rgba(120,0,0,0.18));
  z-index: 998; /* below ability splash which is 999 */
}

/*menu css  */

.settings { margin-top: 8px; }
.slider-row {
  display: grid;
  grid-template-columns: 72px 1fr 52px;
  align-items: center;
  gap: 10px;
  margin: 8px 0;
}
.slider-row input[type="range"] { width: 100%; }
.sl-val { text-align: right; opacity: .9; font-weight: 800; }

/*end menu  */
.final-row { display:flex; justify-content:center; margin:6px 0 10px; }
.final-card { background:#fff; color:#333; border-radius:12px; padding:10px 16px; box-shadow:0 6px 18px rgba(0,0,0,.12); min-width:140px; text-align:center; }
.final-card .label { font-size:.8rem; opacity:.75; margin-bottom:2px; }
.final-score { font-size:2rem; font-weight:800; }

.form-grid {
  display:grid; grid-template-columns:1fr 1fr; gap:12px; margin:10px 0 6px;
}
.form-grid input { width:100%; padding:10px 12px; border-radius:10px; border:1px solid rgba(255,255,255,.25); background:rgba(255,255,255,.06); color:#fff; }
.form-grid input::placeholder { color:rgba(255,255,255,.6); }

.fineprint { font-size:.8rem; opacity:.8; margin:2px 0 12px; }
.note { margin:6px 0 6px; font-size:.9rem; opacity:.9; }

/* ===== Rewards panel polish ===== */
.rewards .panel-inner { padding: 24px 28px; }
.rewards .rewards-header { text-align: center; margin-bottom: 12px; }
.rewards .rewards-sub { margin: 6px 0 0; opacity: .9; }

.prize-badge{
  display:flex; flex-direction:column; align-items:center; justify-content:center;
  width:140px; height:140px; margin:0 auto 14px;
  border-radius:999px;
  background: radial-gradient(circle at 50% 30%, #ffe066, #f9c74f 70%, #f9844a 100%);
  box-shadow: 0 8px 20px rgba(0,0,0,.35), inset 0 4px 10px rgba(255,255,255,.6);
  border: 3px solid rgba(255,255,255,.4);
  color:#24184a;
}
.prize-badge .prize-currency{ font-size:.85rem; font-weight:800; line-height:1; transform: translateY(6px); opacity:.9; }
.prize-badge .prize-amount{ font-size:42px; font-weight:900; line-height:1; }
.prize-badge .prize-label{ font-size:12px; font-weight:800; letter-spacing:.06em; text-transform:uppercase; opacity:.85; }

.rewards .rewards-header h2{
  font-size:1.4rem; font-weight:800; color:var(--accent);
  text-shadow:0 0 8px rgba(155,113,255,.6);
  margin-bottom:6px;
}

.rewards-steps{ margin:14px 0; padding-left:22px; }
.rewards-steps li{ margin:8px 0; font-size:.95rem; }

.rewards-details{ display:flex; flex-wrap:wrap; gap:8px; margin:10px 0 8px; }
.detail-chip{
  padding:6px 12px; border-radius:999px;
  background: rgba(155,113,255,.15);
  border:1px solid var(--accent);
  color:var(--accent); font-weight:700; font-size:.85rem;
  backdrop-filter: blur(4px);
}

.rewards-fineprint{ font-size:.82rem; opacity:.82; margin:4px 0 10px; }
.rewards-actions{ display:flex; justify-content:center; }

/* === Story Panel Polish === */
.story .panel-inner { padding: 26px 30px; }

.story-header { text-align: center; margin-bottom: 12px; }
.story-header h2 {
  font-size: 1.6rem;
  font-weight: 900;
  color: var(--accent);
  text-shadow: 0 0 10px rgba(155,113,255,0.6), 0 0 20px rgba(255,255,255,0.4);
}
.story-sub {
  margin-top: 4px;
  font-size: 0.95rem;
  opacity: 0.85;
  font-style: italic;
}

.story-body p { margin: 12px 0; line-height: 1.55; }
.story-body .highlight {
  color: var(--accent);
  font-weight: 700;
}

.mission-box {
  margin-top: 14px;
  padding: 14px 16px;
  border-radius: 10px;
  background: linear-gradient(180deg, rgba(155,113,255,.15), rgba(255,255,255,.05));
  border: 1px solid var(--accent);
  box-shadow: 0 0 12px rgba(155,113,255,.25);
}
.mission-box h3 {
  margin: 0 0 6px;
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--accent);
  text-transform: uppercase;
}
.mission-box p { margin: 0; }

.story-actions { display: flex; justify-content: center; margin-top: 16px; }

/* === Rules Panel Polish === */
.rules .panel-inner { padding: 26px 30px; }

.rules-header { text-align: center; margin-bottom: 12px; }
.rules-badge{
  width:64px; height:64px; margin:0 auto 8px; border-radius:16px;
  display:grid; place-items:center; font-size:30px;
  background: linear-gradient(180deg, rgba(155,113,255,.2), rgba(255,255,255,.06));
  border:1px solid var(--border);
  box-shadow: 0 6px 18px rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.3);
}
.rules-header h2{
  font-size:1.5rem; font-weight:900; color:var(--accent);
  text-shadow:0 0 10px rgba(155,113,255,.55);
}
.rules-sub{ margin-top:4px; opacity:.85; font-size:.95rem; }

.rules-list{ margin:14px 0 10px; padding:0; list-style:none; }
.rules-list li{
  display:flex; gap:10px; align-items:flex-start;
  padding:8px 0; border-bottom:1px dashed rgba(255,255,255,.08);
}
.rules-list li:last-child{ border-bottom:none; }
.rules-list .ri{
  width:28px; height:28px; flex:0 0 28px;
  display:grid; place-items:center; font-size:18px;
  border-radius:8px;
  background: rgba(155,113,255,.18);
  border:1px solid var(--accent);
  color:var(--accent); font-weight:800;
}

.rule-grid{
  display:grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap:12px; margin:12px 0 4px;
}

.rule-card{
  padding:12px; border-radius:12px;
  background: linear-gradient(180deg, rgba(255,255,255,.10), rgba(255,255,255,.04));
  border:1px solid var(--border);
  box-shadow: 0 8px 18px rgba(0,0,0,.18);
}
.rule-card .card-title{
  font-weight:900; letter-spacing:.02em; margin-bottom:6px;
  color:var(--accent); text-transform:uppercase; font-size:.9rem;
}
.rule-card .mini{ margin:0; opacity:.95; line-height:1.45; }
.rule-card .mini-list{ list-style:disc inside; margin:0; padding:0; opacity:.95; }
.rule-card.danger{
  background: linear-gradient(180deg, rgba(255,120,120,.12), rgba(255,255,255,.04));
  border-color: rgba(255,120,120,.5);
  box-shadow: 0 8px 18px rgba(255,120,120,.22);
}

.rules-actions{ display:flex; justify-content:center; margin-top:16px; }

/* === Credits Panel Polish === */
.credits .panel-inner { padding: 26px 30px; }

.credits-header { text-align: center; margin-bottom: 14px; }
.credits-badge{
  width:64px; height:64px; margin:0 auto 8px; border-radius:16px;
  display:grid; place-items:center; font-size:30px;
  background: linear-gradient(180deg, rgba(255,215,100,.25), rgba(255,255,255,.06));
  border:1px solid rgba(255,215,100,.6);
  box-shadow: 0 6px 18px rgba(0,0,0,.25), inset 0 2px 0 rgba(255,255,255,.3);
}
.credits-header h2{
  font-size:1.5rem; font-weight:900; color:var(--accent);
  text-shadow:0 0 10px rgba(155,113,255,.55);
}
.credits-sub{ margin-top:4px; font-size:.95rem; opacity:.85; font-style:italic; }

.credits-list{ display:flex; flex-direction:column; gap:12px; }
.credit-card{
  display:flex; gap:10px; align-items:flex-start;
  padding:10px 12px; border-radius:12px;
  background: linear-gradient(180deg, rgba(255,255,255,.08), rgba(255,255,255,.04));
  border:1px solid var(--border);
  box-shadow: 0 4px 12px rgba(0,0,0,.18);
}
.credit-icon{
  width:34px; height:34px; flex:0 0 34px;
  display:grid; place-items:center;
  font-size:20px; border-radius:10px;
  background: rgba(155,113,255,.15);
  border:1px solid var(--accent);
  color:var(--accent); font-weight:800;
}

.credits-actions{ display:flex; justify-content:center; margin-top:16px; }

/* ===== Run Complete (endModal) – center + polish ===== */
/* ===== Run Complete (endModal) – center + polish ===== */
#endModal .panel-inner { 
  text-align: center;
}

/* Score row (center) */
#endModal .final-row{
  display:flex; justify-content:center; align-items:center;
  margin:14px 0;
}

/* (Kept for safety if you still use .final-card elsewhere) */
#endModal .final-card{
  display:flex; flex-direction:column; align-items:center; gap:6px;
  padding:12px 16px; border-radius:12px;
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.05));
  border:1px solid var(--border);
  box-shadow: 0 8px 18px rgba(0,0,0,.18);
  min-width: 140px;
}
#endModal .final-card .label{ font-weight:700; opacity:.9; }
#endModal .final-score{ font-size:2rem; font-weight:900; line-height:1; }

/* Deadline note + fineprint */
#endModal .note,
#endModal .fineprint{
  text-align:center; margin:8px auto; opacity:.9;
}

/* Form: center labels + inputs */
#endModal .form-grid{
  display:grid; grid-template-columns:1fr; gap:10px;
  justify-items:center; margin-top:6px;
}
#endModal .form-grid label{
  display:flex; flex-direction:column; align-items:center; gap:6px;
  width:100%; max-width:380px; text-align:center;
}
#endModal .form-grid input{
  width:100%; text-align:center;
}

/* Buttons row */
#endModal .row{
  display:flex; justify-content:center; gap:10px; margin-top:12px;
}

/* === Run Complete Coin Badge  === */

/* === Run Complete Coin Badge (clipped circular shine) === */
#endModal .final-row{
  display:flex; justify-content:center; margin:14px 0;
}

#endModal .coin-badge{
  position:relative;
  width:clamp(96px, 12vw, 132px);
  height:clamp(96px, 12vw, 132px);
  display:grid; place-items:center;

  /* The magic: make the wrapper a circular clip mask */
  border-radius:50%;
  overflow:hidden;              /* clips the shine to the circle */
}

#endModal .coin-img{
  width:100%; height:100%; object-fit:contain;
  position:relative; z-index:1;
  filter: drop-shadow(0 6px 12px rgba(0,0,0,.45));
}

/* Shine sweep – now clipped by the circular wrapper */
#endModal .coin-badge::after{
  content:"";
  position:absolute;
  z-index:2;                    /* above the image, below the score */

  /* a narrow diagonal ribbon that sweeps across */
  width:60%;
  height:160%;
  left:-80%;                    /* start off-canvas left */
  top:-30%;
  transform: rotate(24deg);
  background: linear-gradient(100deg,
    rgba(255,255,255,0)   0%,
    rgba(255,255,255,.10) 35%,
    rgba(255,255,255,.80) 50%,
    rgba(255,255,255,.10) 65%,
    rgba(255,255,255,0)  100%);
  filter: blur(2px);
  pointer-events:none;
  mix-blend-mode: screen;

  animation: coinShine 2.8s ease-in-out infinite;
}

@keyframes coinShine{
  0%   { left:-80%; opacity:0; }
  10%  { opacity:.95; }
  45%  { left:120%; opacity:0; }
  100% { left:120%; opacity:0; }
}

/* Score on top */
#endModal .coin-score{
  position:absolute; z-index:3;
  font-size:clamp(28px, 4.2vw, 40px);
  font-weight:900;
  color:#fff;
  text-shadow:
    0 0 10px rgba(0,0,0,.75),
    0 0 18px rgba(255,215,0,.55);
}

/* Leaderboard: centered layout */
.leaderboard-centered { text-align: center; }
.leaderboard-centered h2 { margin-bottom: 8px; }

/* Make the tables sit centered within the panel */
.leaderboard-centered table.lb { margin: 0 auto; }

/* Tabs */
.tabs {
  display: inline-flex; gap: 8px; margin: 8px 0 14px;
  background: rgba(255,255,255,0.06); padding: 6px; border-radius: 10px;
  border: 1px solid var(--border);
}
.tab {
  appearance: none; border: 1px solid var(--border);
  background: linear-gradient(180deg, rgba(255,255,255,.12), rgba(255,255,255,.06));
  color: var(--text); font-weight: 800; padding: 8px 12px; border-radius: 8px;
  cursor: pointer;
}
.tab.active {
  background: linear-gradient(135deg, var(--primary), #efe6ff);
  color: #1b1238; box-shadow: 0 6px 16px rgba(0,0,0,.25);
}

/* Tab panels */
.tab-panel.hidden { display: none; }
