* { box-sizing: border-box; }

html {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  width: 100%;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background:
    radial-gradient(circle at 50% 18%, rgba(82, 121, 170, 0.24), transparent 34%),
    radial-gradient(circle at 12% 85%, rgba(255, 91, 91, 0.12), transparent 28%),
    linear-gradient(180deg, #080910, #15151d 54%, #0b0b10);
  font-family: "Segoe UI", "Microsoft JhengHei", sans-serif;
  color: #eee;
  padding: 24px 12px;
  overflow-x: hidden;
  touch-action: manipulation;
}

button,
label,
input,
video {
  touch-action: manipulation;
}

.is-starting #game-wrap,
.is-starting #quiz-panel {
  display: none;
}

body:not(.is-starting) #start-screen {
  display: none;
}

#opening-video-screen {
  position: fixed;
  inset: 0;
  z-index: 120;
  display: grid;
  place-items: center;
  padding: 24px;
  background: #05070d;
}

#opening-video-screen.hidden {
  display: none;
}

#opening-video {
  display: block;
  width: min(1180px, 96vw);
  max-height: 86vh;
  background: #000;
  border: 2px solid rgba(255, 244, 190, 0.52);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.64);
}

.opening-download {
  position: fixed;
  left: 50%;
  bottom: 28px;
  width: min(520px, calc(100vw - 180px));
  transform: translateX(-50%);
  color: #fff4be;
  font-size: 14px;
  font-weight: 900;
  text-align: center;
}

.opening-download progress {
  width: 100%;
  height: 14px;
  margin-top: 7px;
  accent-color: #ffd23f;
}

.host-login-scene {
  position: relative;
  width: 112px;
  height: 62px;
  margin: 0 auto 5px;
}

.login-person,
.login-computer {
  position: absolute;
  bottom: 0;
}

.login-person {
  left: 8px;
  width: 48px;
  height: 58px;
  animation: login-work 0.7s ease-in-out infinite alternate;
}

.login-head,
.login-body,
.login-arm,
.login-computer i,
.login-computer b {
  position: absolute;
  display: block;
}

.login-head {
  left: 12px;
  top: 2px;
  width: 25px;
  height: 25px;
  border: 3px solid #24180f;
  border-radius: 50%;
  background: #ffd09d;
}

.login-body {
  left: 9px;
  bottom: 0;
  width: 33px;
  height: 31px;
  border-radius: 12px 12px 4px 4px;
  background: #4f92e8;
}

.login-arm {
  right: -4px;
  bottom: 12px;
  width: 25px;
  height: 7px;
  border-radius: 999px;
  background: #ffd09d;
  transform-origin: left center;
  animation: login-type 0.25s linear infinite alternate;
}

.login-sweat {
  position: absolute;
  right: -5px;
  top: 0;
  font-size: 17px;
  animation: login-sweat 0.8s ease-in infinite;
}

.login-computer {
  right: 3px;
  width: 59px;
  height: 45px;
}

.login-computer i {
  inset: 0 0 9px;
  border: 4px solid #bac7db;
  border-radius: 5px;
  background: linear-gradient(135deg, #20304d, #4fdee8);
  box-shadow: 0 0 12px rgba(79, 222, 232, 0.55);
}

.login-computer b {
  left: 25px;
  bottom: 0;
  width: 24px;
  height: 10px;
  border-top: 5px solid #bac7db;
}

@keyframes login-work { to { transform: translateY(2px) rotate(1deg); } }
@keyframes login-type { to { transform: rotate(10deg); } }
@keyframes login-sweat { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(9px); } }

.opening-download.ready {
  display: none;
}

.video-play-btn {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  padding: 10px 18px;
  border: 0;
  border-radius: 8px;
  background: rgba(255, 244, 190, 0.9);
  color: #17120a;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 900;
}

.video-play-btn.hidden { display: none; }

.opening-skip-btn {
  position: fixed;
  right: 22px;
  bottom: 20px;
  z-index: 121;
  min-width: 92px;
  padding: 10px 18px;
  border: 1px solid rgba(255, 244, 190, 0.58);
  border-radius: 8px;
  background: rgba(8, 10, 16, 0.82);
  color: #fff4be;
  cursor: pointer;
  font: inherit;
  font-weight: 900;
}

.opening-skip-btn.hidden { display: none; }

#start-screen {
  display: flex;
  flex-direction: column;
  width: 1120px;
  max-width: calc(100vw - 24px);
  padding: 22px 24px 24px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.06), transparent 32%),
    linear-gradient(180deg, #1b2130, #11131a);
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  box-shadow: 0 22px 48px rgba(0, 0, 0, 0.42);
}

.start-header {
  order: -2;
  text-align: center;
  margin-bottom: 18px;
}

.game-title {
  color: #fff4be;
  font-size: 42px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-shadow: 0 0 18px rgba(255, 210, 63, 0.42), 0 0 40px rgba(255, 94, 58, 0.28);
}

.game-subtitle {
  margin-top: 4px;
  color: #aeb8c9;
  font-size: 15px;
}

.online-entry {
  margin-bottom: 16px;
  padding: 14px 16px;
  border: 1px solid rgba(79, 222, 232, 0.38);
  border-radius: 8px;
  background: linear-gradient(135deg, rgba(20, 54, 76, 0.84), rgba(28, 35, 62, 0.84));
}

.online-entry-title {
  margin-bottom: 10px;
  color: #4fdee8;
  font-size: 17px;
  font-weight: 900;
}

.online-entry-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.online-join-inline {
  display: flex;
  gap: 8px;
}

.online-entry button,
.online-entry input,
.online-room-panel button {
  min-height: 44px;
  border-radius: 7px;
  font: inherit;
  font-weight: 900;
}

.online-entry button,
.online-room-panel button {
  border: 0;
  cursor: pointer;
}

.online-primary-btn,
.online-pair-btn {
  background: linear-gradient(90deg, #ffd23f, #ffb829);
  color: #21160a;
}

.online-join-inline input {
  min-width: 0;
  flex: 1;
  padding: 0 12px;
  border: 1px solid #536078;
  background: #111827;
  color: #fff;
  text-transform: uppercase;
}

.online-join-inline button,
.online-secondary-btn {
  padding: 0 14px;
  background: #343c54;
  color: #fff;
}

.online-entry-note {
  margin-top: 8px;
  color: #aeb8c9;
  font-size: 12px;
}

#online-room-panel.hidden,
#teacher-analytics.hidden,
#ai-question-panel.hidden,
#song-ci-question-panel.hidden,
#ai-question-preview.hidden,
#mobile-controller-screen.hidden,
#mobile-join-card.hidden,
#mobile-waiting-card.hidden {
  display: none;
}

#start-screen.hosting-room > :not(#online-room-panel):not(#question-mode-panel) {
  display: none;
}

.question-mode-panel {
  order: -1;
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(255, 210, 63, 0.32);
  border-radius: 8px;
  background: rgba(35, 31, 48, 0.86);
}

