/* ===== Reset & Base ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --bg: #0d1117;
  --bg-surface: #161b22;
  --bg-surface-alt: #1c2333;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #58a6ff;
  --accent-hover: #79c0ff;
  --green: #3fb950;
  --red: #f85149;
  --orange: #d29922;
  --purple: #bc8cff;
  --border: #30363d;
  --font-mono: 'Merriweather', Georgia, 'Times New Roman', serif;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Helvetica, Arial, sans-serif;
  --radius: 8px;
  --radius-sm: 4px;
}

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ===== Utility ===== */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.hidden {
  display: none !important;
}

/* ===== Screens ===== */
.screen {
  display: none;
  width: 100%;
  height: 100%;
}

.screen.active {
  display: flex;
}

/* ===== Buttons ===== */
.btn {
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 10px 20px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
  color: var(--text);
  background: var(--bg-surface);
}

.btn:hover:not(:disabled) {
  border-color: var(--accent);
}

.btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}

.btn-primary:hover:not(:disabled) {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

.btn-secondary {
  background: transparent;
  border-color: var(--text-dim);
}

.btn-secondary:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-small {
  padding: 6px 12px;
  font-size: 12px;
}

#btn-start-game {
  margin-bottom: 24px;
}

.btn-large {
  padding: 14px 32px;
  font-size: 16px;
}

/* ===== Home Screen ===== */
#screen-home {
  align-items: center;
  justify-content: center;
}

.home-container {
  text-align: center;
  max-width: 460px;
  padding: 24px;
  width: 100%;
}

.home-title {
  font-size: 2.4rem;
  margin-bottom: 12px;
  font-family: var(--font-sans);
  font-weight: 700;
}

.home-subtitle {
  color: var(--text-dim);
  margin-bottom: 48px;
  font-size: 15px;
  line-height: 1.5;
}

.home-buttons {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.btn-home {
  padding: 20px 32px;
  font-size: 18px;
  font-weight: 600;
  border-radius: var(--radius);
  letter-spacing: 0.01em;
}

/* ===== Manual Join Screen ===== */
#screen-join-manual {
  align-items: center;
  justify-content: center;
}

/* ===== Join Screen ===== */
#screen-join {
  align-items: center;
  justify-content: center;
}

/* ===== Game Not Found Screen ===== */
#screen-game-not-found {
  align-items: center;
  justify-content: center;
}

.join-container {
  text-align: center;
  max-width: 400px;
  padding: 24px;
  width: 100%;
}

.join-title {
  font-size: 2rem;
  margin-bottom: 8px;
  font-family: var(--font-sans);
  font-weight: 700;
}

.join-subtitle {
  color: var(--text-dim);
  margin-bottom: 32px;
  font-size: 14px;
}

.join-form {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.join-name-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.join-name-label {
  display: block;
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  text-align: left;
}

.join-form input[type="text"] {
  width: 100%;
  padding: 16px 18px;
  font-size: 18px;
  font-family: var(--font-mono);
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.join-form input[type="text"]:focus {
  border-color: var(--accent);
}

.join-code-inline {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  color: var(--text-dim);
  font-size: 13px;
}

.join-code-prefix {
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.join-code-value {
  font-family: var(--font-mono);
  font-weight: 600;
  color: var(--accent);
  letter-spacing: 0.08em;
}

.join-host-link {
  display: block;
  color: var(--text-dim);
  font-size: 13px;
  text-decoration: none;
  transition: color 0.15s;
  margin-top: 8px;
}

.join-host-link:hover {
  color: var(--accent);
}

/* ===== Landing Screen ===== */
#screen-landing {
  flex-direction: column;
  align-items: center;
  overflow-y: auto;
  padding: 32px 0;
}

.landing-container {
  text-align: center;
  max-width: 440px;
  padding: 24px;
}

.landing-title {
  font-size: 2rem;
  margin-bottom: 8px;
  font-family: var(--font-sans);
  font-weight: 700;
}

.landing-subtitle {
  color: var(--text-dim);
  margin-bottom: 32px;
  font-size: 14px;
}

.landing-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.host-name-label {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
}

.landing-form input[type="text"] {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px;
  font-family: var(--font-mono);
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

.landing-form input[type="text"]:focus {
  border-color: var(--accent);
}

/* ===== World Selector ===== */
.world-selector-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.world-selector-label {
  color: var(--text-dim);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  text-align: left;
}

.world-selector-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.world-card {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 12px 16px;
  background: var(--bg-surface);
  border: 2px solid var(--border);
  border-radius: var(--radius);
  cursor: pointer;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.world-card:hover {
  border-color: var(--text-dim);
  background: var(--bg-surface-alt);
}

.world-card.selected {
  border-color: var(--accent);
  background: rgba(88, 166, 255, 0.08);
}

.world-card-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  font-family: var(--font-mono);
}

.world-card.selected .world-card-name {
  color: var(--accent);
}

.world-card-desc {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.4;
}

.world-card-loading {
  padding: 16px;
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}

/* ===== Settings Section ===== */
.settings-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  text-align: left;
}

.settings-section-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-dim);
  font-weight: 600;
  margin-bottom: 2px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 10px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
}

