:root {
  --sand: #e8c07a;
  --ink: #241a12;
  --accent: #ff5a3c;
  --gold: #ffc93c;
  --green: #7bc950;
  --panel: rgba(20, 14, 10, 0.82);
  --hud-shadow: 0 2px 0 rgba(0,0,0,.45);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #1a120b;
  font-family: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
  -webkit-user-select: none; user-select: none;
  touch-action: none;
}

#game { position: fixed; inset: 0; display: block; }

.hidden { display: none !important; }
.dim { color: #b9a68f; }
.tiny { font-size: 11px; margin-top: 14px; letter-spacing: .08em; }

#vignette {
  position: fixed; inset: 0; pointer-events: none; z-index: 3;
  background: radial-gradient(ellipse at center, transparent 58%, rgba(15,8,4,.42) 100%);
}
#flash {
  position: fixed; inset: 0; pointer-events: none; z-index: 4;
  background: radial-gradient(ellipse at center, rgba(255,40,20,.28), rgba(160,10,0,.55));
  opacity: 0; transition: opacity .12s ease-out;
}
#gflash {
  position: fixed; inset: 0; pointer-events: none; z-index: 4;
  background: radial-gradient(ellipse at center, rgba(255,232,160,.5), rgba(255,190,60,.22));
  opacity: 0; transition: opacity .5s ease-out;
}

#hud { position: fixed; inset: 0; z-index: 5; pointer-events: none; color: #fff; }
.hud-left { position: absolute; top: 18px; left: 22px; text-shadow: var(--hud-shadow); }
.hud-big { font-size: 44px; font-weight: 900; letter-spacing: .02em; line-height: 1; font-variant-numeric: tabular-nums; }
.hud-big::after { content: " m"; font-size: 16px; opacity: .75; font-weight: 700; }
.hud-sub { margin-top: 6px; font-size: 13px; letter-spacing: .14em; color: #ffd9a0; }
.hud-sub .label { opacity: .65; }
.hud-sub span:last-child { font-weight: 800; font-variant-numeric: tabular-nums; }

#journey {
  margin-top: 12px; width: 150px; height: 7px; border-radius: 99px;
  background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.22);
  position: relative; overflow: visible;
}
#journeyfill {
  display: block; height: 100%; width: 0%; border-radius: 99px;
  background: linear-gradient(90deg, #7bd66f, #ffd23c 55%, #ff4b2e);
  transition: width .3s linear;
}
.jtick { position: absolute; top: -2px; width: 2px; height: 11px; background: rgba(255,255,255,.55); }
#zonename {
  margin-top: 7px; font-size: 11px; letter-spacing: .18em; color: #ffd9a0; font-weight: 800;
  transform-origin: left center;
}
#zonename.pulse { animation: zonepulse .8s cubic-bezier(.2,1.4,.4,1); }
@keyframes zonepulse { 0% { transform: scale(1.3); filter: brightness(2); } 100% { transform: scale(1); filter: brightness(1); } }

.hud-right { position: absolute; top: 18px; right: 22px; text-align: right; text-shadow: var(--hud-shadow); }
.egg-row { display: flex; align-items: center; justify-content: flex-end; gap: 8px; font-size: 26px; font-weight: 900; font-variant-numeric: tabular-nums; }
.egg-icon {
  width: 17px; height: 21px; display: inline-block;
  background: linear-gradient(160deg, #ffe9a8, #ffb62e 55%, #d98a00);
  border-radius: 50% 50% 50% 50% / 60% 60% 42% 42%;
  box-shadow: inset -2px -3px 4px rgba(140,70,0,.55), 0 1px 2px rgba(0,0,0,.5);
}
.egg-icon.small { transform: scale(.72); vertical-align: middle; }

.speed-wrap { margin-top: 12px; display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
#speedtxt { font-size: 13px; letter-spacing: .1em; font-weight: 800; color: #ffd9a0; font-variant-numeric: tabular-nums; }
#speedbar {
  width: 110px; height: 8px; border-radius: 99px; overflow: hidden;
  background: rgba(0,0,0,.45); border: 1px solid rgba(255,255,255,.22);
}
#speedfill { display: block; height: 100%; width: 8%;
  background: linear-gradient(90deg, #7bd66f, #ffd23c 55%, #ff4b2e);
  transition: width .25s ease-out; }

#combo {
  position: absolute; top: 26%; left: 50%; transform: translateX(-50%) scale(1);
  font-size: 30px; font-weight: 900; letter-spacing: .06em; color: var(--gold);
  text-shadow: 0 2px 0 rgba(0,0,0,.55), 0 0 22px rgba(255,200,40,.55);
  animation: comboPop .5s cubic-bezier(.2,1.6,.4,1);
}
@keyframes comboPop { 0% { transform: translateX(-50%) scale(.4); opacity: 0; } 100% { transform: translateX(-50%) scale(1); opacity: 1; } }

