:root {
  --navy: #1c2a44;
  --navy2: #26385c;
  --blue: #3a6ea5;
  --gold: #e8b23a;
  --ok: #3fbf7f;
  --bad: #e05252;
  --wall: #cdd6e0;
  --floor: #b9a07c;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background:
    radial-gradient(1200px 700px at 50% 20%, #1f2a40, #10151f 70%);
  font-family: "Hiragino Kaku Gothic ProN", "Yu Gothic UI", Meiryo, system-ui, sans-serif;
  color: #fff;
  user-select: none;
}

body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}

#stage {
  position: relative;
  width: min(96vw, 980px);
  max-height: 92vh;
  aspect-ratio: 16 / 10;
  border-radius: 18px;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,.12);
  box-shadow: 0 24px 80px rgba(0,0,0,.6);
  background: #10151f;
}

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

.hidden { display: none !important; }

/* ---- HUD ---- */
#hud {
  position: absolute; inset: 0;
  pointer-events: none;
  z-index: 5;
}

.hud-top {
  display: flex; align-items: flex-start; justify-content: space-between;
  padding: 14px 18px;
  gap: 10px;
}

#phaseBadge {
  background: var(--navy);
  border: 1px solid rgba(255,255,255,.15);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 700;
  letter-spacing: .1em;
  font-size: 14px;
  color: #ffd76a;
}

#clockDisplay {
  font-variant-numeric: tabular-nums;
  font-size: 34px;
  font-weight: 800;
  letter-spacing: .02em;
  background: rgba(0,0,0,.45);
  padding: 4px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.2);
  text-align: center;
}
#clockDisplay.warn { color: var(--bad); }
#clockDisplay.ok { color: var(--ok); }

#timeBlock { display: flex; flex-direction: column; align-items: center; gap: 5px; }
#targets { display: flex; gap: 12px; }
.target {
  font-size: 13px;
  background: rgba(0,0,0,.35);
  padding: 4px 12px;
  border-radius: 999px;
  color: #cdd7e4;
  border: 1px solid rgba(255,255,255,.12);
  letter-spacing: .03em;
}
.target.active { color: #fff; font-weight: 800; background: var(--navy2); border-color: var(--gold); }
.target.active.in { color: var(--gold); }
.target.active.out { color: var(--blue); }

#scoreWrap {
  position: absolute;
  left: 50%; top: 12px;
  transform: translateX(-50%);
  text-align: center;
  background: rgba(0,0,0,.4);
  padding: 6px 18px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.15);
  z-index: 6;
}
#scoreLabel { font-size: 11px; opacity: .7; letter-spacing: .2em; }
#scoreValue { font-size: 22px; font-weight: 800; color: var(--gold); font-variant-numeric: tabular-nums; line-height: 1; }
#combo { font-size: 13px; color: var(--ok); font-weight: 700; min-height: 18px; margin-top: 2px; }

/* ---- Verdict ---- */
#verdict {
  position: absolute; left: 50%; top: 42%;
  transform: translate(-50%, -50%);
  z-index: 10;
  text-align: center;
  background: linear-gradient(180deg, rgba(28,42,68,.96), rgba(20,28,46,.96));
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 18px;
  padding: 22px 26px 26px;
  min-width: 300px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  animation: pop .18s ease;
}
@keyframes pop { from { transform: translate(-50%,-50%) scale(.85); opacity: 0; } }

#verdictPrompt { font-size: 17px; font-weight: 700; margin-bottom: 18px; letter-spacing: .05em; }
#verdictBtns { display: flex; gap: 14px; justify-content: center; }

