/* screens.css -- per-screen styles for all JS-rendered screens
   Palette tokens: --bg --panel --line --ink --muted --accent --accent2 --danger
   All rules are mobile-first; tap targets >= 44px; dvh units used where appropriate.
*/

/* =========================================================
   LOBBY / PARTY
   ========================================================= */

.lobby {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 24px 16px 32px;
  gap: 16px;
  min-height: 100dvh;
}

.party {
  width: 100%;
  max-width: 400px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  overflow: hidden;
}

.player-list {
  list-style: none;
  margin: 0;
  padding: 8px 0;
}

.player {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  min-height: 44px;
  font-size: 14px;
  color: var(--ink);
  border-bottom: 1px solid var(--line);
}
.player:last-child { border-bottom: none; }
.player.self { color: var(--accent); font-weight: 700; }

/* Room code chip -- big monospace display with copy button */
.code-chip {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 12px 16px;
  font-family: ui-monospace, monospace;
  font-size: 28px;
  font-weight: 800;
  letter-spacing: 8px;
  color: var(--accent);
}
.code-chip button {
  font-size: 13px;
  letter-spacing: 0;
  font-weight: 400;
  font-family: system-ui, sans-serif;
  padding: 6px 12px;
  min-height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
}

.party-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100%;
  max-width: 400px;
}

/* =========================================================
   CHARACTER CREATION WIZARD
   ========================================================= */

.wizard {
  display: flex;
  flex-direction: column;
  min-height: 100dvh;
  padding: 16px;
  gap: 16px;
  max-width: 560px;
  margin: 0 auto;
}

/* Step indicator strip */
.wizard-steps {
  display: flex;
  gap: 6px;
  justify-content: center;
  padding: 4px 0;
}

.step {
  width: 28px;
  height: 6px;
  border-radius: 3px;
  background: var(--line);
  transition: background 0.2s;
}
.step.active { background: var(--accent); }

/* Choice grid -- selectable cards (race / class / background) */
.choice-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
}

.choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 14px 10px;
  border-radius: 14px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  min-height: 44px;
  text-align: center;
  transition: border-color 0.15s, background 0.15s;
}
.choice:hover { border-color: var(--muted); }
.choice.selected {
  border-color: var(--accent);
  background: #221e0e;
}

.choice img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  border-radius: 8px;
}

.choice-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--ink);
}
.choice-desc {
  font-size: 11px;
  color: var(--muted);
  line-height: 1.4;
}

/* Attribute point-buy rows */
.attr-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
  padding: 6px 0;
  border-bottom: 1px solid var(--line);
}
.attr-row:last-child { border-bottom: none; }

.attr-name {
  flex: 1;
  font-size: 13px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.attr-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--ink);
  min-width: 28px;
  text-align: center;
}
.attr-mod {
  font-size: 12px;
  color: var(--muted);
  min-width: 28px;
  text-align: right;
}

.stepper-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  min-width: 44px;
}
.stepper-btn:disabled { opacity: 0.4; cursor: default; }

/* Remaining points badge */
.points {
  display: inline-block;
  background: var(--accent2);
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: 999px;
  padding: 2px 10px;
  font-size: 12px;
  font-weight: 700;
}

/* Wizard nav row (Geri / Ileri / Onayla) */
.wizard-nav {
  display: flex;
  gap: 8px;
  margin-top: auto;
  padding-top: 16px;
}
.wizard-nav .btn { flex: 1; min-height: 48px; }

/* =========================================================
   PLAY SCREEN (SCREEN B)
   ========================================================= */

/* Scene banner -- ~26vh, background-image cover + gradient fallback */
.scene {
  position: relative;
  height: 26dvh;
  min-height: 140px;
  background-color: #241f17;
  background-image: linear-gradient(160deg, #6b5a3a, #241f17);
  background-size: cover;
  background-position: center;
  display: flex;
  align-items: flex-end;
  padding: 10px 12px;
  color: #d8cba0;
  font-size: 13px;
  flex-shrink: 0;
}
/* Gradient overlay so text is legible over scene images */
.scene::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, transparent 40%, rgba(17,19,15,0.85) 100%);
  pointer-events: none;
}
.scene-label {
  position: relative;
  z-index: 1;
  line-height: 1.4;
}

