:root {
  --sky-top: #f9fbff;
  --sky-bottom: #ffe1b6;
  --panel: rgba(255, 252, 246, 0.94);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --ink: #18324a;
  --ink-soft: #4f6782;
  --brand-red: #ff6a66;
  --brand-yellow: #ffd24d;
  --brand-green: #5dd48a;
  --brand-blue: #5aa8ff;
  --shadow: 0 24px 50px rgba(27, 58, 93, 0.18);
  --radius-xl: 28px;
  --radius-lg: 22px;
  --radius-md: 16px;
  --border-strong: 4px solid #18324a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", "Avenir Next", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.95), transparent 32%),
    radial-gradient(circle at 85% 18%, rgba(255, 248, 198, 0.88), transparent 24%),
    linear-gradient(180deg, var(--sky-top), var(--sky-bottom));
}

body {
  position: relative;
  overflow-x: hidden;
}

body::before,
body::after {
  content: "";
  position: fixed;
  inset: auto;
  pointer-events: none;
  z-index: 0;
}

body::before {
  width: 360px;
  height: 360px;
  top: 36px;
  left: -60px;
  background: radial-gradient(circle, rgba(255, 255, 255, 0.75), rgba(255, 255, 255, 0));
}

body::after {
  width: 280px;
  height: 280px;
  right: -70px;
  bottom: 20px;
  background: radial-gradient(circle, rgba(124, 214, 178, 0.3), rgba(124, 214, 178, 0));
}

.game-shell {
  position: relative;
  z-index: 1;
  width: min(1120px, calc(100% - 32px));
  margin: 24px auto 40px;
}

.game-header,
.status-ribbon,
.control-grid,
.battlefield {
  position: relative;
}

.game-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
  flex-wrap: wrap;
}

.eyebrow {
  margin: 0 0 8px;
  font-size: 0.88rem;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

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

.subcopy {
  margin: 10px 0 0;
  max-width: 560px;
  font-size: 1rem;
  color: var(--ink-soft);
}

.status-ribbon {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 18px;
}

.status-chip,
.panel-tag,
.combatant-role,
.battle-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 14px;
  border: var(--border-strong);
  border-radius: 999px;
  background: var(--panel-strong);
  box-shadow: 0 10px 22px rgba(24, 50, 74, 0.1);
  font-weight: 800;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.status-chip.accent {
  background: linear-gradient(135deg, #fff2a4, #ffe0a8);
}

.battlefield {
  display: grid;
  grid-template-columns: 1fr 180px 1fr;
  gap: 16px;
  align-items: stretch;
  padding: 20px;
  border-radius: var(--radius-xl);
  border: var(--border-strong);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(255, 248, 233, 0.98)),
    linear-gradient(135deg, rgba(255, 255, 255, 0.8), rgba(255, 244, 209, 0.8));
  box-shadow: var(--shadow);
}

.combatant-card {
  position: relative;
  padding: 20px;
  border-radius: var(--radius-lg);
  border: var(--border-strong);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 251, 255, 0.96));
  overflow: hidden;
}

.combatant-card::after {
  content: "";
  position: absolute;
  inset: -50% auto auto -16%;
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  filter: blur(6px);
}

.player-card {
  background:
    linear-gradient(180deg, rgba(235, 248, 255, 0.98), rgba(221, 243, 255, 0.94));
}

.enemy-card {
  background:
    linear-gradient(180deg, rgba(255, 242, 236, 0.98), rgba(255, 232, 226, 0.94));
}

.card-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.combatant-name {
  margin: 10px 0 0;
  font-size: clamp(1.4rem, 2vw, 1.9rem);
}

.sprite {
  position: relative;
  display: grid;
  place-items: center;
  min-height: 250px;
  margin: 12px 0 18px;
}

.sprite-core,
.hero-sprite::before,
.hero-sprite::after,
.enemy-sprite::before,
.enemy-sprite::after {
  position: absolute;
  content: "";
}

