/* La mesa: el mapa ocupa la pantalla y todo lo demás se ordena a su alrededor.
   Se carga la última y solo afecta a .room-page. */
.room-page main { padding: 0; max-width: none; }
.room-page .board {
  display: grid; gap: 10px; padding: 10px 14px 12px;
  grid-template-columns: minmax(0, 1fr) 340px;
  grid-template-rows: auto minmax(0, 1fr);
  grid-template-areas: "head head" "stage dock";
  height: calc(100dvh - 55px);
}
.room-page.dock-collapsed .board { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "stage"; }
.room-page.dock-collapsed .game-dock { display: none; }

/* Cabecera: quién, dónde y las tres acciones de mesa. */
.board-head { grid-area: head; display: flex; align-items: center; justify-content: space-between; gap: 16px; min-width: 0; }
.board-title { display: flex; align-items: baseline; gap: 14px; min-width: 0; }
.board-title h1 { margin: 0; font: 400 1.45rem/1.15 var(--serif); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-title h2 { margin: 0; font-weight: 400; color: var(--muted); font-size: .9rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.board-actions { display: flex; align-items: center; gap: 8px; flex: none; }
.board-actions button { min-height: 38px; padding: 8px 14px; }
.board-actions button[aria-pressed=true] { border-color: var(--gold); color: var(--gold); }
.presence { display: inline-flex; align-items: center; gap: 7px; color: var(--muted); font-size: .8rem; margin-right: 6px; }

/* Escenario. */
.room-page .map-workspace {
  grid-area: stage; display: flex; flex-direction: column; min-height: 0; min-width: 0;
  background: #12161e; border: 1px solid var(--edge); border-radius: 12px; overflow: hidden;
}
.room-page .map-workspace:fullscreen { padding: 0; border-radius: 0; }

/* La cinta de turnos: lo que más se mira durante un combate. */
.turn-strip { display: flex; align-items: center; gap: 14px; padding: 8px 12px; min-height: 58px; border-bottom: 1px solid var(--edge); background: #171c25; }
.turn-strip .round { font: 400 1.05rem var(--serif); color: var(--text); white-space: nowrap; }
.turn-strip.idle .round { color: var(--muted); }
.turn-strip .initiative-tokens { display: flex; gap: 6px; overflow-x: auto; min-width: 0; padding: 4px 2px; }
.turn-strip .turn-label { margin-left: auto; white-space: nowrap; font-weight: 600; font-size: .9rem; }
.turn-strip.idle .turn-label { margin-left: 0; font-weight: 400; font-size: .82rem; }
.turn-strip button { min-height: 36px; padding: 7px 12px; font-size: .8rem; flex: none; }
.turn-strip.idle button { margin-left: auto; }
.turn-strip .initiative-token { position: relative; flex: none; opacity: .62; transition: opacity .2s; }
.turn-strip .initiative-token.current { opacity: 1; }
.turn-strip .initiative-token img, .turn-strip .initiative-token .unknown-mark { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; border: 2px solid #374050; display: grid; place-items: center; }
.turn-strip .initiative-token.current img, .turn-strip .initiative-token.current .unknown-mark { border-color: var(--gold); box-shadow: 0 0 0 3px #dfc18d33; }
.turn-strip .initiative-token b { position: absolute; right: -4px; bottom: -3px; min-width: 19px; padding: 1px 4px; border-radius: 8px; background: #242933; font-size: .62rem; text-align: center; }
.turn-strip.mine { background: linear-gradient(90deg, #dfc18d2e, #171c25 65%); box-shadow: inset 4px 0 var(--gold); }
.turn-strip.mine .turn-label { color: var(--gold); font: 400 1.2rem var(--serif); }
@media (prefers-reduced-motion: no-preference) {
  .turn-strip.mine .turn-label { animation: your-turn 1.6s ease-out 1; }
  @keyframes your-turn { from { letter-spacing: .14em; opacity: 0; } to { letter-spacing: normal; opacity: 1; } }
}

/* El mapa llena el escenario; herramientas flotan encima. */
.map-stage { position: relative; flex: 1; min-height: 0; }
.room-page .map-scroll { position: absolute; inset: 0; max-height: none; min-height: 0; display: flex; overflow: auto; background: #0c1017; }
.room-page #map-canvas { margin: auto; flex: none; }
.room-page #map3d-host { width: 100%; }
.room-page .map-scroll:has(#map3d-host) #map-canvas { width: 100%; height: 100%; }

.tool-rail, .tool-options, .view-controls {
  position: absolute; z-index: 3; display: flex; gap: 4px; padding: 5px;
  background: #101319e6; border: 1px solid var(--edge); border-radius: 10px; backdrop-filter: blur(6px);
}
.tool-rail { left: 10px; top: 10px; flex-direction: column; }
.tool-rail .tool { width: 56px; min-height: 50px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px; padding: 4px 2px; background: transparent; border-color: transparent; font-size: 1.05rem; }
.tool-rail .tool small { font-size: .62rem; color: var(--muted); }
.tool-rail .tool[aria-pressed=true] { background: #2e3541; color: var(--gold); }
.tool-rail .tool[aria-pressed=true] small { color: var(--gold); }
.tool-options { left: 80px; top: 10px; flex-wrap: wrap; align-items: center; max-width: calc(100% - 180px); }
.tool-options button, .tool-options select, .tool-options input { min-height: 36px; padding: 6px 10px; font-size: .8rem; }
.tool-options .radius { display: inline-flex; align-items: center; gap: 6px; font-size: .75rem; margin: 0 4px; }
.tool-options .radius-input { width: 58px; }
.tool-options button[aria-pressed=true] { color: var(--gold); border-color: var(--gold); }
.view-controls { right: 10px; top: 10px; align-items: center; }
.view-controls button { min-height: 34px; min-width: 34px; padding: 4px 8px; font-size: .85rem; background: transparent; border-color: transparent; }
.view-controls button[aria-pressed=true] { color: var(--gold); background: #2e3541; }
.view-controls span { font-size: .7rem; color: var(--muted); min-width: 36px; text-align: center; }

.story-card { position: absolute; z-index: 4; right: 10px; top: 58px; width: min(400px, calc(100% - 100px)); max-height: calc(100% - 140px); overflow: auto; padding: 16px 18px; background: #191d25f5; border: 1px solid var(--edge); border-radius: 12px; }
.story-card h2 { margin: 0 0 8px; font: 400 1.25rem var(--serif); }
.story-card p { font: 1rem/1.6 var(--serif); margin: 0 0 12px; }
.story-card h3 { font-size: .82rem; color: var(--gold); margin: 14px 0 4px; }
.story-card .private { font-size: .92rem; color: #eddcbf; }

/* Barra de la ficha seleccionada: vida, armadura y ataques sin abrir menús. */
.focus-bar { position: absolute; z-index: 3; left: 50%; bottom: 12px; transform: translateX(-50%); display: flex; align-items: center; gap: 14px; max-width: calc(100% - 24px); padding: 8px 10px 8px 8px; background: #101319f0; border: 1px solid var(--edge); border-radius: 14px; box-shadow: 0 10px 30px #0008; }
.focus-bar > img { width: 46px; height: 46px; border-radius: 10px; object-fit: cover; flex: none; }
.focus-name { display: flex; flex-direction: column; min-width: 0; }
.focus-name strong { font: 400 1.05rem var(--serif); white-space: nowrap; }
.focus-name span { font-size: .72rem; color: var(--muted); }
.focus-hp { display: flex; align-items: center; gap: 6px; }
.focus-hp meter { width: 90px; height: 10px; }
.focus-hp span { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.focus-hp span b { color: var(--text); font-size: 1rem; }
.focus-hp button { min-height: 30px; min-width: 30px; padding: 2px 8px; }
.focus-ac { font-size: .8rem; color: var(--muted); white-space: nowrap; }
.focus-ac b { color: var(--text); font-size: 1rem; }
.focus-conditions { display: flex; gap: 4px; flex-wrap: wrap; max-width: 180px; }
.focus-actions { display: flex; gap: 6px; }
.focus-actions button { min-height: 36px; padding: 6px 11px; font-size: .8rem; white-space: nowrap; }
.focus-attack { background: #262c37; border-color: #4b525c; }

.room-page .map-help { display: flex; justify-content: space-between; gap: 12px; padding: 6px 12px; font-size: .74rem; color: var(--muted); border-top: 1px solid var(--edge); background: #141820; }

/* Escenas: solo el director, como tira bajo el mapa. */
.scene-strip { display: flex; gap: 8px; overflow-x: auto; padding: 8px 10px; border-top: 1px solid var(--edge); background: #141820; flex: none; }
.room-page .scene-strip .scene-thumb { flex: none; width: 190px; min-height: 0; display: grid; grid-template-columns: 64px 1fr; align-items: center; gap: 0; padding: 0; overflow: hidden; text-align: left; position: relative; }
.room-page .scene-strip .scene-thumb img { width: 64px; height: 44px; object-fit: cover; display: block; }
.room-page .scene-strip .scene-thumb span { position: absolute; left: 4px; top: 3px; font-size: .62rem; background: #101319cc; border-radius: 4px; padding: 0 4px; }
.room-page .scene-strip .scene-thumb strong { font-size: .76rem; padding: 6px 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Panel lateral. */
.room-page .game-dock { grid-area: dock; height: auto; min-height: 0; border-radius: 12px; }
.room-page .dock-tabs { padding: 5px; gap: 2px; }
.room-page .dock-tabs button { min-height: 40px; flex-direction: row; justify-content: center; font-size: .78rem; padding: 6px 4px; }
.dock-tabs .badge { display: inline-grid; place-items: center; min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px; background: var(--gold); color: #1b1f26; font-size: .65rem; font-weight: 700; }
.room-page .dock-content:has(.chat) { display: flex; flex-direction: column; overflow: hidden; }

.room-page .game-dock .dice-tray { display: block; padding: 10px; border-top: 1px solid var(--edge); background: #171c25; }
.room-page .game-dock .dice-buttons { display: grid; grid-template-columns: repeat(7, minmax(0, 1fr)); gap: 4px; }
.room-page .game-dock .dice-buttons button { min-height: 36px; padding: 4px 0; font-size: .74rem; }
.room-page .game-dock .dice-buttons .d20 { border-color: var(--gold); color: var(--gold); }
.room-page .game-dock .dice-options { display: grid; grid-template-columns: 1fr 1fr 1.5fr; gap: 6px; margin-top: 8px; }
.room-page .game-dock .dice-options label { display: flex; flex-direction: column; gap: 3px; margin: 0; width: auto; min-width: 0; font-size: .66rem; }
.room-page .game-dock .dice-options input, .room-page .game-dock .dice-options select { width: 100%; min-height: 32px; padding: 4px 6px; font-size: .8rem; margin: 0; }

/* Chat. */
.chat { display: flex; flex-direction: column; flex: 1; min-height: 0; gap: 8px; }
.chat-log { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; padding-right: 2px; }
.chat-log .empty { margin: auto 0; color: var(--muted); font-size: .85rem; }
.chat-message { padding: 7px 10px; border-radius: 10px; background: #212630; }
.chat-message.mine { background: #252b35; }
.chat-message.whisper { background: #252b36; outline: 1px dashed #6d7c90; }
.chat-message .msg-head { display: flex; align-items: baseline; gap: 8px; font-size: .74rem; }
.chat-message .msg-head span { color: var(--purple); }
.chat-message time { margin-left: auto; color: var(--muted); font-size: .66rem; }
.chat-message p { margin: 3px 0 0; font-size: .9rem; line-height: 1.4; overflow-wrap: anywhere; }
.chat-roll { display: flex; align-items: center; gap: 10px; }
.chat-roll b { font: 400 1.5rem var(--serif); color: var(--gold); }
.chat-roll span { font-size: .78rem; color: var(--muted); }
.chat-form { display: grid; gap: 6px; }
.chat-form select { min-height: 34px; padding: 4px 8px; font-size: .78rem; }
.chat-input-row { display: flex; gap: 6px; }
.chat-input-row input { flex: 1; min-width: 0; min-height: 40px; }
.chat-input-row button { min-height: 40px; padding: 6px 12px; }

/* Ficha 5e: cada valor es una tirada. */
.sheet5e { margin: 14px 0; }
.sheet5e h3 { font-size: .85rem; margin: 14px 0 6px; }
.sheet-meta { display: flex; flex-wrap: wrap; gap: 4px 14px; font-size: .78rem; color: var(--muted); }
.sheet-meta b { color: var(--text); }
.ability-grid { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; margin-top: 10px; }
.ability-grid .ability { display: flex; flex-direction: column; align-items: center; gap: 0; padding: 7px 4px; min-height: 0; background: #1f242c; border-color: #384151; }
.ability-grid .ability small { font-size: .62rem; color: var(--muted); }
.ability-grid .ability b { font: 400 1.35rem var(--serif); }
.ability-grid .ability span { font-size: .66rem; color: var(--muted); }
.check-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 4px; }
.check-grid button { display: flex; justify-content: space-between; align-items: center; gap: 6px; min-height: 32px; padding: 4px 8px; font-size: .76rem; background: transparent; text-align: left; }
.check-grid button small { color: var(--muted); font-size: .6rem; }
.check-grid button.proficient span::before { content: "● "; color: var(--mint); }
.check-grid button.expert span::before { content: "◆ "; color: var(--gold); }
.ability-grid .ability:hover, .check-grid button:hover { border-color: var(--gold); }

/* Portátil estrecho. */
@media (max-width: 1150px) {
  .room-page .board { grid-template-columns: minmax(0, 1fr) 290px; }
  .presence { display: none; }
  .focus-conditions { display: none; }
}

/* Móvil: el mapa o el panel, a pantalla completa, con navegación inferior. */
@media (max-width: 600px) {
  .room-page .board { grid-template-columns: minmax(0, 1fr); grid-template-areas: "head" "stage"; height: calc(100dvh - 55px - 62px); padding: 8px; gap: 8px; }
  .board-title h1 { display: none; }
  .board-title h2 { color: var(--text); font: 400 1.05rem var(--serif); }
  .board-actions { gap: 4px; }
  .board-actions button { min-height: 36px; padding: 6px 9px; font-size: .78rem; }
  #toggle-dock { display: none; }
  .room-page .game-dock { grid-area: stage; }
  .room-page.mobile-map .game-dock { display: none; }
  .room-page:not(.mobile-map) .map-workspace { display: none; }
  .room-page:not(.mobile-map) .game-dock { display: flex; height: auto; min-height: 0; }
  .turn-strip { gap: 8px; min-height: 52px; }
  .turn-strip .round { font-size: .9rem; }
  .turn-strip .turn-label { display: none; }
  .turn-strip.mine .turn-label { display: inline; font-size: .95rem; }
  .tool-rail { left: 6px; top: 6px; }
  .tool-rail .tool { width: 46px; min-height: 44px; }
  .tool-rail .tool small { display: none; }
  .tool-options { left: 62px; top: 6px; max-width: calc(100% - 70px); }
  .view-controls { top: auto; bottom: 6px; right: 6px; }
  .focus-bar { left: 6px; right: 6px; bottom: 54px; transform: none; gap: 8px; flex-wrap: wrap; }
  .focus-ac { display: none; }
  .focus-hp meter { width: 60px; }
  .room-page .map-help span:first-child { display: none; }
  .scene-strip .scene-thumb { width: 150px; }
}

/* Ajustes tras revisar capturas. */
.tool-rail .tool svg { display: block; }
.focus-attack { display: inline-flex; align-items: center; gap: 6px; }
.focus-attack svg { width: 16px; height: 16px; }
.board-actions button.quiet, .board-actions button.quiet[aria-pressed=true] { border-color: transparent; background: transparent; color: var(--muted); }
.room-page #notice:not(:empty) { top: 120px; bottom: auto; left: 50%; transform: translateX(-50%); }