#start-screen.hosting-room .question-mode-panel {
  margin-top: 18px;
  margin-bottom: 0;
}

.question-mode-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.question-mode-title {
  color: #fff4be;
  font-size: 17px;
  font-weight: 900;
}

.question-mode-hint {
  margin-top: 3px;
  color: #aeb8c9;
  font-size: 12px;
}

.question-source-options {
  display: flex;
  gap: 8px;
}

.question-source-options button,
.ai-question-actions button {
  min-height: 40px;
  padding: 0 14px;
  border: 1px solid #58647a;
  border-radius: 7px;
  background: #252d40;
  color: #f3f6ff;
  cursor: pointer;
  font-family: inherit;
  font-weight: 900;
}

.question-source-options button.selected {
  border-color: #ffd23f;
  background: #ffd23f;
  color: #21160a;
}

.ai-question-panel {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.question-admin-link {
  display: inline-block;
  margin-top: 10px;
  color: #7de7ff;
  font-weight: 700;
}

.ai-question-panel label {
  display: block;
  margin-bottom: 7px;
  color: #dce7ff;
  font-weight: 900;
}

.ai-question-panel textarea {
  display: block;
  width: 100%;
  min-height: 160px;
  resize: vertical;
  padding: 12px;
  border: 1px solid #58647a;
  border-radius: 7px;
  outline: none;
  background: #111827;
  color: #f7f9ff;
  font: inherit;
  line-height: 1.6;
}

.ai-question-panel textarea:focus {
  border-color: #ffd23f;
  box-shadow: 0 0 0 3px rgba(255, 210, 63, 0.12);
}

.ai-question-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 9px;
}

.ai-question-actions span {
  color: #aeb8c9;
  font-size: 12px;
}

.ai-question-actions button {
  border: 0;
  background: linear-gradient(90deg, #ffd23f, #ffb829);
  color: #21160a;
}

.ai-question-actions button:disabled {
  cursor: wait;
  filter: grayscale(0.6);
  opacity: 0.6;
}

.ai-privacy-note {
  margin-top: 8px;
  color: #8793a8;
  font-size: 11px;
}

.ai-question-status {
  min-height: 22px;
  margin-top: 10px;
  color: #aeb8c9;
  font-size: 13px;
}

.ai-question-status.ready {
  color: #7effc9;
  font-weight: 900;
}

.ai-question-status.error {
  color: #ff9a9a;
}

.ai-question-preview {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 7px;
  background: #171d2e;
  color: #dce7ff;
  font-size: 12px;
  line-height: 1.6;
}

.online-room-panel {
  padding: 4px;
}

.room-title {
  margin-bottom: 16px;
  color: #4fdee8;
  font-size: 24px;
  font-weight: 900;
  text-align: center;
}

.room-grid {
  display: grid;
  grid-template-columns: minmax(300px, 0.8fr) 1.2fr;
  gap: 20px;
}

.room-qr-card,
.room-roster-card {
  padding: 18px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 10px;
  background: rgba(34, 42, 67, 0.84);
}

.room-qr-card {
  text-align: center;
}

.room-lead {
  margin-bottom: 10px;
  color: #fff4be;
  font-weight: 900;
}

#online-room-qr {
  display: block;
  width: min(260px, 100%);
  margin: 0 auto 10px;
  border: 9px solid #fff;
  border-radius: 10px;
  background: #fff;
}

.room-code {
  color: #ffd23f;
  font-size: 32px;
  font-weight: 1000;
  letter-spacing: 0.14em;
}

.room-url {
  overflow-wrap: anywhere;
  color: #aeb8c9;
  font-size: 11px;
}

.roster-heading {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
  color: #aeb8c9;
}

.roster-heading strong {
  color: #fff;
}

.online-player-roster {
  min-height: 210px;
  max-height: 330px;
  overflow-y: auto;
  margin: 0 0 12px;
  padding: 0;
  list-style: none;
}

.online-player-roster li {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 7px;
  padding: 9px 11px;
  border-radius: 7px;
  background: #171d2e;
  color: #f4f7ff;
}

.online-player-roster li.offline {
  opacity: 0.48;
}

.online-player-roster em {
  color: #ffd23f;
  font-style: normal;
}

.online-status {
  min-height: 22px;
  margin-bottom: 9px;
  color: #7effc9;
  text-align: center;
}

.online-pair-btn,
.online-secondary-btn {
  width: 100%;
  margin-top: 8px;
}

.online-pair-btn:disabled {
  cursor: not-allowed;
  filter: grayscale(0.8);
  opacity: 0.5;
}

.schedule-options {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin: 10px 0 4px;
}

.schedule-options button {
  min-height: 42px;
  border: 1px solid #4c5870;
  border-radius: 7px;
  background: #20283a;
  color: #dce7ff;
  font: inherit;
  font-weight: 900;
  cursor: pointer;
}

.schedule-options button.selected {
  border-color: #ffd23f;
  background: #4b3b11;
  color: #fff4be;
}

.tournament-status {
  margin-top: 9px;
  padding: 10px;
  border-radius: 7px;
  background: #171d2e;
  color: #dce7ff;
  font-size: 13px;
  line-height: 1.6;
  text-align: center;
}

.tournament-status strong {
  color: #ffd23f;
}
.tournament-standing-row { display: block; margin: 6px 0; color: #ffd23f; font-size: 17px; font-weight: 1000; line-height: 1.45; }

.arena-live-panel,
.tournament-bracket {
  margin-top: 18px;
  padding: 16px;
  border: 1px solid rgba(79, 222, 232, 0.32);
  border-radius: 10px;
  background: rgba(16, 23, 40, 0.95);
}

.arena-live-heading {
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  color: #fff4be;
  font-size: 18px;
}

.arena-live-heading span {
  color: #4fdee8;
}

.arena-match-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 12px;
}

