/* =========================================================
   COLONOS — mesa de juego al anochecer
   Paleta: mar #0E2A3A / mar profundo #081C28 / pergamino #F3E9D2
           tinta #2B2118 / ambar #E8A33D
   Tipografias: Fraunces (display) / Karla (cuerpo) / JetBrains Mono (codigos)
   ========================================================= */
:root {
  --sea: #0E2A3A;
  --sea-deep: #081C28;
  --parchment: #F3E9D2;
  --parchment-dim: #E4D6B8;
  --ink: #2B2118;
  --amber: #E8A33D;
  --amber-dark: #C4842A;
  --line: rgba(243, 233, 210, 0.14);
  --panel: rgba(8, 28, 40, 0.72);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; }
body {
  font-family: 'Karla', sans-serif;
  background: radial-gradient(120% 90% at 50% 10%, var(--sea) 0%, var(--sea-deep) 78%);
  color: var(--parchment);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}
button { font-family: inherit; cursor: pointer; }
button:disabled { opacity: 0.4; cursor: not-allowed; }
button:focus-visible, input:focus-visible { outline: 2px solid var(--amber); outline-offset: 2px; }
h1, h2, h3 { font-family: 'Fraunces', serif; font-weight: 600; letter-spacing: 0.01em; }
.muted { color: rgba(243, 233, 210, 0.55); }
.hint { color: var(--amber); font-size: 0.95rem; padding: 6px 2px; }

/* ============ pantalla de inicio ============ */
#screen-home {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 26px;
  padding: 24px;
}
.home-title { font-size: clamp(2.6rem, 7vw, 4.4rem); color: var(--parchment); }
.home-title em { font-style: italic; color: var(--amber); }
.home-sub { color: rgba(243, 233, 210, 0.6); margin-top: -16px; text-align: center; }
.home-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 26px 28px;
  width: min(420px, 94vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
  backdrop-filter: blur(6px);
}
.inp {
  background: rgba(243, 233, 210, 0.07);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--parchment);
  font-size: 1.05rem;
  padding: 12px 14px;
  width: 100%;
}
.inp::placeholder { color: rgba(243, 233, 210, 0.35); }
#inp-code { font-family: 'JetBrains Mono', monospace; text-transform: uppercase; letter-spacing: 0.35em; }
.join-row { display: flex; gap: 10px; }
.join-row .inp { flex: 1 1 auto; min-width: 0; }
.home-or { text-align: center; color: rgba(243, 233, 210, 0.35); font-size: 0.85rem; }
#online-note { font-size: 0.85rem; color: var(--amber); }

/* ============ botones ============ */
.act-btn {
  background: rgba(243, 233, 210, 0.08);
  border: 1px solid var(--line);
  border-radius: 10px;
  color: var(--parchment);
  font-size: 0.98rem;
  padding: 10px 16px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  transition: background 0.15s;
}
.act-btn:hover:not(:disabled) { background: rgba(243, 233, 210, 0.16); }
.act-btn.primary {
  background: var(--amber);
  border-color: var(--amber-dark);
  color: var(--ink);
  font-weight: 700;
}
.act-btn.primary:hover:not(:disabled) { background: #F0B255; }
.act-btn.big { font-size: 1.15rem; padding: 14px 22px; }
.act-btn.end { border-color: rgba(214, 69, 65, 0.6); }
.act-btn.active { background: var(--amber); color: var(--ink); font-weight: 700; }
.cost { font-size: 0.85em; opacity: 0.85; letter-spacing: 0.05em; }

/* ============ partida: rejilla ============ */
#screen-game {
  height: 100%;
  display: grid;
  grid-template-columns: 240px 1fr;
  grid-template-rows: auto 1fr auto;
  grid-template-areas:
    'players status'
    'players board'
    'players hand';
}
#status {
  grid-area: status;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--line);
  background: var(--panel);
  min-height: 56px;
}
.status-msg { font-size: 1.02rem; }
#players {
  grid-area: players;
  border-right: 1px solid var(--line);
  background: var(--panel);
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
}
#board-wrap { grid-area: board; position: relative; overflow: hidden; }
#board { width: 100%; height: 100%; touch-action: none; display: block; }
#bottom {
  grid-area: hand;
  border-top: 1px solid var(--line);
  background: var(--panel);
  padding: 10px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* jugadores */
