/* Word Fighter - Cyberpunk Arcade Style CSS */
:root {
  --bg-dark: #0b0f19;
  --bg-card: #161f30;
  --bg-card-hover: #1e2b42;
  --cyan-neon: #00f2fe;
  --blue-neon: #4facfe;
  --red-neon: #ff0844;
  --orange-neon: #ffb199;
  --purple-neon: #a18cd1;
  --green-neon: #00f5a0;
  --yellow-neon: #f9d423;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-glow: rgba(0, 242, 254, 0.3);
  --font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, 'Noto Sans TC', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
}

body {
  background: radial-gradient(circle at center, #131b2e 0%, #080c14 100%);
  color: var(--text-main);
  font-family: var(--font-family);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  overflow-x: hidden;
  position: relative;
}

/* Canvas Overlay for Sparks & Slash Effects */
#effectCanvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99;
}

/* App Container */
.game-container {
  width: 100%;
  max-width: 960px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
  position: relative;
  z-index: 2;
}

/* Header & Control Bar */
.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  background: rgba(22, 31, 48, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 12px;
  margin-bottom: 12px;
}

.logo-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 1.25rem;
  font-weight: 900;
  background: linear-gradient(135deg, var(--cyan-neon), var(--blue-neon));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.header-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-icon {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.85rem;
  font-weight: 600;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 4px;
}

.btn-icon:hover {
  background: rgba(0, 242, 254, 0.15);
  border-color: var(--cyan-neon);
  transform: translateY(-1px);
}

/* Battle Arena (Top Half) */
.battle-arena {
  background: linear-gradient(180deg, rgba(20, 28, 45, 0.8) 0%, rgba(10, 15, 26, 0.95) 100%);
  border: 1px solid rgba(0, 242, 254, 0.2);
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 0 20px rgba(0, 242, 254, 0.05);
  border-radius: 16px;
  padding: 16px;
  margin-bottom: 12px;
  display: flex;
  flex-direction: column;
  position: relative;
  overflow: hidden;
}

/* Arena Background Grid Animation */
.battle-arena::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: 
    linear-gradient(rgba(0, 242, 254, 0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0, 242, 254, 0.04) 1px, transparent 1px);
  background-size: 24px 24px;
  pointer-events: none;
}

/* Health Bars & Status Row */
.fighters-status-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 12px;
  position: relative;
  z-index: 2;
}

