/* ==========================================================================
 * 《魔幻蒸汽 Arcana Metropolis》— Full-Screen / Mobile Game Settings Modal
 * File: src/styles/game-settings-modal.css
 * Astral Midnight-Sapphire & Champagne-Platinum Styling
 * Zero OS Emojis · Desktop Two-Pane + Mobile Landscape Compact Sheet
 * ========================================================================== */

.game-settings-modal {
  position: absolute;
  inset: 0;
  z-index: 960;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 16px;
  box-sizing: border-box;
  font-family: var(--ff-serif, 'Noto Serif TC', 'PingFang TC', 'Microsoft JhengHei', serif);
  color: var(--ivory-ink, #f5f0e6);
}

body > .game-settings-modal {
  position: fixed;
}

.game-settings-modal.show {
  display: flex;
  animation: gsmFadeIn 0.18s cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes gsmFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.gsm-backdrop {
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 45%, rgba(6, 12, 26, 0.76) 0%, rgba(2, 5, 12, 0.90) 100%);
  backdrop-filter: blur(5px);
}

.gsm-shell {
  position: relative;
  z-index: 1;
  width: min(860px, 94vw);
  max-height: min(84vh, 620px);
  display: flex;
  flex-direction: column;
  background: linear-gradient(180deg, var(--sapphire-950, rgba(4, 8, 18, 0.96)) 0%, rgba(5, 10, 24, 0.98) 100%);
  border-top: 1.5px solid var(--champagne, #e5d5b5);
  border-bottom: 1.5px solid var(--champagne, #e5d5b5);
  border-left: 1px solid rgba(229, 213, 181, 0.32);
  border-right: 1px solid rgba(229, 213, 181, 0.32);
  box-shadow:
    0 24px 68px rgba(0, 0, 0, 0.94),
    inset 0 0 32px rgba(125, 211, 252, 0.06);
  overflow: hidden;
}

/* Header */
.gsm-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 18px;
  background: linear-gradient(90deg, rgba(10, 20, 42, 0.94) 0%, rgba(6, 12, 26, 0.88) 100%);
  border-bottom: 1px solid rgba(229, 213, 181, 0.28);
  flex-shrink: 0;
}

.gsm-title-group {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

.gsm-emblem {
  color: var(--astral-cyan, #7dd3fc);
  font-size: 14px;
  line-height: 1;
  text-shadow: 0 0 10px rgba(125, 211, 252, 0.55);
}

.gsm-title-col {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.gsm-kicker {
  font-family: var(--ff-roman, Georgia, serif);
  font-size: 9.5px;
  letter-spacing: 0.22em;
  color: var(--astral-cyan, #7dd3fc);
}

.gsm-title {
  margin: 0;
  font-family: var(--ff-serif, serif);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--champagne-bright, #f7efe0);
}

.gsm-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.gsm-close-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 12px;
  font-family: var(--ff-roman, Georgia, serif);
  font-size: 11px;
  letter-spacing: 0.08em;
  color: var(--champagne-bright, #f7efe0);
  background: rgba(12, 22, 44, 0.85);
  border: 1px solid rgba(229, 213, 181, 0.38);
  cursor: pointer;
  transition: all 0.15s ease;
}

.gsm-close-btn:hover {
  color: #ffffff;
  border-color: var(--astral-cyan, #7dd3fc);
  background: rgba(12, 74, 110, 0.52);
}

/* Main two-pane body */
.gsm-main {
  display: grid;
  grid-template-columns: 186px 1fr;
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
}

.gsm-tab-rail {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 10px;
  background: rgba(4, 9, 20, 0.84);
  border-right: 1px solid rgba(229, 213, 181, 0.22);
  overflow-y: auto;
}

.gsm-tab-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  text-align: left;
  background: rgba(10, 18, 38, 0.42);
  color: var(--silver-ink, #c6d0e0);
  border: 1px solid transparent;
  border-left: 2px solid transparent;
  cursor: pointer;
  transition: all 0.14s ease;
}

.gsm-tab-btn:hover {
  color: var(--champagne-bright, #f7efe0);
  background: rgba(18, 32, 64, 0.56);
  border-color: rgba(229, 213, 181, 0.2);
}

.gsm-tab-btn.is-active {
  color: var(--astral-ice, #e0f2fe);
  background: linear-gradient(90deg, rgba(12, 74, 110, 0.62) 0%, rgba(10, 20, 44, 0.86) 100%);
  border-color: rgba(125, 211, 252, 0.45);
  border-left: 2.5px solid var(--astral-cyan, #7dd3fc);
  box-shadow: inset 0 0 14px rgba(125, 211, 252, 0.14);
}

.gsm-tab-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--champagne, #e5d5b5);
}

.gsm-tab-btn.is-active .gsm-tab-icon {
  color: var(--astral-cyan, #7dd3fc);
}

.gsm-tab-svg {
  width: 16px;
  height: 16px;
  display: block;
}

.gsm-tab-texts {
  display: flex;
  flex-direction: column;
  gap: 1px;
  min-width: 0;
}

.gsm-tab-zh {
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.06em;
}

.gsm-tab-en {
  font-family: var(--ff-roman, Georgia, serif);
  font-size: 9px;
  letter-spacing: 0.14em;
  color: var(--muted-ink, #8e9cb2);
}

.gsm-tab-btn.is-active .gsm-tab-en {
  color: var(--champagne-soft, rgba(229, 213, 181, 0.72));
}

/* Right scrollable body */
.gsm-body {
  overflow-y: auto;
  padding: 14px 18px;
  background: rgba(6, 11, 24, 0.56);
  -webkit-overflow-scrolling: touch;
}

.gsm-panel {
  display: none;
  flex-direction: column;
  gap: 8px;
}

.gsm-panel.is-active {
  display: flex;
}

.gsm-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  padding-bottom: 7px;
  margin-bottom: 2px;
  border-bottom: 1px solid rgba(229, 213, 181, 0.22);
}

.gsm-panel-title {
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.08em;
  color: var(--champagne-bright, #f7efe0);
}

.gsm-panel-sub {
  font-family: var(--ff-roman, Georgia, serif);
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--astral-cyan, #7dd3fc);
}

/* Setting rows */
.gsm-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 9px 12px;
  background: rgba(10, 18, 38, 0.68);
  border: 1px solid rgba(229, 213, 181, 0.16);
  border-left: 2px solid transparent;
  transition: border-color 0.14s ease, background-color 0.14s ease, box-shadow 0.14s ease;
}

.gsm-item:hover {
  background: rgba(14, 26, 52, 0.76);
  border-color: rgba(229, 213, 181, 0.34);
}

.gsm-item.is-focused,
.gsm-item.gp-focus {
  background: linear-gradient(90deg, rgba(12, 74, 110, 0.42) 0%, rgba(12, 22, 46, 0.9) 100%);
  border-color: var(--astral-cyan, #7dd3fc);
  border-left: 3px solid var(--champagne-bright, #f7efe0);
  box-shadow: 0 0 0 1px rgba(125, 211, 252, 0.4), 0 0 14px rgba(125, 211, 252, 0.22);
}

.gsm-item-meta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1 1 auto;
}

.gsm-item-title-line {
  display: flex;
  align-items: center;
  gap: 7px;
  flex-wrap: wrap;
}

.gsm-item-label {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--ivory-ink, #f5f0e6);
  letter-spacing: 0.04em;
}

.gsm-badge {
  display: inline-block;
  padding: 1px 6px;
  font-size: 9.5px;
  letter-spacing: 0.08em;
  color: var(--champagne-bright, #f7efe0);
  background: rgba(12, 74, 110, 0.68);
  border: 0.8px solid rgba(125, 211, 252, 0.55);
}

.gsm-item-desc {
  font-size: 10.5px;
  line-height: 1.45;
  color: var(--muted-ink, #8e9cb2);
}

/* Segmented controls */
.gsm-seg-group {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  background: rgba(4, 8, 18, 0.86);
  border: 1px solid rgba(229, 213, 181, 0.28);
  padding: 2px;
  gap: 2px;
}

.gsm-seg-btn {
  padding: 5px 10px;
  font-family: var(--ff-serif, serif);
  font-size: 11px;
  font-weight: 500;
  color: var(--silver-ink, #c6d0e0);
  background: transparent;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.12s ease;
}

.gsm-seg-btn:hover {
  color: #ffffff;
  background: rgba(125, 211, 252, 0.12);
}

.gsm-seg-btn.is-active {
  color: var(--astral-ice, #e0f2fe);
  background: linear-gradient(135deg, rgba(12, 74, 110, 0.92) 0%, rgba(16, 34, 72, 0.96) 100%);
  border-color: var(--astral-cyan, #7dd3fc);
  box-shadow: 0 0 8px rgba(125, 211, 252, 0.32);
}

/* Sliders */
.gsm-slider-wrap {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(230px, 44%);
  flex-shrink: 0;
}

.gsm-slider {
  flex: 1 1 auto;
}

.gsm-slider-val {
  min-width: 42px;
  text-align: right;
  font-family: var(--ff-num, Georgia, serif);
  font-size: 11.5px;
  font-variant-numeric: tabular-nums;
  color: var(--champagne-bright, #f7efe0);
}

/* Toggle pills */
.gsm-toggle-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-width: 82px;
  padding: 4px 10px 4px 6px;
  background: rgba(6, 12, 26, 0.9);
  border: 1px solid rgba(229, 213, 181, 0.32);
  border-radius: 999px;
  color: var(--muted-ink, #8e9cb2);
  font-family: var(--ff-serif, serif);
  font-size: 11px;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.14s ease;
}

.gsm-toggle-knob {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: rgba(142, 156, 178, 0.72);
  border: 1px solid rgba(229, 213, 181, 0.4);
  transition: transform 0.14s ease, background-color 0.14s ease;
}

.gsm-toggle-btn.is-on {
  color: var(--celadon-ok, #6ee7b7);
  background: rgba(6, 78, 59, 0.45);
  border-color: rgba(110, 231, 183, 0.65);
}

.gsm-toggle-btn.is-on .gsm-toggle-knob {
  background: var(--celadon-ok, #6ee7b7);
  border-color: #ecfdf5;
  box-shadow: 0 0 8px rgba(110, 231, 183, 0.7);
}

/* Select & action buttons */
.gsm-select {
  width: min(290px, 52%);
  flex-shrink: 0;
}

.gsm-action-btn {
  padding: 6px 14px;
  font-family: var(--ff-serif, serif);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--astral-ice, #e0f2fe);
  background: linear-gradient(135deg, rgba(12, 74, 110, 0.78) 0%, rgba(10, 22, 48, 0.94) 100%);
  border: 1px solid rgba(125, 211, 252, 0.55);
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: all 0.14s ease;
}

.gsm-action-btn:hover {
  border-color: #ffffff;
  box-shadow: 0 0 10px rgba(125, 211, 252, 0.35);
}

.gsm-action-btn.is-danger {
  color: var(--crimson-hi, #fda4af);
  background: linear-gradient(135deg, rgba(136, 19, 55, 0.58) 0%, rgba(28, 10, 22, 0.92) 100%);
  border-color: rgba(253, 164, 175, 0.52);
}

/* Gamepad status & mapping reference card */
.gsm-gamepad-card {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: rgba(5, 11, 26, 0.85);
  border: 1px solid rgba(125, 211, 252, 0.28);
}

.gsm-gamepad-status {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding-bottom: 7px;
  border-bottom: 1px solid rgba(229, 213, 181, 0.16);
}

.gsm-gamepad-status-left {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
}

.gsm-gamepad-dot {
  width: 9px;
  height: 9px;
  transform: rotate(45deg);
  background: var(--muted-ink, #8e9cb2);
  border: 1px solid rgba(229, 213, 181, 0.45);
  flex-shrink: 0;
}

.gsm-gamepad-status.is-connected .gsm-gamepad-dot {
  background: var(--celadon-ok, #6ee7b7);
  box-shadow: 0 0 10px rgba(110, 231, 183, 0.85);
}

.gsm-gamepad-state {
  font-size: 12px;
  font-weight: 700;
  color: var(--champagne-bright, #f7efe0);
}

.gsm-gamepad-name {
  font-size: 10.5px;
  color: var(--muted-ink, #8e9cb2);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.gsm-gamepad-glyph-badge {
  padding: 3px 9px;
  font-size: 10.5px;
  color: var(--astral-ice, #e0f2fe);
  background: rgba(12, 74, 110, 0.55);
  border: 0.8px solid rgba(125, 211, 252, 0.45);
  white-space: nowrap;
  flex-shrink: 0;
}

.gsm-mapping-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(136px, 1fr));
  gap: 5px 8px;
}

.gsm-map-cell {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: 4px 8px;
  background: rgba(12, 22, 44, 0.72);
  border: 0.8px solid rgba(229, 213, 181, 0.16);
  font-size: 10.5px;
}

.gsm-map-action {
  color: var(--silver-ink, #c6d0e0);
}

.gsm-map-bind {
  font-family: var(--ff-roman, Georgia, serif);
  font-weight: 700;
  color: var(--champagne-bright, #f7efe0);
}

/* Footer */
.gsm-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 18px;
  background: rgba(4, 8, 18, 0.94);
  border-top: 1px solid rgba(229, 213, 181, 0.24);
  flex-shrink: 0;
}

.gsm-legend {
  font-family: var(--ff-roman, Georgia, serif);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  color: var(--champagne-soft, rgba(229, 213, 181, 0.72));
}

.gsm-footer-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.gsm-footer-btn {
  padding: 5px 13px;
  font-family: var(--ff-serif, serif);
  font-size: 11px;
  font-weight: 600;
  color: var(--silver-ink, #c6d0e0);
  background: rgba(12, 22, 44, 0.84);
  border: 1px solid rgba(229, 213, 181, 0.32);
  cursor: pointer;
}

.gsm-footer-btn:hover {
  color: #ffffff;
  border-color: var(--champagne, #e5d5b5);
}

.gsm-footer-btn.is-primary {
  color: var(--astral-ice, #e0f2fe);
  background: linear-gradient(135deg, rgba(12, 74, 110, 0.85) 0%, rgba(10, 24, 54, 0.96) 100%);
  border-color: var(--astral-cyan, #7dd3fc);
}

/* ==========================================================================
 * Mobile Landscape & Compact Viewport Overrides
 * ========================================================================== */
body.mobile-landscape .game-settings-modal {
  padding: 0;
}

body.mobile-landscape .gsm-shell {
  position: absolute;
  inset: 6px;
  width: auto;
  max-width: none;
  max-height: none;
}

body.mobile-landscape .gsm-header {
  position: sticky;
  top: 0;
  z-index: 4;
  padding: 6px 12px;
}

body.mobile-landscape .gsm-title {
  font-size: 14px;
}

body.mobile-landscape .gsm-close-btn {
  min-width: 44px;
  min-height: 32px;
  padding: 4px 10px;
}

body.mobile-landscape .gsm-main {
  grid-template-columns: 1fr;
  grid-template-rows: auto 1fr;
}

body.mobile-landscape .gsm-tab-rail {
  flex-direction: row;
  border-right: none;
  border-bottom: 1px solid rgba(229, 213, 181, 0.22);
  padding: 5px 8px;
  overflow-x: auto;
  overflow-y: hidden;
  gap: 6px;
  -webkit-overflow-scrolling: touch;
}

body.mobile-landscape .gsm-tab-btn {
  width: auto;
  flex: 1 0 auto;
  justify-content: center;
  padding: 6px 12px;
  min-height: 36px;
  border-left: 1px solid transparent;
  border-bottom: 2px solid transparent;
}

body.mobile-landscape .gsm-tab-btn.is-active {
  border-left-color: rgba(125, 211, 252, 0.45);
  border-bottom: 2.5px solid var(--astral-cyan, #7dd3fc);
}

body.mobile-landscape .gsm-tab-en {
  display: none;
}

body.mobile-landscape .gsm-body {
  padding: 8px 12px 14px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

body.mobile-landscape .gsm-item {
  min-height: 40px;
  padding: 8px 10px;
  gap: 10px;
}

body.mobile-landscape .gsm-seg-btn {
  min-height: 30px;
  padding: 5px 10px;
}

body.mobile-landscape .gsm-toggle-btn {
  min-height: 32px;
  min-width: 84px;
  padding: 5px 12px 5px 8px;
}

body.mobile-landscape .gsm-toggle-knob {
  width: 16px;
  height: 16px;
}

body.mobile-landscape .gsm-slider-wrap {
  width: min(220px, 48%);
  min-height: 32px;
}

body.mobile-landscape input[type="range"].gsm-slider::-webkit-slider-thumb {
  width: 16px;
  height: 16px;
}

body.mobile-landscape input[type="range"].gsm-slider::-moz-range-thumb {
  width: 16px;
  height: 16px;
}

body.mobile-landscape .gsm-footer {
  padding: 6px 12px;
}

body.mobile-landscape .gsm-legend {
  font-size: 9.5px;
}

@media (max-height: 540px), (max-width: 900px) {
  .game-settings-modal {
    padding: 0;
  }

  .gsm-shell {
    position: absolute;
    inset: 6px;
    width: auto;
    max-width: none;
    max-height: none;
  }

  .gsm-header {
    position: sticky;
    top: 0;
    z-index: 4;
    padding: 6px 12px;
  }

  .gsm-close-btn {
    min-width: 44px;
    min-height: 32px;
  }

  .gsm-main {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr;
  }

  .gsm-tab-rail {
    flex-direction: row;
    border-right: none;
    border-bottom: 1px solid rgba(229, 213, 181, 0.22);
    padding: 5px 8px;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 6px;
    -webkit-overflow-scrolling: touch;
  }

  .gsm-tab-btn {
    width: auto;
    flex: 1 0 auto;
    justify-content: center;
    padding: 6px 12px;
    min-height: 36px;
    border-left: 1px solid transparent;
    border-bottom: 2px solid transparent;
  }

  .gsm-tab-btn.is-active {
    border-left-color: rgba(125, 211, 252, 0.45);
    border-bottom: 2.5px solid var(--astral-cyan, #7dd3fc);
  }

  .gsm-tab-en {
    display: none;
  }

  .gsm-body {
    padding: 8px 12px 14px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .gsm-item {
    min-height: 40px;
    flex-wrap: wrap;
    padding: 8px 10px;
    gap: 8px 10px;
  }

  .gsm-seg-btn {
    min-height: 30px;
  }

  .gsm-toggle-btn {
    min-height: 32px;
  }

  .gsm-slider-wrap {
    width: min(220px, 48%);
    min-height: 32px;
  }

  input[type="range"].gsm-slider::-webkit-slider-thumb {
    width: 16px;
    height: 16px;
  }

  input[type="range"].gsm-slider::-moz-range-thumb {
    width: 16px;
    height: 16px;
  }

  .gsm-footer {
    padding: 6px 12px;
  }

  .gsm-legend {
    display: none;
  }
}
