/* Space Adventure: The Odyssey - Page Specific Styles.
 * Sci-Fi HUD, cockpit aesthetic, holographic accents, neon cyan/purple highlights.
 */

:root {
  --sa-ink: #e0f2fe;
  --sa-muted: #7dd3fc;
  --sa-deep: #030712;
  --sa-panel: rgba(8, 18, 38, 0.82);
  --sa-cyan: #00f0ff;
  --sa-cyan-dim: #0284c7;
  --sa-hp: #ef4444;
  --sa-hp-low: #991b1b;
  --sa-force: #c084fc;
  --sa-force-bg: #581c87;
  --sa-gold: #38bdf8;
  --sa-gold-2: #0284c7;

  /* Aliases matching fa-* layout rules */
  --fa-ink: var(--sa-ink);
  --fa-muted: var(--sa-muted);
  --fa-deep: var(--sa-deep);
  --fa-panel: var(--sa-panel);
  --fa-gold: var(--sa-cyan);
  --fa-gold-2: var(--sa-cyan-dim);
  --fa-hp: var(--sa-hp);
  --fa-hp-low: var(--sa-hp-low);
}

html {
  height: 100%;
}

body {
  background: #030712 !important;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  min-height: 100dvh;
  height: 100dvh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  text-align: center;
  overflow: hidden;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
}

#background-video,
.bg-video-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
  background-color: #030712;
}

.page-scrim {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(circle at 50% 10%, rgba(0, 240, 255, 0.08), transparent 50%),
    linear-gradient(180deg, rgba(3, 7, 18, 0.4), rgba(3, 7, 18, 0.85));
}

#gameContainer {
  position: relative;
  z-index: 2;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  width: min(100%, 1400px);
  margin: 0 auto;
  height: 100%;
  max-height: 100dvh;
  min-height: 0;
  overflow: hidden;
  padding: clamp(0.4rem, 1.5vw, 1.25rem);
  background-color: var(--sa-panel);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: var(--sa-ink);
  border-left: 1px solid rgba(0, 240, 255, 0.15);
  border-right: 1px solid rgba(0, 240, 255, 0.15);
}

.game-header {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

#gameContainer h1 {
  margin: 0.15rem 0 0.35rem;
  font-size: clamp(1.2rem, 3.5vw, 2.1rem);
  color: var(--sa-cyan);
  text-shadow: 0 0 12px rgba(0, 240, 255, 0.6);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 800;
}

.game-intro {
  flex: 0 0 auto;
  width: 100%;
  max-width: 760px;
  margin: 0 auto 0.4rem;
  font-size: 0.85rem;
  color: var(--sa-ink);
}

.game-intro summary {
  list-style: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.25rem 0.85rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: #030712;
  background: var(--sa-cyan);
  border: 1px solid rgba(0, 240, 255, 0.8);
  border-radius: 999px;
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
  letter-spacing: 0.04em;
}

.game-intro summary::-webkit-details-marker { display: none; }
.game-intro[open] summary .intro-arrow { transform: rotate(180deg); }
.game-intro .intro-arrow { display: inline-block; transition: transform 0.2s ease; }

.game-intro .intro-content {
  margin-top: 0.4rem;
  padding: 0.6rem 0.85rem;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid rgba(0, 240, 255, 0.4);
  font-size: 0.85rem;
  line-height: 1.45;
  color: var(--sa-ink);
  text-align: left;
  max-height: 150px;
  overflow-y: auto;
  box-shadow: inset 0 0 15px rgba(0, 0, 0, 0.6);
}

.game-intro .intro-content div { margin-bottom: 0.4rem; }

/* HUD */
#faHud {
  flex: 0 0 auto;
  margin: 0.25rem 0 0.55rem;
  padding: 0.6rem 0.8rem;
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(15, 23, 42, 0.88) 0%, rgba(8, 14, 28, 0.96) 100%);
  border: 1px solid rgba(0, 240, 255, 0.3);
  box-shadow: inset 0 1px 0 rgba(0, 240, 255, 0.15), 0 4px 16px rgba(0, 0, 0, 0.6);
  text-align: left;
  font-size: 0.82rem;
}