.pcard {
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(243, 233, 210, 0.04);
}
.pcard-turn { border-color: var(--amber); box-shadow: 0 0 0 1px var(--amber); }
.pcard-top { display: flex; align-items: center; gap: 8px; }
.pdot { width: 13px; height: 13px; border-radius: 50%; display: inline-block; border: 1px solid rgba(8, 20, 28, 0.5); flex: 0 0 auto; }
.pname { font-weight: 700; flex: 1 1 auto; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.pvp { font-family: 'Fraunces', serif; font-size: 1.05rem; color: var(--amber); }
.pcard-sub { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 6px; font-size: 0.88rem; color: rgba(243, 233, 210, 0.75); }
.badge {
  background: rgba(232, 163, 61, 0.18);
  border: 1px solid rgba(232, 163, 61, 0.5);
  border-radius: 6px;
  padding: 1px 6px;
  font-size: 0.8rem;
}

/* dados */
.dice { display: flex; gap: 8px; }
.die {
  width: 38px; height: 38px;
  background: var(--parchment);
  border-radius: 8px;
  display: inline-grid;
  grid-template-columns: repeat(3, 1fr);
  padding: 6px;
  gap: 2px;
  box-shadow: inset 0 -3px 0 rgba(43, 33, 24, 0.25);
}
.die i { border-radius: 50%; }
.die i.on { background: var(--ink); }
.dice.rolling .die { animation: tumble 0.45s ease-in-out; }
@keyframes tumble {
  0% { transform: rotate(0) translateY(0); }
  35% { transform: rotate(160deg) translateY(-8px); }
  70% { transform: rotate(310deg) translateY(2px); }
  100% { transform: rotate(360deg) translateY(0); }
}

/* mano y acciones */
#hand { display: flex; align-items: center; gap: 16px; flex-wrap: wrap; }
.hand-res { display: flex; gap: 8px; flex-wrap: wrap; }
.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 9px;
  padding: 5px 10px;
  font-weight: 700;
  font-size: 1rem;
  color: var(--ink);
  background: var(--parchment);
  border: 1px solid rgba(43, 33, 24, 0.3);
}
.chip-wood { background: #A8C39A; }
.chip-brick { background: #E0A188; }
.chip-wool { background: #D8E4C4; }
.chip-wheat { background: #F0D48A; }
.chip-ore { background: #C3CBD4; }
.hand-dev { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.dev-btn {
  background: rgba(243, 233, 210, 0.1);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--parchment);
  padding: 6px 10px;
  font-size: 0.88rem;
  display: inline-flex;
  gap: 6px;
  align-items: center;
}
.dev-btn:hover:not(:disabled) { background: rgba(243, 233, 210, 0.2); }
.new-dev { font-size: 0.72rem; color: var(--amber); }
.dev-vp { font-size: 0.88rem; color: var(--amber); }
#actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* banner de comercio */
#trade-banner {
  display: none;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  background: rgba(232, 163, 61, 0.13);
  border: 1px solid rgba(232, 163, 61, 0.45);
  border-radius: 10px;
  padding: 8px 12px;
}

/* registro */
#log-toggle {
  position: absolute;
  top: 10px; right: 10px;
  z-index: 5;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--parchment);
  padding: 7px 12px;
}
#log-panel {
  position: absolute;
  top: 52px; right: 10px;
  width: min(320px, 84vw);
  max-height: 55%;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  display: none;
  overflow: hidden;
  backdrop-filter: blur(6px);
  z-index: 5;
}
#log-panel.open { display: block; }
#log { max-height: 100%; overflow-y: auto; padding: 10px 12px; font-size: 0.86rem; }
.log-line { display: flex; gap: 7px; align-items: baseline; padding: 2px 0; color: rgba(243, 233, 210, 0.85); }
.log-dot { width: 8px; height: 8px; border-radius: 50%; flex: 0 0 auto; position: relative; top: -1px; }

/* controles de zoom */
#zoom-ctl {
  position: absolute;
  bottom: 12px; right: 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  z-index: 5;
}
#zoom-ctl button {
  width: 38px; height: 38px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: var(--parchment);
  font-size: 1.1rem;
}

/* resaltados del tablero */
.hl-vertex {
  fill: rgba(232, 163, 61, 0.55);
  stroke: var(--amber);
  stroke-width: 3;
  cursor: pointer;
  animation: pulse 1.1s ease-in-out infinite;
}
.hl-edge {
  stroke: rgba(232, 163, 61, 0.55);
  stroke-width: 16;
  stroke-linecap: round;
  cursor: pointer;
  animation: pulse 1.1s ease-in-out infinite;
}
.hl-tile {
  fill: rgba(232, 163, 61, 0.18);
  stroke: var(--amber);
  stroke-width: 5;
  cursor: pointer;
}
@keyframes pulse { 0%, 100% { opacity: 0.55; } 50% { opacity: 1; } }
.tile-icon { opacity: 0.85; pointer-events: none; }
.robber { pointer-events: none; }
@media (prefers-reduced-motion: reduce) {
  .hl-vertex, .hl-edge, .dice.rolling .die { animation: none; }
}

