:root {
  --bg: #14161a;
  --bg-grid: #1a1d1f;
  --panel: #1d211d;
  --panel-header: #262b23;
  --gold: #c9a227;
  --gold-bright: #e8c766;
  --gold-dim: #6b5a2e;
  --red: #8c2a22;
  --red-bright: #c23b2f;
  --green: #3f6b45;
  --text: #d9d2b8;
  --text-dim: #8a8f7a;
  --text-faint: #5c6355;
  --shadow: rgba(0, 0, 0, 0.6);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: 'Roboto Condensed', 'Segoe UI', sans-serif;
}

body {
  background-image:
    repeating-linear-gradient(0deg, rgba(201, 162, 39, 0.035) 0px, rgba(201, 162, 39, 0.035) 1px, transparent 1px, transparent 40px),
    repeating-linear-gradient(90deg, rgba(201, 162, 39, 0.035) 0px, rgba(201, 162, 39, 0.035) 1px, transparent 1px, transparent 40px),
    radial-gradient(ellipse at 50% -10%, #262b23 0%, var(--bg) 60%);
}

.frame {
  max-width: 900px;
  margin: 0 auto;
  padding: 20px 16px 60px;
  min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
  text-align: center;
  padding: 18px 12px 22px;
  border-bottom: 3px solid var(--gold-dim);
  margin-bottom: 22px;
  position: relative;
}

.topbar__emblem {
  color: var(--gold);
  font-size: 22px;
  margin-bottom: 4px;
  text-shadow: 0 0 12px rgba(201, 162, 39, 0.5);
}

.topbar__title {
  font-family: 'Staatliches', 'Roboto Condensed', sans-serif;
  font-size: clamp(34px, 8vw, 54px);
  letter-spacing: 0.12em;
  margin: 0;
  color: var(--gold-bright);
  text-transform: uppercase;
  text-shadow: 0 2px 0 #000, 0 0 20px rgba(201, 162, 39, 0.25);
}

.topbar__subtitle {
  font-size: 13px;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--text-dim);
  margin-top: 6px;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 100;
  background: var(--panel-header);
  border: 2px solid var(--red-bright);
  color: var(--text);
  padding: 10px 18px;
  font-size: 14px;
  letter-spacing: 0.03em;
  box-shadow: 0 4px 16px var(--shadow);
  max-width: 90vw;
}

/* ---------- Panels (HOI4-style beveled window) ---------- */
.panel {
  background: var(--panel);
  border: 2px solid var(--gold-dim);
  box-shadow: 0 6px 22px var(--shadow), inset 0 0 0 1px rgba(0,0,0,0.4);
  margin-bottom: 18px;
  position: relative;
}

.panel::before, .panel::after {
  content: '';
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--gold);
  top: -2px;
  pointer-events: none;
}
.panel::before { left: -2px; border-right: none; border-bottom: none; }
.panel::after { right: -2px; border-left: none; border-bottom: none; }

.panel__header {
  background: var(--panel-header);
  border-bottom: 2px solid var(--gold-dim);
  padding: 10px 16px;
  font-family: 'Staatliches', sans-serif;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  font-size: 18px;
  color: var(--gold-bright);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.panel__body {
  padding: 16px;
}

.panel--wide { max-width: 900px; }

.room-code {
  font-family: 'Staatliches', sans-serif;
  letter-spacing: 0.3em;
  color: var(--gold);
  font-size: 20px;
  border: 1px solid var(--gold-dim);
  padding: 2px 10px;
  background: rgba(0,0,0,0.3);
}

.room-code--copyable {
  cursor: pointer;
  transition: box-shadow 0.15s ease, border-color 0.15s ease;
}
.room-code--copyable:hover { border-color: var(--gold); box-shadow: 0 0 10px rgba(201, 162, 39, 0.3); }
.room-code--copyable:active { transform: translateY(1px); }
.room-code--copied {
  border-color: var(--gold-bright) !important;
  box-shadow: 0 0 14px rgba(201, 162, 39, 0.5) !important;
  color: var(--gold-bright) !important;
}

.player-badge {
  font-family: 'Staatliches', sans-serif;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--gold);
  font-size: 16px;
  border: 1px solid var(--gold-dim);
  padding: 4px 12px;
  background: rgba(0,0,0,0.3);
}