.fa-hud-summary {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  width: 100%;
  margin-bottom: 0.45rem;
  cursor: pointer;
  user-select: none;
  background: rgba(15, 23, 42, 0.8);
  padding: 0.35rem 0.6rem;
  border-radius: 8px;
  border: 1px solid rgba(0, 240, 255, 0.22);
  box-sizing: border-box;
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.fa-hud-summary:hover {
  border-color: rgba(0, 240, 255, 0.45);
  background: rgba(15, 23, 42, 0.9);
}

.fa-summary-row {
  display: flex;
  align-items: center;
  width: 100%;
  min-width: 0;
}

.fa-summary-row-main {
  justify-content: flex-start;
  gap: 0.6rem;
  flex-wrap: nowrap;
}

.fa-summary-row-sub {
  justify-content: flex-start;
  gap: 0.75rem;
  flex-wrap: wrap;
  border-top: 1px solid rgba(0, 240, 255, 0.1);
  padding-top: 0.25rem;
  font-size: 0.76rem;
}

.fa-summary-item {
  display: inline-flex;
  align-items: center;
  gap: 0.22rem;
  white-space: nowrap;
  flex-shrink: 0;
  font-size: 0.78rem;
}

.fa-summary-hp {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex: 0 1 auto;
  min-width: 0;
}

.fa-summary-companion {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 1 auto;
  min-width: 0;
}

.fa-summary-companion-short {
  display: none;
}

.fa-summary-label {
  font-size: 0.68rem;
  color: var(--sa-muted);
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.fa-summary-val {
  font-weight: 700;
  color: var(--sa-ink);
}

.fa-summary-location {
  flex: 0 1 auto;
  min-width: 0;
  overflow: hidden;
}

.fa-summary-location .fa-summary-val {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  display: inline-block;
  max-width: 140px;
}

.fa-summary-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 0.72rem;
  font-weight: 700;
  color: #030712;
  background: var(--sa-cyan);
  padding: 0.18rem 0.55rem;
  border-radius: 9999px;
  flex-shrink: 0;
  cursor: pointer;
  margin-left: auto;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
  transition: all 0.2s ease;
  z-index: 5;
}

.fa-summary-toggle:hover {
  background: #38bdf8;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.7);
}

.fa-hud-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 0.35rem 0.45rem;
  transition: max-height 0.25s ease, opacity 0.2s ease;
}

.fa-hud-grid.fa-collapsed {
  display: none;
}

.fa-stat {
  display: flex;
  flex-direction: column;
  background: rgba(30, 41, 59, 0.45);
  padding: 0.25rem 0.38rem;
  border-radius: 6px;
  border: 1px solid rgba(0, 240, 255, 0.12);
  min-width: 0;
  box-sizing: border-box;
}

.fa-stat-wide {
  grid-column: span 1;
}

.fa-stat-full,
#saCompanionStat {
  grid-column: 1 / -1;
}

.fa-label {
  font-size: 0.62rem;
  text-transform: uppercase;
  color: var(--sa-muted);
  font-weight: 700;
  letter-spacing: 0.04em;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  margin-bottom: 0.15rem;
}

.fa-value {
  font-size: 0.78rem;
  line-height: 1.25;
  font-weight: 700;
  color: var(--sa-ink);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.fa-stat-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.fa-comp-badge {
  font-size: 0.65rem;
  font-weight: 700;
  color: #030712;
  background: var(--sa-cyan);
  padding: 0.1rem 0.45rem;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border: 1px solid transparent;
  line-height: 1.2;
}

.fa-comp-badge.is-novice,
.fa-comp-badge.is-rookie {
  background: rgba(245, 158, 11, 0.2);
  border-color: rgba(245, 158, 11, 0.5);
  color: #fbbf24;
}

.fa-comp-badge.is-proficient,
.fa-comp-badge.is-veteran {
  background: rgba(59, 130, 246, 0.2);
  border-color: rgba(59, 130, 246, 0.5);
  color: #93c5fd;
}

.fa-comp-badge.is-master,
.fa-comp-badge.is-elite {
  background: rgba(16, 185, 129, 0.2);
  border-color: rgba(16, 185, 129, 0.5);
  color: #6ee7b7;
}

.fa-comp-badge.is-down {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.5);
  color: #f87171;
}