.btn {
  cursor: pointer;
  border: none;
  font-family: inherit;
  font-weight: 800;
  font-size: 16px;
  color: #fff;
  padding: 12px 22px;
  border-radius: 12px;
  letter-spacing: .05em;
  transition: transform .08s ease, filter .12s ease;
  box-shadow: 0 6px 0 rgba(0,0,0,.3);
}
.btn:active { transform: translateY(3px); box-shadow: 0 3px 0 rgba(0,0,0,.3); }
.btn.warn { background: linear-gradient(180deg, #e05252, #c13a3a); }
.btn.ok { background: linear-gradient(180deg, #3fbf7f, #2f9a64); }
.btn.big { font-size: 20px; padding: 15px 34px; margin-top: 8px; }
.btn:hover { filter: brightness(1.08); }
.btn kbd {
  margin-left: 8px;
  background: rgba(0,0,0,.28);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: 5px;
  padding: 1px 7px;
  font-size: 13px;
  font-family: inherit;
}
#verdictHint { margin-top: 14px; font-size: 12px; color: #9fb0c4; letter-spacing: .02em; }
#verdictHint kbd {
  background: #2a3550; border: 1px solid rgba(255,255,255,.2);
  border-radius: 4px; padding: 0 5px; font-family: inherit; font-weight: 800;
  color: #d7e2f0;
}

/* ---- Flash text ---- */
#flashText {
  position: absolute; left: 50%; top: 18%;
  transform: translateX(-50%);
  z-index: 12;
  font-size: 26px;
  font-weight: 900;
  padding: 8px 22px;
  border-radius: 12px;
  background: rgba(0,0,0,.6);
  pointer-events: none;
  animation: rise 1.4s ease forwards;
}
@keyframes rise {
  0% { opacity: 0; transform: translate(-50%, 14px); }
  15% { opacity: 1; transform: translate(-50%, 0); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -26px); }
}

/* ---- Panels ---- */
.panel {
  position: absolute; left: 50%; top: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  background: linear-gradient(180deg, rgba(28,42,68,.97), rgba(18,26,44,.97));
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 22px;
  padding: 22px 30px;
  text-align: center;
  max-width: 84%;
  max-height: 82%;
  overflow: auto;
  box-shadow: 0 24px 70px rgba(0,0,0,.55);
}
.panel h1 { font-size: 34px; letter-spacing: .12em; color: var(--gold); margin-bottom: 12px; text-shadow: 0 2px 0 rgba(0,0,0,.3); }
.panel p { line-height: 1.8; color: #e8edf5; font-size: 15px; margin-bottom: 14px; }

.rules {
  text-align: left;
  display: inline-block;
  margin-bottom: 14px;
  background: rgba(0,0,0,.25);
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 14px;
  line-height: 1.9;
}
.rules b { color: var(--gold); }
.okdot { display:inline-block; width:10px; height:10px; border-radius:50%; background: var(--ok); margin: 0 4px; }
.badred { display:inline-block; width:10px; height:10px; border-radius:50%; background: var(--bad); margin: 0 4px; }

.ops {
  text-align: left;
  display: inline-block;
  width: 100%;
  margin-bottom: 12px;
  background: rgba(0,0,0,.25);
  border-radius: 14px;
  padding: 12px 18px;
  font-size: 14px;
  line-height: 1.9;
}
.ops .keys { margin-top: 4px; color: #cdd7e4; }
.ops .keys span { color: var(--bad); font-weight: 800; }
.ops .keys span.ok { color: var(--ok); }
.ops kbd {
  background: #2a3550; border: 1px solid rgba(255,255,255,.2);
  border-radius: 5px; padding: 1px 7px; font-family: inherit; font-weight: 800;
}

#resultScore { font-size: 46px; font-weight: 900; color: var(--gold); margin: 8px 0 4px; font-variant-numeric: tabular-nums; }
#resultRank { font-size: 22px; font-weight: 800; margin-bottom: 8px; letter-spacing: .05em; }
#resultStats { font-size: 14px; color: #c8d2e0; line-height: 2; margin-bottom: 20px; }

@media (max-width: 520px) {
  #clockDisplay { font-size: 26px; }
  #scoreWrap { top: 10px; right: auto; }
  #verdict { min-width: 240px; }
}
