:root {
  --bg: #0b0f14;
  --panel: #131d2b;
  --panel-2: #132133;
  --panel-3: #0f1c2d;
  --line: #29415e;
  --line-strong: #365173;
  --text: #e7eef8;
  --muted: #9cb0c6;
  --accent: #55c5ff;
  --accent-2: #93f7cd;
  --danger: #ff7d7d;
  --warn: #ffd479;
  --shadow: 0 18px 42px rgba(0, 0, 0, 0.28);
  --radius: 18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(900px 460px at 15% -10%, #163560 0%, rgba(22, 53, 96, 0) 60%),
    radial-gradient(900px 520px at 100% 0%, #123b58 0%, rgba(18, 59, 88, 0) 55%),
    linear-gradient(180deg, #08101a 0%, #0b0f14 100%);
  color: var(--text);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

button, input, select {
  font: inherit;
}

button {
  touch-action: manipulation;
}

.shell {
  width: min(1120px, calc(100vw - 24px));
  margin: 0 auto;
  padding: 18px 0 32px;
}

.breadcrumb {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 14px;
  color: var(--muted);
  font-size: 14px;
}

.breadcrumb a {
  color: var(--accent);
  text-decoration: none;
}

.breadcrumb a:hover {
  text-decoration: underline;
}

.top {
  margin-bottom: 16px;
}

h1 {
  margin: 0;
  font-size: clamp(28px, 4vw, 42px);
  line-height: 1.05;
}

.hud {
  display: grid;
  gap: 14px;
  grid-template-columns: repeat(4, minmax(0, 1fr)) minmax(220px, 260px) auto auto;
  margin-bottom: 14px;
  align-items: stretch;
}

.stat {
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 12px;
  background: linear-gradient(180deg, rgba(19, 29, 43, 0.96), rgba(15, 28, 45, 0.98));
  box-shadow: var(--shadow);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  margin-bottom: 4px;
}

.stat strong {
  font-size: 20px;
}

.difficulty-control {
  display: grid;
  gap: 6px;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(19, 29, 43, 0.96), rgba(15, 28, 45, 0.98));
  box-shadow: var(--shadow);
}

.difficulty-control span {
  color: var(--muted);
  font-size: 12px;
}

select,
.input-answer {
  border: 1px solid var(--line);
  background: rgba(9, 17, 28, 0.96);
  color: var(--text);
  border-radius: 12px;
  padding: 10px 12px;
  min-height: 46px;
  outline: none;
}

select:focus,
.input-answer:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(85, 197, 255, 0.18);
}

.btn {
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  min-height: 46px;
  padding: 10px 14px;
  color: var(--text);
  background: linear-gradient(180deg, rgba(28, 44, 68, 0.96), rgba(15, 28, 45, 0.96));
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, opacity 120ms ease;
}

.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }
.btn:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.btn-primary {
  background: linear-gradient(180deg, rgba(73, 149, 196, 0.32), rgba(15, 28, 45, 0.96));
}

.btn-ghost {
  background: linear-gradient(180deg, rgba(28, 44, 68, 0.96), rgba(15, 28, 45, 0.96));
}

.btn-secondary {
  background: linear-gradient(180deg, rgba(31, 42, 60, 0.96), rgba(12, 20, 32, 0.96));
}

.combat-summary {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr 1fr;
  margin-bottom: 14px;
}

.combat-card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px;
  background: linear-gradient(180deg, rgba(19, 29, 43, 0.96), rgba(15, 28, 45, 0.98));
  box-shadow: var(--shadow);
}