#toast {
  position: absolute; bottom: 14%; left: 50%; transform: translateX(-50%);
  padding: 9px 20px; border-radius: 999px; font-size: 15px; font-weight: 800; letter-spacing: .05em;
  background: var(--panel); color: #ffe9bf; border: 1px solid rgba(255,220,150,.25);
}

#boosts { position: absolute; left: 22px; bottom: 26px; display: flex; flex-direction: column; gap: 8px; }
.boost {
  display: none; align-items: center; gap: 10px; padding: 7px 12px;
  border-radius: 12px; background: rgba(20,14,10,.78);
  border: 1px solid rgba(255,255,255,.18); min-width: 200px;
}
.boost.on { display: flex; }
.b-label { font-size: 12px; font-weight: 900; letter-spacing: .12em; color: #fff; width: 88px; text-align: left; }
.b-time { font-size: 12px; font-weight: 800; color: #ffd9a0; font-variant-numeric: tabular-nums; width: 40px; text-align: right; }
.bbar {
  flex: 1; height: 6px; border-radius: 99px; overflow: hidden;
  background: rgba(0,0,0,.5); border: 1px solid rgba(255,255,255,.15);
}
.bbar i { display: block; height: 100%; width: 100%; border-radius: 99px; }

#btn-cam {
  position: fixed; top: 16px; left: 50%; transform: translateX(-50%); z-index: 6;
  padding: 8px 18px; font-family: inherit; font-size: 12px; font-weight: 900; letter-spacing: .14em;
  color: #ffe9bf; background: rgba(20,14,10,.7); border: 1px solid rgba(255,220,150,.35);
  border-radius: 999px; cursor: pointer;
}

.overlay {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 35%, rgba(46,28,14,.55), rgba(10,5,2,.86));
  backdrop-filter: blur(5px); -webkit-backdrop-filter: blur(5px);
}

.panel {
  text-align: center; color: #fff; padding: 34px 44px; max-width: 520px; width: calc(100% - 48px);
  background: var(--panel); border-radius: 22px;
  border: 1px solid rgba(255,205,140,.16);
  box-shadow: 0 30px 80px rgba(0,0,0,.6), inset 0 1px 0 rgba(255,255,255,.06);
}