.fa-comp-badge.is-romanced {
  background: rgba(236, 72, 153, 0.25);
  border-color: rgba(236, 72, 153, 0.6);
  color: #f472b6;
}

.fa-comp-sub,
#saCompanionGear {
  font-size: 0.72rem;
  color: var(--sa-muted);
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
}

.fa-hp-bar {
  width: 100%;
  height: 8px;
  background: rgba(15, 23, 42, 0.85);
  border-radius: 4px;
  overflow: hidden;
  margin-top: 0.25rem;
  border: 1px solid rgba(239, 68, 68, 0.35);
}

.fa-hp-bar-sm {
  flex: 0 1 140px;
  width: 110px;
  min-width: 75px;
  max-width: 160px;
  height: 8px;
  display: inline-block;
  vertical-align: middle;
  margin: 0;
  border-radius: 4px;
}

.fa-companion-summary-hp-bar {
  flex: 0 1 80px;
  width: 70px;
  min-width: 45px;
  max-width: 95px;
  height: 8px;
  border-radius: 4px;
  border-color: rgba(0, 240, 255, 0.4);
}

.fa-companion-summary-hp-bar .fa-hp-fill {
  background: linear-gradient(90deg, #00f0ff, #38bdf8);
}

.fa-hp-fill {
  height: 100%;
  background: linear-gradient(90deg, #ef4444, #f87171);
  width: 100%;
  transition: width 0.3s ease;
}

/* Play Area */
#faPlay {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: rgba(15, 23, 42, 0.75);
  border-radius: 10px;
  border: 1px solid rgba(0, 240, 255, 0.2);
  padding: 0.5rem;
  overflow: hidden;
}

.fa-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding-bottom: 0.4rem;
  border-bottom: 1px solid rgba(0, 240, 255, 0.15);
}

.fa-header-brand {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  min-width: 0;
}

.fa-mark { font-size: 1.25rem; line-height: 1; flex-shrink: 0; }
.fa-name { font-weight: 800; color: var(--sa-cyan); text-align: left; font-size: 0.95rem; white-space: nowrap; }

.fa-header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin-left: auto;
  flex-shrink: 0;
}

.fa-tts-controls {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.fa-icon-btn,
.fa-mute,
.fa-tts-toggle,
.fa-tts-settings,
.fa-reset {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  cursor: pointer;
  background: rgba(30, 41, 59, 0.7);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: var(--sa-ink);
  border-radius: 6px;
  font-size: 0.95rem;
  line-height: 1;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-sizing: border-box;
}

.fa-icon-btn:hover,
.fa-mute:hover,
.fa-tts-toggle:hover,
.fa-tts-settings:hover {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--sa-cyan);
}

.fa-reset {
  background: rgba(239, 68, 68, 0.2);
  border-color: rgba(239, 68, 68, 0.4);
}
.fa-reset:hover {
  background: rgba(239, 68, 68, 0.4);
  border-color: #ef4444;
}

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

.fa-messages-wrap {
  flex: 1 1 auto;
  min-height: 0;
  position: relative;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#saMessages,
#faMessages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.5rem 0.25rem;
  text-align: left;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  -webkit-overflow-scrolling: touch;
}

#saScrollBottom,
.fa-scroll-bottom {
  position: absolute;
  bottom: 12px;
  right: 16px;
  width: 36px !important;
  height: 36px !important;
  min-width: 36px !important;
  max-width: 36px !important;
  border-radius: 50% !important;
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.9) 0%, rgba(0, 240, 255, 0.9) 100%) !important;
  color: #030712 !important;
  border: 1px solid rgba(0, 240, 255, 0.8) !important;
  box-shadow: 0 0 12px rgba(0, 240, 255, 0.5) !important;
  cursor: pointer;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 18px !important;
  font-weight: bold;
  line-height: 1 !important;
  z-index: 20;
  opacity: 0;
  pointer-events: none;
  transform: translateY(6px);
  transition: opacity 0.2s ease, transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
  padding: 0 !important;
  margin: 0 !important;
}