/* ---------- Landing ---------- */
.landing-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 18px;
}

@media (max-width: 640px) {
  .landing-grid { grid-template-columns: 1fr; }
}

.op-box {
  border: 1px solid var(--gold-dim);
  padding: 16px;
  background: rgba(0,0,0,0.2);
}

.op-box__title {
  font-family: 'Staatliches', sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--gold-bright);
  font-size: 22px;
  margin: 0 0 6px;
}

.op-box__hint {
  color: var(--text-dim);
  font-size: 13px;
  margin: 0 0 14px;
  line-height: 1.4;
}

/* ---------- Fields & buttons ---------- */
.field {
  display: block;
  margin-bottom: 12px;
}

.field span {
  display: block;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-bottom: 4px;
}

input[type="text"] {
  width: 100%;
  background: #0e100d;
  border: 1px solid var(--gold-dim);
  color: var(--text);
  padding: 10px 12px;
  font-family: 'Roboto Condensed', sans-serif;
  font-size: 15px;
  outline: none;
}

input[type="text"]:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.2);
}

.btn {
  font-family: 'Staatliches', sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  font-size: 16px;
  padding: 10px 18px;
  border: 1px solid var(--gold);
  background: linear-gradient(180deg, #2a2f24, #1a1d17);
  color: var(--gold-bright);
  cursor: pointer;
  clip-path: polygon(8px 0, 100% 0, 100% calc(100% - 8px), calc(100% - 8px) 100%, 0 100%, 0 8px);
  transition: box-shadow 0.15s ease, transform 0.05s ease;
}

.btn:hover { box-shadow: 0 0 14px rgba(201, 162, 39, 0.35); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; box-shadow: none; }

.btn--primary { width: 100%; }

.btn--large { font-size: 20px; padding: 14px 22px; }

.btn--small { font-size: 13px; padding: 6px 12px; }

.btn--ghost {
  background: transparent;
  border-color: var(--gold-dim);
  color: var(--text-dim);
}
.btn--ghost:hover { border-color: var(--gold); color: var(--gold-bright); }

.btn--danger {
  border-color: var(--red-bright);
  color: #e2a49c;
  background: linear-gradient(180deg, #2a1c1a, #180f0d);
}
.btn--danger:hover { box-shadow: 0 0 14px rgba(194, 59, 47, 0.35); }

/* ---------- Barra de esquina (abandonar sala / volver al lobby) ---------- */
.corner-toolbar {
  position: fixed;
  top: 10px;
  left: 10px;
  z-index: 400;
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}
.corner-toolbar[hidden] { display: none; }

.corner-btn {
  font-family: 'Staatliches', sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 11px;
  padding: 5px 10px;
  background: rgba(14, 16, 13, 0.9);
  border: 1px solid var(--gold-dim);
  color: var(--text-dim);
  cursor: pointer;
  box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}
.corner-btn:hover { border-color: var(--gold); color: var(--gold-bright); }
.corner-btn--danger { border-color: #6b2a24; color: #e2a49c; }
.corner-btn--danger:hover { border-color: var(--red-bright); }

/* ---------- Ventanas flotantes: se colocan en cualquier punto de la pantalla ---------- */
.window-stage {
  position: static;
  height: 0;
  overflow: visible;
}

.floating-window {
  position: fixed;
  margin-bottom: 0;
  display: flex;
  flex-direction: column;
  min-width: 220px;
  min-height: 160px;
  overflow: hidden;
}

.floating-window__header {
  cursor: grab;
  touch-action: none;
}
.floating-window__header:active { cursor: grabbing; }

.floating-window__body {
  overflow: auto;
  flex: 1;
}

.floating-window__resize {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 18px;
  height: 18px;
  cursor: nwse-resize;
  touch-action: none;
  background:
    linear-gradient(135deg, transparent 0 50%, var(--gold-dim) 50% 58%, transparent 58% 66%, var(--gold-dim) 66% 74%, transparent 74% 82%, var(--gold-dim) 82% 90%, transparent 90%);
}
.floating-window__resize:hover { filter: brightness(1.4); }

/* Las ventanas solo se pueden mover/redimensionar en la pantalla de partida,
   una vez asignada la misión. En el lobby quedan fijas en su sitio. */
body.windows-locked .floating-window__header {
  cursor: default;
}
body.windows-locked .floating-window__resize {
  display: none;
}

.section-title {
  font-family: 'Staatliches', sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 15px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--gold-dim);
  padding-bottom: 6px;
  margin: 16px 0 8px;
}

.players-list, .missions-list {
  list-style: none;
  margin: 8px 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.2);
  border-left: 3px solid var(--gold-dim);
  font-size: 14px;
}

.player-row--disconnected { opacity: 0.45; }

.color-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1px solid rgba(0,0,0,0.5);
  flex-shrink: 0;
  padding: 0;
  cursor: default;
}