/* ===== Lobby Adventure Name ===== */
.lobby-adventure-name {
  color: var(--accent);
  font-size: 14px;
  margin-bottom: 16px;
  font-style: italic;
}

.landing-buttons {
  display: flex;
  gap: 12px;
}

.landing-buttons .btn {
  flex: 1;
}

.join-code-group {
  display: flex;
  gap: 8px;
}

.join-code-group input {
  flex: 1;
}

/* ===== Lobby Screen ===== */
#screen-lobby {
  align-items: center;
  justify-content: center;
}

.lobby-container {
  text-align: center;
  max-width: 500px;
  padding: 24px;
  width: 100%;
}

.lobby-title {
  font-family: var(--font-sans);
  font-size: 1.5rem;
  margin-bottom: 24px;
}

.lobby-share {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 24px;
}

.lobby-label {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 12px;
}

.lobby-error {
  color: #ff6b6b;
  background: rgba(255, 107, 107, 0.1);
  border: 1px solid rgba(255, 107, 107, 0.3);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-top: 12px;
  font-size: 14px;
}

.lobby-url-row {
  display: flex;
  gap: 8px;
  margin-bottom: 16px;
}

.lobby-url-row input {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-mono);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  outline: none;
}

.qr-container {
  display: flex;
  justify-content: center;
  padding: 12px;
}

.qr-container canvas {
  border-radius: var(--radius-sm);
}

.lobby-players {
  text-align: left;
  margin-bottom: 24px;
}

.lobby-players h3 {
  font-size: 14px;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.lobby-players ul {
  list-style: none;
}

.lobby-players li {
  padding: 6px 12px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 4px;
  font-size: 14px;
}

.lobby-players li::before {
  content: '● ';
  color: var(--green);
}

/* ===== Lobby Waiting Message ===== */
.lobby-waiting-msg {
  color: var(--text-dim);
  font-size: 14px;
  font-style: italic;
  padding: 14px 0;
  animation: waitingPulse 2s ease-in-out infinite;
}

@keyframes waitingPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ===== Game Screen ===== */
#screen-game {
  flex-direction: column;
  height: 100%;
}

.game-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.game-title {
  font-family: var(--font-sans);
  font-weight: 600;
  font-size: 16px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  min-width: 0;
  flex: 1;
}

.game-header-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.game-players {
  font-size: 13px;
  color: var(--text-dim);
  white-space: nowrap;
}

.btn-share {
  padding: 6px 12px;
  font-size: 12px;
  background: transparent;
  border-color: var(--border);
  color: var(--text);
}

.btn-share:hover:not(:disabled) {
  border-color: var(--accent);
  color: var(--accent);
}

.btn-host-new {
  padding: 6px 10px;
  font-size: 11px;
  background: transparent;
  border-color: var(--border);
  color: var(--text-dim);
}

.btn-host-new:hover:not(:disabled) {
  border-color: var(--text);
  color: var(--text);
}

.game-output {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  scroll-behavior: smooth;
}

/* Scrollbar styling */
.game-output::-webkit-scrollbar {
  width: 6px;
}

.game-output::-webkit-scrollbar-track {
  background: transparent;
}

.game-output::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

.game-output::-webkit-scrollbar-thumb:hover {
  background: var(--text-dim);
}

