/* Touch 'n' Go — luminous dusk. UI floats on the sky, nothing is boxed. */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --cream: #fff6e8;
  --cream-dim: rgba(255, 244, 226, 0.62);
  --teal: #2fb5a3;
  --amber: #ffb038;
  --coral: #ff6a7d;
  --twilight: #2e2a55;
  --shadow-soft: 0 2px 26px rgba(20, 14, 34, 0.7), 0 1px 2px rgba(16, 10, 28, 0.8);
  --font-display: "Unbounded", system-ui, sans-serif;
  --font-body: "Manrope", system-ui, sans-serif;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: linear-gradient(180deg, #16143a 0%, #453a6a 40%, #8f5548 74%, #b3805e 100%);
  font-family: var(--font-body);
  color: var(--cream);
  user-select: none;
  -webkit-user-select: none;
}

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  display: block;
  touch-action: none;
}

/* a deeper vignette — the frame holds the dark */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(ellipse at 50% 44%, transparent 58%, rgba(16, 11, 30, 0.5) 100%);
  z-index: 1;
}

/* ---------- HUD: quiet typography floating on the twilight ---------- */
#hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  gap: clamp(18px, 3.4vw, 46px);
  padding: 18px clamp(18px, 4.5vw, 48px) 10px;
  pointer-events: none;
  z-index: 5;
}

.stat label {
  display: block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--cream-dim);
  text-shadow: 0 1px 12px rgba(46, 32, 68, 0.5);
}

.stat span {
  font-family: var(--font-body);
  font-weight: 800;
  font-size: clamp(16px, 2.2vw, 22px);
  line-height: 1.3;
  letter-spacing: 0.02em;
  color: var(--cream);
  text-shadow: var(--shadow-soft);
  font-variant-numeric: tabular-nums;
}

.stat.grow { flex: 1; max-width: 400px; margin-left: auto; }

.heart { color: var(--coral); font-size: 17px; margin-right: 3px; text-shadow: 0 1px 10px rgba(46,32,68,0.55); }
.heart.off { color: rgba(255, 244, 226, 0.22); }

.timebar {
  margin-top: 6px;
  height: 8px;
  border-radius: 4px;
  background: rgba(46, 42, 85, 0.35);
  box-shadow: inset 0 1px 2px rgba(30, 20, 50, 0.4);
  overflow: hidden;
}
#hud-time {
  height: 100%;
  width: 100%;
  border-radius: 4px;
  transition: width 0.15s linear;
}
#hud-time.ok   { background: linear-gradient(90deg, #1f9184, var(--teal)); }
#hud-time.warn { background: linear-gradient(90deg, #d98f1c, var(--amber)); }
#hud-time.low  { background: linear-gradient(90deg, #d33a52, var(--coral)); animation: pulse 0.5s infinite; }

@keyframes pulse { 50% { filter: brightness(1.5); } }

/* ---------- screens: type set straight onto the sky ---------- */
#screen {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  padding: 24px;
}