.color-dot--mine {
  width: 16px;
  height: 16px;
  cursor: pointer;
  box-shadow: 0 0 0 2px rgba(0,0,0,0.4);
}
.color-dot--mine:hover { box-shadow: 0 0 0 2px var(--gold); }

.color-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 6px 10px 10px 4px;
  background: rgba(0,0,0,0.25);
  border-left: 3px solid var(--gold-dim);
}

.color-swatch {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid rgba(0,0,0,0.5);
  cursor: pointer;
  padding: 0;
}
.color-swatch:hover:not(:disabled) { border-color: var(--gold); }
.color-swatch--active { border-color: var(--gold-bright); box-shadow: 0 0 0 2px var(--gold-bright); }
.color-swatch:disabled { opacity: 0.2; cursor: not-allowed; }

.player-row__name { flex: 1; }

.badge {
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--bg);
  background: var(--gold);
  padding: 1px 6px;
}

.badge--muted {
  background: transparent;
  border: 1px solid var(--text-faint);
  color: var(--text-faint);
}

.mission-row {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.2);
  border-left: 3px solid var(--gold-dim);
  font-size: 13.5px;
  line-height: 1.35;
}

.mission-row--disabled { opacity: 0.35; }

.mission-row__type {
  font-size: 9px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
  border: 1px solid var(--text-faint);
  padding: 1px 5px;
  flex-shrink: 0;
  margin-top: 1px;
}