#saScrollBottom.visible,
.fa-scroll-bottom.visible {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

#saScrollBottom:hover,
.fa-scroll-bottom:hover {
  background: linear-gradient(135deg, rgba(0, 240, 255, 1) 0%, rgba(56, 189, 248, 1) 100%) !important;
  box-shadow: 0 0 18px rgba(0, 240, 255, 0.8) !important;
  transform: translateY(-2px);
}

.fa-msg {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  font-size: 0.88rem;
  line-height: 1.45;
  margin-bottom: 0.35rem;
  width: 100%;
  box-sizing: border-box;
}

.fa-msg-bot {
  justify-content: flex-start;
  align-self: flex-start;
}

.fa-msg-user {
  flex-direction: row-reverse;
  justify-content: flex-start;
  align-self: flex-end;
}

.fa-msg-avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  overflow: hidden;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(0, 240, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.2);
}
.fa-msg-avatar img { width: 100%; height: 100%; object-fit: cover; }

.fa-msg-user .fa-msg-avatar {
  border-color: rgba(56, 189, 248, 0.6);
  box-shadow: 0 0 8px rgba(56, 189, 248, 0.3);
}

.fa-msg-body {
  flex: 0 1 auto;
  max-width: min(82%, 65ch);
  background: rgba(15, 23, 42, 0.75);
  padding: 0.55rem 0.85rem;
  border-radius: 12px 12px 12px 2px;
  border: 1px solid rgba(0, 240, 255, 0.25);
  color: var(--sa-ink);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  overflow-wrap: anywhere;
  word-break: break-word;
  text-align: left;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.fa-msg-body:hover {
  filter: brightness(1.08);
}

.fa-msg-user .fa-msg-body {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.35) 0%, rgba(3, 105, 161, 0.45) 100%);
  border: 1px solid rgba(56, 189, 248, 0.5);
  border-radius: 12px 12px 2px 12px;
  color: #f0f9ff;
  box-shadow: 0 2px 10px rgba(2, 132, 199, 0.2);
  text-align: left;
}

.fa-msg-system {
  display: block;
  align-self: center;
  margin: 0.3rem auto;
  font-style: italic;
  color: var(--sa-muted);
  font-size: 0.82rem;
  padding: 0.3rem 0.75rem;
  background: rgba(3, 7, 18, 0.55);
  border: 1px dashed rgba(0, 240, 255, 0.25);
  border-radius: 6px;
  max-width: min(90%, 70ch);
  text-align: center;
  box-sizing: border-box;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.fa-msg-system:hover {
  filter: brightness(1.15);
}

.fa-boss-taunt {
  align-self: center;
  max-width: min(90%, 65ch);
  margin: 0.35rem auto;
  background: rgba(239, 68, 68, 0.15);
  border-left: 3px solid #ef4444;
  border-top: 1px solid rgba(239, 68, 68, 0.25);
  border-right: 1px solid rgba(239, 68, 68, 0.25);
  border-bottom: 1px solid rgba(239, 68, 68, 0.25);
  padding: 0.45rem 0.75rem;
  color: #fca5a5;
  font-size: 0.85rem;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease, border-color 0.15s ease;
}

.fa-boss-taunt:hover {
  filter: brightness(1.15);
}

.fa-msg-body.is-speaking,
.fa-msg-system.is-speaking,
.fa-boss-taunt.is-speaking {
  border-color: #00f0ff !important;
  box-shadow: 0 0 14px rgba(0, 240, 255, 0.7), inset 0 0 8px rgba(0, 240, 255, 0.2) !important;
  animation: sa-speaking-pulse 1.6s ease-in-out infinite alternate;
}

@keyframes sa-speaking-pulse {
  0% { transform: scale(1); box-shadow: 0 0 6px rgba(0, 240, 255, 0.4); }
  100% { transform: scale(1.01); box-shadow: 0 0 16px rgba(0, 240, 255, 0.8); }
}
  border-radius: 0 6px 6px 0;
  box-shadow: 0 0 10px rgba(239, 68, 68, 0.15);
  text-align: left;
}

.fa-cursor {
  display: inline-block;
  animation: blink 1s infinite;
  color: var(--sa-cyan);
}
@keyframes blink { 0%, 50% { opacity: 1; } 51%, 100% { opacity: 0; } }

[hidden] {
  display: none !important;
}

/* Combat Box */
#saCombat[hidden],
#faCombat[hidden] {
  display: none !important;
}