.team-hud {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.team-hud.right {
  align-items: flex-end;
}

.hud-info {
  display: flex;
  justify-content: space-between;
  width: 100%;
  font-size: 0.85rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.team-hud.blue .hud-info {
  color: var(--cyan-neon);
}

.team-hud.red .hud-info {
  color: var(--red-neon);
}

.hp-bar-outer {
  width: 100%;
  height: 18px;
  background: rgba(0, 0, 0, 0.6);
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.8);
}

.hp-bar-fill {
  height: 100%;
  width: 100%;
  transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 999px;
}

.team-hud.blue .hp-bar-fill {
  background: linear-gradient(90deg, #00c6ff, #0072ff);
  box-shadow: 0 0 12px rgba(0, 198, 255, 0.6);
}

.team-hud.red .hp-bar-fill {
  background: linear-gradient(90deg, #ff0844, #ffb199);
  box-shadow: 0 0 12px rgba(255, 8, 68, 0.6);
  margin-left: auto;
}

.vs-badge {
  font-size: 1.1rem;
  font-weight: 900;
  color: var(--yellow-neon);
  text-shadow: 0 0 10px rgba(249, 212, 35, 0.6);
  padding: 4px 10px;
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(249, 212, 35, 0.4);
  border-radius: 50%;
}

/* Fighters Character Stage */
.fighters-stage {
  display: flex;
  justify-content: space-around;
  align-items: flex-end;
  height: 140px;
  position: relative;
  margin-top: 4px;
}

.fighter {
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: transform 0.2s ease;
  position: relative;
}

.fighter-avatar {
  width: 90px;
  height: 90px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
  animation: breathing 3s ease-in-out infinite alternate;
}

.fighter.blue .fighter-avatar {
  filter: drop-shadow(0 0 16px rgba(0, 242, 254, 0.4));
}

.fighter.red .fighter-avatar {
  filter: drop-shadow(0 0 16px rgba(255, 8, 68, 0.4));
  transform: scaleX(-1);
  animation: breathingRed 3s ease-in-out infinite alternate;
}

@keyframes breathing {
  0% { transform: translateY(0px) scale(1); }
  100% { transform: translateY(-6px) scale(1.03); }
}

@keyframes breathingRed {
  0% { transform: scaleX(-1) translateY(0px) scale(1); }
  100% { transform: scaleX(-1) translateY(-6px) scale(1.03); }
}

/* Attack & Recoil Animations */
.attack-lunge-blue {
  animation: attackBlue 0.35s ease forwards !important;
}

.attack-lunge-red {
  animation: attackRed 0.35s ease forwards !important;
}

.hit-recoil {
  animation: hurtShake 0.4s ease forwards !important;
}

@keyframes attackBlue {
  0% { transform: translateX(0); }
  50% { transform: translateX(80px) scale(1.1); }
  100% { transform: translateX(0); }
}

@keyframes attackRed {
  0% { transform: translateX(0); }
  50% { transform: translateX(-80px) scale(1.1); }
  100% { transform: translateX(0); }
}

@keyframes hurtShake {
  0%, 100% { transform: translateX(0); filter: brightness(1); }
  20% { transform: translateX(-12px); filter: brightness(2) drop-shadow(0 0 20px #ff0844); }
  40% { transform: translateX(12px); }
  60% { transform: translateX(-8px); }
  80% { transform: translateX(8px); }
}

.fighter-name-tag {
  font-size: 0.8rem;
  font-weight: 700;
  margin-top: 4px;
  background: rgba(0, 0, 0, 0.6);
  padding: 2px 8px;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.1);
}

/* Combat Feed Log */
.combat-feed {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  text-align: center;
  font-size: 0.95rem;
  font-weight: 800;
  color: var(--yellow-neon);
  text-shadow: 0 0 12px rgba(249, 212, 35, 0.8);
  pointer-events: none;
  min-height: 24px;
  transition: all 0.2s ease;
}

/* Action Skills Selector (Tabs) */
.skills-tab-bar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  margin-bottom: 12px;
}

.skill-tab {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 8px;
  border-radius: 12px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  position: relative;
  overflow: hidden;
}

.skill-tab:hover {
  background: var(--bg-card-hover);
  border-color: rgba(0, 242, 254, 0.5);
  transform: translateY(-2px);
}

.skill-tab.active {
  background: linear-gradient(145deg, #1b2840, #223554);
  border-color: var(--cyan-neon);
  box-shadow: 0 0 16px rgba(0, 242, 254, 0.3);
}

.skill-tab.active::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 10%;
  width: 80%;
  height: 3px;
  background: var(--cyan-neon);
  border-radius: 999px;
  box-shadow: 0 0 8px var(--cyan-neon);
}

.skill-icon {
  font-size: 1.25rem;
}

.skill-name {
  font-size: 0.85rem;
  font-weight: 800;
  color: var(--text-main);
}

.skill-desc {
  font-size: 0.7rem;
  color: var(--text-muted);
}

/* Question & Combat Interaction Box (Bottom Half) */
.question-panel {
  background: var(--bg-card);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  position: relative;
}

/* Word Prompt Card */
.word-prompt-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 12px;
  background: rgba(0, 0, 0, 0.25);
  border-radius: 12px;
  border: 1px dashed rgba(255, 255, 255, 0.15);
  position: relative;
}

.word-target {
  font-size: 2rem;
  font-weight: 900;
  color: var(--cyan-neon);
  letter-spacing: 1px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.btn-speak {
  background: rgba(0, 242, 254, 0.15);
  border: 1px solid var(--cyan-neon);
  color: var(--cyan-neon);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.btn-speak:hover {
  background: var(--cyan-neon);
  color: #0b0f19;
  transform: scale(1.1);
}

.word-meta {
  display: flex;
  gap: 10px;
  margin-top: 4px;
  font-size: 0.85rem;
  color: var(--text-muted);
  font-family: monospace;
}

.question-instruction {
  font-size: 0.9rem;
  color: var(--orange-neon);
  font-weight: 600;
}

/* Mode 1: 4-Choice Options Grid */
.choices-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.btn-choice {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  padding: 14px 16px;
  border-radius: 12px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
  outline: none;
}

.btn-choice:hover {
  background: rgba(0, 242, 254, 0.15);
  border-color: var(--cyan-neon);
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.3);
  transform: translateY(-2px);
}

.btn-choice.correct {
  background: rgba(0, 245, 160, 0.25) !important;
  border-color: var(--green-neon) !important;
  color: var(--green-neon) !important;
  box-shadow: 0 0 16px rgba(0, 245, 160, 0.5);
}

.btn-choice.wrong {
  background: rgba(255, 8, 68, 0.25) !important;
  border-color: var(--red-neon) !important;
  color: var(--red-neon) !important;
  box-shadow: 0 0 16px rgba(255, 8, 68, 0.5);
  animation: shake 0.3s ease;
}

/* Mode 2: Spell Puzzle (Letter Bubbles) */
.spell-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.spell-slots-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  min-height: 48px;
  padding: 6px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 12px;
  width: 100%;
}

.letter-slot {
  width: 42px;
  height: 46px;
  background: rgba(255, 255, 255, 0.06);
  border: 2px dashed rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--cyan-neon);
  text-transform: uppercase;
  cursor: pointer;
  transition: all 0.2s ease;
}

.letter-slot.filled {
  border-style: solid;
  border-color: var(--cyan-neon);
  background: rgba(0, 242, 254, 0.15);
  box-shadow: 0 0 10px rgba(0, 242, 254, 0.3);
}

.scrambled-letters-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.letter-bubble {
  width: 44px;
  height: 48px;
  background: linear-gradient(145deg, #1f2d48, #162033);
  border: 1px solid rgba(0, 242, 254, 0.4);
  color: var(--text-main);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.3rem;
  font-weight: 900;
  text-transform: uppercase;
  cursor: pointer;
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
  transition: all 0.15s ease;
}

.letter-bubble:hover {
  background: var(--cyan-neon);
  color: #0b0f19;
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 0 14px var(--cyan-neon);
}

.letter-bubble.used {
  opacity: 0.2;
  pointer-events: none;
  transform: scale(0.9);
}

.spell-actions {
  display: flex;
  gap: 12px;
}

/* Mode 3: Example Sentence Cloze (Heal Spell) */
.cloze-board {
  display: flex;
  flex-direction: column;
  gap: 14px;
  align-items: center;
  text-align: center;
}

.cloze-sentence {
  font-size: 1.15rem;
  line-height: 1.6;
  background: rgba(0, 0, 0, 0.3);
  padding: 16px 20px;
  border-radius: 12px;
  border-left: 4px solid var(--green-neon);
  color: #e2e8f0;
}

.cloze-blank {
  display: inline-block;
  min-width: 100px;
  border-bottom: 2px solid var(--green-neon);
  color: var(--green-neon);
  font-weight: 800;
  padding: 0 8px;
}

/* Modal Popup (Custom Vocab, Victory, Defeat) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background: rgba(6, 9, 15, 0.85);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-overlay.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid rgba(0, 242, 254, 0.4);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.8), 0 0 30px rgba(0, 242, 254, 0.2);
  border-radius: 20px;
  width: 100%;
  max-width: 540px;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  transform: scale(0.92);
  transition: transform 0.25s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.active .modal-card {
  transform: scale(1);
}

.modal-title {
  font-size: 1.4rem;
  font-weight: 900;
  text-align: center;
}

.modal-textarea {
  width: 100%;
  height: 150px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  padding: 10px;
  color: var(--text-main);
  font-family: monospace;
  font-size: 0.9rem;
  resize: vertical;
}

.modal-btn-row {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.btn-primary {
  background: linear-gradient(135deg, var(--cyan-neon), var(--blue-neon));
  border: none;
  color: #0b0f19;
  font-weight: 800;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-primary:hover {
  box-shadow: 0 0 16px var(--cyan-neon);
  transform: translateY(-2px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: var(--text-main);
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 10px;
  cursor: pointer;
}


/* ── 多人模式新增樣式 ────────────────────────────────────────────────── */

/* Utility: hidden class */
.hidden { display: none !important; }

/* Room Info Badge */
.room-info-badge {
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.2), rgba(79, 172, 254, 0.2));
  border-color: var(--cyan-neon) !important;
  color: var(--cyan-neon);
  font-weight: 800;
  animation: pulseBadge 2s ease-in-out infinite;
}