/* Topbar -- room code left, turn indicator + menu buttons right */
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  font-size: 13px;
  color: var(--muted);
  flex-shrink: 0;
  gap: 8px;
}
.topbar-room {
  font-family: ui-monospace, monospace;
  letter-spacing: 2px;
  color: var(--accent);
  font-weight: 700;
}
.topbar-turn { color: var(--ink); font-size: 12px; }
.topbar-actions { display: flex; gap: 6px; }
.topbar-actions button {
  min-height: 36px;
  min-width: 36px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: transparent;
  color: var(--muted);
  font-size: 15px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Flow -- scrollable message column */
.flow {
  flex: 1;
  overflow-y: auto;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Messages */
.msg {
  padding: 8px 12px;
  border-radius: 10px;
  background: #23271f;
  max-width: 85%;
  line-height: 1.45;
  font-size: 14px;
}
.msg.me   { background: #3a2e1c; align-self: flex-end; color: var(--accent); }
.msg.dm   { background: #1d241c; border: 1px solid var(--line); align-self: flex-start; }
.msg.other { background: #23271f; align-self: flex-start; }

/* Dice result line */
.dice {
  font-family: ui-monospace, monospace;
  font-size: 13px;
  padding: 6px 10px;
  border-radius: 8px;
  background: var(--panel);
  border: 1px solid var(--line);
  align-self: center;
  color: var(--muted);
}
.dice.success { color: var(--accent); }
.dice.fail    { color: var(--danger); }

/* Quick-action horizontal scroll bar */
.quickbar {
  display: flex;
  gap: 6px;
  padding: 6px 12px;
  overflow-x: auto;
  border-top: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
  scrollbar-width: none;
}
.quickbar::-webkit-scrollbar { display: none; }
.quickbar button {
  white-space: nowrap;
  flex-shrink: 0;
  min-height: 36px;
  padding: 6px 14px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-size: 13px;
  cursor: pointer;
}

/* Input bar */
.inputbar {
  display: flex;
  gap: 8px;
  padding: 10px;
  border-top: 1px solid var(--line);
  background: #15170f;
  flex-shrink: 0;
}
.inputbar .field { margin: 0; }
.inputbar .btn   { white-space: nowrap; }
.inputbar.locked { opacity: 0.5; pointer-events: none; }

/* =========================================================
   COMBAT SCREEN
   ========================================================= */

.combat {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overflow: hidden;
}

/* Initiative strip */
.initiative {
  display: flex;
  gap: 6px;
  padding: 8px 12px;
  overflow-x: auto;
  background: var(--panel);
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
  scrollbar-width: none;
}
.initiative::-webkit-scrollbar { display: none; }

.init-unit {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 6px 10px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--bg);
  font-size: 11px;
  color: var(--muted);
  min-width: 52px;
  flex-shrink: 0;
}
.init-unit.active {
  border-color: var(--accent);
  background: #221e0e;
  color: var(--accent);
  font-weight: 700;
}

/* Combat grid */
.grid {
  display: grid;
  grid-template-columns: repeat(var(--cols, 8), 1fr);
  gap: 2px;
  aspect-ratio: 1;
  width: 100%;
  background: var(--bg);
  flex-shrink: 0;
}

.cell {
  border: 1px solid var(--line);
  background: var(--panel);
  aspect-ratio: 1;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.cell.reachable  { background: #1c2518; border-color: #3a5030; }
.cell.selectable { background: #251d0e; border-color: var(--accent2); cursor: pointer; }

/* Unit tokens */
.unit {
  position: absolute;
  inset: 2px;
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  font-size: 9px;
  overflow: hidden;
  cursor: pointer;
}
.unit.player { background: #1a2a1a; border: 1px solid var(--accent); }
.unit.npc    { background: #2a1a1a; border: 1px solid var(--danger); }
.unit.selected { outline: 2px solid var(--accent); outline-offset: 1px; }
.unit-name { color: var(--ink); padding: 0 2px 1px; font-size: 9px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }

/* CP bar on unit token */
.cp-bar {
  width: 100%;
  height: 3px;
  background: var(--line);
}
.cp-fill {
  height: 100%;
  background: var(--accent);
  transition: width 0.3s;
}
.unit.npc .cp-fill { background: var(--danger); }

/* Combat log */
.combat-log {
  flex: 1;
  overflow-y: auto;
  padding: 8px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 13px;
  color: var(--muted);
}

/* Combat action bar */
.combatbar {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: var(--panel);
  flex-shrink: 0;
  flex-wrap: wrap;
}
.combatbar .btn { flex: 1; min-height: 44px; font-size: 13px; }
.combatbar .btn.primary { flex: 0 0 auto; min-width: 100px; }

/* Victory / defeat result banner */
.combat-result {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(17, 19, 15, 0.9);
  z-index: 30;
  gap: 16px;
}
.combat-result h2 {
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 4px;
}
.combat-result.victory h2 { color: var(--accent); }
.combat-result.defeat  h2 { color: var(--danger); }

/* =========================================================
   SUPPORT OVERLAYS (character sheet, inventory, quest log)
   ========================================================= */

/* Overlay header with close button */
.overlay-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0 16px;
  border-bottom: 1px solid var(--line);
  margin-bottom: 16px;
}
.overlay-header h2 {
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--ink);
  margin: 0;
}
.close-btn {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* Sheet wrapper */
.sheet {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding-bottom: 32px;
}

/* Labeled progress bars (CP, radiation, hunger, thirst, fatigue) */
.bars {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.bar-label {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.bar-track {
  height: 8px;
  border-radius: 4px;
  background: var(--line);
  overflow: hidden;
}
.bar-fill {
  height: 100%;
  border-radius: 4px;
  background: var(--accent);
  transition: width 0.4s;
}
.bar-fill.danger { background: var(--danger); }
.bar-fill.warn   { background: var(--accent2); }

/* Attribute grid (3 columns) */
.attr-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}
.attr-cell {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 10px 6px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
}
.attr-cell-name {
  font-size: 10px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.attr-cell-val {
  font-size: 20px;
  font-weight: 800;
  color: var(--ink);
}
.attr-cell-mod {
  font-size: 11px;
  color: var(--muted);
}

/* Limb list */
.limb-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.limb {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  font-size: 13px;
  min-height: 44px;
}
.limb-name  { flex: 1; color: var(--ink); }
.limb-state { font-size: 11px; color: var(--muted); }
.limb.injured   .limb-name { color: var(--danger); }
.limb.crippled  .limb-name { color: var(--danger); font-weight: 700; }

/* Status condition chips */
.chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.chip {
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--muted);
}
.chip.active { background: #221e0e; border-color: var(--accent2); color: var(--accent); }
.chip.bad    { background: #2a1010; border-color: var(--danger); color: var(--danger); }

/* Inventory */
.inv {
  display: flex;
  flex-direction: column;
  gap: 16px;
}
.inv-section-title {
  font-size: 11px;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}
.inv-equipped,
.inv-bag {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.inv-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: var(--panel);
  border: 1px solid var(--line);
  min-height: 52px;
}
.inv-item img {
  width: 36px;
  height: 36px;
  object-fit: contain;
  border-radius: 6px;
  flex-shrink: 0;
}
.inv-item-info { flex: 1; display: flex; flex-direction: column; gap: 2px; }
.inv-item-name  { font-size: 14px; color: var(--ink); }
.inv-item-count { font-size: 11px; color: var(--muted); }
.inv-item-actions { display: flex; gap: 6px; }
.inv-item-actions button {
  min-height: 36px;
  padding: 4px 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--bg);
  color: var(--muted);
  font-size: 12px;
  cursor: pointer;
}

/* Quest log */
.questlog {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.quest {
  padding: 12px 14px;
  border-radius: 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-height: 44px;
}
.quest-title { font-size: 14px; font-weight: 700; color: var(--ink); }
.quest-desc  { font-size: 12px; color: var(--muted); line-height: 1.4; }
.quest.done .quest-title { color: var(--muted); text-decoration: line-through; }
.quest.done { border-color: var(--line); opacity: 0.6; }