#saCombat,
#faCombat {
  flex: 0 0 auto;
  margin-top: 0.4rem;
  padding: 0.5rem;
  border-radius: 8px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(239, 68, 68, 0.4);
  box-shadow: 0 0 12px rgba(239, 68, 68, 0.2);
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.4rem;
}

#saMonster,
#faMonster {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  font-weight: 700;
  color: #fca5a5;
  font-size: 0.85rem;
  text-align: left;
}

#saAttack,
#faAttack,
#saMagicBtn,
#faMagicBtn,
#saForceBtn,
#saFlee,
#faFlee {
  flex: 1 1 auto;
  cursor: pointer;
  padding: 0.45rem 0.8rem;
  border-radius: 6px;
  font-weight: 700;
  font-size: 0.85rem;
  transition: all 0.2s ease;
}

#saAttack,
#faAttack {
  background: linear-gradient(135deg, #0284c7, #0369a1);
  color: #fff;
  border: 1px solid #38bdf8;
}
#saAttack:hover,
#faAttack:hover { background: #0284c7; box-shadow: 0 0 8px rgba(56, 189, 248, 0.5); }

#saMagicBtn,
#faMagicBtn {
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
  border: 1px solid #34d399;
}
#saMagicBtn:hover,
#faMagicBtn:hover { background: #059669; box-shadow: 0 0 8px rgba(52, 211, 153, 0.5); }

#saForceBtn {
  background: linear-gradient(135deg, #6b21a8, #7e22ce);
  color: #f3e8ff;
  border: 1px solid #c084fc;
  text-shadow: 0 0 6px #d8b4fe;
}
#saForceBtn:hover:not(:disabled) {
  background: linear-gradient(135deg, #7e22ce, #9333ea);
  box-shadow: 0 0 12px rgba(192, 132, 252, 0.6);
}
#saForceBtn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

#saFlee,
#faFlee {
  background: rgba(51, 65, 85, 0.8);
  color: #cbd5e1;
  border: 1px solid #64748b;
}
#saFlee:hover,
#faFlee:hover { background: #475569; }

/* Actions & Stims */
#saActions,
#faActions {
  flex: 0 0 auto;
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
  flex-wrap: wrap;
}

#saPotion,
#faPotion,
#saPotion2,
#faPotion2,
#saHealCompanion,
#faHealCompanion {
  flex: 1 1 auto;
  cursor: pointer;
  padding: 0.35rem 0.65rem;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: var(--sa-ink);
  font-size: 0.78rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

#saPotion:hover:not(:disabled),
#faPotion:hover:not(:disabled),
#saPotion2:hover:not(:disabled),
#faPotion2:hover:not(:disabled),
#saHealCompanion:hover:not(:disabled),
#faHealCompanion:hover:not(:disabled) {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--sa-cyan);
}

#saPotion:disabled,
#faPotion:disabled,
#saPotion2:disabled,
#faPotion2:disabled,
#saHealCompanion:disabled,
#faHealCompanion:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Choices */
#saChoices,
#faChoices {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

.fa-choice-btn {
  flex: 1 1 auto;
  cursor: pointer;
  padding: 0.4rem 0.75rem;
  border-radius: 6px;
  background: rgba(30, 41, 59, 0.75);
  border: 1px solid rgba(0, 240, 255, 0.35);
  color: var(--sa-ink);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  transition: all 0.2s ease;
}

.fa-choice-btn:hover {
  background: rgba(0, 240, 255, 0.25);
  border-color: var(--sa-cyan);
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.3);
}

.fa-reward-note {
  width: 100%;
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--sa-cyan);
  text-align: center;
  margin-bottom: 0.2rem;
}

.fa-reward-btn {
  background: linear-gradient(135deg, rgba(2, 132, 199, 0.4), rgba(14, 165, 233, 0.3));
  border-color: var(--sa-cyan);
}

.fa-companion-btn {
  background: linear-gradient(135deg, rgba(16, 185, 129, 0.3), rgba(5, 150, 105, 0.25));
  border-color: #10b981;
  color: #a7f3d0;
}
.fa-companion-btn:hover {
  background: rgba(16, 185, 129, 0.45);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.4);
}

/* Input Form */
#saForm,
#faForm {
  flex: 0 0 auto;
  display: flex;
  gap: 0.4rem;
  margin-top: 0.4rem;
}