.arena-match-card {
  overflow: hidden;
  border: 1px solid #3c4963;
  border-radius: 9px;
  background: linear-gradient(180deg, #253452, #111827);
}

.arena-match-card.finished { opacity: 0.72; }

.arena-match-label {
  padding: 7px 10px;
  background: rgba(0, 0, 0, 0.28);
  color: #ffd23f;
  font-size: 12px;
  font-weight: 900;
  text-align: center;
}

.arena-fighters {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: end;
  gap: 6px;
  padding: 10px;
}

.arena-fighter { min-width: 0; text-align: center; }
.arena-fighter img { width: 100%; height: 105px; object-fit: contain; }
.arena-fighter.p2 img { transform: scaleX(-1); }
.arena-fighter strong { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12px; }
.arena-health,
.arena-meter { height: 7px; margin-top: 5px; overflow: hidden; border-radius: 999px; background: #341a22; }
.arena-health i,
.arena-meter i { display: block; height: 100%; background: #5ae083; transition: width 0.25s ease; }
.arena-health i { background: linear-gradient(90deg, #b70f27, #ff4054); }
.arena-meter { height: 5px; background: #111; }
.arena-meter i { background: linear-gradient(90deg, #1268d8, #37b8ff); }
.arena-meter.ultimate-ready { height: 9px; box-shadow: 0 0 10px 3px #f7ff73; }
.arena-meter.ultimate-ready i { background: repeating-linear-gradient(180deg, #d9f7ff 0 2px, #38bfff 2px 4px, #155ee8 4px 6px); }
.arena-vs { align-self: center; color: #ffd23f; font-weight: 1000; }
.arena-match-result { min-height: 25px; padding: 4px 10px 10px; color: #dce7ff; font-size: 12px; text-align: center; }
.arena-fighter.attacking img { animation: arena-attack 0.4s ease; }
.arena-fighter.hit img { animation: arena-hit 0.55s steps(2, end); }
.arena-fighter.winner::after { content: "🏆"; display: block; margin: 10px auto 2px; font-size: 76px; line-height: 1; filter: drop-shadow(0 0 14px #ffd23f); }
.arena-fighter.ko::after { content: "K.O."; display: block; margin: 8px auto 2px; color: #fff; font-family: Impact, "Arial Black", sans-serif; font-size: 54px; font-style: italic; line-height: 1; text-shadow: 3px 3px 0 #9d0000, 0 0 15px #ff3030; }
@keyframes arena-attack { 50% { transform: translateX(15px) scale(1.08); filter: drop-shadow(0 0 12px #fff4be); } }
.arena-fighter.p2.attacking img { animation-name: arena-attack-p2; }
@keyframes arena-attack-p2 { 50% { transform: scaleX(-1) translateX(15px) scale(1.08); filter: drop-shadow(0 0 12px #fff4be); } }
@keyframes arena-hit { 25%, 75% { opacity: 0.2; filter: brightness(2.2) saturate(2); } }
.arena-energy-blast { position: absolute; top: 47%; left: 28%; z-index: 4; width: 44%; height: 5px; border-radius: 999px; background: #eaffff; box-shadow: 0 0 6px #fff, 0 0 16px #35eaff; animation: arena-blast 0.55s ease-out both; pointer-events: none; }
.arena-energy-blast.p2 { transform: scaleX(-1); }
.arena-energy-blast.ultimate { height: 6px; background: #fff9b5; box-shadow: 0 -10px 4px #ff5e3a, 0 10px 4px #52e7ff, 0 0 10px 4px #fff, 0 0 28px 8px #ffd23f; }
@keyframes arena-blast { from { clip-path: inset(0 100% 0 0); } 45% { clip-path: inset(0); } to { opacity: 0; } }

.tournament-bracket {
  overflow-x: auto;
}

.bracket-title { margin-bottom: 12px; color: #ffd23f; font-size: 20px; font-weight: 1000; text-align: center; }
.bracket-world-cup { display: grid; grid-template-columns: 1fr minmax(150px, 0.42fr) 1fr; align-items: stretch; gap: 18px; min-width: 900px; min-height: 430px; padding: 14px; border-radius: 12px; background: radial-gradient(circle at 50% 45%, rgba(255,210,63,0.13), transparent 25%), linear-gradient(180deg, #063c48, #07131f 52%, #080b13); }
.bracket-side { display: flex; align-items: stretch; gap: 14px; }
.bracket-side.right { justify-content: flex-end; }
.bracket-round { display: flex; min-width: 125px; flex: 1; flex-direction: column; }
.bracket-round h3, .bracket-center h3 { margin: 0 0 9px; color: #ffd23f; font-size: 12px; text-align: center; }
.bracket-round-nodes { display: flex; height: 100%; flex-direction: column; justify-content: space-around; gap: 12px; }
.bracket-center { display: flex; align-items: center; justify-content: center; flex-direction: column; }
.bracket-cup { margin-bottom: 16px; font-size: 92px; line-height: 1; filter: drop-shadow(0 0 18px rgba(255,210,63,0.8)); }
.bracket-match { position: relative; margin: 9px 0; padding: 9px; border: 1px solid #43506a; border-radius: 7px; background: #242f48; color: #fff; font-size: 12px; }
.bracket-round.left .bracket-match::after { content: ""; position: absolute; right: -15px; top: 50%; width: 14px; border-top: 2px solid #d39e28; }
.bracket-round.right .bracket-match::before { content: ""; position: absolute; left: -15px; top: 50%; width: 14px; border-top: 2px solid #d39e28; }
.bracket-match strong { display: block; color: #ffd23f; }
.bracket-match.live { border-color: #7effc9; box-shadow: 0 0 10px rgba(126, 255, 201, 0.25); }
.champion-trophy { position: static; display: block; margin: 0 auto 28px; font-size: clamp(76px, 10vw, 120px); line-height: 1; text-align: center; filter: drop-shadow(0 0 22px rgba(255, 210, 63, 0.9)); }
.champion-clear-art { display: block; width: min(300px, 70vw); height: 260px; margin: 8px auto; object-fit: contain; }
.tournament-restart-btn { display: block; min-height: 48px; margin: 22px auto 4px; padding: 10px 22px; border: 2px solid #ffd23f; border-radius: 9px; background: #33280d; color: #fff4be; font: inherit; font-weight: 1000; cursor: pointer; }

.teacher-analytics {
  margin-top: 18px;
  padding: 18px;
  border: 1px solid rgba(79, 222, 232, 0.3);
  border-radius: 10px;
  background: rgba(19, 27, 45, 0.94);
}

.analytics-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  margin-bottom: 14px;
}

.analytics-heading strong,
.analytics-heading span {
  display: block;
}

.analytics-heading strong {
  color: #4fdee8;
  font-size: 19px;
}

.analytics-heading span {
  margin-top: 3px;
  color: #aeb8c9;
  font-size: 12px;
}

.analytics-heading button {
  width: auto;
  min-width: 120px;
  margin: 0;
}

.analytics-summary {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

.analytics-summary div {
  padding: 12px;
  border-radius: 8px;
  background: #242d43;
  text-align: center;
}

.analytics-summary span,
.analytics-summary strong {
  display: block;
}

.analytics-summary span {
  color: #aeb8c9;
  font-size: 12px;
}

.analytics-summary strong {
  margin-top: 4px;
  color: #ffd23f;
  font-size: 24px;
}

.analytics-tables {
  display: grid;
  grid-template-columns: 0.8fr 1.2fr;
  gap: 16px;
}

.analytics-tables h3 {
  margin: 0 0 8px;
  color: #f3f6ff;
  font-size: 15px;
}

.analytics-table-wrap {
  max-height: 300px;
  overflow: auto;
  border: 1px solid #364158;
  border-radius: 7px;
}

.analytics-table-wrap table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.analytics-table-wrap th,
.analytics-table-wrap td {
  padding: 8px;
  border-bottom: 1px solid #30394d;
  text-align: left;
  vertical-align: top;
}

.analytics-table-wrap th {
  position: sticky;
  top: 0;
  background: #303a51;
  color: #fff4be;
}

.analytics-table-wrap td {
  color: #dce7ff;
}

.analytics-result-good {
  color: #7effc9 !important;
  font-weight: 900;
}

.analytics-result-bad {
  color: #ff9a9a !important;
  font-weight: 900;
}

body.is-mobile-controller {
  justify-content: flex-start;
  padding: 24px 12px;
  background: linear-gradient(150deg, #422f4d, #182b55 52%, #11142d);
}

body.is-mobile-controller > :not(#mobile-controller-screen) {
  display: none !important;
}

.mobile-controller-screen {
  width: min(520px, 100%);
  margin: auto;
}

.mobile-card {
  padding: 28px 22px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 18px;
  background: rgba(33, 42, 70, 0.94);
  box-shadow: 0 22px 60px rgba(0, 0, 0, 0.38);
  text-align: center;
}

.mobile-card h1 {
  margin: 8px 0 18px;
  color: #fff;
}

.mobile-globe {
  font-size: 54px;
}

.mobile-room-label,
.mobile-player-badge {
  margin: 0 auto 18px;
  color: #aeb8c9;
}

.mobile-room-label strong,
.mobile-player-badge {
  color: #ffd23f;
  letter-spacing: 0.1em;
}

.mobile-card label {
  display: block;
  margin-bottom: 7px;
  color: #dce7ff;
  text-align: left;
  font-weight: 900;
}

.mobile-card input,
.mobile-card button {
  width: 100%;
  min-height: 52px;
  border-radius: 9px;
  font: inherit;
  font-size: 17px;
}

.mobile-battle-preview {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 10px;
  margin: 0 0 16px;
  padding: 12px;
  border: 1px solid rgba(255, 210, 63, 0.36);
  border-radius: 12px;
  background: linear-gradient(180deg, #19243b, #0e1422);
}

.mobile-fighter {
  min-width: 0;
}

.mobile-fighter span,
.mobile-fighter img,
.mobile-fighter i {
  display: block;
}

.mobile-fighter span {
  overflow: hidden;
  color: #fff;
  font-size: 12px;
  font-weight: 900;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mobile-fighter img {
  width: 100%;
  height: 92px;
  object-fit: contain;
}

.mobile-fighter.p2 img {
  transform: scaleX(-1);
}

.mobile-fighter i {
  height: 7px;
  overflow: hidden;
  border-radius: 999px;
  background: #411e27;
}

.mobile-fighter i b {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, #b70f27, #ff4054);
  transition: width 0.25s ease;
}

.mobile-fighter i.mobile-meter {
  height: 5px;
  margin-top: 4px;
  background: #090a0f;
}

.mobile-fighter i.mobile-meter b {
  width: 0;
  background: linear-gradient(90deg, #1268d8, #37b8ff);
}

.mobile-fighter i.mobile-meter.ultimate-ready {
  height: 9px;
  box-shadow: 0 0 10px 3px #eaff52;
}

.mobile-card .mobile-back-opening-btn {
  margin-top: 18px;
  border: 1px solid #66728c;
  background: #20283a;
  color: #eef3ff;
}
.mobile-fighter i.mobile-meter.ultimate-ready b { background: repeating-linear-gradient(180deg, #d9f7ff 0 2px, #38bfff 2px 4px, #155ee8 4px 6px); }

#mobile-status-text.question { text-align: left; text-align-last: left; }

.mobile-battle-preview::after { content: ""; position: absolute; top: 49%; left: 26%; z-index: 5; width: 48%; height: 5px; border-radius: 999px; background: #efffff; box-shadow: 0 0 8px #fff, 0 0 18px #36eaff; opacity: 0; pointer-events: none; }
.mobile-battle-preview.blast-p1::after { animation: mobile-blast 0.6s ease-out; }
.mobile-battle-preview.blast-p2::after { animation: mobile-blast-p2 0.6s ease-out; }
.mobile-battle-preview.ultimate-blast::after { height: 6px; background: #fff9b5; box-shadow: 0 -10px 4px #ff5e3a, 0 10px 4px #52e7ff, 0 0 10px 4px #fff, 0 0 28px 8px #ffd23f; }
@keyframes mobile-blast { from { opacity: 1; clip-path: inset(0 100% 0 0); } 55% { opacity: 1; clip-path: inset(0); } to { opacity: 0; } }
@keyframes mobile-blast-p2 { from { opacity: 1; clip-path: inset(0 0 0 100%); } 55% { opacity: 1; clip-path: inset(0); } to { opacity: 0; } }
.mobile-fighter.attacking img { animation: mobile-attack 0.5s ease; }
.mobile-fighter.hit img { animation: arena-hit 0.55s steps(2, end); }
@keyframes mobile-attack { 50% { transform: translateX(15px) scale(1.08); } }
.mobile-fighter.p2.attacking img { animation-name: mobile-attack-p2; }
@keyframes mobile-attack-p2 { 50% { transform: scaleX(-1) translateX(15px) scale(1.08); } }
.mobile-player-badge.winner { display: block; font-size: clamp(34px, 11vw, 64px); line-height: 1.15; color: #ffd23f; text-shadow: 0 0 20px rgba(255, 210, 63, 0.8); }
.mobile-standing-row { display: block; margin: 5px 0; font-size: clamp(18px, 5.5vw, 28px); line-height: 1.3; }
.mobile-player-badge.ko { display: block; color: #fff; font-family: Impact, "Arial Black", sans-serif; font-size: clamp(72px, 22vw, 120px); font-style: italic; line-height: 1; text-shadow: 5px 5px 0 #9d0000, 0 0 22px #ff3030; }
.mobile-actions button.selected { border: 3px solid #ffd23f; box-shadow: 0 0 20px rgba(255, 210, 63, 0.9); }

.mobile-card input {
  padding: 0 13px;
  border: 1px solid #66728c;
  background: #111827;
  color: #fff;
}

.mobile-card button {
  margin-top: 12px;
  border: 0;
  background: #ffd23f;
  color: #21160a;
  font-weight: 900;
}

.mobile-error {
  min-height: 22px;
  margin-top: 8px;
  color: #ff9a9a;
}

.mobile-win-record {
  display: inline-block;
  margin: 6px 0 20px;
  padding: 8px 16px;
  border-radius: 999px;
  background: #ffd23f;
  color: #21160a;
  font-weight: 900;
}

.mobile-actions {
  display: grid;
  gap: 10px;
}

.mobile-actions button {
  margin: 0;
}

.mobile-actions button.answer-choice {
  background: #eef2ff;
  color: #18213a;
}

.mobile-actions button:disabled {
  opacity: 0.48;
}

.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;
}

.player-profile {
  margin-bottom: 18px;
  padding: 14px 16px;
  border: 1px solid rgba(126, 255, 201, 0.3);
  border-radius: 8px;
  background: rgba(20, 31, 48, 0.78);
}

.profile-heading,
.profile-entry {
  display: flex;
  align-items: center;
  gap: 12px;
}

.profile-heading {
  justify-content: space-between;
  margin-bottom: 10px;
}

.profile-title {
  color: #7effc9;
  font-size: 17px;
  font-weight: 900;
}

.profile-hint {
  margin-top: 2px;
  color: #aeb8c9;
  font-size: 12px;
}

.profile-record {
  display: flex;
  align-items: center;
  gap: 10px;
  color: #dce7ff;
  font-size: 14px;
}

.profile-record strong {
  min-width: 58px;
  padding: 5px 9px;
  border-radius: 999px;
  background: #ffd23f;
  color: #21160a;
  text-align: center;
}

.profile-entry input {
  min-width: 0;
  flex: 1;
  padding: 11px 12px;
  border: 1px solid #4b586d;
  border-radius: 7px;
  outline: none;
  background: #101722;
  color: #f7f9ff;
  font: inherit;
}

.profile-entry input:focus {
  border-color: #7effc9;
  box-shadow: 0 0 0 3px rgba(126, 255, 201, 0.12);
}

.profile-entry button {
  min-height: 42px;
  padding: 0 16px;
  border: 0;
  border-radius: 7px;
  background: #7effc9;
  color: #102019;
  cursor: pointer;
  font-family: inherit;
  font-weight: 900;
}

.profile-error {
  min-height: 18px;
  margin-top: 5px;
  color: #ff9a9a;
  font-size: 12px;
}

.mode-select {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.difficulty-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin: -4px 0 16px;
}

.difficulty-label {
  color: #fff4be;
  font-weight: 900;
}

.difficulty-options {
  display: inline-flex;
  gap: 8px;
}

.difficulty-options label {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 7px 10px;
  background: #202431;
  border: 1px solid #3e485a;
  border-radius: 6px;
  color: #f3f6ff;
  cursor: pointer;
  font-size: 14px;
  font-weight: 800;
}

.difficulty-options input {
  accent-color: #ffd23f;
}

.mode-btn,
.start-btn {
  border: 0;
  color: #f7f9ff;
  cursor: pointer;
  font-family: inherit;
}

.mode-btn {
  padding: 14px 16px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.07), transparent 45%),
    linear-gradient(180deg, #252b38, #151821);
  border: 2px solid #3e485a;
  border-radius: 8px;
  text-align: left;
  transition: transform 0.12s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.mode-btn:hover {
  transform: translateY(-2px);
  border-color: #7effc9;
}

.mode-btn.selected {
  border-color: #ffd23f;
  box-shadow: 0 0 20px rgba(255, 210, 63, 0.2);
}

.mode-name,
.mode-desc {
  display: block;
}

.mode-name {
  font-size: 18px;
  font-weight: 900;
}

.mode-desc {
  margin-top: 3px;
  color: #aeb8c9;
  font-size: 13px;
}

.start-btn {
  display: block;
  width: min(320px, 100%);
  margin: 18px auto 0;
  padding: 14px 22px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.24), transparent 45%),
    linear-gradient(90deg, #ff8c1a, #ffd23f);
  border-radius: 8px;
  color: #21160a;
  font-size: 20px;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(255, 140, 26, 0.24);
}

#game-wrap {
  position: relative;
  width: 1120px;
  max-width: calc(100vw - 24px);
  filter: drop-shadow(0 22px 45px rgba(0, 0, 0, 0.45));
}

canvas {
  display: block;
  width: 100%;
  height: auto;
  aspect-ratio: 1120 / 540;
  object-fit: contain;
  background: #161822;
  border: 2px solid #5d6578;
  border-radius: 8px;
  box-shadow:
    inset 0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 28px rgba(126, 231, 255, 0.18);
}

#hud {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 8px;
  gap: 12px;
  padding: 10px 12px 0;
}

.side {
  flex: 1 1 0;
  min-width: 0;
}
.side.p2 { text-align: right; }

.name {
  display: inline-block;
  min-width: 54px;
  padding: 3px 10px;
  margin-bottom: 4px;
  background: linear-gradient(180deg, #252b39, #11141d);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
  color: #f6f7fb;
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.08em;
  text-shadow: 0 0 8px rgba(0, 0, 0, 0.9);
}

.health-bar {
  width: 100%;
  height: 20px;
  background: #08090d;
  border: 2px solid #05060a;
  border-radius: 5px;
  overflow: hidden;
  box-shadow: inset 0 0 8px rgba(0, 0, 0, 0.85);
}

.health-fill {
  height: 100%;
  width: 100%;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.42), transparent 38%),
    linear-gradient(90deg, #73f25f, #ffd23f 62%, #ff5e3a);
  transition: width 0.15s ease-out;
  box-shadow: 0 0 12px rgba(115, 242, 95, 0.4);
}

.side.p2 .health-fill { margin-left: auto; }

.meter-bar {
  width: 100%;
  height: 9px;
  margin-top: 4px;
  background: #090a0f;
  border: 1px solid #000;
  border-radius: 5px;
  overflow: hidden;
}

.meter-fill {
  height: 100%;
  width: 0%;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.5), transparent),
    linear-gradient(90deg, #3fa9ff, #7effc9);
  box-shadow: 0 0 12px rgba(126, 231, 255, 0.75);
}

.meter-fill.full {
  animation: pulse 0.6s infinite alternate;
}

.meter-bar.ultimate-ready {
  border-color: #efff69;
  box-shadow: 0 0 7px 2px #dfff45, 0 0 15px rgba(223, 255, 69, 0.85);
  animation: meter-ready-glow 0.7s infinite alternate;
}

@keyframes meter-ready-glow {
  to { box-shadow: 0 0 10px 3px #fff5a0, 0 0 22px rgba(223, 255, 69, 1); }
}

@keyframes pulse {
  from { filter: brightness(1); }
  to { filter: brightness(1.6); }
}

.rounds { margin-top: 4px; font-size: 16px; letter-spacing: 4px; }

.center {
  flex: 0 0 120px;
  text-align: center;
}

#timer-display {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 64px;
  height: 44px;
  margin-top: 4px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.14), transparent 48%),
    linear-gradient(180deg, #1f2634, #080a0f);
  border: 2px solid rgba(255, 244, 190, 0.72);
  border-radius: 8px;
  color: #fff4be;
  font-size: 30px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 0 12px rgba(255, 210, 63, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.08), 0 0 18px rgba(255, 210, 63, 0.18);
}

#timer-display.urgent {
  color: #fff;
  border-color: #ff5b5b;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.18), transparent 48%),
    linear-gradient(180deg, #7a1515, #270808);
  text-shadow: 0 0 8px #ff5b5b, 0 0 22px #ff1f1f;
  animation: timerUrgentPulse 0.45s infinite alternate;
}

#round-banner {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  font-size: 42px;
  font-weight: bold;
  color: #fff4be;
  text-shadow: 0 0 10px #000, 0 0 20px #ff0, 0 0 42px #ff5e3a;
  pointer-events: none;
  white-space: nowrap;
}

#round-banner.countdown-banner {
  top: 48%;
  font-size: 112px;
  font-weight: 1000;
  letter-spacing: 0.08em;
  color: #fff4be;
  text-shadow:
    0 0 14px #000,
    0 0 28px #ffd23f,
    0 0 58px #ff5e3a;
  animation: countdownPop 0.78s ease-out both;
}

#round-banner.countdown-banner.fight {
  font-size: 92px;
  color: #ffffff;
  text-shadow:
    0 0 16px #000,
    0 0 30px #ffef8a,
    0 0 70px #ff2a2a,
    0 0 110px #7ee7ff;
  animation: fightPop 0.58s ease-out both;
}

.combo-popup {
  position: absolute;
  top: 120px;
  font-size: 22px;
  font-weight: bold;
  color: #ffe25b;
  text-shadow: 0 0 6px #000, 0 0 18px #ff8c1a;
  pointer-events: none;
  opacity: 0;
}

#combo-p1 { left: 30px; }
#combo-p2 { right: 30px; }

#quiz-panel {
  width: 1120px;
  max-width: calc(100vw - 24px);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), transparent 32%),
    linear-gradient(180deg, #1c202b, #11131a);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 8px;
  padding: 16px 24px;
  min-height: 150px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.34);
}

body:not(.is-starting) {
  width: 100%;
  align-items: start;
  justify-content: center;
}

body:not(.is-starting).mode-single {
  display: grid;
  grid-template-columns: minmax(260px, 380px) minmax(480px, 1120px);
  grid-template-areas: "quiz game";
  gap: 16px;
}

body:not(.is-starting).mode-single #game-wrap {
  grid-area: game;
  width: 100%;
  max-width: none;
}

body:not(.is-starting).mode-single #quiz-panel {
  grid-area: quiz;
  width: 100%;
  max-width: none;
  align-self: start;
}

body:not(.is-starting).mode-single #skill-tray {
  display: grid;
  grid-template-columns: 1fr;
  gap: 10px;
}

body:not(.is-starting).mode-single .skill-btn {
  min-width: 0;
  width: 100%;
}

body:not(.is-starting).mode-single #answer-list {
  grid-template-columns: 1fr;
}

body:not(.is-starting).mode-two-player {
  display: grid;
  grid-template-columns: minmax(190px, 250px) minmax(620px, 900px) minmax(190px, 250px);
  grid-template-areas:
    "turn turn turn"
    "duel-left game duel-right"
    "feedback feedback feedback";
  gap: 12px 16px;
}

body:not(.is-starting).mode-two-player #game-wrap {
  grid-area: game;
  width: 100%;
  max-width: none;
}

body:not(.is-starting).mode-two-player #quiz-panel,
body:not(.is-starting).mode-two-player #duel-question-box {
  display: contents;
}

body:not(.is-starting).mode-two-player #turn-indicator {
  grid-area: turn;
  margin-bottom: 0;
}

body:not(.is-starting).mode-two-player #duel-p1 {
  grid-area: duel-left;
}

body:not(.is-starting).mode-two-player #duel-p2 {
  grid-area: duel-right;
}

body:not(.is-starting).mode-two-player #feedback-text {
  grid-area: feedback;
  margin-top: 0;
}

body:not(.is-starting).mode-two-player #duel-question-box.hidden {
  display: none;
}

body:not(.is-starting).mode-single #game-wrap,
body:not(.is-starting).mode-single #quiz-panel,
body:not(.is-starting).mode-two-player #game-wrap,
body:not(.is-starting).mode-two-player .duel-panel {
  min-width: 0;
}

#character-select {
  margin-bottom: 16px;
  padding-bottom: 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.select-title {
  text-align: center;
  margin-bottom: 10px;
  color: #fff4be;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-shadow: 0 0 14px rgba(255, 210, 63, 0.35);
}

.select-columns {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

#start-screen.mode-single .select-columns {
  grid-template-columns: 1fr 1fr;
}

.select-label {
  margin-bottom: 8px;
  font-weight: 800;
  color: #dce7ff;
}

.character-list {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.character-card {
  position: relative;
  min-width: 0;
  padding: 7px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.07), transparent 42%),
    linear-gradient(180deg, #252b38, #151821);
  border: 1px solid #3e485a;
  border-radius: 8px;
  color: #f3f6ff;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.15s ease, transform 0.12s ease, box-shadow 0.15s ease;
}

.character-card::before {
  content: attr(data-badge);
  position: absolute;
  top: 6px;
  left: 6px;
  z-index: 2;
  min-width: 30px;
  padding: 2px 6px;
  background: rgba(8, 10, 16, 0.78);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 4px;
  color: #fff4be;
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.04em;
  line-height: 1.35;
  pointer-events: none;
}

.character-card:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: #7effc9;
  box-shadow: 0 0 18px rgba(126, 231, 255, 0.2);
}

.character-card.selected {
  border-color: #ffd23f;
  animation: selectedFramePulse 0.95s infinite alternate;
  box-shadow: 0 0 18px rgba(255, 210, 63, 0.22);
}

.character-card.flash-select {
  animation: selectFlash 0.42s ease-out;
}

.character-card.cpu-card {
  cursor: default;
}

.character-card.cpu-card::before {
  color: #7effc9;
  border-color: rgba(126, 255, 201, 0.45);
}

.character-card.cpu-card.defeated {
  filter: grayscale(1) brightness(0.58);
  opacity: 0.58;
}

.character-card.cpu-roulette {
  border-color: #7effc9;
  animation: cpuRouletteSweep 0.2s ease-out both;
  box-shadow:
    0 0 24px rgba(126, 255, 201, 0.42),
    inset 0 0 0 2px rgba(255, 255, 255, 0.24);
}

.portrait-frame {
  display: block;
  width: 100%;
  height: 104px;
  overflow: hidden;
  margin-bottom: 5px;
  border-radius: 6px;
  background: radial-gradient(circle at 50% 20%, rgba(255,255,255,0.14), rgba(0,0,0,0.18));
}

.portrait-frame img {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 8%;
  transform: scale(1.42) translateY(15%);
  transform-origin: 50% 20%;
}

#start-screen.mode-two-player .player-select:last-child .portrait-frame img {
  transform: scaleX(-1) scale(1.42) translateY(15%);
}

#start-screen.mode-single .player-select:last-child .portrait-frame img {
  transform: scaleX(-1) scale(1.42) translateY(15%);
}

.character-name,
.character-title {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.character-name {
  font-size: 14px;
  font-weight: 800;
}

.character-title {
  margin-top: 2px;
  color: #aeb8c9;
  font-size: 11px;
}

#turn-indicator {
  text-align: center;
  font-size: 18px;
  font-weight: bold;
  margin-bottom: 12px;
}

#turn-indicator.turn-p1 { color: #4fa3ff; }
#turn-indicator.turn-p2 { color: #ff5b5b; }

#skill-tray {
  display: flex;
  justify-content: center;
  gap: 16px;
}

.skill-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  min-width: 140px;
  padding: 14px 18px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), transparent 40%),
    linear-gradient(#2d3444, #171a24);
  border: 2px solid #4a5264;
  border-radius: 8px;
  color: #fff;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.06), 0 8px 18px rgba(0,0,0,0.25);
  transition: transform 0.1s ease, border-color 0.15s ease, box-shadow 0.15s ease;
}

.skill-btn:hover:not(.locked) {
  transform: translateY(-3px);
  border-color: #ffd23f;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.12), 0 0 22px rgba(255, 210, 63, 0.24);
}

.ko-overlay {
  position: absolute;
  top: 43%;
  z-index: 18;
  display: none;
  color: #fff;
  font-family: Impact, "Arial Black", sans-serif;
  font-size: clamp(78px, 11vw, 150px);
  font-style: italic;
  letter-spacing: 0.04em;
  line-height: 1;
  text-shadow: 5px 5px 0 #a90000, 0 0 18px #ff3030, 0 0 42px #ffba3a;
  transform: translateY(-50%) rotate(-7deg);
  pointer-events: none;
}

.ko-overlay.p1 { left: 8%; }
.ko-overlay.p2 { right: 8%; }
.ko-overlay.visible { display: block; animation: koSlam 0.72s cubic-bezier(.18,.89,.32,1.28) both; }
@keyframes koSlam { 0% { opacity: 0; transform: translateY(-50%) scale(2.2) rotate(-14deg); } 55% { opacity: 1; transform: translateY(-50%) scale(0.9) rotate(-7deg); } 100% { opacity: 1; transform: translateY(-50%) scale(1) rotate(-7deg); } }

.skill-btn.selected {
  border-color: #ffd23f;
  box-shadow: inset 0 0 0 2px #ffd23f, 0 0 24px rgba(255, 210, 63, 0.9);
  transform: translateY(-2px) scale(1.02);
}

.skill-btn .skill-tag {
  font-size: 12px;
  font-weight: normal;
  color: #aaa;
}

.skill-btn.locked {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.6);
}

#question-box.hidden, #skill-tray.hidden, #duel-question-box.hidden { display: none; }

#question-text {
  text-align: left;
  text-align-last: left;
  font-size: 18px;
  margin-bottom: 14px;
  line-height: 1.5;
}

#answer-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.answer-btn {
  padding: 12px 16px;
  background: #202431;
  border: 2px solid #3d465a;
  border-radius: 6px;
  color: #eee;
  font-size: 15px;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}

.answer-btn:hover:not(:disabled) {
  border-color: #7effc9;
  box-shadow: 0 0 16px rgba(126, 231, 255, 0.18);
}
.answer-btn:disabled { cursor: default; }

.answer-btn.correct {
  background: #1f4d2e;
  border-color: #4ade80;
  color: #d7ffe4;
}

.answer-btn.wrong {
  background: #4d1f1f;
  border-color: #ff5b5b;
  color: #ffd7d7;
}

#feedback-text {
  text-align: center;
  margin-top: 12px;
  font-size: 16px;
  font-weight: bold;
  min-height: 20px;
}

.feedback-good { color: #4ade80; }
.feedback-bad { color: #ff8080; }

.back-menu-btn {
  display: block;
  position: fixed;
  left: 50%;
  bottom: 24px;
  z-index: 90;
  width: 180px;
  margin: 0;
  padding: 10px 16px;
  border: 0;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.18), transparent 45%),
    linear-gradient(90deg, #3fa9ff, #7effc9);
  color: #071019;
  cursor: pointer;
  font-family: inherit;
  font-size: 15px;
  font-weight: 900;
  transform: translateX(-50%);
  box-shadow: 0 10px 22px rgba(63, 169, 255, 0.22);
}

.back-menu-btn.hidden {
  display: none;
}

.bgm-toggle-btn {
  position: fixed;
  right: 18px;
  bottom: 16px;
  z-index: 95;
  padding: 8px 12px;
  border: 1px solid rgba(255, 244, 190, 0.42);
  border-radius: 6px;
  background: rgba(8, 10, 16, 0.78);
  color: #fff4be;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 900;
}

#all-clear-screen,
#character-clear-screen {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(4, 6, 12, 0.9);
}

#all-clear-screen::before,
#all-clear-screen::after,
#character-clear-screen::before,
#character-clear-screen::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle, rgba(255, 244, 190, 0.95) 0 2px, transparent 3px) 12% 18% / 120px 120px,
    radial-gradient(circle, rgba(126, 231, 255, 0.9) 0 2px, transparent 3px) 82% 20% / 150px 150px,
    radial-gradient(circle, rgba(255, 91, 150, 0.85) 0 2px, transparent 3px) 64% 12% / 110px 110px;
  animation: allClearFireworks 1.2s ease-out infinite;
}

#all-clear-screen::after,
#character-clear-screen::after {
  animation-delay: 0.55s;
  transform: scale(0.82);
  opacity: 0.7;
}

#all-clear-screen.hidden,
#character-clear-screen.hidden {
  display: none;
}

#all-clear-screen img,
#character-clear-screen img {
  display: block;
  width: min(1180px, 96vw);
  max-height: 86vh;
  object-fit: contain;
  border: 2px solid rgba(255, 244, 190, 0.6);
  border-radius: 8px;
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.58), 0 0 42px rgba(255, 210, 63, 0.2);
}

.clear-actions {
  position: fixed;
  right: 28px;
  bottom: 24px;
  z-index: 102;
  display: flex;
  gap: 10px;
}

.all-clear-close {
  position: relative;
  min-width: 132px;
  padding: 12px 18px;
  border: 0;
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.22), transparent 45%),
    linear-gradient(90deg, #ff8c1a, #ffd23f);
  color: #21160a;
  cursor: pointer;
  font-family: inherit;
  font-size: 16px;
  font-weight: 900;
  box-shadow: 0 12px 28px rgba(255, 140, 26, 0.24);
}

#character-clear-next {
  position: fixed;
  right: 28px;
  bottom: 24px;
  z-index: 102;
}

#duel-question-box {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.duel-panel {
  min-height: 150px;
  padding: 12px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.05), transparent 42%),
    linear-gradient(180deg, #202637, #141720);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 8px;
}

.duel-panel.p1 { border-color: rgba(79, 163, 255, 0.48); }
.duel-panel.p2 { border-color: rgba(255, 91, 91, 0.48); }

.duel-title {
  margin-bottom: 10px;
  font-size: 16px;
  font-weight: 900;
}

.duel-panel.p1 .duel-title { color: #8cc8ff; }
.duel-panel.p2 .duel-title { color: #ff9b9b; }

.duel-skill-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.duel-panel .skill-btn {
  min-width: 0;
  padding: 10px 8px;
  font-size: 13px;
}

.duel-question-text {
  margin-bottom: 10px;
  min-height: 46px;
  color: #f6f7fb;
  font-size: 15px;
  line-height: 1.45;
  text-align: left;
  text-align-last: left;
}

.duel-question-text.hidden { display: none; }

.duel-answer-list {
  display: grid;
  grid-template-columns: 1fr;
  gap: 7px;
}

.duel-feedback {
  min-height: 20px;
  margin-top: 9px;
  font-weight: 800;
}

.duel-panel.p1 .duel-feedback { color: #8cc8ff; }
.duel-panel.p2 .duel-feedback { color: #ff9b9b; }

@keyframes selectedFramePulse {
  from {
    box-shadow: 0 0 12px rgba(255, 210, 63, 0.24), inset 0 0 0 1px rgba(255,255,255,0.04);
  }
  to {
    box-shadow: 0 0 28px rgba(255, 210, 63, 0.48), inset 0 0 0 1px rgba(255,255,255,0.18);
  }
}

@keyframes selectFlash {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 rgba(255,255,255,0);
  }
  45% {
    transform: scale(1.04);
    box-shadow: 0 0 34px rgba(126, 231, 255, 0.62), inset 0 0 0 2px rgba(255,255,255,0.34);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 18px rgba(255, 210, 63, 0.28);
  }
}

@keyframes cpuRouletteSweep {
  0% {
    transform: scale(0.98);
    filter: brightness(1);
  }
  55% {
    transform: scale(1.04);
    filter: brightness(1.42);
  }
  100% {
    transform: scale(1);
    filter: brightness(1.12);
  }
}

@keyframes timerUrgentPulse {
  from { transform: scale(1); filter: brightness(1); }
  to { transform: scale(1.08); filter: brightness(1.35); }
}

@keyframes countdownPop {
  0% { transform: translate(-50%, -50%) scale(0.52); opacity: 0; filter: blur(3px); }
  35% { transform: translate(-50%, -50%) scale(1.16); opacity: 1; filter: blur(0); }
  100% { transform: translate(-50%, -50%) scale(0.92); opacity: 0.92; }
}

@keyframes fightPop {
  0% { transform: translate(-50%, -50%) scale(0.7) skewX(-8deg); opacity: 0; }
  45% { transform: translate(-50%, -50%) scale(1.18) skewX(-8deg); opacity: 1; }
  100% { transform: translate(-50%, -50%) scale(1) skewX(-8deg); opacity: 0.96; }
}

@keyframes allClearFireworks {
  0% { opacity: 0; filter: blur(0); transform: scale(0.62); }
  28% { opacity: 0.95; }
  100% { opacity: 0; filter: blur(1px); transform: scale(1.18); }
}

@media (max-width: 900px) {
  body:not(.is-starting).mode-single,
  body:not(.is-starting).mode-two-player {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
    padding: 10px 8px 18px;
    gap: 10px;
  }

  body:not(.is-starting).mode-single #game-wrap,
  body:not(.is-starting).mode-single #quiz-panel,
  body:not(.is-starting).mode-two-player #game-wrap,
  body:not(.is-starting).mode-two-player #quiz-panel {
    width: 1120px;
    max-width: calc(100vw - 16px);
  }

  #hud {
    gap: 8px;
    padding: 7px 8px 0;
  }

  .name {
    min-width: 46px;
    padding: 2px 7px;
    font-size: 12px;
  }

  .health-bar {
    height: 16px;
  }

  .meter-bar {
    height: 8px;
  }

  #timer-display {
    min-width: 54px;
    height: 38px;
    font-size: 25px;
  }

  #round-banner {
    font-size: clamp(28px, 8vw, 64px);
  }

  canvas {
    border-width: 1px;
    max-height: 56dvh;
  }

  body:not(.is-starting).mode-two-player #quiz-panel {
    display: block;
    padding: 12px;
  }

  body:not(.is-starting).mode-two-player #duel-question-box {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 14px;
  }

  body:not(.is-starting).mode-two-player #duel-question-box.hidden {
    display: none;
  }
}