/* ===== Messages ===== */
.msg {
  margin-bottom: 12px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  animation: msgFadeIn 0.2s ease-out;
}

@keyframes msgFadeIn {
  from {
    opacity: 0;
    transform: translateY(4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.msg-system {
  color: var(--text-dim);
  font-style: italic;
  font-size: 13px;
}

.msg-narrative {
  color: var(--green);
  white-space: pre-wrap;
  word-break: break-word;
}

.msg-error {
  color: var(--red);
  background: rgba(248, 81, 73, 0.08);
  border-left: 3px solid var(--red);
}

.msg-player-event {
  color: var(--text-dim);
  font-style: italic;
  font-size: 13px;
}

.msg-command {
  color: var(--purple);
  font-size: 13px;
}

.msg-command::before {
  content: '> ';
  color: var(--text-dim);
}

/* Room (look) messages */
.msg-room {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 12px 16px;
}

.msg-room .room-name {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-sans);
  margin-bottom: 8px;
  color: var(--accent);
}

.msg-room .room-desc {
  margin-bottom: 10px;
  line-height: 1.7;
}

.msg-room .room-section {
  font-size: 13px;
  margin-bottom: 4px;
}

.msg-room .room-section-label {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-size: 11px;
  display: block;
  margin-bottom: 2px;
}

.msg-room .room-section-value {
  color: var(--text);
}

.msg-room .room-hazard {
  color: var(--orange);
}

.msg-room .room-items {
  color: var(--green);
}

.msg-room .room-exits {
  color: var(--accent);
}

.msg-room .room-players-list {
  color: var(--purple);
}

.msg-room .room-ghosts {
  color: #7a8a9e;
  font-style: italic;
  opacity: 0.75;
}

.msg-room .room-ghost-hint {
  color: var(--text-dim);
  font-size: 11px;
  font-style: italic;
  opacity: 0.7;
  margin-top: 2px;
}

/* Ghost-styled messages */
.msg-ghost {
  color: #7a8a9e;
  font-style: italic;
  opacity: 0.8;
  font-size: 13px;
}

/* Inventory messages */
.msg-inventory {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  padding: 12px 16px;
}

.msg-inventory .inv-title {
  font-weight: 700;
  font-family: var(--font-sans);
  margin-bottom: 8px;
  color: var(--accent);
}

.msg-inventory .inv-item {
  margin-bottom: 4px;
  font-size: 14px;
}

.msg-inventory .inv-item-name {
  color: var(--green);
  font-weight: 600;
}

.msg-inventory .inv-item-desc {
  color: var(--text-dim);
  font-size: 13px;
}

.msg-inventory .inv-empty {
  color: var(--text-dim);
  font-style: italic;
}

/* ===== Command Bar ===== */
.command-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.prompt-char {
  color: var(--accent);
  font-weight: 700;
  font-size: 16px;
  flex-shrink: 0;
}

#command-input {
  flex: 1;
  padding: 10px 12px;
  font-size: 15px;
  font-family: var(--font-mono);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  transition: border-color 0.15s;
}

#command-input:focus {
  border-color: var(--accent);
}

.btn-send {
  padding: 10px 16px;
  font-size: 14px;
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-weight: 600;
}

.btn-send:hover {
  background: var(--accent-hover);
  border-color: var(--accent-hover);
}

/* ===== Reconnect Banner ===== */
.reconnect-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 900;
  padding: 10px 16px;
  text-align: center;
  font-size: 13px;
  font-family: var(--font-mono);
  color: var(--bg);
  background: var(--orange);
  animation: bannerSlideIn 0.3s ease-out;
}

.reconnect-banner.hidden {
  display: none;
}

.reconnect-banner.reconnect-tappable {
  cursor: pointer;
  background: var(--red);
  color: var(--text);
}

.reconnect-banner.reconnect-tappable:hover {
  opacity: 0.9;
}

@keyframes bannerSlideIn {
  from {
    transform: translateY(-100%);
  }
  to {
    transform: translateY(0);
  }
}

/* ===== Share Overlay ===== */
.share-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: overlayFadeIn 0.2s ease-out;
}

@keyframes overlayFadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.share-overlay.hidden {
  display: none;
}

.share-overlay-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
}