#saInput,
#faInput {
  flex: 1 1 auto;
  padding: 0.45rem 0.75rem;
  border-radius: 6px;
  background: rgba(15, 23, 42, 0.9);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: #fff;
  font-size: 0.85rem;
  outline: none;
}
#saInput:focus,
#faInput:focus {
  border-color: var(--sa-cyan);
  box-shadow: 0 0 8px rgba(0, 240, 255, 0.4);
}

#saSend,
#faSend {
  cursor: pointer;
  padding: 0.45rem 1rem;
  border-radius: 6px;
  background: var(--sa-cyan) !important;
  color: #030712 !important;
  font-weight: 800;
  font-size: 0.85rem;
  border: none;
  transition: all 0.2s ease;
}
#saSend:hover:not(:disabled),
#faSend:hover:not(:disabled) {
  box-shadow: 0 0 10px rgba(0, 240, 255, 0.6);
}
#saSend:disabled,
#faSend:disabled { opacity: 0.4; cursor: not-allowed; }

/* Save / Load */
#saSave,
#faSave {
  flex: 0 0 auto;
  margin-top: 0.4rem;
  text-align: left;
  font-size: 0.78rem;
}
#saSave summary,
#faSave summary {
  cursor: pointer;
  color: var(--sa-muted);
}
#saSave summary:hover,
#faSave summary:hover { color: var(--sa-cyan); }

#saSaveBody,
#faSaveBody {
  margin-top: 0.3rem;
  padding: 0.4rem;
  background: rgba(15, 23, 42, 0.8);
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}
#saSaveCode,
#faSaveCode {
  width: 100%;
  box-sizing: border-box;
  background: #030712;
  border: 1px solid rgba(0, 240, 255, 0.2);
  color: var(--sa-muted);
  font-family: monospace;
  font-size: 0.72rem;
  padding: 0.3rem;
  border-radius: 4px;
  resize: vertical;
}
#saSaveRow,
#faSaveRow {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-top: 0.3rem;
}
#saSaveCopy,
#faSaveCopy,
#saSaveLoad,
#faSaveLoad {
  cursor: pointer;
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: var(--sa-ink);
  font-size: 0.75rem;
}
#saSaveCopy:hover,
#faSaveCopy:hover,
#saSaveLoad:hover,
#faSaveLoad:hover {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--sa-cyan);
}
#saSaveMsg,
#faSaveMsg {
  font-size: 0.75rem;
  color: var(--sa-cyan);
  line-height: 1.35;
}
#saSaveMsg.is-bad,
#faSaveMsg.is-bad {
  color: #ff6b6b;
}
#saSaveMsg.is-good,
#faSaveMsg.is-good {
  color: #51cf66;
}
#saSaveMsg a,
#faSaveMsg a,
.fa-msg a {
  color: #00f0ff;
  text-decoration: underline;
  font-weight: 600;
}
#saSaveMsg a:hover,
#faSaveMsg a:hover,
.fa-msg a:hover {
  color: #ffffff;
}

/* TTS Panel Modal */
.fa-tts-panel[hidden] {
  display: none !important;
}

.fa-tts-panel {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.fa-tts-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}
.fa-tts-dialog {
  position: relative;
  z-index: 1000;
  width: min(90%, 420px);
  background: #0f172a;
  border: 1px solid rgba(0, 240, 255, 0.4);
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 0 25px rgba(0, 240, 255, 0.2);
  text-align: left;
  color: var(--sa-ink);
}
.fa-tts-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
}
.fa-tts-dialog-head h2 { margin: 0; font-size: 1.1rem; color: var(--sa-cyan); flex: 1 1 auto; }
#saVolDefault,
#faVolDefault {
  cursor: pointer;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  background: rgba(30, 41, 59, 0.8);
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: var(--sa-cyan);
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 0.5rem;
  transition: all 0.2s ease;
}
#saVolDefault:hover,
#faVolDefault:hover {
  background: rgba(0, 240, 255, 0.2);
  border-color: var(--sa-cyan);
}
#saTtsClose,
#faTtsClose {
  background: transparent;
  border: none;
  color: var(--sa-muted);
  font-size: 1.2rem;
  cursor: pointer;
}
#saTtsClose:hover,
#faTtsClose:hover {
  color: var(--sa-cyan);
}
.fa-vol-list {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}
.fa-vol-row {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}
.fa-vol-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  font-weight: 600;
}
.fa-vol-row input[type="range"] {
  accent-color: var(--sa-cyan);
}
.fa-tts-voice-block {
  margin-top: 0.8rem;
  padding-top: 0.6rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}