@media (max-width: 780px) {
  body {
    padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(12px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left));
  }

  #opening-video-screen {
    padding: 8px;
  }

  #opening-video {
    width: 100%;
    max-height: 76dvh;
  }

  .video-play-btn {
    min-height: 44px;
  }

  .opening-skip-btn {
    right: 12px;
    bottom: 12px;
    min-height: 44px;
  }

  .opening-download {
    bottom: 72px;
    width: calc(100vw - 32px);
  }

  #start-screen {
    max-width: calc(100vw - 16px);
    padding: 16px 14px 18px;
  }

  .game-title {
    font-size: clamp(30px, 10vw, 42px);
  }

  .mode-select {
    grid-template-columns: 1fr;
  }

  .online-entry-actions,
  .room-grid,
  .analytics-tables {
    grid-template-columns: 1fr;
  }

  .analytics-summary {
    grid-template-columns: 1fr;
  }

  .analytics-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .online-join-inline {
    flex-direction: column;
  }

  .profile-heading,
  .profile-entry,
  .question-mode-heading {
    align-items: stretch;
    flex-direction: column;
  }

  .question-source-options {
    display: grid;
    grid-template-columns: 1fr 1fr;
  }

  .profile-record {
    justify-content: space-between;
  }

  .difficulty-row {
    flex-direction: column;
    gap: 8px;
  }

  .select-columns {
    grid-template-columns: 1fr;
  }

  .character-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  #start-screen.mode-single .character-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .portrait-frame {
    height: 88px;
  }

  #quiz-panel {
    padding: 12px;
    min-height: 0;
  }

  body:not(.is-starting).mode-single #skill-tray {
    grid-template-columns: 1fr;
  }

  .skill-btn,
  .answer-btn,
  .mode-btn,
  .start-btn,
  .character-card,
  .all-clear-close {
    min-height: 44px;
  }

  .skill-btn {
    padding: 12px 10px;
    font-size: 15px;
  }

  #question-text,
  .duel-question-text {
    font-size: 16px;
  }

  #answer-list {
    grid-template-columns: 1fr;
  }

  .answer-btn {
    padding: 12px 13px;
    font-size: 15px;
  }

  #duel-question-box {
    grid-template-columns: 1fr;
  }

  body:not(.is-starting).mode-two-player #duel-question-box {
    grid-template-columns: 1fr;
  }

  .all-clear-close {
    min-width: 118px;
  }

  .clear-actions {
    right: 16px;
    bottom: 16px;
    flex-direction: column;
  }

  #character-clear-next {
    right: 16px;
    bottom: 16px;
  }
}

@media (max-width: 520px) {
  body:not(.is-starting).mode-single #game-wrap,
  body:not(.is-starting).mode-single #quiz-panel,
  body:not(.is-starting).mode-two-player #game-wrap,
  body:not(.is-starting).mode-two-player #quiz-panel {
    max-width: calc(100vw - 10px);
  }

  #hud {
    margin-bottom: 5px;
  }

  .rounds {
    font-size: 14px;
  }

  .duel-panel {
    padding: 10px;
  }

  .duel-skill-row {
    grid-template-columns: 1fr;
  }

  .bgm-toggle-btn {
    right: 10px;
    bottom: 10px;
  }
}