@keyframes pulseBadge {
  0%, 100% { box-shadow: 0 0 6px rgba(0, 242, 254, 0.3); }
  50%       { box-shadow: 0 0 16px rgba(0, 242, 254, 0.7); }
}

/* Lobby Modal */
.lobby-card {
  max-width: 420px;
  gap: 14px;
}

.lobby-subtitle {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: -8px;
}

.lobby-big-btn {
  width: 100%;
  padding: 14px 20px;
  border-radius: 14px;
  font-size: 1.05rem;
  font-weight: 800;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  transition: all 0.2s ease;
}

.btn-sublabel {
  font-size: 0.75rem;
  font-weight: 500;
  opacity: 0.75;
}

.btn-multiplayer {
  background: linear-gradient(135deg, #a18cd1, #fbc2eb);
  border: none;
  color: #1a0a2e;
  font-weight: 800;
  padding: 10px 20px;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-multiplayer:hover {
  box-shadow: 0 0 16px rgba(161, 140, 209, 0.7);
  transform: translateY(-2px);
}

.lobby-divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  letter-spacing: 1px;
}

.lobby-join-row {
  display: flex;
  gap: 10px;
  align-items: stretch;
}

.room-code-input {
  flex: 1;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(161, 140, 209, 0.5);
  border-radius: 10px;
  padding: 10px 14px;
  color: var(--text-main);
  font-size: 1.2rem;
  font-weight: 900;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 4px;
  outline: none;
}

.room-code-input:focus {
  border-color: var(--purple-neon);
  box-shadow: 0 0 12px rgba(161, 140, 209, 0.4);
}

.join-btn {
  padding: 10px 18px;
  font-size: 0.9rem;
}

.lobby-difficulty-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding-top: 4px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

/* Waiting Room */
.room-code-display {
  font-size: 3rem;
  font-weight: 900;
  letter-spacing: 12px;
  color: var(--cyan-neon);
  text-shadow: 0 0 20px rgba(0, 242, 254, 0.7);
  background: rgba(0, 0, 0, 0.4);
  padding: 16px 24px;
  border-radius: 14px;
  border: 2px solid rgba(0, 242, 254, 0.3);
  margin: 8px 0;
}

.waiting-spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(0, 242, 254, 0.3);
  border-top-color: var(--cyan-neon);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 8px auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* Turn Timer Bar */
.turn-timer-bar {
  width: 100%;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
  position: relative;
  margin-bottom: 8px;
}

.turn-timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #00f2fe, #4facfe);
  border-radius: 999px;
  transition: width 1s linear, background 0.3s ease;
}