.hero-sprite .sprite-core {
  width: 126px;
  height: 152px;
  border-radius: 28px;
  border: var(--border-strong);
  background:
    linear-gradient(180deg, #89dbff 0 30%, #fff3ae 30% 55%, #4e9bff 55% 100%);
  box-shadow: 0 18px 0 rgba(24, 50, 74, 0.08);
}

.hero-sprite::before {
  width: 70px;
  height: 70px;
  border: var(--border-strong);
  border-radius: 50%;
  background: #ffe5bf;
  top: 24px;
  z-index: 2;
}

.hero-sprite::after {
  width: 154px;
  height: 54px;
  border-radius: 999px 999px 24px 24px;
  border: var(--border-strong);
  background: #3762b5;
  top: 6px;
  z-index: 3;
}

.enemy-sprite .sprite-core {
  width: 152px;
  height: 112px;
  border-radius: 60px 60px 42px 42px;
  border: var(--border-strong);
  background:
    radial-gradient(circle at 50% 30%, #fff6d5 0 16%, rgba(255, 246, 213, 0) 16%),
    linear-gradient(180deg, #ff9d72, #ff6557);
  box-shadow: 0 18px 0 rgba(24, 50, 74, 0.08);
}

.enemy-sprite::before {
  width: 32px;
  height: 32px;
  top: 30px;
  left: calc(50% - 56px);
  border-radius: 50%;
  border: var(--border-strong);
  background: #fff;
}

.enemy-sprite::after {
  width: 32px;
  height: 32px;
  top: 30px;
  right: calc(50% - 56px);
  border-radius: 50%;
  border: var(--border-strong);
  background: #fff;
}

.hero-sprite,
.enemy-sprite {
  isolation: isolate;
}

.hero-sprite .sprite-core::before,
.hero-sprite .sprite-core::after,
.enemy-sprite .sprite-core::before,
.enemy-sprite .sprite-core::after {
  content: "";
  position: absolute;
}

.hero-sprite .sprite-core::before {
  inset: 18px auto auto 26px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--ink);
  box-shadow: 54px 0 0 var(--ink);
}

.hero-sprite .sprite-core::after {
  left: 40px;
  top: 48px;
  width: 42px;
  height: 20px;
  border-bottom: 4px solid var(--ink);
  border-radius: 0 0 24px 24px;
}

.enemy-sprite .sprite-core::before {
  inset: 34px auto auto 40px;
  width: 16px;
  height: 24px;
  border-radius: 16px;
  background: var(--ink);
  box-shadow: 56px 0 0 var(--ink);
}

.enemy-sprite .sprite-core::after {
  left: 48px;
  bottom: 20px;
  width: 56px;
  height: 22px;
  border-top: 4px solid var(--ink);
  border-radius: 20px 20px 0 0;
}

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  font-weight: 800;
}

.hp-track {
  height: 20px;
  margin-top: 10px;
  border: var(--border-strong);
  border-radius: 999px;
  background: rgba(24, 50, 74, 0.1);
  overflow: hidden;
}

.hp-fill {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  transition: width 240ms ease;
}

.player-fill {
  background: linear-gradient(90deg, #75e4ff, #26a4f5);
}

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

.mp-track {
  margin-top: 10px;
  background: rgba(84, 92, 197, 0.12);
}

.mp-fill {
  background: linear-gradient(90deg, #90a0ff, #5762df);
}

.battle-center {
  display: grid;
  place-items: center;
  gap: 12px;
  text-align: center;
}

.battle-tip {
  margin: 0;
  max-width: 160px;
  color: var(--ink-soft);
  font-weight: 700;
}

.control-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(280px, 0.8fr);
  gap: 16px;
  margin-top: 16px;
}

.question-arena-shell,
.question-panel,
.log-panel {
  padding: 22px;
  border-radius: var(--radius-lg);
  border: var(--border-strong);
  background: var(--panel);
  box-shadow: var(--shadow);
}

.question-arena-shell {
  display: grid;
  gap: 18px;
}

.question-arena-head {
  display: grid;
  gap: 10px;
}

.question-arena-head p {
  margin: 0;
  color: var(--ink-soft);
  font-weight: 700;
}

.question-arena {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 16px;
}

.player-question-panel {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(246, 251, 255, 0.96));
  transition:
    transform 140ms ease,
    box-shadow 140ms ease,
    border-color 140ms ease;
}

.player-question-panel[data-character-id="mingxi"] {
  background:
    linear-gradient(180deg, rgba(239, 247, 255, 0.98), rgba(228, 242, 255, 0.95));
}

.player-question-panel[data-character-id="tingxi"] {
  background:
    linear-gradient(180deg, rgba(255, 249, 230, 0.98), rgba(255, 244, 211, 0.95));
}

.player-question-panel.is-active-player {
  border-color: #3762b5;
  box-shadow:
    0 0 0 6px rgba(55, 98, 181, 0.12),
    var(--shadow);
}

.player-question-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
}

