:root {
  color-scheme: light;
  --ink: #1d2433;
  --muted: #5c677d;
  --paper: #fffdf7;
  --line: #d9dfec;
  --blue: #2e69d1;
  --green: #20896a;
  --red: #c74444;
  --gold: #d99118;
  --violet: #6d4fd3;
  --shadow: 0 18px 45px rgba(34, 51, 84, 0.16);
}

* {
  box-sizing: border-box;
}

body {
  min-height: 100vh;
  margin: 0;
  font-family: "Yu Gothic", "Meiryo", system-ui, sans-serif;
  color: var(--ink);
  background:
    linear-gradient(135deg, rgba(46, 105, 209, 0.15), transparent 32%),
    linear-gradient(315deg, rgba(32, 137, 106, 0.13), transparent 34%),
    #f5f7fb;
}

button {
  font: inherit;
}

.app {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 32px 0;
}

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 18px;
}

.eyebrow {
  margin: 0 0 5px;
  color: var(--green);
  font-weight: 700;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 4vw, 4.2rem);
  line-height: 1;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(3, minmax(74px, 1fr));
  gap: 10px;
  min-width: 310px;
}

.scoreboard div,
.hero-card,
.monster-card,
.event-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 8px 18px rgba(34, 51, 84, 0.08);
}

.scoreboard div {
  padding: 10px 12px;
}

.scoreboard span {
  display: block;
  color: var(--muted);
  font-size: 0.88rem;
}

.scoreboard strong {
  display: block;
  margin-top: 3px;
  font-size: 1.55rem;
}

.adventure,
.game-panel,
.notebook {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.96);
  box-shadow: var(--shadow);
}

.adventure {
  padding: 16px;
  margin-bottom: 18px;
}

.stage-map {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 10px;
  margin-bottom: 14px;
}

.stage-node {
  min-height: 74px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: white;
  padding: 10px;
}

.stage-node span {
  display: block;
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.stage-node strong {
  display: block;
  margin-top: 4px;
  line-height: 1.25;
}

.stage-node.active {
  border-color: var(--blue);
  background: #eef4ff;
}

.stage-node.clear {
  border-color: var(--green);
  background: #ebf8f3;
}

.battlefield {
  display: grid;
  grid-template-columns: 1fr minmax(260px, 1.2fr) 1fr;
  gap: 12px;
  align-items: stretch;
}

.hero-card,
.monster-card {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 132px;
  padding: 12px;
}

.monster-card.boss {
  border-color: var(--violet);
  background: #f5f1ff;
}

.sprite {
  display: grid;
  place-items: center;
  flex: 0 0 72px;
  width: 72px;
  height: 72px;
  border-radius: 8px;
  color: white;
  font-size: 1.35rem;
  font-weight: 900;
}

.hero-sprite {
  background: linear-gradient(135deg, #2e69d1, #20896a);
}

.monster-sprite {
  background: linear-gradient(135deg, #48a2db, #20896a);
}

.monster-card.boss .monster-sprite {
  background: linear-gradient(135deg, #3b1a72, #c74444);
  font-size: 1.75rem;
}

.combat-info {
  flex: 1;
  min-width: 0;
}

.name-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
  line-height: 1.35;
}

.name-row strong {
  overflow-wrap: anywhere;
}

.name-row span {
  flex: 0 0 auto;
  color: var(--muted);
  font-weight: 800;
}

.hp-bar {
  height: 13px;
  overflow: hidden;
  border-radius: 999px;
  background: #e4e8f1;
}

.hp-bar span {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  background: var(--green);
  transition: width 220ms ease;
}

.hp-bar.monster span {
  background: var(--red);
}

.event-card {
  min-height: 132px;
  padding: 14px;
  display: grid;
  align-content: center;
}

.event-card p {
  margin: 0;
  font-weight: 800;
  line-height: 1.55;
}

.event-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.event-actions:empty {
  display: none;
}

.game-panel {
  padding: 20px;
}

.mode-row {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 22px;
}

.mode,
.primary,
.secondary,
.option,
.event-button {
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease;
}

.mode {
  background: white;
  color: var(--muted);
  font-weight: 700;
}

.mode.active {
  border-color: var(--blue);
  color: white;
  background: var(--blue);
}

.question-area {
  min-height: 320px;
  display: grid;
  align-content: start;
}

.mode-label {
  margin: 0 0 12px;
  color: var(--green);
  font-weight: 800;
}

.question-area h2 {
  min-height: 86px;
  margin: 0 0 18px;
  font-size: clamp(1.35rem, 2.45vw, 2.2rem);
  line-height: 1.35;
}

.options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.option {
  width: 100%;
  min-height: 76px;
  padding: 12px 14px;
  background: white;
  color: var(--ink);
  text-align: left;
  font-weight: 800;
  line-height: 1.35;
}

.option:hover,
.mode:hover,
.primary:hover,
.secondary:hover,
.event-button:hover {
  transform: translateY(-1px);
}

.option.correct {
  border-color: var(--green);
  background: #e8f8f2;
}

.option.wrong {
  border-color: var(--red);
  background: #fff0f0;
}

.feedback {
  min-height: 82px;
  margin-top: 16px;
  padding: 14px;
  border-radius: 8px;
  background: #eef3ff;
  color: var(--ink);
  font-weight: 700;
  line-height: 1.5;
}

.feedback:empty {
  visibility: hidden;
}

.actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 14px;
}

.primary,
.secondary,
.event-button {
  padding: 0 18px;
  font-weight: 800;
}

.primary,
.event-button {
  border-color: var(--blue);
  background: var(--blue);
  color: white;
}

.primary:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

.secondary {
  background: white;
  color: var(--blue);
}

.event-button.gold {
  border-color: var(--gold);
  background: var(--gold);
}

.notebook {
  margin-top: 18px;
  padding: 18px;
}

.notebook h2 {
  margin: 0 0 12px;
  font-size: 1.25rem;
}

.notebook-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.note {
  min-height: 92px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px;
  background: white;
}

.note strong {
  display: block;
  margin-bottom: 5px;
}

.note span {
  color: var(--muted);
  line-height: 1.45;
}

@media (max-width: 900px) {
  .battlefield {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .app {
    width: min(100% - 20px, 1120px);
    padding: 18px 0;
  }

  .topbar {
    display: block;
  }

  .scoreboard,
  .mode-row,
  .options,
  .notebook-list,
  .stage-map {
    grid-template-columns: 1fr;
  }

  .scoreboard {
    min-width: 0;
    margin-top: 16px;
  }

  .question-area {
    min-height: 390px;
  }

  .actions {
    justify-content: stretch;
  }

  .primary,
  .secondary {
    flex: 1;
  }
}