.game-title {
  font-size: clamp(56px, 11vw, 96px); font-weight: 900; line-height: .92; letter-spacing: -.02em;
  color: var(--sand);
  text-shadow: 0 4px 0 #7a4a1e, 0 8px 24px rgba(0,0,0,.6);
}
.game-title span { color: var(--accent); display: block; letter-spacing: .32em; font-size: .52em; margin-top: 4px;
  text-shadow: 0 3px 0 #7e1f0d; }
.title-tag { margin-top: 16px; font-size: 11px; letter-spacing: .34em; color: #cdb08a; }

h2 { font-size: 40px; font-weight: 900; letter-spacing: .04em; color: var(--sand); text-shadow: 0 3px 0 rgba(90,40,0,.8); }
.dead-panel h2 { color: var(--accent); text-shadow: 0 3px 0 rgba(80,10,0,.85); font-size: 52px; }
.win-title { color: var(--green); text-shadow: 0 3px 0 rgba(20,80,10,.85); }
.win-panel { border-color: rgba(160,255,140,.25); }
.panel p { margin-top: 8px; font-size: 15px; }

.btn {
  display: block; width: 100%; margin-top: 14px; padding: 15px 20px;
  font-family: inherit; font-size: 16px; font-weight: 900; letter-spacing: .12em;
  color: #fff; background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.22); border-radius: 14px; cursor: pointer;
  transition: transform .08s ease, background .15s ease, box-shadow .15s ease;
}
.btn:hover { background: rgba(255,255,255,.16); transform: translateY(-1px); }
.btn:active { transform: translateY(1px) scale(.99); }
.btn-primary {
  margin-top: 26px;
  background: linear-gradient(180deg, #ff7a4d, #f04a24);
  border-color: rgba(255,190,140,.5);
  box-shadow: 0 6px 0 #96260c, 0 14px 30px rgba(240,74,36,.35);
}
.btn-primary:hover { background: linear-gradient(180deg, #ff8a5e, #f75631); box-shadow: 0 6px 0 #96260c, 0 18px 38px rgba(240,74,36,.5); }
.btn-primary:active { box-shadow: 0 2px 0 #96260c; transform: translateY(4px); }
.btn-small {
  margin-top: 10px; padding: 10px 16px; font-size: 12.5px;
  background: rgba(255,255,255,.05); letter-spacing: .1em;
}
.zone-line {
  margin-top: 10px; font-size: 11px; letter-spacing: .22em; font-weight: 800;
  color: var(--green);
}

.controls-grid {
  margin-top: 26px; display: grid; grid-template-columns: 1fr 1fr; gap: 10px 18px;
}
.ctl { display: flex; align-items: center; justify-content: center; gap: 6px; color: #d8c3a5; font-size: 12.5px; }
.ctl em { font-style: normal; letter-spacing: .04em; }
.key {
  min-width: 26px; padding: 4px 7px; font-size: 12px; font-weight: 800; color: #2b1c10;
  background: linear-gradient(180deg, #f5deb8, #cf9f63);
  border-radius: 6px; box-shadow: 0 2px 0 #8a5c2c; text-align: center;
}
.key.wide { padding-inline: 12px; }
.hint-touch { margin-top: 18px; font-size: 12.5px; letter-spacing: .06em; color: #d8c3a5; }
.best-line { margin-top: 22px; font-size: 13px; letter-spacing: .12em; color: #b9a68f; display: flex; align-items: center; justify-content: center; gap: 6px; }

.newbest {
  margin: 14px auto 2px; display: inline-block; padding: 6px 18px;
  font-size: 13px; font-weight: 900; letter-spacing: .22em; color: #3a2400;
  background: linear-gradient(180deg, #ffe08a, #ffb62e);
  border-radius: 999px; box-shadow: 0 3px 0 #b97a00, 0 0 30px rgba(255,190,60,.5);
  animation: bestGlow 1s ease-in-out infinite alternate;
}
@keyframes bestGlow { from { filter: brightness(1); } to { filter: brightness(1.18); } }

.stats-row { display: flex; gap: 26px; justify-content: center; margin: 22px 0 8px; }
.stat-num { display: block; font-size: 34px; font-weight: 900; color: #fff; font-variant-numeric: tabular-nums; }
.stat-lbl { display: block; margin-top: 3px; font-size: 10.5px; letter-spacing: .2em; color: #b9a68f; }

@media (max-width: 640px) {
  .panel { padding: 26px 22px; border-radius: 18px; }
  .controls-grid { grid-template-columns: 1fr; }
  .hud-big { font-size: 32px; }
  .stats-row { gap: 18px; }
  #boosts { left: 14px; bottom: 16px; gap: 6px; }
  .boost { min-width: 156px; padding: 5px 9px; }
  .b-label { width: 72px; font-size: 10.5px; }
}