.mission-row__type--alliance { color: var(--gold); border-color: var(--gold-dim); }
.mission-row__type--eliminate_color { color: #c98a6a; border-color: #6b4230; }

.mission-row__text { flex: 1; }

.mission-row__remove {
  background: none;
  border: none;
  color: var(--red-bright);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  padding: 0 2px;
}

.add-mission-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.add-mission-row input { flex: 1; }

.import-trigger-row {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed var(--gold-dim);
}
.import-trigger-row .btn { width: 100%; }

/* ---------- Import missions modal ---------- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 200;
}
.modal-overlay[hidden] { display: none; }

.modal-panel {
  width: 100%;
  max-width: 560px;
  max-height: 85vh;
  margin: 0;
  display: flex;
  flex-direction: column;
}

.modal-panel .panel__body {
  overflow-y: auto;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 4px;
}
.modal-close:hover { color: var(--gold-bright); }

.import-textarea-wrap {
  display: flex;
  align-items: stretch;
  height: 260px;
  background: #0e100d;
  border: 1px solid var(--gold-dim);
}
.import-textarea-wrap:focus-within {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.2);
}

.import-line-numbers {
  flex-shrink: 0;
  min-width: 30px;
  height: 100%;
  padding: 12px 8px 12px 0;
  text-align: right;
  font-family: 'Roboto Condensed', monospace;
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-faint);
  background: rgba(0,0,0,0.25);
  border-right: 1px solid var(--gold-dim);
  overflow: hidden;
  white-space: pre;
  user-select: none;
  box-sizing: border-box;
}

.import-textarea {
  flex: 1 1 auto;
  min-width: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  border: none;
  color: var(--text);
  font-family: 'Roboto Condensed', monospace;
  font-size: 14px;
  line-height: 1.6;
  padding: 12px;
  resize: none;
  outline: none;
  box-sizing: border-box;
}

.import-modal-actions {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  margin-top: 14px;
}

/* ---------- Comunicaciones secretas ---------- */
.comms-players-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.comms-player-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  background: rgba(0,0,0,0.2);
  border-left: 3px solid var(--gold-dim);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.comms-player-row:hover {
  border-left-color: var(--gold);
  background: rgba(201, 162, 39, 0.08);
}

.comms-player-row__name { flex: 1; }

.comms-unread-badge {
  background: var(--red-bright);
  color: #fff;
  border-radius: 50%;
  min-width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Staatliches', sans-serif;
  font-size: 12px;
  padding: 0 5px;
}

/* ---------- Ventanas de chat: mismas ventanas flotantes que el resto ---------- */
.chat-window {
  width: 280px;
  height: 360px;
}

.chat-window__header-name {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
}

.chat-window__badge {
  background: var(--red-bright);
  color: #fff;
  border-radius: 50%;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  padding: 0 4px;
  flex-shrink: 0;
}

.chat-window__btn {
  background: none;
  border: none;
  color: var(--text-dim);
  cursor: pointer;
  font-size: 15px;
  line-height: 1;
  padding: 2px 4px;
  flex-shrink: 0;
}
.chat-window__btn:hover { color: var(--gold-bright); }
.chat-window__btn.is-active { color: var(--gold-bright); }

.chat-window__body {
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}

.floating-window--minimized {
  min-height: 0;
  height: auto !important;
}
.floating-window--minimized .floating-window__body,
.floating-window--minimized .floating-window__resize {
  display: none;
}

.chat-window__messages-wrap {
  position: relative;
  flex: 1;
  min-height: 0;
  display: flex;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px;
}

.chat-messages--hidden {
  filter: blur(9px);
  pointer-events: none;
  user-select: none;
}

.chat-window__privacy-overlay {
  position: absolute;
  inset: 0;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: rgba(14, 16, 13, 0.35);
  color: var(--text-dim);
  font-size: 12px;
  text-align: center;
  padding: 10px;
  pointer-events: none;
}
.chat-window__privacy-overlay--active { display: flex; }
.chat-window__privacy-overlay span { font-size: 20px; }

.chat-bubble {
  max-width: 85%;
  padding: 7px 10px;
  font-size: 13px;
  line-height: 1.4;
  border: 1px solid var(--gold-dim);
  background: rgba(0,0,0,0.25);
  word-break: break-word;
}
.chat-bubble--mine {
  align-self: flex-end;
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.12);
}
.chat-bubble--theirs { align-self: flex-start; }

.chat-bubble__meta {
  font-size: 9px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
  margin-top: 3px;
}

.chat-empty {
  color: var(--text-faint);
  font-size: 12px;
  text-align: center;
  padding: 20px 10px;
}

.chat-input-row {
  display: flex;
  gap: 6px;
  padding: 8px;
  border-top: 1px solid var(--gold-dim);
}
.chat-input-row input {
  flex: 1 1 auto;
  min-width: 0;
  font-size: 13px;
  padding: 8px 10px;
}
.chat-input-row .btn {
  width: auto;
  flex-shrink: 0;
  padding: 8px 12px;
  font-size: 13px;
}

.chat-window__emoji-btn {
  flex-shrink: 0;
  width: 34px;
  background: #0e100d;
  border: 1px solid var(--gold-dim);
  color: var(--text);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}
.chat-window__emoji-btn:hover { border-color: var(--gold); }
.chat-window__emoji-btn.is-active { border-color: var(--gold); box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.2); }