.player-question-stage {
  margin: 10px 0 0;
  color: var(--ink-soft);
  font-weight: 800;
}

.player-question-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 10px 16px;
  margin: 16px 0 10px;
  font-weight: 800;
}

.player-question-stats span {
  padding: 8px 12px;
  border-radius: 999px;
  border: 3px solid rgba(24, 50, 74, 0.12);
  background: rgba(255, 255, 255, 0.76);
}

.mini-progress-track {
  height: 14px;
  margin-bottom: 14px;
  border-radius: 999px;
  border: 3px solid rgba(24, 50, 74, 0.12);
  background: rgba(24, 50, 74, 0.08);
  overflow: hidden;
}

.mini-progress-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #7ed9ff, #ffcc55);
  transition: width 240ms ease;
}

.skip-button {
  white-space: nowrap;
}

.panel-success {
  animation: panel-success 420ms ease-out;
}

.panel-failure {
  animation: panel-failure 420ms ease-out;
}

.question-text {
  margin: 16px 0 22px;
  font-size: clamp(1.2rem, 2.2vw, 1.8rem);
  font-weight: 800;
  line-height: 1.35;
}

.hint-panel {
  min-height: 152px;
  margin-bottom: 18px;
  padding: 16px;
  border: 3px dashed rgba(24, 50, 74, 0.24);
  border-radius: 20px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.94), rgba(248, 252, 255, 0.95));
}

.hint-panel.has-content {
  border-style: solid;
  border-color: rgba(90, 168, 255, 0.28);
  background:
    linear-gradient(180deg, rgba(244, 251, 255, 0.98), rgba(255, 251, 237, 0.98));
}

.hint-empty {
  display: grid;
  place-items: center;
  min-height: 116px;
  text-align: center;
  color: var(--ink-soft);
  font-weight: 700;
}

.hint-header {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: flex-start;
  margin-bottom: 14px;
}

.hint-kicker {
  margin: 0 0 6px;
  font-size: 0.78rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--ink-soft);
}

.hint-title {
  margin: 0;
  font-size: 1.15rem;
}

.hint-cost-pill {
  padding: 8px 12px;
  border-radius: 999px;
  border: 3px solid rgba(24, 50, 74, 0.16);
  background: rgba(87, 98, 223, 0.12);
  color: #4251b8;
  font-weight: 900;
  white-space: nowrap;
}

.answer-form {
  display: flex;
  gap: 12px;
  align-items: stretch;
}

.answer-form input {
  flex: 1 1 280px;
  min-width: 0;
  width: 100%;
  padding: 16px 18px;
  border-radius: 18px;
  border: var(--border-strong);
  font: inherit;
  font-size: 1.05rem;
  color: var(--ink);
  background: #fff;
}

.answer-form input:focus {
  outline: 4px solid rgba(90, 168, 255, 0.3);
  outline-offset: 2px;
}

