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

html, body {
  width: 100%; height: 100%; overflow: hidden;
  background: #14091f;
  font-family: "Hiragino Sans", "Yu Gothic", "Meiryo", sans-serif;
  color: #f2e9ff;
  user-select: none;
}

#game {
  position: fixed; inset: 0;
  display: block;
  width: 100%; height: 100%;
  background: #1a0f2e;
}

.hidden { display: none !important; }

.overlay {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: rgba(10, 4, 20, 0.72);
  z-index: 20;
}

.panel {
  background: linear-gradient(160deg, #2a1444 0%, #1a0d2e 100%);
  border: 2px solid #7d4fd6;
  box-shadow: 0 0 30px rgba(157, 92, 255, 0.45), inset 0 0 20px rgba(157,92,255,0.08);
  border-radius: 16px;
  padding: 32px 36px;
  max-width: 520px;
  width: 90%;
  max-height: 85vh;
  overflow-y: auto;
  text-align: center;
}

.panel h1 {
  font-size: 32px;
  color: #e7c9ff;
  text-shadow: 0 0 12px #b083ff;
  letter-spacing: 2px;
}

.panel h2 {
  font-size: 18px;
  color: #c9a8ff;
  margin-top: 4px;
  font-weight: 400;
}

.lore {
  margin: 20px 0;
  line-height: 1.8;
  font-size: 13px;
  color: #cbb8ea;
}

.lore-details {
  text-align: left;
  margin: -8px 0 14px;
  background: rgba(157, 92, 255, 0.06);
  border: 1px solid rgba(106, 63, 181, 0.5);
  border-radius: 8px;
  padding: 8px 12px;
}
.lore-details summary {
  cursor: pointer;
  font-size: 12px;
  color: #c9a8ff;
  letter-spacing: 0.5px;
}
.lore-details summary:hover { color: #e7c9ff; }
.lore-extra {
  margin-top: 8px;
  font-size: 12px;
  line-height: 1.8;
  color: #b8a6d9;
}

.field { margin: 18px 0 10px; text-align: left; }
.field label, .field-label-standalone { display: block; font-size: 12px; color: #b39ddb; margin-bottom: 6px; }
.field input {
  width: 100%; padding: 10px 12px;
  background: #12081f; border: 1px solid #6a3fb5;
  border-radius: 8px; color: #f2e9ff; font-size: 14px;
}
.field input:focus { outline: none; border-color: #c792ea; }

.stage-list { display: flex; flex-direction: column; gap: 8px; }
.stage-card {
  text-align: left;
  padding: 10px 12px;
  background: rgba(157,92,255,0.05);
  border: 1px solid #4a2e7d;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.stage-card:hover { background: rgba(157,92,255,0.14); }
.stage-card.selected { border-color: #c792ea; background: rgba(157,92,255,0.22); }
.stage-card-head { display: flex; justify-content: space-between; align-items: baseline; }
.stage-name { font-size: 13px; font-weight: 700; color: #e7c9ff; }
.stage-diff { font-size: 11px; font-weight: 700; }
.stage-desc { margin-top: 4px; font-size: 11px; line-height: 1.6; color: #a893cf; }

.stage-tag { color: #a685ff; }

button {
  display: block; width: 100%;
  margin-top: 14px;
  padding: 13px 18px;
  border: none; border-radius: 10px;
  background: linear-gradient(135deg, #9d5cff, #6a3fb5);
  color: #fff; font-size: 15px; font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(157, 92, 255, 0.35);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
button:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(157, 92, 255, 0.5); }
button:active { transform: translateY(0); }
button.secondary {
  background: transparent;
  border: 1px solid #6a3fb5;
  color: #c9a8ff;
  box-shadow: none;
}

.controls {
  margin-top: 18px;
  font-size: 11px;
  color: #8a76b0;
  line-height: 1.6;
}

/* HUD */
#hud {
  position: fixed; top: 0; left: 0; right: 0;
  padding: 14px 18px;
  z-index: 10;
  pointer-events: none;
}

.top-bar {
  display: flex; align-items: center; gap: 16px;
}

.hp-wrap, .watch-wrap { flex: 1; }
.watch-wrap { max-width: 180px; }
.hp-wrap { max-width: 260px; }

.bar-label {
  font-size: 10px; color: #cbb8ea; margin-bottom: 3px; letter-spacing: 1px;
}

.bar {
  height: 14px; border-radius: 7px;
  background: rgba(20, 9, 31, 0.75);
  border: 1px solid rgba(157, 92, 255, 0.4);
  overflow: hidden;
}
.bar .fill { height: 100%; width: 0%; transition: width 0.15s ease; }
.hp-bar .fill { background: linear-gradient(90deg, #ff5c8a, #ff2e63); }
.watch-bar .fill { background: linear-gradient(90deg, #ffd76a, #ffb020); }

.timer {
  font-size: 20px; font-weight: 700;
  color: #f2e9ff; text-shadow: 0 0 8px rgba(157,92,255,0.6);
  min-width: 90px; text-align: center;
}

.stats-row {
  margin-top: 8px;
  display: flex; gap: 18px; flex-wrap: wrap;
  font-size: 12px; color: #c9a8ff;
}

.xp-bar {
  position: fixed; left: 0; right: 0; bottom: 0;
  height: 8px; background: rgba(20,9,31,0.8);
}
.xp-bar .fill { height: 100%; width: 0%; background: linear-gradient(90deg, #6ae3ff, #6a8fff); transition: width 0.2s ease; }

.watch-ready {
  margin-top: 10px;
  font-size: 13px; color: #ffd76a;
  text-shadow: 0 0 10px rgba(255, 215, 106, 0.8);
  animation: pulse 1s infinite;
}
@keyframes pulse { 0%,100% { opacity: 0.5; } 50% { opacity: 1; } }

.sub { font-size: 12px; color: #a893cf; margin-top: 4px; margin-bottom: 16px; }

.choices { display: flex; flex-direction: column; gap: 10px; margin-top: 6px; }
.choice-btn {
  text-align: left;
  padding: 14px 16px;
  background: rgba(157,92,255,0.08);
  border: 1px solid #6a3fb5;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
}
.choice-btn:hover { background: rgba(157,92,255,0.22); border-color: #c792ea; }
.choice-btn .c-name { font-weight: 700; color: #e7c9ff; font-size: 14px; }
.choice-btn .c-desc { font-size: 11px; color: #b8a6d9; margin-top: 4px; }

.result-stats { margin: 18px 0; font-size: 14px; line-height: 2; color: #dcc9ff; }

.leaderboard {
  margin-top: 12px; text-align: left;
  list-style: decimal-leading-zero inside;
  font-size: 13px; color: #dcc9ff;
  max-height: 220px; overflow-y: auto;
}
.leaderboard li { padding: 6px 4px; border-bottom: 1px solid rgba(157,92,255,0.15); display: flex; justify-content: space-between; }
.leaderboard .lb-name { font-weight: 700; }
.leaderboard .lb-meta { color: #9a86c0; font-size: 11px; }

#leaderboardWrap { margin-top: 10px; }