.share-overlay-content {
  position: relative;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  max-width: 400px;
  width: 90%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
  animation: overlayContentIn 0.2s ease-out;
}

@keyframes overlayContentIn {
  from {
    opacity: 0;
    transform: scale(0.95) translateY(-10px);
  }
  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

.share-overlay-close {
  position: absolute;
  top: 12px;
  right: 12px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-size: 32px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  transition: background 0.15s, color 0.15s;
}

.share-overlay-close:hover {
  background: var(--bg);
  color: var(--text);
}

.share-overlay-title {
  font-family: var(--font-sans);
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: 8px;
  text-align: center;
}

.share-overlay-subtitle {
  color: var(--text-dim);
  font-size: 13px;
  text-align: center;
  margin-bottom: 20px;
}

.share-qr-container {
  display: flex;
  justify-content: center;
  padding: 16px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  margin-bottom: 16px;
}

.share-qr-container canvas {
  border-radius: var(--radius-sm);
}

.share-url-row {
  display: flex;
  gap: 8px;
}

.share-url-row input {
  flex: 1;
  padding: 8px 12px;
  font-size: 13px;
  font-family: var(--font-mono);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--accent);
  outline: none;
}

/* ===== Room Item Rows ===== */
.msg-room .room-item-row {
  margin-bottom: 2px;
}

.msg-room .room-item-name {
  color: var(--green);
  font-weight: 600;
}

.room-dropped-items {
  color: #b0b0b0;
  font-style: italic;
  margin-top: 4px;
}

.msg-room .room-item-desc {
  color: var(--text-dim);
  font-size: 13px;
  margin-bottom: 2px;
  line-height: 1.5;
}

/* ===== Death Overlay ===== */
.death-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 1100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: deathFadeIn 0.5s ease-out;
}

@keyframes deathFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.death-overlay.hidden {
  display: none;
}

.death-overlay-backdrop {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
}

.death-overlay-content {
  position: relative;
  text-align: center;
  max-width: 480px;
  width: 90%;
  padding: 40px 32px;
  animation: deathPulse 3s ease-in-out infinite;
}

@keyframes deathPulse {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 1; }
}

.death-overlay-title {
  font-family: var(--font-sans);
  font-size: 2.5rem;
  font-weight: 700;
  color: var(--red);
  margin-bottom: 20px;
  text-shadow: 0 0 30px rgba(248, 81, 73, 0.5);
}

.death-overlay-text {
  font-size: 16px;
  color: var(--text);
  line-height: 1.7;
  margin-bottom: 24px;
}

.death-overlay-countdown {
  font-size: 14px;
  color: var(--text-dim);
  font-style: italic;
  animation: countdownPulse 1s ease-in-out infinite;
}

@keyframes countdownPulse {
  0%, 100% { opacity: 0.6; }
  50% { opacity: 1; }
}

/* ===== Death / Respawn Notifications ===== */
.msg-death-notification {
  color: var(--red);
  font-weight: 600;
  background: rgba(248, 81, 73, 0.08);
  border-left: 3px solid var(--red);
}

.msg-damage {
  color: var(--red);
  background: rgba(248, 81, 73, 0.08);
  border-left: 3px solid var(--red);
}

.room-health {
  color: var(--red);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 6px;
}

.msg-respawn-notification {
  color: var(--green);
  font-style: italic;
  font-size: 13px;
}

/* ===== Setting Controls ===== */
.setting-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
}

.setting-label {
  color: var(--text-dim);
  font-size: 13px;
  white-space: nowrap;
}

.setting-help {
  color: #999;
  font-size: 0.75em;
  margin: 0;
  font-style: italic;
  line-height: 1.3;
}

.setting-select {
  padding: 8px 32px 8px 12px;
  font-size: 14px;
  font-family: var(--font-mono);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  outline: none;
  cursor: pointer;
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%238b949e' d='M1.41 0L6 4.58 10.59 0 12 1.41l-6 6-6-6z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  transition: border-color 0.15s;
}

.setting-select:focus {
  border-color: var(--accent);
}

.setting-select option {
  background: var(--bg-surface);
  color: var(--text);
}

/* ===== Room Puzzle Hints ===== */
.room-hint {
  color: #d4a017;
  font-style: italic;
  margin-top: 4px;
}