.answer-actions {
  flex: 0 0 auto;
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.hint-button {
  background: linear-gradient(180deg, #ffffff, #ece9ff);
}

.primary-button,
.secondary-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: var(--border-strong);
  border-radius: 18px;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
  transition:
    transform 120ms ease,
    filter 120ms ease;
}

.primary-button {
  padding: 15px 22px;
  color: var(--ink);
  background: linear-gradient(180deg, var(--brand-yellow), #ffbc3d);
}

.secondary-button {
  padding: 12px 18px;
  color: var(--ink);
  background: linear-gradient(180deg, #ffffff, #e4f4ff);
}

.button-link {
  text-decoration: none;
}

.primary-button:hover,
.secondary-button:hover {
  transform: translateY(-2px);
  filter: saturate(1.06);
}

.primary-button:disabled,
.secondary-button:disabled,
.answer-form input:disabled {
  cursor: not-allowed;
  filter: grayscale(0.18);
  opacity: 0.7;
}

.log-heading h2 {
  margin: 0;
}

.log-heading p {
  margin: 8px 0 0;
  color: var(--ink-soft);
}

.message-log {
  list-style: none;
  margin: 18px 0 0;
  padding: 0;
  display: grid;
  gap: 10px;
  max-height: 280px;
  overflow: auto;
}

.message-log li {
  padding: 12px 14px;
  border-radius: 16px;
  border: 3px solid rgba(24, 50, 74, 0.12);
  background: rgba(255, 255, 255, 0.94);
  font-weight: 700;
  color: var(--ink);
}

.message-log li.good {
  border-color: rgba(93, 212, 138, 0.5);
  background: rgba(237, 255, 245, 0.96);
}

.message-log li.bad {
  border-color: rgba(255, 106, 102, 0.45);
  background: rgba(255, 242, 242, 0.96);
}

.message-log li.info {
  border-color: rgba(90, 168, 255, 0.38);
  background: rgba(242, 249, 255, 0.96);
}

.message-log li.warn {
  border-color: rgba(255, 198, 83, 0.58);
  background: rgba(255, 249, 224, 0.98);
}

.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(24, 34, 48, 0.58);
  z-index: 10;
}

.overlay.hidden {
  display: none;
}

.hidden {
  display: none !important;
}

.overlay-card {
  position: relative;
  width: min(720px, 100%);
  padding: 30px 28px 26px;
  border-radius: 28px;
  border: 5px solid var(--ink);
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(255, 248, 233, 0.98));
  box-shadow: 0 34px 80px rgba(0, 0, 0, 0.22);
  text-align: center;
}

.overlay-star {
  position: absolute;
  width: 90px;
  height: 90px;
  top: -22px;
  right: 24px;
  clip-path: polygon(50% 0%, 61% 34%, 98% 35%, 68% 57%, 79% 91%, 50% 70%, 21% 91%, 32% 57%, 2% 35%, 39% 34%);
  background: linear-gradient(180deg, #fff4a8, #ffbd49);
  border: 4px solid var(--ink);
}

.overlay-card h2 {
  margin: 12px 0 8px;
  font-size: clamp(2rem, 4vw, 2.8rem);
}

.overlay-card p {
  margin: 0 0 18px;
  color: var(--ink-soft);
  font-size: 1.02rem;
}

.report-card {
  margin: 0 auto 20px;
  max-width: 560px;
  text-align: left;
}

.report-card .report-banner {
  margin-bottom: 14px;
  padding: 14px 16px;
  border-radius: 18px;
  border: var(--border-strong);
  background: rgba(255, 251, 226, 0.98);
  font-weight: 800;
}

.report-card ul {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 10px;
}

.report-card li {
  padding: 14px 16px;
  border-radius: 18px;
  border: 3px solid rgba(24, 50, 74, 0.14);
  background: rgba(255, 255, 255, 0.94);
}

.overlay-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
}

.overlay-action {
  min-width: 180px;
}

.floating-layer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.floating-text {
  position: absolute;
  top: 42%;
  transform: translate(-50%, 0);
  padding: 10px 14px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  font-weight: 900;
  letter-spacing: 0.03em;
  animation: float-up 900ms ease-out forwards;
  box-shadow: 0 14px 28px rgba(24, 50, 74, 0.18);
}

.floating-text.damage {
  color: #b62a1a;
  background: #fff1ef;
}

.floating-text.mp {
  color: #3957b7;
  background: #eef2ff;
}

.screen-shake {
  animation: screen-shake 320ms ease-in-out;
}

.screen-flash {
  animation: screen-flash 360ms ease-out;
}

.is-attack {
  animation: combatant-attack 280ms ease-out;
}

.enemy-hit {
  animation: enemy-hit 500ms ease-out;
}

.player-hit {
  animation: player-hit 500ms ease-out;
}

.question-panel.is-highlight {
  animation: panel-glow 420ms ease-out;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@keyframes screen-shake {
  0%,
  100% {
    transform: translateX(0);
  }
  20% {
    transform: translateX(-10px);
  }
  40% {
    transform: translateX(10px);
  }
  60% {
    transform: translateX(-8px);
  }
  80% {
    transform: translateX(8px);
  }
}

@keyframes screen-flash {
  0% {
    box-shadow: inset 0 0 0 0 rgba(255, 242, 157, 0);
  }
  50% {
    box-shadow: inset 0 0 0 999px rgba(255, 242, 157, 0.22);
  }
  100% {
    box-shadow: inset 0 0 0 999px rgba(255, 242, 157, 0);
  }
}

@keyframes combatant-hit {
  0%,
  100% {
    transform: translateX(0) scale(1);
    filter: saturate(1);
  }
  25% {
    transform: translateX(-10px) scale(1.02);
    filter: brightness(1.15);
  }
  50% {
    transform: translateX(10px) scale(0.98);
    filter: brightness(1.25);
  }
  75% {
    transform: translateX(-6px) scale(1.01);
  }
}

@keyframes enemy-hit {
  0%,
  100% {
    transform: translateX(0) scale(1);
    filter: saturate(1);
  }
  18% {
    transform: translateX(-12px) scale(1.03);
    filter: brightness(1.1);
  }
  36% {
    transform: translateX(12px) scale(0.99);
    filter: brightness(1.18);
  }
  54% {
    transform: translateX(-8px) scale(1.02);
  }
  72% {
    transform: translateX(8px) scale(1);
  }
}

@keyframes player-hit {
  0%,
  100% {
    transform: translateX(0) scale(1);
  }
  16% {
    transform: translateX(-14px) rotate(-1deg);
  }
  32% {
    transform: translateX(12px) rotate(1deg);
  }
  48% {
    transform: translateX(-10px);
  }
  64% {
    transform: translateX(10px);
  }
}

@keyframes combatant-attack {
  0%,
  100% {
    transform: translateY(0) scale(1);
  }
  45% {
    transform: translateY(-12px) scale(1.05);
  }
}

@keyframes panel-glow {
  0% {
    box-shadow: var(--shadow);
  }
  40% {
    box-shadow:
      0 0 0 8px rgba(255, 210, 77, 0.22),
      var(--shadow);
  }
  100% {
    box-shadow: var(--shadow);
  }
}

@keyframes panel-success {
  0% {
    transform: translateY(0);
  }
  35% {
    transform: translateY(-4px);
    box-shadow:
      0 0 0 8px rgba(93, 212, 138, 0.2),
      var(--shadow);
  }
  100% {
    transform: translateY(0);
  }
}

@keyframes panel-failure {
  0%,
  100% {
    transform: translateX(0);
  }
  25% {
    transform: translateX(-6px);
  }
  50% {
    transform: translateX(6px);
  }
  75% {
    transform: translateX(-4px);
  }
}

@keyframes float-up {
  0% {
    opacity: 0;
    transform: translate(-50%, 18px) scale(0.88);
  }
  18% {
    opacity: 1;
    transform: translate(-50%, -2px) scale(1);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -72px) scale(1.02);
  }
}