/* ===========================================================
   Vanishing Path — visual identity
   A collapsing-cave palette: near-black stone, warm ember amber
   for interactive/title elements, danger red for hazards, and
   a distinct accent per world (moss for World 1, crystal violet
   for World 2). Flat shapes, no gradients-as-decoration, no
   rounded-card kit.
   =========================================================== */

:root{
  --bg: #0d0f14;
  --stone: #171a22;
  --stone-2: #1f232e;
  --line: #2b303c;
  --text: #eae7dd;
  --text-dim: #9a9fae;
  --ember: #f2a93b;
  --ember-dim: #a97a2e;
  --danger: #e4572e;
  --world-1: #5fae63;
  --world-2: #8a6fd1;
  --locked: #3a3f4a;
  --radius: 3px;
}

*{ box-sizing: border-box; }

html, body{
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overflow: hidden;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#app{
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
}

.screen{
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
}
.screen.active{ display: flex; }

button{
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
  color: inherit;
}
button:focus-visible{
  outline: 2px solid var(--ember);
  outline-offset: 2px;
}

/* ---------------- MENU ---------------- */

#screen-menu{
  padding: 18px 20px 0;
  overflow-y: auto;
}

.menu-top{
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.coin-chip{
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: var(--stone);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 12px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}
.coin-chip .coin-icon{ color: var(--ember); }

.mode-buttons{
  display: flex;
  align-items: center;
  gap: 8px;
}

.mode-btn{
  padding: 7px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--stone);
  color: var(--text);
  font-size: 13px;
  letter-spacing: .02em;
}
.mode-btn[aria-pressed="true"]{
  background: var(--ember);
  border-color: var(--ember);
  color: #1a1300;
  font-weight: 700;
}

.icon-btn{
  width: 34px;
  height: 34px;
  border-radius: var(--radius);
  background: var(--stone);
  border: 1px solid var(--line);
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-btn.muted, .hud-round-btn.muted{ color: var(--text-dim); }

.title-wrap{
  padding: 34px 4px 20px;
}
 /* ---------------- MOVE TO DOOR LOGO ---------------- */

.brand-logo{
  position: relative;
  display: inline-block;
  padding: 0 0 8px;
  color: var(--text);
}

.brand-move{
  margin-left: 3px;
  margin-bottom: 2px;
  font-size: clamp(18px, 4vw, 25px);
  line-height: 1;
  font-weight: 900;
  letter-spacing: .22em;
  color: var(--text-dim);
}

.brand-main{
  display: flex;
  align-items: center;
  gap: 7px;
  line-height: .88;
}

.brand-to{
  font-size: clamp(34px, 8vw, 56px);
  font-weight: 900;
  letter-spacing: -.04em;
  color: var(--ember);
  text-shadow: 2px 2px 0 #6e4a18;
}

.brand-door{
  font-size: clamp(42px, 10vw, 68px);
  font-weight: 900;
  letter-spacing: -.06em;
  color: var(--text);
  text-shadow: 3px 3px 0 #090b0f;
}

.brand-door-icon{
  width: clamp(25px, 6vw, 38px);
  height: clamp(34px, 8vw, 50px);
  margin-left: 5px;
  color: var(--ember);
  flex-shrink: 0;
}

/* Small path leading toward the door */

.brand-path{
  display: flex;
  align-items: center;
  gap: 5px;
  height: 10px;
  margin: 8px 0 0 5px;
  opacity: .75;
}

.brand-path span{
  display: block;
  width: 18px;
  height: 3px;
  background: var(--line);
  transform: skewX(-28deg);
}

.brand-path span:nth-child(2){
  width: 14px;
}

.brand-path span:nth-child(3){
  width: 10px;
}

.brand-path b{
  margin-left: 2px;
  color: var(--ember);
  font-size: 16px;
  line-height: 1;
}

/* Tagline */

.tagline{
  margin: 12px 0 0;
  color: var(--text-dim);
  font-size: 14px;
  letter-spacing: .01em;
}

/* Mobile */

@media (max-width: 480px){
  .title-wrap{
    padding-top: 26px;
    padding-bottom: 18px;
  }

  .brand-main{
    gap: 5px;
  }

  .brand-door-icon{
    margin-left: 2px;
  }

  .brand-path{
    margin-top: 7px;
  }
}
.tagline{
  margin: 10px 0 0;
  color: var(--text-dim);
  font-size: 14px;
}

.continue-btn{
  margin-top: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border-radius: var(--radius);
  border: 1px solid var(--ember);
  background: rgba(242,169,59,0.12);
  color: var(--ember);
  font-weight: 700;
  font-size: 14px;
}
.continue-btn.hidden{ display: none; }

.world-list{
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding-bottom: 24px;
}

.world-block{
  border: 1px solid var(--line);
  border-radius: var(--radius);
  overflow: hidden;
  background: var(--stone);
}

.world-header{
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--line);
  border-left: 4px solid var(--world-color, var(--ember));
}
.world-header h2{
  margin: 0;
  font-size: 15px;
  font-weight: 700;
}
.world-header .world-sub{
  font-size: 12px;
  color: var(--text-dim);
}