/* ===== Goal Progress (Room View) ===== */
.goal-progress {
  color: #FFD700;
  font-size: 12px;
  font-weight: 600;
  margin-top: 2px;
  margin-bottom: 6px;
  opacity: 0.9;
}

/* ===== Goal Complete Message ===== */
.goal-complete {
  background: var(--bg-surface);
  border: 2px solid #d4a017;
  border-radius: var(--radius);
  padding: 16px;
  margin: 8px 0;
  text-align: center;
}

.goal-complete .goal-ascii-art {
  color: #FFD700;
  font-family: 'Cascadia Mono', 'Fira Code', 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
  font-size: 13px;
  white-space: pre;
  line-height: 1.2;
  text-align: left;
  display: inline-block;
  overflow-x: auto;
  margin-bottom: 12px;
}

.goal-complete .goal-text {
  color: #FFD700;
  font-size: 16px;
  font-weight: 700;
  margin-bottom: 6px;
}

.goal-complete .goal-progress-text {
  color: var(--text-dim);
  font-size: 13px;
  font-style: italic;
}

/* ===== Victory Complete Message ===== */
.victory-complete {
  background: var(--bg-surface);
  border: 3px double #FFD700;
  border-radius: var(--radius);
  padding: 20px;
  margin: 12px 0;
  text-align: center;
  box-shadow: 0 0 20px rgba(255, 215, 0, 0.2);
}

.victory-complete .victory-ascii-art {
  color: #FFD700;
  font-family: 'Cascadia Mono', 'Fira Code', 'JetBrains Mono', 'Consolas', 'Monaco', monospace;
  font-size: 14px;
  white-space: pre;
  line-height: 1.2;
  text-align: left;
  display: inline-block;
  overflow-x: auto;
  margin-bottom: 16px;
  font-weight: 600;
}

.victory-complete .victory-text {
  color: #FFD700;
  font-size: 18px;
  font-weight: 700;
  text-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
}

/* ===== Share Hint (game start) ===== */
.msg-share-hint {
  color: var(--accent);
  background: rgba(88, 166, 255, 0.08);
  border-left: 3px solid var(--accent);
  font-size: 14px;
  padding: 10px 14px;
}

/* ===== Lobby Share Button ===== */
.lobby-share-btn {
  width: 100%;
  font-size: 18px;
  padding: 16px 32px;
}

.lobby-qr-container {
  display: flex;
  justify-content: center;
  padding: 16px 0 4px;
}

.lobby-qr-container canvas {
  border-radius: var(--radius-sm);
}

.lobby-qr-label {
  text-align: center;
  color: var(--text-dim);
  font-size: 13px;
  margin-top: 4px;
}

/* ===== Responsive ===== */
@media (max-width: 600px) {
  .join-title {
    font-size: 1.5rem;
  }

  .join-form input[type="text"] {
    font-size: 16px;
  }

  .landing-title {
    font-size: 1.5rem;
  }

  .landing-container {
    padding: 16px;
    max-width: 100%;
  }

  .landing-buttons {
    flex-direction: column;
  }

  /* World cards — full width, easy tap */
  .world-card {
    padding: 14px 16px;
  }

  .world-card-desc {
    white-space: normal;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
  }

  /* Settings — stack vertically */
  .settings-section {
    gap: 6px;
  }

  .setting-row {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }

  .setting-label {
    font-size: 14px;
  }

  .setting-select {
    width: 100%;
    min-height: 44px;
    font-size: 16px;
    padding: 10px 36px 10px 14px;
  }

  .setting-group {
    padding: 12px 14px;
  }

  .game-header {
    padding: 8px 12px;
  }

  .game-title {
    font-size: 14px;
  }

  .game-output {
    padding: 12px;
  }

  .command-bar {
    padding: 8px 12px;
  }

  #command-input {
    font-size: 16px; /* prevent iOS zoom */
  }

  .msg-room .room-name {
    font-size: 16px;
  }

  .share-overlay-content {
    width: 95%;
    padding: 20px;
  }

  .btn-share {
    padding: 5px 8px;
    font-size: 11px;
  }

  .btn-host-new {
    padding: 5px 8px;
    font-size: 10px;
  }

  .game-header-right {
    gap: 6px;
  }
}
