:root {
  --accent: #ffb347;
  --accent2: #ff7b4f;
}
* { margin: 0; padding: 0; box-sizing: border-box; }

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #10091d;
  overscroll-behavior: none;
  font-family: 'Jua', 'Noto Sans KR', sans-serif;
}

body {
  display: grid;
  place-items: center;
}

#wrap {
  position: relative;
  width: min(1024px, 100vw, calc(100vh * 16 / 9));
  aspect-ratio: 16 / 9;
  overflow: hidden;
  background: #1b1130;
  box-shadow: 0 0 48px rgba(0,0,0,.45);
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

/* ---------- HUD ---------- */
#hud {
  position: absolute;
  top: 0; left: 0; right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 14px 16px;
  pointer-events: none;
  z-index: 5;
}
#score { color: #fff; text-shadow: 0 2px 8px rgba(0,0,0,.5); flex-shrink: 0; }
#score .label { font-size: 12px; opacity: .85; margin-right: 6px; }
#scoreVal { font-family: 'Russo One', sans-serif; font-size: 26px; color: #ffd34d; }
#score .unit { font-size: 12px; opacity: .7; margin-left: 2px; }

#gauge {
  position: absolute;
  left: 50%;
  top: 14px;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
}
#gauge .label {
  color: #fff; font-size: 12px; letter-spacing: 1px;
  text-shadow: 0 2px 6px rgba(0,0,0,.5);
}
#gaugeBar {
  position: relative;
  width: min(220px, 32vw);
  height: 16px;
  border-radius: 10px;
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.25);
  overflow: hidden;
  box-shadow: inset 0 2px 4px rgba(0,0,0,.4);
}
#gaugeFill {
  height: 100%;
  width: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width .08s linear;
}
#gaugeFill.full   { animation: pulse 1.1s infinite; }
#gaugeFill.boosting { background: linear-gradient(90deg, #ff5e3a, #ff2e63); }
@keyframes pulse {
  0%,100% { box-shadow: 0 0 4px #ffd34d; }
  50%     { box-shadow: 0 0 14px #ffd34d; }
}

#lives { display: flex; gap: 6px; font-size: 19px; color: #ff5e6c; text-shadow: 0 2px 6px rgba(0,0,0,.6); flex-shrink: 0; }

/* ---------- 터치 컨트롤 ---------- */
#touch {
  position: absolute;
  left: 0; right: 0; bottom: 0;
  display: none;
  justify-content: space-between;
  align-items: flex-end;
  padding: 0 18px 26px;
  z-index: 4;
  pointer-events: none;
}
#laneBtns, #btnBoost { pointer-events: auto; }
#laneBtns { display: flex; gap: 16px; }
.ctrl-btn {
  width: 78px; height: 78px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.14);
  color: #fff;
  font-size: 26px;
  font-family: inherit;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0,0,0,.35);
  touch-action: none;
}
.ctrl-btn:active { transform: scale(.92); background: rgba(255,255,255,.28); }
#btnBoost {
  width: 96px; height: 96px;
  font-size: 18px; font-weight: bold; letter-spacing: 1px;
  background: rgba(255,122,60,.78);
  border-color: rgba(255,255,255,.5);
  box-shadow: 0 0 24px rgba(255,122,60,.6);
}
#btnBoost:active { transform: scale(.94); background: rgba(255,122,60,.98); }
@media (pointer: coarse) { #touch { display: flex; } }

/* ---------- 오버레이 ---------- */
.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  text-align: center;
  color: #fff;
  background: rgba(20,12,40,.55);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: 10;
  padding: 24px;
}
.overlay.hidden { display: none; }
.overlay h1 {
  font-size: 46px;
  letter-spacing: 2px;
  text-shadow: 0 4px 0 rgba(0,0,0,.4), 0 0 34px rgba(255,150,60,.55);
  animation: titleIn .7s ease both;
}
.overlay h1 span { color: var(--accent); }
@keyframes titleIn {
  from { opacity: 0; transform: translateY(-18px) scale(.95); }
  to   { opacity: 1; transform: none; }
}
.overlay .sub { font-size: 15px; opacity: .92; max-width: 460px; line-height: 1.7; }
.controls { font-size: 13px; opacity: .85; line-height: 2.2; color: #ffe9c9; }
kbd {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.35);
  border-bottom-width: 3px;
  border-radius: 6px;
  padding: 1px 7px;
  font-family: inherit;
  font-size: 12px;
}
.overlay h2 { font-size: 38px; color: #ff5e6c; text-shadow: 0 4px 0 rgba(0,0,0,.35); }
#finalScore { font-family: 'Russo One', sans-serif; font-size: 46px; color: var(--accent); }
#bestScore { font-size: 14px; opacity: .8; }
.overlay button {
  font-family: inherit;
  font-size: 22px;
  letter-spacing: 2px;
  padding: 14px 54px;
  border: none;
  border-radius: 14px;
  color: #4a2300;
  background: linear-gradient(180deg, var(--accent), var(--accent2));
  box-shadow: 0 6px 0 #b3542a, 0 8px 22px rgba(255,120,60,.45);
  cursor: pointer;
  animation: btnIn .5s ease .15s both;
}
.overlay button:active {
  transform: translateY(4px);
  box-shadow: 0 2px 0 #b3542a, 0 4px 12px rgba(255,120,60,.4);
}
@keyframes btnIn { from { opacity: 0; transform: scale(.9); } to { opacity: 1; transform: none; } }

@media (max-width: 560px), (max-height: 360px) {
  #hud { padding: 5px 7px; }
  #score .label, #score .unit, #gauge .label { font-size: 8px; }
  #scoreVal { font-size: 16px; }
  #gauge { top: 5px; gap: 4px; }
  #gaugeBar { width: min(120px, 32vw); height: 10px; }
  #lives { gap: 3px; font-size: 12px; }

  #touch { padding: 0 8px 8px; }
  #laneBtns { gap: 8px; }
  .ctrl-btn { width: 40px; height: 40px; font-size: 15px; }
  #btnBoost { width: 50px; height: 50px; font-size: 10px; }

  .overlay { gap: 6px; padding: 8px; }
  .overlay h1 { font-size: 25px; letter-spacing: 1px; }
  .overlay .sub { max-width: 96%; font-size: 9px; line-height: 1.3; }
  .controls { font-size: 8px; line-height: 1.5; }
  kbd { border-bottom-width: 2px; border-radius: 4px; padding: 0 4px; font-size: 8px; }
  .overlay h2 { font-size: 24px; }
  #finalScore { font-size: 28px; }
  #bestScore { font-size: 9px; }
  .overlay button {
    font-size: 13px;
    letter-spacing: 1px;
    padding: 7px 30px;
    border-radius: 8px;
    box-shadow: 0 3px 0 #b3542a, 0 4px 12px rgba(255,120,60,.4);
  }
}