.level-grid{
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 1px;
  background: var(--line);
}

.level-tile{
  position: relative;
  aspect-ratio: 1 / 1;
  background: var(--stone-2);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  color: var(--text);
  font-weight: 700;
  font-size: 18px;
  border-top: 3px solid var(--world-color, var(--ember));
}
.level-tile .best-time{
  font-size: 10px;
  font-weight: 500;
  color: var(--text-dim);
  font-variant-numeric: tabular-nums;
}
.level-tile.completed::after{
  content: "";
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  background: var(--world-color, var(--ember));
  border-radius: 50%;
}
.level-tile.locked{
  color: var(--locked);
  cursor: default;
  border-top-color: var(--line);
}
.level-tile.locked .lock-icon{
  width: 16px;
  height: 14px;
  position: relative;
  border: 2px solid var(--locked);
  border-radius: 2px;
}
.level-tile.locked .lock-icon::before{
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  top: -8px;
  height: 8px;
  border: 2px solid var(--locked);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
}
.level-tile:not(.locked):hover{
  background: #262b38;
}

.ad-slot{
  min-height: 0;
  height: 0;
  overflow: hidden;
  margin: 0 0 16px;
  border-radius: var(--radius);
}
.ad-slot.ad-slot-active{
  height: 90px;
  border: 1px dashed var(--line);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-dim);
  font-size: 12px;
}

/* ---------------- GAME SCREEN ---------------- */

#screen-game{
  background: #000;
}

.canvas-wrap{
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #000;
}

#game-canvas{
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  display: block;
  image-rendering: -webkit-optimize-contrast;
}

.hud{
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  pointer-events: none;
}
.hud > *{ pointer-events: auto; }

.hud-left{
  display: flex;
  gap: 8px;
}

.hud-round-btn{
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(23,26,34,0.8);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.hud-round-btn.small{ width: 32px; height: 32px; font-size: 13px; }

.checkpoints{
  display: flex;
  gap: 6px;
}
.checkpoint-seg{
  width: 14px;
  height: 14px;
  border: 2px solid var(--ember);
  border-radius: 2px;
  background: transparent;
  transform: rotate(45deg);
}
.checkpoint-seg.filled{
  background: var(--ember);
}

.speedrun-timer{
  background: rgba(23,26,34,0.8);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 6px 10px;
  font-variant-numeric: tabular-nums;
  font-weight: 700;
  font-size: 14px;
}
.speedrun-timer.hidden{ display: none; }

.touch-controls{
  display: none;
  align-items: center;
  justify-content: space-between;
  padding: 10px 18px;
  height: 92px;
  flex-shrink: 0;
  background: var(--stone);
  border-top: 1px solid var(--line);
}
.touch-cluster{
  display: flex;
  gap: 10px;
}
.touch-btn{
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: rgba(234,231,221,0.08);
  border: 1px solid var(--line);
  color: var(--text);
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.touch-btn:active{ background: rgba(242,169,59,0.25); }
.touch-jump{
  background: rgba(242,169,59,0.18);
  border-color: var(--ember-dim);
}

@media (pointer: coarse){
  .touch-controls{ display: flex; }
}

/* ---------------- OVERLAYS ---------------- */

.overlay{
  position: absolute;
  inset: 0;
  background: rgba(8,9,12,0.82);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}
.overlay.hidden{ display: none; }

.overlay-card{
  background: var(--stone);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 28px 26px;
  width: min(320px, 86vw);
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: center;
}
.overlay-card.wide{
  width: min(420px, 90vw);
  max-height: 80vh;
}
.overlay-card h2{
  margin: 0 0 6px;
  font-size: 20px;
}
.stat-line{
  margin: 0;
  color: var(--text-dim);
  font-size: 14px;
}
.stat-line span{
  color: var(--text);
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.stat-line.best{ color: var(--ember); font-weight: 700; }
.stat-line.hidden{ display: none; }

.menu-action{
  margin-top: 6px;
  padding: 12px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--stone-2);
  font-size: 14px;
  font-weight: 600;
}
.menu-action.primary{
  background: var(--ember);
  border-color: var(--ember);
  color: #1a1300;
}

.trophy-list{
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-height: 50vh;
  overflow-y: auto;
  text-align: left;
}
.trophy-item{
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: var(--stone-2);
  border-radius: var(--radius);
  border-left: 3px solid var(--locked);
  font-size: 13px;
  color: var(--text-dim);
}
.trophy-item.earned{
  border-left-color: var(--ember);
  color: var(--text);
}
.trophy-badge{
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--locked);
  flex-shrink: 0;
}
.trophy-item.earned .trophy-badge{ background: var(--ember); }