.panel {
  text-align: center;
  max-width: min(94vw, 760px);
  animation: rise-in 0.7s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes rise-in {
  from { transform: translateY(22px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}

.panel h1 {
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.2rem, 7vw, 4.6rem);
  line-height: 1.04;
  letter-spacing: 0.01em;
  text-transform: uppercase;
  color: var(--cream);
  text-shadow: 0 3px 0 rgba(60, 30, 42, 0.5), 0 12px 48px rgba(16, 11, 30, 0.7);
}
.panel h1 em {
  font-style: normal;
  color: var(--amber);
}
.panel h1.over { color: var(--coral); }

.panel h2 {
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1.3rem, 3.6vw, 2.2rem);
  letter-spacing: 0.02em;
  text-transform: uppercase;
  text-shadow: var(--shadow-soft);
}
.panel.good h2 { color: #7dffe4; }
.panel.bad h2 { color: #ffb9c2; }

.sub {
  margin-top: 14px;
  font-size: clamp(10px, 1.5vw, 13px);
  font-weight: 700;
  letter-spacing: 0.38em;
  text-transform: uppercase;
  color: var(--cream-dim);
  text-shadow: 0 1px 14px rgba(46, 32, 68, 0.6);
}

.rule {
  margin: 26px auto 4px;
  max-width: 34em;
  font-size: clamp(15px, 2vw, 18px);
  font-weight: 500;
  line-height: 1.7;
  color: var(--cream);
  text-shadow: 0 1px 16px rgba(46, 32, 68, 0.65);
}
.rule b { color: #ffd98c; font-weight: 700; }

.lvlname {
  margin-top: 10px;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: clamp(1rem, 2.6vw, 1.5rem);
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--amber);
  text-shadow: var(--shadow-soft);
}

.keys {
  margin-top: 22px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.24em;
  color: var(--cream-dim);
  text-shadow: 0 1px 12px rgba(46, 32, 68, 0.55);
}

.blink {
  margin-top: 26px;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: clamp(0.8rem, 1.9vw, 1.05rem);
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--cream);
  text-shadow: var(--shadow-soft);
  animation: breathe 2s ease-in-out infinite;
}
@keyframes breathe { 50% { opacity: 0.35; } }

.hi {
  margin-top: 16px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.34em;
  color: var(--cream-dim);
  text-shadow: 0 1px 12px rgba(46, 32, 68, 0.55);
}

/* title type rides high; the board breathes beneath it */
.panel.title-panel {
  align-self: flex-start;
  margin-top: max(5vh, 26px);
}

/* level preview rides high too — the flyover needs the frame */
.panel.preview {
  align-self: flex-start;
  margin-top: max(4vh, 18px);
}

.countdown {
  margin-top: 12px;
  font-family: var(--font-display);
  font-weight: 900;
  font-size: clamp(2.2rem, 5.5vw, 3.6rem);
  line-height: 1;
  color: var(--amber);
  text-shadow: var(--shadow-soft);
}

/* ---------- floating score popups ---------- */
#popups { position: fixed; inset: 0; pointer-events: none; z-index: 6; }
.pop-score {
  position: absolute;
  transform: translate(-50%, -50%);
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 15px;
  color: var(--cream);
  text-shadow: 0 1px 10px rgba(16, 10, 28, 0.8);
  animation: pop-rise 0.85s ease-out forwards;
}
.pop-score.hot { color: var(--amber); font-size: 18px; }
.pop-score.blazing { color: var(--coral); font-size: 21px; }
@keyframes pop-rise {
  0%   { opacity: 0; transform: translate(-50%, -30%) scale(0.7); }
  15%  { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  100% { opacity: 0; transform: translate(-50%, -170%) scale(1); }
}

/* ---------- combo heat in the HUD ---------- */
#hud-combo.hot { color: var(--amber); }
#hud-combo.blazing { color: var(--coral); animation: pulse 0.4s infinite; }

/* ---------- medal chips ---------- */
.medal {
  display: inline-block;
  padding: 3px 12px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.22em;
  margin: 2px;
}
.medal.m4 { background: rgba(255, 210, 58, 0.22); color: #ffd23a; box-shadow: 0 0 18px rgba(255, 210, 58, 0.35); }
.medal.m3 { background: rgba(255, 176, 56, 0.18); color: #ffb038; }
.medal.m2 { background: rgba(220, 226, 240, 0.16); color: #dfe4f0; }
.medal.m1 { background: rgba(205, 130, 90, 0.2); color: #e0a17a; }

/* ---------- level select ---------- */
.panel.select { pointer-events: auto; max-width: min(94vw, 720px); }
.level-grid {
  display: grid;
  grid-template-columns: repeat(10, 1fr);
  gap: 8px;
  margin-top: 22px;
}
.lvl-btn {
  appearance: none;
  border: 1px solid rgba(255, 244, 226, 0.22);
  background: rgba(20, 14, 34, 0.42);
  color: var(--cream);
  border-radius: 10px;
  padding: 9px 0 7px;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 13px;
  cursor: pointer;
  transition: transform 0.12s, background 0.12s, border-color 0.12s;
}
.lvl-btn:hover { transform: translateY(-2px); background: rgba(47, 181, 163, 0.25); border-color: var(--teal); }
.lvl-btn:disabled { opacity: 0.28; cursor: default; transform: none; }
.lvl-btn .dot { display: block; height: 5px; width: 5px; border-radius: 50%; margin: 4px auto 0; background: transparent; }
.lvl-btn .dot.m4 { background: #ffd23a; box-shadow: 0 0 8px #ffd23a; }
.lvl-btn .dot.m3 { background: #ffb038; }
.lvl-btn .dot.m2 { background: #dfe4f0; }
.lvl-btn .dot.m1 { background: #e0a17a; }

/* ---------- danger: the last five seconds burn at the frame ---------- */
body.danger::after {
  background: radial-gradient(ellipse at 50% 44%, transparent 52%, rgba(140, 30, 40, 0.5) 100%);
  animation: danger-breathe 0.5s ease-in-out infinite;
}
@keyframes danger-breathe { 50% { opacity: 0.55; } }