.combat-card-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.panel {
  background: linear-gradient(180deg, rgba(19, 29, 43, 0.96), rgba(15, 28, 45, 0.98));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel-label {
  padding: 12px 14px 0;
  color: var(--muted);
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.bar {
  height: 12px;
  border-radius: 999px;
  overflow: hidden;
  background: rgba(11, 18, 28, 0.86);
  border: 1px solid var(--line);
}

.bar-fill {
  height: 100%;
  width: 100%;
  transition: width 180ms ease;
}

.player-fill {
  background: linear-gradient(90deg, #69c2ff, #93f7cd);
}

.enemy-fill {
  background: linear-gradient(90deg, #ff8f8f, #ffd479);
}

.split-layout {
  display: grid;
  grid-template-rows: 1fr 1.05fr;
  gap: 14px;
  min-height: 68vh;
}

.battle-panel,
.question-panel {
  display: flex;
  flex-direction: column;
}

.battle-stage {
  display: grid;
  grid-template-columns: 1fr minmax(220px, 0.9fr) 1fr;
  gap: 14px;
  align-items: center;
  padding: 18px;
  min-height: 300px;
}

.avatar-card {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 16px;
  background: rgba(9, 17, 28, 0.42);
}

.sprite-frame {
  min-height: 164px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background:
    radial-gradient(circle at 50% 18%, rgba(85, 197, 255, 0.22), transparent 50%),
    linear-gradient(180deg, rgba(17, 29, 44, 0.95), rgba(9, 17, 28, 0.95));
  border: 1px solid rgba(54, 81, 115, 0.85);
  margin-bottom: 12px;
}

.enemy-card .sprite-frame {
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 125, 125, 0.24), transparent 52%),
    linear-gradient(180deg, rgba(44, 24, 33, 0.92), rgba(19, 17, 28, 0.95));
}

.sprite {
  font-size: clamp(70px, 10vw, 108px);
  line-height: 1;
  user-select: none;
}

.battle-center {
  text-align: center;
}

.floor-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 14px;
  margin-bottom: 12px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(9, 17, 28, 0.62);
  color: var(--accent-2);
  font-weight: 700;
}

.message-line {
  min-height: 52px;
  display: grid;
  place-items: center;
  border-radius: 16px;
  padding: 12px;
  background: rgba(9, 17, 28, 0.42);
  border: 1px solid var(--line);
  margin-bottom: 12px;
}

.intent-chip {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-height: 34px;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(85, 197, 255, 0.12);
  border: 1px solid rgba(85, 197, 255, 0.28);
  color: var(--accent);
  font-size: 13px;
}

.combat-log {
  list-style: none;
  padding: 0;
  margin: 12px 0 0;
  display: grid;
  gap: 8px;
  text-align: left;
}

.combat-log li {
  padding: 8px 10px;
  border-radius: 12px;
  border: 1px solid rgba(54, 81, 115, 0.55);
  background: rgba(9, 17, 28, 0.34);
  color: var(--muted);
  font-size: 13px;
}

.avatar-meta {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  color: var(--muted);
}

.question-header {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
  padding: 16px 18px 8px;
}

.question-header h2 {
  margin: 0 0 8px;
  font-size: clamp(24px, 3.6vw, 36px);
  line-height: 1.15;
}

.question-header h2:lang(ja) {
  letter-spacing: 0.03em;
}

.question-prompt {
  margin: 0;
  color: var(--muted);
}

.word-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: flex-end;
}

.pill {
  display: inline-flex;
  min-height: 32px;
  align-items: center;
  padding: 0 12px;
  border-radius: 999px;
  background: rgba(9, 17, 28, 0.52);
  border: 1px solid var(--line);
  color: var(--muted);
  font-size: 13px;
}

.answer-area {
  padding: 12px 18px 8px;
  display: grid;
  gap: 10px;
  flex: 1;
  align-content: start;
}

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

.answer-btn {
  text-align: left;
  justify-content: flex-start;
  padding: 12px 14px;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  border-radius: 14px;
}

.answer-btn strong {
  font-size: 16px;
  line-height: 1.25;
}

.answer-btn:lang(ja) strong {
  font-size: 19px;
}

.answer-btn span {
  color: var(--muted);
  font-size: 12px;
}

.answer-btn.correct {
  border-color: rgba(147, 247, 205, 0.7);
  box-shadow: 0 0 0 3px rgba(147, 247, 205, 0.16);
}

.answer-btn.wrong {
  border-color: rgba(255, 125, 125, 0.75);
  box-shadow: 0 0 0 3px rgba(255, 125, 125, 0.14);
}

.typed-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
}

.support-line {
  min-height: 48px;
  margin: 0;
  padding: 0 18px 18px;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.45;
}

.message {
  margin: 14px 0 0;
  min-height: 24px;
  color: var(--muted);
}

.message.good { color: var(--accent-2); }
.message.bad { color: var(--danger); }

.footer-nav {
  margin-top: 16px;
}

.link-btn {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
  padding: 0 14px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(19, 29, 43, 0.96), rgba(15, 28, 45, 0.98));
  color: var(--text);
  text-decoration: none;
}

.link-btn:hover {
  border-color: var(--accent);
}

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

@media (max-width: 860px) {
  .combat-summary {
    grid-template-columns: 1fr;
  }

  .split-layout {
    display: flex;
    flex-direction: column;
    min-height: auto;
  }

  .question-panel {
    order: 1;
  }

  .battle-panel {
    order: 2;
  }

  .battle-stage {
    grid-template-columns: 1fr;
    min-height: auto;
  }

  .question-header {
    flex-direction: column;
    align-items: stretch;
  }

  .word-meta {
    justify-content: flex-start;
  }
}

@media (max-width: 680px) {
  .answers-choices {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .shell {
    width: min(100vw - 14px, 100%);
    padding-top: 14px;
  }

  .hud,
  .typed-wrap {
    grid-template-columns: 1fr;
  }

  .sprite-frame {
    min-height: 130px;
  }

  .support-line {
    padding-bottom: 14px;
  }
}