.fa-tts-select-wrap select {
  width: 100%;
  padding: 0.35rem;
  border-radius: 6px;
  background: #1e293b;
  border: 1px solid rgba(0, 240, 255, 0.3);
  color: #fff;
  font-size: 0.82rem;
  margin-top: 0.3rem;
}
.fa-tts-preview-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}
#saTtsPreview,
#faTtsPreview {
  cursor: pointer;
  padding: 0.3rem 0.6rem;
  border-radius: 4px;
  background: rgba(0, 240, 255, 0.2);
  border: 1px solid var(--sa-cyan);
  color: #fff;
  font-size: 0.78rem;
}
#saTtsPreview:hover,
#faTtsPreview:hover {
  background: rgba(0, 240, 255, 0.4);
}

.fa-tts-queue-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.fa-tts-queue-label {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--sa-cyan);
  cursor: pointer;
  user-select: none;
}

.fa-tts-queue-label input[type="checkbox"] {
  accent-color: var(--sa-cyan);
  cursor: pointer;
  width: 1rem;
  height: 1rem;
}

@media (max-width: 767px) {
  body {
    padding: 0 !important;
    height: 100dvh;
    min-height: 100dvh;
    overflow: hidden;
    background-attachment: scroll;
  }

  #gameContainer {
    padding: 0.25rem 0.35rem 0.35rem;
    width: 100%;
    /* Leave room at bottom for floating website assistant widget so it never covers the Send button */
    height: calc(100dvh - 80px);
    max-height: calc(100dvh - 80px);
    margin-bottom: 80px;
  }

  /* Compact floating website assistant on mobile */
  #custom-chat-widget {
    bottom: 12px !important;
    right: 12px !important;
  }
  #custom-chat-widget #chat-widget-button {
    width: 48px !important;
    height: 48px !important;
    min-width: 48px !important;
    min-height: 48px !important;
    max-width: 48px !important;
    max-height: 48px !important;
  }

  .game-header {
    margin-bottom: 0.1rem;
  }

  #gameContainer h1 {
    font-size: 0.95rem;
    margin: 0 0 0.1rem;
    line-height: 1.1;
  }

  .game-intro {
    margin: 0 auto 0.12rem;
    font-size: 0.72rem;
  }

  .game-intro summary {
    padding: 0.12rem 0.45rem;
    font-size: 0.68rem;
  }

  .game-intro .intro-content {
    max-height: 80px;
    font-size: 0.72rem;
    padding: 0.3rem 0.45rem;
  }

  #faPlay {
    flex: 1 1 0;
    min-height: 0;
    border-radius: 10px;
  }

  #saMessages {
    flex: 1 1 0;
    min-height: 0;
    padding: 0.45rem 0.55rem;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
  }

  #saChoices,
  #faChoices {
    margin-top: 0.2rem;
    padding: 0.15rem 0.35rem;
    gap: 0.22rem;
    max-height: 90px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .fa-choice-btn {
    padding: 0.22rem 0.45rem;
    font-size: 0.72rem;
    line-height: 1.2;
    border-radius: 4px;
    min-height: 26px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    word-break: break-word;
  }

  .fa-reward-note {
    font-size: 0.72rem;
    margin-bottom: 0.1rem;
    line-height: 1.2;
  }

  .fa-reward-btn,
  .fa-companion-btn {
    padding: 0.22rem 0.45rem;
    font-size: 0.72rem;
    line-height: 1.2;
  }

  /* Mobile Combat Controls: 2x2 symmetrical grid */
  #saCombat,
  #faCombat {
    margin-top: 0.2rem;
    padding: 0.25rem 0.35rem;
    border-radius: 6px;
    display: grid !important;
    grid-template-columns: 1fr 1fr;
    gap: 0.22rem;
    box-shadow: 0 0 8px rgba(239, 68, 68, 0.25);
  }

  #saCombat[hidden],
  #faCombat[hidden] {
    display: none !important;
  }

  #saMonster,
  #faMonster {
    grid-column: 1 / -1;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 0.3rem;
    padding-bottom: 0.15rem;
    border-bottom: 1px solid rgba(239, 68, 68, 0.25);
    margin-bottom: 0.05rem;
  }

  #saMonsterInfo,
  #faMonsterInfo {
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1.15;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1 1 auto;
    text-align: left;
    color: #fca5a5;
  }

  .fa-monster-hp-bar {
    width: 65px;
    min-width: 50px;
    height: 6px;
    flex: 0 0 auto;
    margin: 0;
  }

  #saAttack,
  #faAttack,
  #saMagicBtn,
  #faMagicBtn,
  #saForceBtn,
  #faForceBtn,
  #saFlee,
  #faFlee {
    padding: 0.22rem 0.3rem;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.15;
    border-radius: 4px;
    min-height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: normal;
    word-break: break-word;
  }

  /* Mobile Stims & Actions Row: single 1-row flex */
  #saActions,
  #faActions {
    margin-top: 0.18rem;
    display: flex;
    flex-direction: row;
    gap: 0.2rem;
    flex-wrap: nowrap;
  }

  #saPotion,
  #faPotion,
  #saPotion2,
  #faPotion2,
  #saHealCompanion,
  #faHealCompanion {
    flex: 1 1 0;
    min-width: 0;
    padding: 0.2rem 0.25rem;
    font-size: 0.67rem;
    line-height: 1.12;
    border-radius: 4px;
    min-height: 24px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #saPotion small,
  #faPotion small,
  #saPotion2 small,
  #faPotion2 small,
  #saHealCompanion small,
  #faHealCompanion small {
    font-size: 0.62rem;
    opacity: 0.85;
    margin-left: 0.15rem;
  }

  #saForm {
    padding: 0.25rem 0.4rem 0.25rem;
    gap: 0.25rem;
    margin-top: 0.2rem;
  }

  #saInput {
    padding: 0.4rem 0.6rem;
    font-size: 0.82rem;
  }

  #saSend {
    padding: 0.4rem 0.65rem;
    font-size: 0.8rem;
  }

  .fa-hud-summary {
    gap: 0.22rem;
    padding: 0.25rem 0.45rem;
    margin-bottom: 0.25rem;
  }

  .fa-summary-row-main {
    gap: 0.35rem;
  }

  .fa-summary-row-sub {
    gap: 0.45rem;
    padding-top: 0.18rem;
    font-size: 0.72rem;
  }

  .fa-summary-item {
    font-size: 0.72rem;
    gap: 0.15rem;
  }

  .fa-summary-hp {
    gap: 0.25rem;
  }

  .fa-hp-bar-sm {
    width: 85px;
    min-width: 60px;
    height: 7px;
  }

  .fa-companion-summary-hp-bar {
    width: 55px;
    min-width: 40px;
    height: 7px;
  }

  .fa-summary-companion-full {
    display: none;
  }

  .fa-summary-companion-short {
    display: inline;
  }

  .fa-summary-location .fa-summary-val {
    max-width: 110px;
  }

  .fa-summary-toggle {
    padding: 0.12rem 0.45rem;
    font-size: 0.68rem;
  }

  .fa-header {
    padding-bottom: 0.25rem;
    gap: 0.35rem;
  }

  .fa-mark {
    font-size: 1.05rem;
  }

  .fa-name {
    font-size: 0.85rem;
  }

  .fa-header-actions {
    gap: 0.25rem;
  }

  .fa-icon-btn,
  .fa-mute,
  .fa-tts-toggle,
  .fa-tts-settings,
  .fa-reset {
    width: 28px;
    height: 28px;
    font-size: 0.82rem;
    border-radius: 5px;
  }

  .fa-hud-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 0.25rem 0.3rem;
  }
  .fa-stat {
    padding: 0.2rem 0.3rem;
  }
  .fa-stat-wide {
    grid-column: span 1;
  }
  .fa-stat-full,
  #saCompanionStat {
    grid-column: 1 / -1;
  }
  .fa-value {
    font-size: 0.74rem;
    line-height: 1.2;
  }
  .fa-label {
    font-size: 0.58rem;
  }
}
