:root {
  --bg: #0f1220;
  --surface: #171a2f;
  --text: #e8ebff;
  --muted: #a6addd;
  --accent: #6aa9ff;
  --accent-2: #8ef1c7;
  --danger: #ff6b6b;
  --warning: #ffd479;
  --ok: #82e482;
  --focus: #ffffff;
  --shadow: 0 10px 30px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: radial-gradient(1200px 600px at 10% 10%, #141731, var(--bg));
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", "Meiryo", Arial, sans-serif;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  background: linear-gradient(180deg, #191c34, #141731);
  border-bottom: 1px solid #23284a;
  position: sticky;
  top: 0;
  z-index: 10;
}

.topbar h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: 0.5px;
}

.controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.select-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--muted);
}
select {
  background: var(--surface);
  color: var(--text);
  border: 1px solid #30365f;
  padding: 6px 8px;
  border-radius: 8px;
  outline: none;
}
select:focus { border-color: var(--accent); }

.primary, .ghost {
  border: 1px solid #2b315a;
  background: #1c2141;
  color: var(--text);
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform .05s ease, box-shadow .2s ease, background .2s ease;
}
.primary:hover, .ghost:hover { box-shadow: var(--shadow); }
.primary:active, .ghost:active { transform: translateY(1px) scale(.99); }
.primary { border-color: #3b79ff; background: #2852a9; }
.ghost { background: transparent; }

.container {
  max-width: 980px;
  margin: 0 auto;
  padding: 20px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-bottom: 20px;
}
.stat {
  background: var(--surface);
  border: 1px solid #2a2f55;
  border-radius: 12px;
  padding: 10px 12px;
}
.stat .label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 6px;
}

.game {
  background: rgba(23,26,47,0.55);
  border: 1px solid #2a2f55;
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}

.prompt {
  min-height: 90px;
  border-radius: 12px;
  background: #12142a;
  border: 1px dashed #2c3158;
  padding: 12px 14px;
  margin-bottom: 12px;
}
#promptBuffer {
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 20px;
  line-height: 1.6;
}
#promptBuffer .done { color: var(--ok); }
#promptBuffer .current { color: var(--focus); text-decoration: underline; text-decoration-thickness: 2px; }
#promptBuffer .remaining { color: var(--muted); }

.input-wrap {
  display: flex;
  gap: 10px;
  align-items: center;
}
input[type="text"] {
  flex: 1;
  padding: 12px 14px;
  border-radius: 12px;
  border: 1px solid #2a2f55;
  background: #0f1220;
  color: var(--text);
  font-family: "SF Mono", Menlo, Consolas, monospace;
  font-size: 18px;
  outline: none;
}
input[type="text"]:focus { border-color: var(--accent-2); box-shadow: 0 0 0 3px rgba(142,241,199,.15); }
input[disabled] { opacity: .6; cursor: not-allowed; }

.progressbar {
  height: 8px;
  background: #22264a;
  border-radius: 999px;
  overflow: hidden;
  margin: 14px 0;
}
#progressBarFill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width .2s ease;
}

.help {
  margin-top: 6px;
  color: var(--muted);
}
.help summary { cursor: pointer; }

.stage-list {
  margin-top: 18px;
}
.stage-list h2 {
  margin: 0 0 10px 0;
  font-size: 18px;
  color: var(--muted);
}
.stages {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
}
.stage-btn {
  padding: 10px 12px;
  border-radius: 12px;
  border: 1px solid #2a2f55;
  background: #151837;
  color: var(--text);
  cursor: pointer;
  transition: transform .05s ease, box-shadow .2s ease, background .2s ease;
  text-align: left;
}
.stage-btn:hover { box-shadow: var(--shadow); }
.stage-btn:active { transform: translateY(1px) scale(.99); }
.stage-btn .title {
  display: block;
  font-weight: 600;
}
.stage-btn .desc {
  display: block;
  color: var(--muted);
  font-size: 13px;
}

.footer {
  text-align: center;
  color: var(--muted);
  padding: 30px 0;
}

.result {
  margin-top: 20px;
  background: rgba(23,26,47,0.65);
  border: 1px solid #2a2f55;
  border-radius: 16px;
  padding: 18px;
  box-shadow: var(--shadow);
}
.hidden { display: none; }

.summary {
  list-style: none;
  padding: 0;
  margin: 0 0 12px 0;
}
.summary li {
  margin: 6px 0;
}

.result-actions {
  display: flex;
  gap: 10px;
}