.turn-timer-label {
  position: absolute;
  right: 8px;
  top: -2px;
  font-size: 0.75rem;
  font-weight: 800;
  color: var(--text-muted);
  pointer-events: none;
}

/* Opponent Turn Overlay */
.opponent-turn-overlay {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  display: flex;
  justify-content: center;
  align-items: flex-end;
  padding-bottom: 16px;
  z-index: 50;
  pointer-events: none;
  opacity: 0;
  transform: translateY(100%);
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.opponent-turn-overlay.active {
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

.opponent-turn-card {
  background: rgba(15, 20, 35, 0.95);
  border: 1px solid rgba(255, 8, 68, 0.4);
  box-shadow: 0 -4px 24px rgba(255, 8, 68, 0.2);
  backdrop-filter: blur(12px);
  border-radius: 16px 16px 0 0;
  padding: 16px 24px;
  width: 100%;
  max-width: 960px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.opponent-turn-label {
  font-size: 1rem;
  font-weight: 800;
  color: var(--orange-neon);
}

.opponent-timer-bar {
  width: 100%;
  height: 6px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.opponent-timer-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #ff0844, #ffb199);
  border-radius: 999px;
  transition: width 1s linear;
}

/* Shake Animation Utility */
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25%       { transform: translateX(-8px); }
  70%       { transform: translateX(8px); }
}

/* Responsive adjustments */
@media (max-width: 600px) {
  .choices-grid { grid-template-columns: 1fr; }
  .fighters-stage { height: 110px; }
  .fighter-avatar { width: 70px; height: 70px; }
  .word-target { font-size: 1.6rem; }
  .room-code-display { font-size: 2rem; letter-spacing: 8px; }
  .lobby-join-row { flex-direction: column; }
}