/* ============ modales ============ */
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(4, 12, 18, 0.72);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 50;
  padding: 18px;
}
.modal {
  position: relative;
  background: #10303F;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 24px;
  width: min(460px, 96vw);
  max-height: 88vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.modal h3 { font-size: 1.4rem; color: var(--amber); }
.modal-x {
  position: absolute;
  top: 12px; right: 14px;
  background: none;
  border: none;
  color: rgba(243, 233, 210, 0.6);
  font-size: 1.1rem;
}
.stepper { display: flex; align-items: center; gap: 10px; }
.st-btn {
  width: 34px; height: 34px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: rgba(243, 233, 210, 0.08);
  color: var(--parchment);
  font-size: 1.15rem;
}
.st-num { min-width: 86px; justify-content: center; }
.tabs { display: flex; gap: 6px; border-bottom: 1px solid var(--line); padding-bottom: 8px; }
.tab {
  background: none;
  border: 1px solid transparent;
  border-radius: 8px;
  color: rgba(243, 233, 210, 0.6);
  padding: 7px 14px;
  font-size: 0.95rem;
}
.tab.active { background: rgba(232, 163, 61, 0.15); border-color: rgba(232, 163, 61, 0.5); color: var(--amber); font-weight: 700; }
.to-row { display: flex; gap: 8px; flex-wrap: wrap; }
.score-table { display: flex; flex-direction: column; gap: 6px; }
.score-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(243, 233, 210, 0.05);
  border-radius: 9px;
  padding: 8px 12px;
}
.score-row b { margin-left: auto; color: var(--amber); }

/* ============ sala online ============ */
#screen-room {
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px;
}
#room-code {
  font-family: 'JetBrains Mono', monospace;
  font-size: clamp(2.4rem, 9vw, 4rem);
  letter-spacing: 0.4em;
  padding-left: 0.4em;
  color: var(--amber);
  background: rgba(232, 163, 61, 0.08);
  border: 1px dashed rgba(232, 163, 61, 0.5);
  border-radius: 14px;
  padding: 12px 18px 12px calc(18px + 0.4em);
}
.room-card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 22px 24px;
  width: min(420px, 94vw);
  display: flex;
  flex-direction: column;
  gap: 12px;
}
.room-player {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(243, 233, 210, 0.05);
  border-radius: 9px;
  padding: 9px 12px;
}
.host-tag { font-size: 0.75rem; color: var(--amber); border: 1px solid rgba(232, 163, 61, 0.5); border-radius: 5px; padding: 1px 6px; }
.kick { margin-left: auto; background: none; border: none; color: rgba(214, 69, 65, 0.8); font-size: 0.95rem; }
.opt-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; }
.opt-row select, .opt-row input[type='number'] {
  background: rgba(243, 233, 210, 0.07);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--parchment);
  padding: 7px 10px;
  font-size: 1rem;
}

/* ============ config partida local ============ */
#local-setup {
  position: fixed;
  inset: 0;
  background: rgba(4, 12, 18, 0.8);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 40;
  padding: 18px;
}
.local-card {
  background: #10303F;
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 24px;
  width: min(440px, 96vw);
  max-height: 90vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 12px;
}
#local-n { display: flex; gap: 8px; }
#local-n button {
  flex: 1;
  padding: 9px 0;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: rgba(243, 233, 210, 0.07);
  color: var(--parchment);
  font-size: 1.05rem;
}
#local-n button.active { background: var(--amber); color: var(--ink); font-weight: 700; }
#local-names { display: flex; flex-direction: column; gap: 8px; }
.local-name { border-left: 4px solid transparent; }
.check-row { display: flex; align-items: center; gap: 9px; font-size: 0.95rem; }
.check-row input { width: 17px; height: 17px; accent-color: var(--amber); }
.setup-note { font-size: 0.85rem; color: var(--amber); }

/* cambio de jugador (modo mesa) */
#handoff {
  position: fixed;
  inset: 0;
  background: var(--sea-deep);
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 60;
  cursor: pointer;
}
#handoff h2 { font-size: 2rem; }
#handoff p { color: rgba(243, 233, 210, 0.55); }

/* toasts */
.toast {
  position: fixed;
  bottom: 26px;
  left: 50%;
  transform: translate(-50%, 16px);
  background: #10303F;
  border: 1px solid var(--line);
  border-radius: 11px;
  color: var(--parchment);
  padding: 11px 18px;
  font-size: 0.95rem;
  opacity: 0;
  transition: opacity 0.25s, transform 0.25s;
  z-index: 70;
  max-width: 90vw;
}
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.error { border-color: rgba(214, 69, 65, 0.7); }

/* boton salir en partida */
#game-leave {
  position: absolute;
  top: 10px; left: 10px;
  z-index: 5;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 9px;
  color: rgba(243, 233, 210, 0.7);
  padding: 7px 12px;
}

/* ============ movil ============ */
@media (max-width: 760px) {
  #screen-game {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto 1fr auto;
    grid-template-areas: 'status' 'players' 'board' 'hand';
  }
  #players {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    border-right: none;
    border-bottom: 1px solid var(--line);
    padding: 8px 10px;
  }
  .pcard { min-width: 170px; flex: 0 0 auto; }
  #status { min-height: 48px; padding: 8px 12px; }
  .status-msg { font-size: 0.92rem; }
  .die { width: 30px; height: 30px; padding: 5px; }
  #bottom { padding: 8px 10px; }
  .act-btn { font-size: 0.9rem; padding: 9px 12px; }
  #game-leave { top: auto; bottom: 12px; left: 10px; }
}