/* ---------- Selector de emojis (popup compartido) ---------- */
.emoji-picker {
  position: fixed;
  width: 244px;
  max-height: 220px;
  background: var(--panel);
  border: 2px solid var(--gold-dim);
  box-shadow: 0 6px 22px rgba(0,0,0,0.6);
  z-index: 250;
  padding: 8px;
  overflow-y: auto;
}
.emoji-picker[hidden] { display: none; }

.emoji-picker__grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 2px;
}

.emoji-picker__btn {
  background: none;
  border: none;
  font-size: 18px;
  line-height: 1;
  padding: 5px 0;
  cursor: pointer;
  border-radius: 3px;
}
.emoji-picker__btn:hover { background: rgba(201, 162, 39, 0.18); }

@media (max-width: 640px) {
  .chat-window {
    width: min(88vw, 300px);
    height: min(70vh, 420px);
  }
}

.lobby-actions {
  position: fixed;
  left: 16px;
  right: 16px;
  bottom: 14px;
  z-index: 170;
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
  max-width: 900px;
  margin: 0 auto;
}
.lobby-actions .btn--primary { flex: 1; min-width: 220px; }

/* ---------- Game / mission card ---------- */
.mission-card {
  position: relative;
  border: 2px solid var(--gold);
  background: radial-gradient(ellipse at 50% 0%, #262b23, #14160f 80%);
  padding: 34px 22px;
  min-height: 160px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  cursor: pointer;
  overflow: hidden;
}

.mission-card__stamp {
  position: absolute;
  top: 10px;
  right: 14px;
  color: var(--red-bright);
  border: 2px solid var(--red-bright);
  padding: 2px 8px;
  font-family: 'Staatliches', sans-serif;
  letter-spacing: 0.2em;
  font-size: 12px;
  transform: rotate(6deg);
  opacity: 0.85;
}

.mission-card__text {
  font-size: 19px;
  line-height: 1.5;
  color: var(--gold-bright);
  margin: 0;
  max-width: 60ch;
}

.mission-card__veil {
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(45deg, #1a1d17, #1a1d17 10px, #20241c 10px, #20241c 20px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Staatliches', sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--gold-bright);
  font-size: 16px;
  transition: opacity 0.2s ease;
}

.mission-card--hidden .mission-card__text { display: none; }
.mission-card:not(.mission-card--hidden) .mission-card__veil { opacity: 0; pointer-events: none; }

.host-controls { margin-top: 18px; }
.host-controls .btn { width: 100%; }

#leave-room-btn-2 { margin-top: 12px; width: 100%; }

/* ---------- Tintado por color de jugador (fase de partida) ---------- */
body {
  --player-accent: var(--gold);
}

body.in-game {
  background-image:
    repeating-linear-gradient(0deg, rgba(201, 162, 39, 0.035) 0px, rgba(201, 162, 39, 0.035) 1px, transparent 1px, transparent 40px),
    repeating-linear-gradient(90deg, rgba(201, 162, 39, 0.035) 0px, rgba(201, 162, 39, 0.035) 1px, transparent 1px, transparent 40px),
    radial-gradient(ellipse at 50% -10%, color-mix(in srgb, var(--player-accent) 22%, #262b23) 0%, var(--bg) 60%);
}

body.in-game .topbar {
  border-bottom-color: color-mix(in srgb, var(--player-accent) 65%, var(--gold-dim));
}

body.in-game .topbar__title {
  color: color-mix(in srgb, var(--player-accent) 50%, var(--gold-bright));
  text-shadow: 0 2px 0 #000, 0 0 24px color-mix(in srgb, var(--player-accent) 45%, transparent);
}

body.in-game .panel {
  border-color: var(--player-accent);
  box-shadow: 0 6px 22px var(--shadow), 0 0 34px color-mix(in srgb, var(--player-accent) 30%, transparent), inset 0 0 0 1px rgba(0,0,0,0.4);
}

body.in-game .panel::before,
body.in-game .panel::after {
  border-color: var(--player-accent);
}

body.in-game .panel__header {
  background: color-mix(in srgb, var(--player-accent) 14%, var(--panel-header));
  border-bottom-color: var(--player-accent);
  color: color-mix(in srgb, var(--player-accent) 35%, var(--gold-bright));
}

body.in-game .player-badge {
  border-color: var(--player-accent);
  color: color-mix(in srgb, var(--player-accent) 70%, var(--gold-bright));
  background: color-mix(in srgb, var(--player-accent) 18%, #0e100d);
}

body.in-game .mission-card {
  border-color: var(--player-accent);
  background: radial-gradient(ellipse at 50% 0%, color-mix(in srgb, var(--player-accent) 16%, #262b23), #14160f 80%);
}

body.in-game .mission-card__text {
  color: color-mix(in srgb, var(--player-accent) 30%, var(--gold-bright));
}

body.in-game .mission-card__veil {
  color: color-mix(in srgb, var(--player-accent) 30%, var(--gold-bright));
}

body.in-game .btn {
  border-color: color-mix(in srgb, var(--player-accent) 55%, var(--gold));
}
body.in-game .btn:hover {
  box-shadow: 0 0 16px color-mix(in srgb, var(--player-accent) 45%, transparent);
}

body.in-game .footer {
  color: color-mix(in srgb, var(--player-accent) 25%, var(--text-faint));
}

/* ---------- Ventana de dados ---------- */
.dice-window-body {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

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

.dice-controls__label {
  font-size: 12px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.dice-count-buttons {
  display: flex;
  gap: 4px;
}

.dice-count-btn {
  width: 30px;
  height: 30px;
  background: #0e100d;
  border: 1px solid var(--gold-dim);
  color: var(--text-dim);
  font-family: 'Staatliches', sans-serif;
  font-size: 15px;
  cursor: pointer;
}
.dice-count-btn:hover { border-color: var(--gold); color: var(--gold-bright); }
.dice-count-btn.is-active {
  border-color: var(--gold);
  background: rgba(201, 162, 39, 0.18);
  color: var(--gold-bright);
}

.dice-tray-wrap {
  margin-top: 10px;
  padding: 10px;
  background: rgba(0,0,0,0.25);
  border: 1px solid var(--gold-dim);
  text-align: center;
}

.dice-tray__label {
  font-size: 12px;
  color: var(--text-dim);
  margin-bottom: 10px;
  min-height: 16px;
}

.dice-tray {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  min-height: 60px;
}

.die {
  width: 52px;
  height: 52px;
  flex-shrink: 0;
  background: linear-gradient(160deg, #efe6c8, #cbbf98);
  border: 2px solid #2a2416;
  border-radius: 9px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 7px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.5);
}

.die__pip {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #211d10;
  align-self: center;
  justify-self: center;
  opacity: 0;
}
.die__pip--on { opacity: 1; }

@keyframes dice-shake {
  0%, 100% { transform: rotate(0deg) scale(1); }
  25% { transform: rotate(-14deg) scale(1.06); }
  50% { transform: rotate(11deg) scale(0.94); }
  75% { transform: rotate(-7deg) scale(1.05); }
}
.die--rolling {
  animation: dice-shake 0.22s ease-in-out infinite;
  border-color: var(--gold);
  box-shadow: 0 3px 8px rgba(0,0,0,0.5), 0 0 14px rgba(201, 162, 39, 0.5);
}

.dice-history-list {
  list-style: none;
  margin: 6px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  overflow-y: auto;
}

.dice-history-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  background: rgba(0,0,0,0.2);
  border-left: 3px solid var(--gold-dim);
  font-size: 13px;
}
.dice-history-row__name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.dice-history-row__dice { color: var(--gold-bright); font-family: 'Staatliches', sans-serif; letter-spacing: 0.05em; }
.dice-history-row__time { font-size: 10px; color: var(--text-faint); flex-shrink: 0; }

/* ---------- Ventana de notas personales ---------- */
.notes-window-body {
  display: flex;
  flex-direction: column;
}

.notes-textarea {
  flex: 1;
  width: 100%;
  min-height: 140px;
  margin-top: 8px;
  background: #0e100d;
  border: 1px solid var(--gold-dim);
  color: var(--text);
  font-family: 'Roboto Condensed', monospace;
  font-size: 14px;
  line-height: 1.6;
  padding: 10px 12px;
  resize: none;
  outline: none;
  box-sizing: border-box;
}
.notes-textarea:focus {
  border-color: var(--gold);
  box-shadow: 0 0 0 2px rgba(201, 162, 39, 0.2);
}

/* ---------- Escenarios históricos ---------- */
.scenario-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scenario-card {
  padding: 10px 12px;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--gold-dim);
  border-left: 3px solid var(--gold-dim);
  cursor: pointer;
}
.scenario-card:hover { border-color: var(--gold); }
.scenario-card--active {
  border-color: var(--gold);
  border-left-color: var(--gold);
  background: rgba(201, 162, 39, 0.1);
}
.scenario-card--disabled {
  cursor: not-allowed;
  opacity: 0.45;
}
.scenario-card--readonly { cursor: default; }

.scenario-card__title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  font-family: 'Staatliches', sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  font-size: 15px;
  color: var(--gold-bright);
}

.scenario-card__count {
  font-size: 11px;
  letter-spacing: 0.05em;
  text-transform: none;
  color: var(--text-faint);
  border: 1px solid var(--text-faint);
  padding: 1px 6px;
  flex-shrink: 0;
}
.scenario-card--active .scenario-card__count,
.scenario-card__count--match {
  color: var(--gold-bright);
  border-color: var(--gold-dim);
}

.scenario-card__desc {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.4;
  margin: 4px 0 6px;
}

.scenario-card__factions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.scenario-faction-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: 11px;
  color: var(--text-dim);
  border: 1px solid var(--gold-dim);
  padding: 2px 7px;
  background: rgba(0,0,0,0.2);
}

/* ---------- Briefing del escenario (en partida) ---------- */
.briefing-header {
  margin-bottom: 10px;
}
.briefing-header__desc {
  font-size: 12.5px;
  color: var(--text-dim);
  line-height: 1.4;
  margin: 4px 0 0;
}

.briefing-continent-title {
  font-family: 'Staatliches', sans-serif;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  font-size: 13px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--gold-dim);
  padding-bottom: 4px;
  margin: 12px 0 6px;
}
.briefing-continent-title:first-of-type { margin-top: 4px; }

.briefing-territory-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.briefing-territory-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  background: rgba(0,0,0,0.18);
  border-left: 3px solid var(--gold-dim);
  font-size: 12.5px;
}
.briefing-territory-row--mine {
  border-left-color: var(--gold);
  background: rgba(201, 162, 39, 0.1);
}
.briefing-territory-row__name { flex: 1; }
.briefing-territory-row__troops {
  font-family: 'Staatliches', sans-serif;
  color: var(--gold-bright);
  font-size: 12px;
}

/* ---------- Footer ---------- */
.footer {
  text-align: center;
  color: var(--text-faint);
  font-size: 11px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 30px;
}

/* =====================================================================
   MÓVIL (< 680px, mismo punto de corte que NARROW_STAGE_WIDTH en app.js)
   =====================================================================
   En escritorio las "ventanas" son paneles con position:fixed que el
   usuario arrastra y redimensiona libremente por toda la pantalla. Eso
   funciona porque hay sitio de sobra. En un móvil, apiladas una debajo de
   otra siguen siendo position:fixed con coordenadas en píxeles -- y como
   la página en sí no tiene scroll real (el contenedor de las ventanas mide
   height:0), cualquier ventana que quede más abajo de la primera pantalla
   es literalmente inalcanzable: no hay manera de desplazarse hasta ella.
   Aquí abajo se cambia el modelo por completo solo para pantallas
   estrechas: las ventanas pasan a flujo normal (apiladas, con scroll de
   página de verdad) y el arrastre/redimensionado se desactiva (no tiene
   sentido en una pantalla táctil estrecha). El código JS correspondiente
   (isNarrow(), layoutWindows(), etc. en app.js) ya deja de fijar
   posición/tamaño en línea por debajo de este ancho, así que estas reglas
   no tienen que pelear con estilos en línea para las ventanas normales.
   ===================================================================== */
@media (max-width: 680px) {

  .frame { padding: 16px 12px 96px; }

  .topbar { padding: 16px 10px 18px; }

  /* ---- Ventanas principales: flujo normal, apiladas, con scroll real ---- */
  .window-stage {
    position: static;
    height: auto;
    display: flex;
    flex-direction: column;
    gap: 14px;
    margin-top: 4px;
  }

  .floating-window {
    position: static;
    width: 100%;
    min-width: 0;
    height: auto;
    min-height: 0;
  }

  .floating-window__header {
    cursor: default;
  }

  /* Las ventanas de chat necesitan seguir siendo overflow:hidden en su body
     (son un flex column con la lista de mensajes scrollable + el input fijo
     abajo); solo las ventanas de contenido normal pasan a overflow:visible
     con alto automático. */
  .floating-window__body:not(.chat-window__body) {
    overflow: visible;
  }

  /* Redimensionar arrastrando no tiene sentido en touch/ancho completo */
  .floating-window__resize {
    display: none;
  }

  /* La barra inferior de acciones del lobby ya no hace falta que "flote"
     sobre el contenido: con las ventanas en flujo normal, basta con que
     quede pegada abajo y que el .frame tenga hueco reservado (ver arriba). */
  .lobby-actions {
    left: 10px;
    right: 10px;
  }
  .lobby-actions .btn--primary { min-width: 0; }

  .corner-toolbar {
    top: 8px;
    left: 8px;
  }
  .corner-btn {
    font-size: 10px;
    padding: 4px 8px;
  }

  /* ---- Ventanas de chat: overlay a pantalla completa cuando están
     abiertas, barra compacta apilada cuando están minimizadas. Usa
     !important porque setWindowMinimized() en app.js sigue fijando
     alto/posición en línea (código compartido con el escritorio) -- aquí
     solo hace falta que la presentación visual gane siempre en móvil. ---- */
  .chat-window {
    width: auto;
    height: auto;
  }

  .chat-window:not(.floating-window--minimized) {
    position: fixed !important;
    inset: 0 !important;
    left: 0 !important;
    top: 0 !important;
    right: 0 !important;
    bottom: 0 !important;
    width: 100% !important;
    height: 100% !important;
    margin: 0 !important;
    /* Por encima incluso de la barra de esquina (z-index 400): mientras el
       chat ocupa toda la pantalla, "abandonar sala" queda detras, se llega
       a el cerrando antes el chat (boton ✕ de su cabecera). */
    /* !important: bringToFront() en app.js sigue fijando un z-index bajo en
       línea (10, 11, 12...) para el apilado de escritorio; en móvil la
       ventana de chat expandida siempre tiene que ganar a la barra inferior
       fija (.lobby-actions) y a la barra de esquina, o el input de chat
       queda tapado por ellas. */
    z-index: 410 !important;
    border-radius: 0;
  }

  .chat-window.floating-window--minimized {
    position: fixed !important;
    left: 10px !important;
    right: 10px !important;
    top: auto !important;
    bottom: calc(84px + var(--mobile-stack-index, 0) * 46px) !important;
    width: auto !important;
    height: auto !important;
    margin: 0 !important;
    z-index: 180 !important;
  }

  .chat-window__header-name { font-size: 13px; }

  .chat-messages { padding: 12px 10px; }

  .chat-input-row {
    padding-bottom: max(8px, env(safe-area-inset-bottom));
  }

  /* ---- Selector de emojis: por encima del chat a pantalla completa ---- */
  .emoji-picker {
    max-width: calc(100vw - 16px);
    z-index: 420;
  }

  /* ---- Modal de importar misiones: ocupa prácticamente toda la pantalla ---- */
  .modal-panel {
    max-height: 92vh;
  }
}
