:root { color-scheme: dark; font-family: Inter, "Segoe UI", sans-serif; background: #0a0d14; color: #eef2ff; }
.echo-selection { display:grid; grid-template-columns:repeat(auto-fit,minmax(190px,1fr)); gap:12px; }
.echo-choice { border:1px solid #63766a; background:#12231eda; padding:16px; text-align:left; }
.echo-choice.selected { border-color:#b7cf9e; box-shadow:inset 3px 0 #b7cf9e; }
.echo-choice p { font-size:.85rem; line-height:1.75; color:#c5cab2; }
* { box-sizing: border-box; }
body { margin: 0; min-height: 100vh; background: radial-gradient(circle at top, #17223d, #0a0d14 55%); }
main { width: min(1180px, calc(100% - 32px)); margin: 40px auto; }
header { margin-bottom: 24px; }
h1 { font-size: clamp(2rem, 6vw, 4rem); margin: 4px 0 12px; letter-spacing: -.04em; }
h2 { margin-top: 0; font-size: 1.05rem; }
.eyebrow { color: #8aa4ff; letter-spacing: .18em; font-size: .75rem; font-weight: 700; }
.card { background: rgba(20, 27, 44, .9); border: 1px solid #2b395b; border-radius: 16px; padding: 20px; box-shadow: 0 18px 60px #0006; }
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.stack { display: grid; gap: 9px; }
input, button, select { border-radius: 9px; border: 1px solid #40527e; padding: 11px 14px; font: inherit; }
input { background: #0d1320; color: inherit; min-width: 180px; }
select { background: #0d1320; color: inherit; }
button { cursor: pointer; background: #6c8cff; color: #071026; font-weight: 750; }
button:hover { filter: brightness(1.08); }
button:disabled { opacity: .45; cursor: not-allowed; }
button.secondary { background: #263451; color: #eef2ff; }
button.danger { background: #4a2734; color: #ffb7ca; }
button.compact { padding: 8px 12px; }
.header-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.auth-actions { margin-top: 10px; }
.field-label { display: grid; gap: 5px; color: #9aa8c4; font-size: .82rem; }
.field-label input { color: #eef2ff; font-size: 1rem; }
.button-link { display: inline-block; border-radius: 9px; border: 1px solid #40527e; padding: 9px 13px; background: #6c8cff; color: #071026; font-weight: 750; text-decoration: none; }
.button-link:hover { filter: brightness(1.08); }
.button-link.secondary { background: #263451; color: #eef2ff; }
.status { display: inline-block; padding: 6px 10px; border-radius: 999px; margin: 0; font-size: .85rem; }
.status.online { background: #173d31; color: #75efc1; }
.status.offline { background: #3e2429; color: #ff9cad; }
.game-layout { display: grid; grid-template-columns: 300px 1fr; gap: 18px; margin-top: 18px; }
.sidebar ul { padding-left: 20px; min-height: 70px; }
.match-result { min-height: 1.3em; color: #e7bd31; font-weight: 700; }
.arena { text-align: center; }
.board { width: min(100%, 620px); aspect-ratio: 1; margin: 16px auto; display: grid; grid-template-columns: repeat(5, 1fr); gap: 7px; }
.cell { position: relative; border-radius: 10px; background: #121a2b; border: 1px solid #25334e; display: grid; place-items: center; padding: 5px; overflow: hidden; font-size: clamp(.62rem, 1.4vw, .82rem); }
.cell.hidden-tile { background: repeating-linear-gradient(135deg, #111827, #111827 9px, #17213a 9px, #17213a 18px); color: #596985; }
.cell.revealed-tile { background: #342b1d; border-color: #8f713b; color: #f2d79c; }
.cell.resolved-tile { background: #16342c; border-color: #347361; color: #9aecd0; }
.event-label { max-width: 100%; line-height: 1.25; }
.pieces { position: absolute; right: 4px; bottom: 4px; display: flex; gap: 3px; }
.piece { width: 24px; height: 24px; border-radius: 50%; display: grid; place-items: center; background: #6c8cff; color: #071026; font-weight: 900; box-shadow: 0 2px 8px #0009; }
.piece.me { background: #6aefbd; }
.turn-bar { display: flex; align-items: center; justify-content: space-between; gap: 12px; border: 1px solid #40527e; background: #111827; border-radius: 10px; padding: 11px 14px; }
.turn-timer { display: flex; align-items: center; gap: 10px; }
#command-status { color: #8aa4ff; font-size: .78rem; }
#turn-countdown { min-width: 54px; color: #e7bd31; font: 800 1.15rem ui-monospace, monospace; }
.player-stats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 9px; margin-top: 12px; text-align: left; }
.player-stat { padding: 11px; border-radius: 10px; border: 1px solid #2b395b; background: #101726; }
.player-stat.active { border-color: #6aefbd; box-shadow: inset 0 0 0 1px #6aefbd44; }
.player-stat strong { display: block; margin-bottom: 5px; }
.player-stat p { margin: 3px 0; color: #aebbd4; font-size: .82rem; }
.stat-track { height: 6px; margin: 5px 0 8px; overflow: hidden; border-radius: 999px; background: #090c12; }
.stat-track span { display: block; height: 100%; transition: width .25s ease; }
.stat-track.health span { background: linear-gradient(90deg, #b63e58, #ef7e77); }
.stat-track.action span { background: linear-gradient(90deg, #5275db, #6aefbd); }
.event-message { min-height: 1.4em; color: #f2d79c; font-weight: 650; }
.map-legend { display: flex; justify-content: center; flex-wrap: wrap; gap: 14px; color: #9aa8c4; font-size: .76rem; }
.map-legend span:nth-child(1) { color: #596985; }
.map-legend span:nth-child(2) { color: #f2d79c; }
.map-legend span:nth-child(3) { color: #9aecd0; }
.combat-panel { margin: 18px auto 8px; max-width: 620px; text-align: left; border: 1px solid #743f48; background: linear-gradient(145deg, #291a22, #151923); border-radius: 14px; padding: 16px; }
.enemy-card { display: flex; align-items: start; justify-content: space-between; gap: 12px; }
.enemy-card h3 { margin: 3px 0 10px; font-size: 1.35rem; }
.health-track { height: 12px; border-radius: 999px; overflow: hidden; background: #090c12; border: 1px solid #4d2a31; }
.health-track span { display: block; height: 100%; background: linear-gradient(90deg, #a92f49, #ef6a6a); transition: width .25s ease; }
.combat-log { min-height: 2.8em; padding: 9px 11px; border-radius: 8px; color: #f3c1c9; background: #0d111a; }
.combat-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.combat-actions button { flex: 1; min-width: 130px; }
.combat-badge { display: inline-block; margin-left: 5px; padding: 2px 6px; border-radius: 999px; background: #693342; color: #ffd1d8; font-size: .7rem; }
.content-panel { margin-top: 1rem; padding: 1rem; border: 1px solid #2b395b; border-radius: 12px; background: rgba(12, 20, 32, .72); }
.content-panel h3 { margin-top: 0; }
.inventory-grid { display: grid; gap: .65rem; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }
.inventory-item { padding: .7rem; border: 1px solid #2b395b; border-radius: 9px; background: rgba(255,255,255,.035); }
.inventory-item p { margin: .25rem 0; }
.item-actions { display: flex; flex-wrap: wrap; gap: .5rem; }
.item-actions button, .inventory-item button { margin: .2rem .25rem .1rem 0; }
.transfer-gold { display: flex; gap: .5rem; margin-top: .75rem; }
.transfer-gold input { max-width: 100px; }
.rules-panel { text-align: left; }
.rules-panel summary { cursor: pointer; color: #8aa4ff; font-weight: 750; }
.rules-panel li { margin: .45rem 0; color: #b8c4db; }
.command-pending #game-panel button { pointer-events: none; opacity: .55; }
.character-panel { margin: 16px 0; }
.character-panel h3 { margin: 0 0 9px; font-size: .92rem; }
.character-list { display: grid; gap: 7px; }
.character-card { text-align: left; background: #17213a; color: #eef2ff; padding: 10px; }
.character-card small { display: block; margin-top: 3px; color: #9aa8c4; font-weight: 500; }
.character-card.selected { border-color: #6aefbd; background: #174035; }
.character-card.taken:not(.selected) { opacity: .38; }
.controls { margin: 18px 0 5px; }
.controls button { width: 48px; margin: 3px; font-size: 1.2rem; }
.hint { color: #9aa8c4; font-size: .88rem; }
.error { color: #ff9cad; min-height: 1.2em; }
.history-card { overflow: hidden; }
.history-toolbar { display: flex; align-items: end; justify-content: space-between; gap: 16px; margin-bottom: 16px; }
.history-toolbar h2 { margin-bottom: 5px; }
.history-toolbar p { margin: 0; color: #9aa8c4; }
.history-controls { display: flex; align-items: end; gap: 9px; flex-wrap: wrap; }
.history-controls label { display: grid; gap: 5px; color: #9aa8c4; font-size: .82rem; }
.history-status { color: #9aa8c4; min-height: 1.4em; }
.history-table-wrap { overflow-x: auto; border: 1px solid #2b395b; border-radius: 12px; }
.history-table { width: 100%; border-collapse: collapse; min-width: 720px; }
.history-table th, .history-table td { padding: 13px 15px; text-align: left; border-bottom: 1px solid #25334e; }
.history-table th { background: #111827; color: #9aa8c4; font-size: .78rem; letter-spacing: .06em; text-transform: uppercase; }
.history-table tbody tr:last-child td { border-bottom: 0; }
.history-table tbody tr:hover { background: #17213a; }
.winner { color: #75efc1; font-weight: 700; }
.room-code { color: #8aa4ff; font-weight: 800; letter-spacing: .08em; }
.room-id { color: #9fb1d8; font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: .84rem; }
.empty-state { padding: 42px 18px; text-align: center; color: #9aa8c4; border: 1px dashed #40527e; border-radius: 12px; }
[hidden] { display: none !important; }
@media (max-width: 760px) {
  main { width: min(100% - 18px, 1180px); margin: 14px auto 28px; }
  .card { padding: 14px; }
  .game-layout { grid-template-columns: 1fr; }
  .sidebar { order: 2; }
  .arena { order: 1; }
  .player-stats { grid-template-columns: 1fr; }
  .board { gap: 4px; }
  .piece { width: 20px; height: 20px; }
  .turn-bar { align-items: flex-start; }
  .history-toolbar { align-items: stretch; flex-direction: column; }
}

/* Phase 11 visual direction: hand-painted wasteland board game. */
:root {
  --ink: #17130f;
  --coal: #211d18;
  --coal-soft: #302921;
  --paper: #d9bd86;
  --paper-bright: #f0d9a7;
  --rust: #9d482c;
  --rust-bright: #d36a3e;
  --terminal: #6ca69b;
  --terminal-bright: #a8d6c5;
  --line: rgba(220, 186, 124, .28);
  color-scheme: dark;
  font-family: "Bahnschrift", "Microsoft YaHei UI", "Segoe UI", sans-serif;
  background: var(--ink);
  color: #f3e6ca;
}
body {
  position: relative;
  overflow-x: hidden;
  background:
    linear-gradient(180deg, rgba(17, 13, 9, .72), rgba(15, 12, 9, .96)),
    url("/assets/optimized/wasteland-map-backdrop.jpg") center / cover fixed;
}
body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  opacity: .28;
  pointer-events: none;
  background-image:
    repeating-linear-gradient(0deg, transparent 0 3px, rgba(255,255,255,.02) 3px 4px),
    radial-gradient(circle at 50% 20%, transparent 0, rgba(0,0,0,.62) 78%);
}
.app-shell { width: min(1440px, calc(100% - 36px)); margin: 28px auto 54px; }
.hero-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 28px;
  margin-bottom: 22px;
  padding: 15px 20px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--rust-bright);
  background: linear-gradient(105deg, rgba(29,24,19,.94), rgba(45,36,27,.78));
  box-shadow: 0 18px 55px rgba(0,0,0,.35);
}
.brand-lockup { display: flex; align-items: center; gap: 16px; }
.brand-mark {
  width: 62px;
  height: 62px;
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  border: 2px solid var(--rust-bright);
  color: var(--paper-bright);
  background: radial-gradient(circle, #5b2d20, #221914 72%);
  font: 900 2rem/1 Georgia, serif;
  transform: rotate(-2deg);
  box-shadow: inset 0 0 0 5px rgba(0,0,0,.2), 0 5px 16px #0008;
}
.hero-header h1 { margin: 0; font-family: Georgia, "STSong", serif; font-size: clamp(2rem, 4vw, 3.6rem); letter-spacing: .05em; text-shadow: 2px 3px 0 #0008; }
.brand-subtitle { margin: 4px 0 0; color: #bfae8c; font-size: .82rem; letter-spacing: .08em; }
.eyebrow, .panel-kicker { color: var(--rust-bright); letter-spacing: .2em; font-size: .66rem; font-weight: 800; }
.panel-kicker { display: block; margin: 0 0 5px; }
.card {
  border: 1px solid var(--line);
  border-radius: 3px;
  background:
    linear-gradient(135deg, rgba(255,255,255,.025), transparent 36%),
    rgba(30, 25, 20, .94);
  box-shadow: 0 22px 60px rgba(0,0,0,.42), inset 0 0 35px rgba(0,0,0,.16);
}
.card::selection { background: var(--rust); color: white; }
.game-layout { grid-template-columns: 286px minmax(0, 1fr); gap: 14px; align-items: start; }
.command-deck { position: sticky; top: 12px; border-top: 3px solid var(--rust); }
.command-deck h2 { font-size: 1.25rem; color: var(--paper-bright); }
.command-deck > p:not(.panel-kicker):not(.match-result) { margin: 7px 0; color: #baa98a; font-size: .82rem; }
.command-deck strong { color: #f1d29a; }
.arena { padding: 14px; background: rgba(22,18,14,.96); }
.turn-bar {
  border: 1px solid rgba(108,166,155,.48);
  border-left: 4px solid var(--terminal);
  border-radius: 2px;
  background: linear-gradient(90deg, rgba(32,56,52,.72), rgba(25,28,25,.9));
  text-align: left;
}
.turn-copy { display: grid; gap: 2px; }
.turn-copy strong { font-size: 1rem; color: #dce8d9; }
#command-status { color: var(--terminal-bright); }
#turn-countdown { color: #f5c66d; font-size: 1.4rem; }
.player-stat {
  position: relative;
  overflow: hidden;
  border-color: rgba(216,183,121,.25);
  border-radius: 2px;
  background: linear-gradient(110deg, rgba(62,50,38,.82), rgba(30,26,22,.9));
}
.player-stat::after { content: ""; position: absolute; top: 0; right: 0; width: 34px; height: 3px; background: var(--rust); }
.player-stat.active { border-color: var(--terminal); box-shadow: inset 3px 0 0 var(--terminal); }
.player-stat p { color: #bfaf91; }
.stat-track { height: 5px; background: #100d0a; border-radius: 0; }
.stat-track.health span { background: linear-gradient(90deg, #8d2f2a, #d86542); }
.stat-track.action span { background: linear-gradient(90deg, #486b67, #8cc6ae); }
.map-stage {
  position: relative;
  margin-top: 12px;
  padding: 15px 18px 13px;
  overflow: hidden;
  border: 1px solid #705a39;
  background:
    linear-gradient(rgba(22,17,11,.08), rgba(22,17,11,.18)),
    url("/assets/optimized/wasteland-map-backdrop.jpg") center / cover;
  box-shadow: inset 0 0 75px rgba(20,12,6,.72), 0 12px 30px #0007;
}
.map-stage::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(90deg, transparent 0 5px, rgba(60,35,18,.03) 5px 6px);
}
.map-heading { position: relative; z-index: 1; display: flex; align-items: end; justify-content: space-between; text-align: left; color: #39291b; text-shadow: 0 1px rgba(255,235,185,.5); }
.map-heading h2 { margin: 2px 0 0; font: 900 1.45rem Georgia, "STSong", serif; letter-spacing: .09em; }
.map-heading .panel-kicker { color: #763a27; }
.map-coordinate { font: 700 .68rem ui-monospace, Consolas, monospace; letter-spacing: .08em; opacity: .72; }
.map-frame { position: relative; z-index: 1; width: min(100%, 650px); margin: 4px auto 0; padding: 16px; }
.map-frame::before {
  content: "";
  position: absolute;
  inset: 5px;
  border: 1px solid rgba(72,47,28,.62);
  box-shadow: 0 0 0 4px rgba(214,173,103,.12), inset 0 0 28px rgba(58,32,17,.22);
  pointer-events: none;
}
.map-corner { position: absolute; width: 21px; height: 21px; border-color: #653c26; opacity: .8; }
.map-corner.top-left { left: 3px; top: 3px; border-left: 3px solid; border-top: 3px solid; }
.map-corner.top-right { right: 3px; top: 3px; border-right: 3px solid; border-top: 3px solid; }
.map-corner.bottom-left { left: 3px; bottom: 3px; border-left: 3px solid; border-bottom: 3px solid; }
.map-corner.bottom-right { right: 3px; bottom: 3px; border-right: 3px solid; border-bottom: 3px solid; }
.board { width: 100%; margin: 0; gap: 6px; }
.cell {
  border-radius: 2px;
  border: 1px solid rgba(42,29,19,.78);
  color: #ead9b7;
  font-weight: 760;
  text-shadow: 0 1px 2px #000;
  box-shadow: 0 3px 8px rgba(33,18,9,.4), inset 0 0 18px rgba(0,0,0,.22);
  transition: transform .15s ease, border-color .15s ease, filter .15s ease;
}
.cell:hover { z-index: 2; transform: translateY(-2px); border-color: #d6aa67; filter: brightness(1.12); }
.cell.hidden-tile { background: repeating-linear-gradient(145deg, rgba(34,31,25,.95) 0 9px, rgba(46,40,31,.95) 9px 18px); color: #887a61; }
.cell.hidden-tile::before { content: "?"; position: absolute; color: rgba(222,194,140,.16); font: 900 clamp(1.8rem, 5vw, 3.6rem) Georgia, serif; }
.cell.revealed-tile { background: rgba(110,66,36,.88); border-color: #bd7d46; color: #ffe1a9; }
.cell.resolved-tile { background: rgba(39,74,62,.9); border-color: #729d86; color: #c5e5cb; }
.event-label { position: relative; z-index: 1; padding: 3px; }
.piece { border: 2px solid #261a11; border-radius: 50% 50% 44% 44%; background: #d0663c; color: #fff1d2; box-shadow: 0 3px 8px #000b; }
.piece.me { background: #75a99a; }
.map-legend { position: relative; z-index: 1; gap: 18px; color: #483622; font-weight: 800; text-shadow: 0 1px rgba(255,235,185,.5); }
.map-legend span { display: inline-flex; align-items: center; gap: 6px; color: inherit !important; }
.legend-swatch { width: 12px; height: 12px; display: inline-block; border: 1px solid #493623; box-shadow: inset 0 0 5px #0005; }
.legend-swatch.unknown { background: #39342a; }
.legend-swatch.revealed { background: #8b542f; }
.legend-swatch.resolved { background: #315f51; }
.event-message { margin-bottom: 8px; color: #e9b96d; font-family: Georgia, "STSong", serif; font-size: 1.05rem; }
input, select { border-color: #65563f; border-radius: 2px; background: #17130f; color: #f1e2c3; }
button, .button-link {
  border: 1px solid #bd7048;
  border-radius: 2px;
  background: linear-gradient(#ba5c37, #833922);
  color: #fff1d2;
  text-transform: none;
  box-shadow: inset 0 1px rgba(255,255,255,.13), 0 3px 8px #0005;
}
button:hover, .button-link:hover { filter: brightness(1.16); }
button.secondary, .button-link.secondary { border-color: #685d49; background: linear-gradient(#453d32, #2e2922); color: #dfcfaf; }
button.danger { border-color: #71392f; background: #4d2721; color: #e9b6a2; }
.character-card { border-color: #61533e; border-radius: 2px; background: #302920; color: #ebdbba; }
.character-card small { color: #b1a184; }
.character-card.selected { border-color: var(--terminal); background: #29433c; box-shadow: inset 3px 0 var(--terminal); }
.content-panel { border-color: rgba(209,174,111,.24); border-radius: 2px; background: rgba(28,23,18,.86); text-align: left; }
.content-panel h3 { color: #e4c48b; font-family: Georgia, "STSong", serif; letter-spacing: .05em; }
.rules-panel summary { color: var(--terminal-bright); }
.inventory-item { border-radius: 2px; border-color: #5a4d3a; background: #2c261e; }
.combat-panel { border-radius: 2px; border-color: #814432; background: linear-gradient(145deg, #48251f, #1b1714); }
.status { border: 1px solid currentColor; border-radius: 2px; background: transparent !important; }
.status.online { color: var(--terminal-bright); }
.status.offline { color: #e99978; }
.hint, .field-label, .history-toolbar p, .history-controls label, .history-status { color: #ad9d81; }
.error { color: #f09a7b; }
@media (max-width: 900px) {
  .game-layout { grid-template-columns: 240px minmax(0, 1fr); }
  .map-stage { padding-inline: 8px; }
}
@media (max-width: 760px) {
  .app-shell { width: min(100% - 14px, 1180px); margin-top: 7px; }
  .hero-header { align-items: flex-start; padding: 12px; }
  .brand-mark { width: 46px; height: 46px; font-size: 1.4rem; }
  .brand-subtitle { display: none; }
  .hero-header .header-actions { justify-content: flex-end; }
  .game-layout { grid-template-columns: 1fr; }
  .command-deck { position: static; }
  .map-heading { align-items: start; }
  .map-coordinate { display: none; }
  .map-frame { padding: 9px; }
  .map-stage { padding: 10px 5px 8px; }
  .board { gap: 3px; }
  .cell { padding: 2px; }
  .map-legend { gap: 10px; }
}
@media (max-width: 520px) {
  .hero-header { flex-direction: column; }
  .hero-header .header-actions { width: auto; max-width: 100%; align-self: stretch; justify-content: flex-start; }
  .hero-header .header-actions > * { flex: 0 1 auto; }
  #identity-panel { overflow: hidden; }
  #identity-panel .row { display: grid; grid-template-columns: minmax(0, 1fr); width: 100%; }
  #identity-panel .field-label, #identity-panel input { width: 100%; min-width: 0; }
  #identity-panel .auth-actions { grid-template-columns: minmax(0, 1fr); }
  #identity-panel .auth-actions button { padding-inline: 7px; }
  .turn-bar { align-items: flex-start; }
  .map-legend { font-size: .65rem; }
}

/* Phase 12: dedicated character lobby and full-width expedition map. */
.session-shell { margin-top: 16px; }
.session-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 12px;
  padding: 10px 12px 10px 16px;
  border: 1px solid var(--line);
  border-left: 4px solid var(--terminal);
  background: rgba(25, 22, 18, .94);
  box-shadow: 0 10px 28px #0006;
}
.session-bar > div:first-child { margin-right: auto; }
.session-bar > div:first-child strong { color: var(--paper-bright); letter-spacing: .08em; }
.session-state { display: flex; align-items: center; gap: 12px; color: #b7a789; font-size: .78rem; }
.session-state span { padding-right: 12px; border-right: 1px solid var(--line); }
.session-bar .match-result { min-height: 0; margin: 0; }
.visually-hidden { position: absolute !important; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
.lobby-stage { padding: clamp(16px, 2.2vw, 28px); border-top: 3px solid var(--rust); }
.lobby-heading { display: flex; align-items: end; justify-content: space-between; gap: 32px; margin-bottom: 14px; text-align: left; }
.lobby-heading h2 { margin: 2px 0 0; color: var(--paper-bright); font: 900 clamp(1.6rem, 3vw, 2.5rem) Georgia, "STSong", serif; letter-spacing: .06em; }
.lobby-heading > p { max-width: 600px; margin: 0; color: #b6a586; font-size: .88rem; line-height: 1.7; }
.player-seats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; margin: 0 0 18px; padding: 0; list-style: none; }
.player-seats li { position: relative; padding: 10px 13px 10px 35px; overflow: hidden; border: 1px solid rgba(108,166,155,.32); background: linear-gradient(90deg, rgba(37,63,58,.72), rgba(30,27,22,.65)); color: #d9d6c0; font-size: .82rem; }
.player-seats li::before { content: ""; position: absolute; left: 13px; top: 50%; width: 8px; height: 8px; border-radius: 50%; background: var(--terminal); box-shadow: 0 0 10px var(--terminal); transform: translateY(-50%); }
.character-panel { margin: 0; }
.character-list { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; }
.character-card {
  position: relative;
  display: flex;
  min-width: 0;
  min-height: 590px;
  padding: 0;
  overflow: hidden;
  border: 1px solid #65513a;
  background: #17130f;
  color: #eadcbd;
  text-align: left;
  box-shadow: 0 12px 24px #0008;
  isolation: isolate;
}
.character-card:hover:not(:disabled) { filter: brightness(1.08); transform: translateY(-3px); border-color: var(--rust-bright); }
.character-card::after { content: ""; position: absolute; inset: 0; z-index: 2; pointer-events: none; box-shadow: inset 0 0 0 1px rgba(255,225,171,.07), inset 0 -90px 90px rgba(0,0,0,.35); }
.character-art { position: absolute; inset: 0 0 245px; z-index: 0; overflow: hidden; background: radial-gradient(circle at 50% 35%, #5b3a25, #100d0a 72%); }
.character-art img { width: 100%; height: 100%; object-fit: cover; object-position: 50% 16%; filter: saturate(.83) contrast(1.04); transition: transform .3s ease, filter .3s ease; }
.character-card:hover:not(:disabled) .character-art img { transform: scale(1.025); filter: saturate(1) contrast(1.04); }
.character-copy { position: relative; z-index: 3; display: flex; flex-direction: column; align-self: flex-end; width: 100%; min-height: 285px; padding: 17px 16px 15px; background: linear-gradient(180deg, transparent, rgba(18,14,10,.95) 18%, #17130f 36%); }
.character-title { display: flex; align-items: start; justify-content: space-between; gap: 9px; }
.character-title > span { display: grid; }
.character-title small { color: var(--rust-bright); font-size: .6rem; letter-spacing: .13em; }
.character-title strong { margin-top: 2px; color: #fae9c5; font: 900 1.45rem Georgia, "STSong", serif; letter-spacing: .08em; }
.character-title b { padding: 4px 7px; border: 1px solid #9a5b39; color: #e8ae78; font-size: .68rem; font-weight: 700; white-space: nowrap; }
.character-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; margin: 10px 0; }
.character-stats i { display: flex; align-items: baseline; justify-content: center; gap: 3px; padding: 6px 3px; border-top: 1px solid #4c4030; border-bottom: 1px solid #4c4030; color: #a99a80; font-size: .66rem; font-style: normal; }
.character-stats strong { color: #f0c675; font: 900 1.05rem ui-monospace, monospace; }
.character-bio { color: #c7b99d; font-size: .73rem; line-height: 1.55; }
.character-feature { display: block; margin-top: 8px; color: #a9c9bb; font-size: .69rem; line-height: 1.45; }
.character-feature em { display: block; margin-bottom: 2px; color: var(--terminal-bright); font-size: .58rem; font-style: normal; letter-spacing: .13em; }
.character-tool { margin-top: auto; padding-top: 8px; color: #d69a68; font-size: .69rem; font-weight: 750; }
.character-card.selected { border-color: var(--terminal-bright); background: #17241f; box-shadow: 0 0 0 2px rgba(108,166,155,.25), 0 14px 32px #0009; }
.character-card.selected .character-title b { border-color: var(--terminal); color: var(--terminal-bright); }
.character-card.taken:not(.selected) { opacity: .48; filter: grayscale(.75); }
.lobby-footer { display: flex; align-items: center; justify-content: space-between; gap: 20px; margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); }
.lobby-footer p { margin: 0; }
.ready-cta { min-width: 250px; padding-block: 14px; font-size: 1rem; letter-spacing: .04em; }
.map-console { width: 100%; }
@media (max-width: 1160px) {
  .character-list { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .character-card { min-height: 560px; }
}
@media (max-width: 760px) {
  .session-bar { flex-wrap: wrap; }
  .session-bar > div:first-child { width: calc(100% - 110px); }
  .session-state { order: 3; width: 100%; }
  .session-bar .match-result { order: 4; width: 100%; }
  .lobby-heading { display: block; }
  .lobby-heading > p { margin-top: 8px; }
  .player-seats { grid-template-columns: 1fr; }
  .character-card { min-height: 540px; }
  .lobby-footer { align-items: stretch; flex-direction: column; }
  .ready-cta { width: 100%; min-width: 0; }
}
@media (max-width: 560px) {
  .character-list { grid-template-columns: 1fr; }
  .character-card { min-height: 585px; }
  .character-art { bottom: 255px; }
  .session-bar > div:first-child { width: 100%; }
  .session-bar .compact { flex: 1; }
}

/* Phase 13: event scenes replace the map while an encounter is active. */
.event-scene {
  position: relative;
  min-height: 640px;
  margin-top: 12px;
  overflow: hidden;
  border: 1px solid #745638;
  background-color: #18120d;
  background-position: center;
  background-size: cover;
  box-shadow: inset 0 0 90px #0008, 0 18px 42px #0008;
  text-align: left;
}
.event-scene::before {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(180deg, rgba(0,0,0,.12), transparent 55%, rgba(0,0,0,.38));
}
.event-scene-copy {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  width: min(52%, 650px);
  min-height: 640px;
  padding: clamp(25px, 4vw, 55px);
}
.event-scene-copy > .panel-kicker { color: #df7448; }
.event-scene-copy > h2 {
  margin: 4px 0 12px;
  color: #f5dfb6;
  font: 900 clamp(2.2rem, 5vw, 4.6rem)/.98 Georgia, "STSong", serif;
  letter-spacing: .08em;
  text-shadow: 2px 3px 0 #000a;
}
.event-scene-story { max-width: 570px; margin: 0; color: #d0c0a2; font: 1rem/1.85 Georgia, "STSong", serif; text-shadow: 0 2px 3px #000; }
.event-scene-status { margin: 16px 0 0; padding: 10px 12px; border-left: 3px solid var(--terminal); background: rgba(16,26,24,.78); color: #b9d6c9; font-size: .8rem; line-height: 1.55; }
.scene-panel { margin-top: 16px; border-color: rgba(222,178,104,.34); background: rgba(18,14,11,.9); box-shadow: 0 10px 28px #0008; backdrop-filter: blur(5px); }
.scene-panel .inventory-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.scene-panel .inventory-item { background: rgba(49,39,29,.9); }
.event-continue { align-self: flex-start; margin-top: 18px; padding: 13px 20px; }
.event-scene .combat-panel { max-width: none; margin: 16px 0 0; }
@media (max-width: 1000px) {
  .event-scene-copy { width: min(64%, 650px); }
}
@media (max-width: 760px) {
  .event-scene { min-height: 590px; background-position: 68% center; }
  .event-scene-copy { width: 100%; min-height: 590px; padding: 25px 18px; background: linear-gradient(90deg, rgba(14,11,8,.96), rgba(14,11,8,.76) 65%, rgba(14,11,8,.28)); }
  .event-scene-story { max-width: 85%; font-size: .9rem; }
  .scene-panel { margin-top: 12px; }
}
@media (max-width: 520px) {
  .event-scene { margin-inline: -8px; border-left: 0; border-right: 0; }
  .event-scene-copy > h2 { font-size: 2.45rem; }
  .event-scene-story { max-width: 100%; }
  .scene-panel .inventory-grid { grid-template-columns: 1fr; }
  .scene-panel .item-actions, .scene-panel .combat-actions { display: grid; grid-template-columns: 1fr; }
  .scene-panel button { width: 100%; }
}

/* Phase 14: reusable character/enemy layers, low-cost combat motion, and scene transitions. */
.sound-toggle[aria-pressed="true"] { border-color: var(--terminal); color: var(--terminal-bright); }
.character-art {
  background:
    radial-gradient(circle at 50% 58%, rgba(132,84,45,.58), transparent 43%),
    linear-gradient(160deg, #49321f, #17110d 72%);
}
.character-art img {
  object-fit: contain;
  object-position: center bottom;
  filter: saturate(.82) contrast(1.04) drop-shadow(0 12px 10px rgba(0,0,0,.66));
}
.event-scene.scene-entering { animation: scene-fade-in .48s ease-out both; }
.event-scene.scene-entering::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 8;
  pointer-events: none;
  background:
    radial-gradient(ellipse at 70% 55%, rgba(190,121,61,.24), transparent 42%),
    linear-gradient(100deg, #1a120d 0%, rgba(93,55,31,.94) 42%, transparent 70%);
  animation: sand-wipe .58s ease-out both;
}
.combat-scene .event-scene-copy {
  z-index: 3;
  width: min(48%, 620px);
  background: linear-gradient(90deg, rgba(12,10,8,.96), rgba(16,13,10,.82) 82%, transparent);
}
.battle-stage {
  position: absolute;
  inset: 0;
  z-index: 2;
  overflow: hidden;
  pointer-events: none;
}
.battle-ground-shadow {
  position: absolute;
  right: 2%;
  bottom: 1.5%;
  width: 51%;
  height: 10%;
  border-radius: 50%;
  background: radial-gradient(ellipse, rgba(0,0,0,.72), transparent 68%);
  filter: blur(6px);
}
.battle-combatant { --fighter-scale: 1; position: absolute; margin: 0; transform-origin: 50% 88%; }
.battle-combatant img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 15px 12px rgba(0,0,0,.75)); }
.battle-combatant figcaption, .battle-enemy span {
  position: absolute;
  left: 50%;
  bottom: 0;
  padding: 3px 9px;
  border: 1px solid rgba(226,184,112,.42);
  background: rgba(18,14,11,.82);
  color: #e8cf9f;
  font-size: .66rem;
  white-space: nowrap;
  transform: translateX(-50%);
}
.battle-party { position: absolute; left: 47%; bottom: 3%; width: 25%; height: 64%; }
.battle-player { inset: 0 auto 0 0; z-index: 1; width: 78%; height: 100%; }
.battle-player.player-2 { --fighter-scale: .86; left: 32%; top: 5%; z-index: 0; transform: scale(var(--fighter-scale)); filter: brightness(.82); }
.battle-enemy { right: 2%; bottom: 2%; width: 34%; height: 78%; }
.combat-scene:not([hidden]) .battle-combatant { animation: combat-idle 3.2s ease-in-out infinite; }
.battle-ready .battle-player { animation: fighter-materialize .48s ease-out both; }
.battle-ready .battle-enemy { animation: fighter-materialize .55s ease-out both; }
.player-strike .battle-player { animation: player-strike .42s ease-in-out; }
.enemy-hit .battle-enemy { animation: target-hit .3s ease-out; }
.enemy-strike .battle-enemy { animation: enemy-strike .44s ease-in-out; }
.party-hit .battle-player { animation: target-hit .3s .18s ease-out; }
.player-strike.enemy-strike .battle-enemy { animation: target-hit .24s ease-out, enemy-strike .44s .22s ease-in-out; }
.player-strike.party-hit .battle-player { animation: player-strike .42s ease-in-out, target-hit .3s .46s ease-out; }

@keyframes scene-fade-in { from { opacity: .35; transform: scale(1.012); } to { opacity: 1; transform: none; } }
@keyframes sand-wipe { 0% { opacity: 1; transform: translateX(0); } 100% { opacity: 0; transform: translateX(105%); } }
@keyframes combat-idle { 0%, 100% { transform: translateY(0) scale(var(--fighter-scale)); } 50% { transform: translateY(-4px) scale(var(--fighter-scale)); } }
@keyframes fighter-materialize { from { opacity: 0; transform: translateY(12px) scale(calc(var(--fighter-scale) * .96)); filter: brightness(.72); } to { opacity: 1; transform: translateY(0) scale(var(--fighter-scale)); filter: none; } }
@keyframes player-strike { 0%, 100% { transform: translateX(0) scale(var(--fighter-scale)); } 38% { transform: translateX(54px) rotate(2deg) scale(var(--fighter-scale)); } 62% { transform: translateX(46px) scale(var(--fighter-scale)); } }
@keyframes enemy-strike { 0%, 100% { transform: translateX(0) scale(var(--fighter-scale)); } 42% { transform: translateX(-62px) rotate(-2deg) scale(var(--fighter-scale)); } }
@keyframes target-hit { 0%, 100% { transform: translateX(0) scale(var(--fighter-scale)); filter: none; } 25% { transform: translateX(-8px) scale(var(--fighter-scale)); filter: brightness(2) sepia(1) saturate(4); } 50% { transform: translateX(7px) scale(var(--fighter-scale)); } 75% { transform: translateX(-4px) scale(var(--fighter-scale)); } }

@media (max-width: 900px) {
  .battle-party { left: 46%; width: 28%; }
  .battle-enemy { width: 38%; }
}
@media (max-width: 760px) {
  .combat-scene { background-position: center; }
  .combat-scene .battle-stage { position: relative; height: 300px; background: linear-gradient(180deg, transparent, rgba(0,0,0,.18)); }
  .combat-scene .event-scene-copy { width: 100%; min-height: auto; background: rgba(14,11,8,.9); }
  .battle-party { left: 5%; bottom: 1%; width: 38%; height: 86%; }
  .battle-enemy { right: 4%; bottom: 1%; width: 47%; height: 94%; }
  .battle-ground-shadow { width: 92%; right: 4%; }
}
@media (max-width: 520px) {
  .combat-scene .battle-stage { height: 235px; }
  .battle-combatant figcaption, .battle-enemy span { display: none; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .001ms !important; animation-iteration-count: 1 !important; transition-duration: .001ms !important; }
}

/* Phase 20: actor-specific cutout animation. Animate the image inside the idle rig. */
.battle-turn-banner { position: absolute; z-index: 8; top: 14px; right: 5%; width: 44%; padding: 10px 16px; text-align: center; color: #ffe0a4; border-block: 1px solid #b89152; background: linear-gradient(90deg, transparent, #211b15ed 20%, #211b15ed 80%, transparent); letter-spacing: .14em; pointer-events: none; }
.battle-turn-banner.enemy-turn { color: #ffb29d; border-color: #bb6547; }
.presentation-running [data-combat-action], .presentation-running [data-use-item], .presentation-running [data-move], .presentation-running .item-card-actions { pointer-events: none; opacity: .6; }
.battle-combatant img { transform-origin: 50% 80%; }
.battle-combatant.motion-cleave img { animation: motion-cleave .7s both; }
.battle-combatant.motion-pick img { animation: motion-pick .7s both; }
.battle-combatant.motion-dash img { animation: motion-dash .7s both; }
.battle-combatant.motion-thrust img { animation: motion-thrust .7s both; }
.battle-combatant.motion-claw img { animation: motion-claw .7s both; }
.battle-combatant.motion-crush img, .battle-combatant.motion-slam img { animation: motion-slam .75s both; }
.battle-combatant.motion-hex img, .battle-combatant.motion-ritual img { animation: motion-ritual .75s both; }
.battle-combatant.motion-weaken img, .battle-combatant.motion-steal img { animation: motion-drain .75s both; }
.battle-combatant.motion-shockwave img { animation: motion-slam .75s both; }
.battle-combatant.motion-hurt img { animation: motion-hurt .7s both; }
.battle-combatant.motion-afflicted img, .battle-combatant.motion-poison img { animation: motion-afflicted .75s both; }
.motion-heal { animation: motion-heal .75s both !important; }
.motion-empower, .motion-guard { animation: motion-empower .75s both !important; }
.motion-travel { animation: motion-travel .75s both !important; }
.motion-quake { animation: motion-quake .75s both; }
.motion-shockwave::after, .motion-ritual::after, .motion-weaken::after { content: ""; position: absolute; inset: 20% 4%; border: 5px solid #cc8852; border-radius: 50%; box-shadow: 0 0 24px #db815b; animation: effect-ring .75s both; pointer-events: none; }
.motion-ritual::after { border-color: #b989e5; box-shadow: 0 0 24px #9263bd; }
.motion-weaken::after { border-color: #8ca669; box-shadow: 0 0 24px #68955c; }
.motion-hex::after, .motion-steal::after { content: ""; position: absolute; left: -35%; top: 40%; width: 60%; height: 16px; background: linear-gradient(90deg, transparent, #cc9aff, #faf0ff); border-radius: 100%; box-shadow: 0 0 25px #8e5cbd; animation: effect-bolt .75s both; pointer-events: none; }
.motion-steal::after { animation-direction: reverse; background: linear-gradient(90deg, transparent, #8ad4c6, #efffed); }
@keyframes effect-ring { 0%,20% { opacity: 0; transform: scale(.2); } 45% { opacity: 1; } 100% { opacity: 0; transform: scale(2.3); } }
@keyframes effect-bolt { 0%,20% { opacity: 0; transform: translateX(40px) scaleX(.2); } 45% { opacity: 1; } 90%,100% { opacity: 0; transform: translateX(-80px) scaleX(1.5); } }
.action-callout { position: absolute; z-index: 15; top: 19%; right: 5%; padding: 8px 18px; border-left: 3px solid #e7b15c; color: #fff2cf; background: #15100cdd; font-weight: bold; font-size: 1.05rem; pointer-events: none; animation: action-callout .78s both; }
.action-callout.cue-heal { color: #aaf0c8; border-color: #73c9a0; }
.action-callout.cue-poison, .action-callout.cue-weaken, .action-callout.cue-steal { color: #c7b2f2; border-color: #a88acb; }
.attack-stroke { pointer-events: none; position: absolute; z-index: 7; top: 10%; right: -12%; width: 10px; height: 68%; background: linear-gradient(#fffce8, #e5bc72 70%, transparent); box-shadow: 0 0 16px #f8db91; transform-origin: 50% 90%; animation: sword-down .7s both; }
.stroke-pick { width: 55%; height: 8px; top: 35%; border-top: 4px solid #e5dabf; animation: pick-arc .7s both; }
.stroke-cleave { width: 23px; clip-path: polygon(50% 0, 74% 14%, 65% 72%, 100% 74%, 100% 79%, 60% 79%, 60% 96%, 40% 96%, 40% 79%, 0 79%, 0 74%, 35% 72%, 26% 14%); }
.stroke-dash, .stroke-thrust { width: 70%; height: 4px; top: 45%; animation: thrust-trail .7s both; }
.stroke-claw, .stroke-crush, .stroke-slam { left: -12%; right: auto; background: #e6a087; box-shadow: 0 0 18px #c35836; animation: claw-arc .7s both; }
.item-target-panel { display: flex; align-items: center; justify-content: space-between; gap: 18px; padding: 14px; border: 1px solid #9fcab5; background: #182b24; color: #d9fbe9; margin-bottom: 12px; }
.item-target-panel[hidden] { display: none; }
.choosing-target .cell { opacity: .35; }
.choosing-target .cell.valid-item-target { opacity: 1; box-shadow: inset 0 0 0 3px #a2e7c1, 0 0 16px #6dbe9b80; filter: none; }
.target-tile-button { position: absolute; inset: 0; z-index: 7; width: 100%; height: 100%; padding: 0; border: 0; border-radius: inherit; background: transparent; cursor: crosshair; }
.target-tile-button:hover, .target-tile-button:focus-visible { background: #91e8b933; outline: 3px solid #eddda5; outline-offset: -4px; }
@keyframes motion-cleave { 0%,100% { transform: none; } 25% { transform: translate(-10px,-18px) rotate(-14deg); } 50% { transform: translate(34px,10px) rotate(14deg); } }
@keyframes motion-pick { 0%,100% { transform: none; } 28% { transform: rotate(-20deg) translateY(-12px); } 52% { transform: rotate(18deg) translateX(30px); } }
@keyframes motion-dash { 0%,100% { transform: none; } 20% { transform: translateX(-14px) scale(.96); } 45%,55% { transform: translateX(85px) skewX(-8deg); } }
@keyframes motion-thrust { 0%,100% { transform: none; } 25% { transform: translateX(-8px); } 48% { transform: translateX(48px) rotate(4deg); } }
@keyframes motion-claw { 0%,100% { transform: none; } 25% { transform: rotate(9deg); } 50% { transform: translateX(-55px) rotate(-8deg); } }
@keyframes motion-slam { 0%,100% { transform: none; } 25% { transform: translateY(-24px) scale(1.06); } 48% { transform: translate(-30px,12px) scale(1.04,.94); } }
@keyframes motion-ritual { 0%,100% { transform: none; filter: none; } 40%,60% { transform: translateY(-16px) scale(1.05); filter: drop-shadow(0 0 28px #b873dc) brightness(1.4); } }
@keyframes motion-drain { 0%,100% { filter: none; transform: none; } 45% { filter: drop-shadow(-25px 0 22px #945caa); transform: translateX(-20px) rotate(-5deg); } }
@keyframes motion-hurt { 0%,30%,100% { transform: none; filter: none; } 43% { transform: translateX(12px) rotate(5deg); filter: brightness(2) sepia(.7); } 57% { transform: translateX(-7px); filter: sepia(1) saturate(3); } 70% { transform: translateX(4px); } }
@keyframes motion-afflicted { 0%,100% { filter: none; } 45% { filter: sepia(.8) hue-rotate(65deg) drop-shadow(0 0 20px #95ce68); } }
@keyframes motion-heal { 0%,100% { filter: none; } 50% { filter: brightness(1.25) drop-shadow(0 0 20px #6ef4bc); } }
@keyframes motion-empower { 0%,100% { filter: none; } 50% { filter: brightness(1.3) drop-shadow(0 0 20px #e9c16e); } }
@keyframes motion-travel { 0%,100% { filter: none; } 50% { filter: drop-shadow(-18px 3px 10px #d9c489); } }
@keyframes motion-quake { 0%,32%,100% { transform: none; } 44%,60% { transform: translate(5px,3px); } 52%,68% { transform: translate(-5px,-2px); } }
@keyframes sword-down { 0%,15%,100% { opacity: 0; transform: rotate(-85deg); } 32% { opacity: 1; transform: rotate(-65deg); } 60% { opacity: .8; transform: rotate(95deg); } 85% { opacity: 0; transform: rotate(120deg); } }
@keyframes pick-arc { 0%,100% { opacity: 0; transform: rotate(-80deg); } 32% { opacity: 1; transform: rotate(-60deg); } 65% { opacity: 0; transform: rotate(100deg); } }
@keyframes thrust-trail { 0%,100% { opacity: 0; transform: scaleX(.2); } 40% { opacity: 1; transform: translateX(30px) scaleX(1.5); } 70% { opacity: 0; transform: translateX(60px) scaleX(1); } }
@keyframes claw-arc { 0%,100% { opacity: 0; transform: rotate(80deg); } 40% { opacity: 1; transform: rotate(30deg); } 70% { opacity: 0; transform: rotate(-80deg); } }
@keyframes action-callout { 0% { opacity: 0; transform: translateY(8px); } 15%,80% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-6px); } }

/* Phase 15: authoritative map movement, discovery, and turn-change feedback. */
.turn-bar.turn-changed { animation: turn-signal .62s ease-out; }
.cell.tile-revealed {
  transform-origin: center;
  animation: tile-discovery .58s cubic-bezier(.2,.75,.2,1) both;
}
.piece.piece-moving {
  position: relative;
  z-index: 4;
  animation: piece-travel .48s cubic-bezier(.22,.8,.25,1) both;
}
@keyframes turn-signal {
  0% { box-shadow: inset 0 0 0 var(--terminal), 0 0 0 rgba(108,166,155,0); }
  36% { box-shadow: inset 8px 0 0 var(--terminal), 0 0 24px rgba(108,166,155,.45); }
  100% { box-shadow: inset 0 0 0 var(--terminal), 0 0 0 rgba(108,166,155,0); }
}
@keyframes tile-discovery {
  0% { opacity: .32; filter: brightness(.35) saturate(.2); transform: scale(.84) rotate(-1deg); }
  55% { opacity: 1; filter: brightness(1.35) saturate(1.15); transform: scale(1.035); }
  100% { filter: none; transform: none; }
}
@keyframes piece-travel {
  from { opacity: .62; transform: translate(var(--move-x), var(--move-y)) scale(.86); }
  72% { opacity: 1; transform: translate(0, 0) scale(1.12); }
  to { transform: none; }
}

/* Phase 16: illustrated event tiles and reusable item catalogue cards. */
.cell.event-image-tile {
  background-image: linear-gradient(180deg, rgba(14,11,8,.08), rgba(12,9,7,.7)), var(--tile-image);
  background-size: cover;
  background-position: center;
}
.cell.event-image-tile.revealed-tile { border-color: #bd7d46; }
.cell.event-image-tile.resolved-tile { border-color: #729d86; filter: saturate(.8); }
.cell.event-image-tile .event-label {
  align-self: end;
  width: calc(100% - 8px);
  margin: 4px;
  padding: 4px 5px;
  border: 1px solid rgba(225,190,127,.28);
  background: rgba(17,13,10,.78);
  color: #f2ddb5;
  font-size: clamp(.6rem, 1.25vw, .78rem);
  text-align: center;
  text-shadow: 0 1px 2px #000;
}
.inventory-group { min-width: 0; }
.inventory-group h4 { margin: 0 0 .55rem; color: #d8bd8e; }
.inventory-group .item-card + .item-card { margin-top: .55rem; }
.item-card { display: grid; grid-template-columns: 72px minmax(0, 1fr); gap: .65rem; min-height: 92px; }
.item-model {
  width: 72px;
  height: 72px;
  align-self: start;
  object-fit: contain;
  border: 1px solid rgba(204,161,93,.32);
  background: radial-gradient(circle, rgba(158,103,50,.2), rgba(13,10,8,.48));
  filter: drop-shadow(0 5px 4px rgba(0,0,0,.5));
}
.item-model-missing { display: grid; place-items: center; color: #876f4b; font: 800 1.8rem Georgia, serif; }
.item-card-copy { min-width: 0; }
.item-card-copy strong { color: #f0d7aa; }
.item-card .item-meta { color: #c49c65; font-size: .72rem; }
.item-card .item-description { color: #bfae90; font-size: .76rem; line-height: 1.42; }
.item-card-actions { display: flex; flex-wrap: wrap; gap: .25rem; margin-top: .35rem; }
.item-card-actions button { padding: 7px 9px; font-size: .76rem; }
.sold-badge { display: inline-block; padding: 5px 8px; border: 1px solid #725f45; color: #988568; }
#pending-loot-message .item-card { max-width: 520px; margin-bottom: .7rem; }
@media (max-width: 520px) {
  .item-card { grid-template-columns: 58px minmax(0, 1fr); }
  .item-model { width: 58px; height: 58px; }
}

/* Phase 17: desktop experience feedback, tutorial, audio mixer, and results. */
.audio-control {
  display: grid;
  grid-template-columns: auto auto 90px;
  align-items: center;
  gap: 7px;
  padding: 4px 8px 4px 4px;
  border: 1px solid rgba(195,157,95,.24);
  background: rgba(18,15,12,.56);
}
.audio-control label { color: #a99779; font-size: .68rem; }
.audio-control input[type="range"] {
  width: 90px;
  min-width: 0;
  height: 4px;
  padding: 0;
  border: 0;
  accent-color: var(--rust-bright);
  cursor: pointer;
}
.player-stat { position: relative; overflow: hidden; }
.player-stat.downed {
  border-color: #8d4337;
  background: linear-gradient(110deg, rgba(82,31,26,.74), rgba(29,24,20,.92));
  filter: saturate(.62);
}
.player-stat.downed::after {
  content: "DOWNED";
  position: absolute;
  right: 8px;
  bottom: -4px;
  color: rgba(235,111,83,.13);
  font: 900 2.15rem/1 ui-monospace, monospace;
  transform: rotate(-6deg);
}
.downed-badge { border: 1px solid #c75f4e; background: #5b241f; color: #ffd0c6; }
.piece.downed {
  background: #5c332c;
  color: #cfa99c;
  filter: grayscale(.8);
  transform: rotate(45deg) scale(.82);
}
.battle-player.downed {
  animation: none !important;
  opacity: .48;
  filter: grayscale(.85) sepia(.25) !important;
  transform: translateY(19%) rotate(-7deg) scale(var(--fighter-scale)) !important;
}
.battle-player.downed::after {
  content: "倒地 · 等待救援";
  position: absolute;
  left: 50%;
  top: 45%;
  width: max-content;
  padding: 5px 9px;
  border: 1px solid #a64b3b;
  background: rgba(47,18,16,.9);
  color: #ffc0b2;
  font-size: .7rem;
  transform: translateX(-50%) rotate(7deg);
}
.stat-delta {
  position: absolute;
  z-index: 8;
  right: 15px;
  top: 40%;
  pointer-events: none;
  color: #f5d27f;
  font: 900 .95rem ui-monospace, monospace;
  text-shadow: 0 2px 3px #000;
  animation: stat-float 1.7s ease-out both;
}
.stat-delta.heal, .stat-delta.revived { color: #80e5b9; }
.stat-delta.damage, .stat-delta.downed { color: #ff806b; }
.stat-delta.gold { color: #f3c85d; }
@keyframes stat-float {
  0% { opacity: 0; transform: translateY(8px) scale(.84); }
  18% { opacity: 1; transform: translateY(0) scale(1.08); }
  100% { opacity: 0; transform: translateY(-30px); }
}
.feedback-layer {
  position: fixed;
  z-index: 80;
  right: 24px;
  top: 92px;
  display: grid;
  width: min(360px, calc(100vw - 48px));
  gap: 8px;
  pointer-events: none;
}
.feedback-toast {
  display: flex;
  align-items: center;
  gap: 11px;
  min-height: 52px;
  padding: 10px 13px;
  border: 1px solid #765c3c;
  border-left: 4px solid var(--rust-bright);
  background: linear-gradient(100deg, rgba(37,30,23,.98), rgba(21,18,15,.96));
  color: #f0d8ad;
  box-shadow: 0 12px 28px #000a;
  font-size: .82rem;
  animation: feedback-arrive 3.2s ease both;
}
.feedback-toast img { width: 42px; height: 42px; object-fit: contain; background: radial-gradient(circle, #6c4828, transparent 66%); }
.feedback-toast.poison { border-left-color: #7faf55; color: #c9ee9f; }
.feedback-toast.danger, .feedback-toast.downed { border-left-color: #c34f3e; color: #ffc0ae; }
.feedback-toast.revived { border-left-color: var(--terminal-bright); color: #bce9d5; }
@keyframes feedback-arrive {
  0% { opacity: 0; transform: translateX(34px); }
  10%, 82% { opacity: 1; transform: none; }
  100% { opacity: 0; transform: translateX(16px); }
}
.experience-overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  display: grid;
  place-items: center;
  padding: 34px;
}
.experience-overlay[hidden] { display: none; }
.overlay-scrim { position: absolute; inset: 0; background: rgba(7,6,5,.84); backdrop-filter: blur(7px); }
.tutorial-sheet, .result-sheet {
  position: relative;
  z-index: 1;
  width: min(1040px, 94vw);
  max-height: 90vh;
  overflow: auto;
  border: 1px solid #8b6843;
  border-top: 4px solid var(--rust-bright);
  background:
    linear-gradient(110deg, rgba(28,23,18,.98), rgba(18,15,12,.97)),
    url("/assets/optimized/events/ancient-temple.jpg") center/cover;
  padding: clamp(28px, 4vw, 54px);
  box-shadow: 0 28px 90px #000, inset 0 0 70px rgba(0,0,0,.32);
}
.tutorial-sheet > h2, .result-sheet > h2 {
  margin: 4px 0 10px;
  color: #f2ddb4;
  font: 900 clamp(2rem, 4vw, 3.7rem) Georgia, "STSong", serif;
  letter-spacing: .06em;
}
.tutorial-sheet > p, .result-sheet > p { color: #bead90; line-height: 1.7; }
.tutorial-steps { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin: 24px 0; }
.tutorial-steps article { min-height: 190px; padding: 17px; border: 1px solid #564936; background: rgba(36,30,23,.88); }
.tutorial-steps b { color: var(--rust-bright); font: 900 1.45rem ui-monospace, monospace; }
.tutorial-steps h3 { margin: 7px 0; color: #eed3a5; }
.tutorial-steps p { color: #ad9f87; font-size: .8rem; line-height: 1.65; }
.tutorial-check { display: flex; align-items: center; gap: 8px; margin-bottom: 14px; color: #ad9d81; font-size: .8rem; }
.tutorial-check input { min-width: auto; accent-color: var(--terminal); }
.result-sheet {
  background:
    linear-gradient(90deg, rgba(22,17,13,.98), rgba(22,17,13,.78)),
    url("/assets/optimized/battle-backgrounds/reactor.jpg") center/cover;
}
.result-sheet.victory { border-top-color: var(--terminal-bright); }
.result-sheet.defeat { border-top-color: #b64f3c; filter: saturate(.78); }
.result-players { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px; margin: 24px 0; }
.result-player { display: grid; grid-template-columns: 120px 1fr; min-height: 150px; overflow: hidden; border: 1px solid #65523b; background: rgba(29,24,19,.9); }
.result-player > img { width: 120px; height: 150px; object-fit: contain; object-position: bottom; background: radial-gradient(circle at 50% 60%, #604226, #17120e 72%); }
.result-player > div { align-self: center; padding: 16px; }
.result-player span { display: block; color: #a99779; font-size: .72rem; }
.result-player strong { display: block; margin: 3px 0 10px; color: #f0d7aa; font: 900 1.45rem Georgia, serif; }
.result-player p { color: #c0ad8c; font-size: .78rem; line-height: 1.6; }
.result-player.downed { border-color: #82473b; filter: grayscale(.65); }
.result-actions { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; }
.playtest-selector { display: flex; gap: 16px; align-items: center; padding: 12px; color: #ddc49b; }
.playtest-selector select { background: #242520; color: #f1dfbd; padding: 10px; border: 1px solid #938061; }
.cell.blocked-tile { background: rgba(13,14,11,.3); opacity: .6; border: 1px dashed rgba(210,194,158,.22); box-shadow: none; }
.echo-status { border-left: 3px solid #7eaaa1; padding: 8px 12px; background: #192625; font-size: 13px; }
.echo-status p { margin: 5px 0; }
.echo-portrait { width: 65px; height: 85px; object-fit: contain; float: right; filter: sepia(.3) hue-rotate(100deg); opacity: .7; }
[data-character="Summoner"] .character-art img { filter: drop-shadow(0 0 12px #67958b66); }
.board.long-road { gap: 5px; }
.long-road .cell { min-width: 0; min-height: 76px; }
.long-road .blocked-tile { opacity: .22; }
.long-road .event-label { font-size: clamp(10px, 1vw, 14px); }
.enemy-intent { color: #f3d8a8; line-height: 1.6; }

/* Phase 25: field manual, spatial combat HUD, readable status resolution. */
.character-choice { min-width: 0; display: flex; flex-direction: column; gap: 8px; }
.character-choice .character-card { width: 100%; flex: 1; }
.profession-guide-button { width: 100%; font-size: .8rem; }
.guide-link { font-size: .78rem; margin-top: 8px; }
.camp-reserves { font-size: .75rem; color: #b1c8a6; margin-top: 6px; }
.field-guide { width: min(820px, 90vw); max-height: 86vh; overflow: auto; color: #eddfc4; background: linear-gradient(130deg, #30281e, #141715); border: 1px solid #ab8755; padding: 32px; box-shadow: 0 28px 100px #000c; }
.field-guide::backdrop { background: #080b0cd9; backdrop-filter: blur(5px); }
.field-guide h2 { font: 700 1.8rem Georgia, 'STSong', serif; margin: 18px 0 8px; }
.field-guide section { border-top: 1px solid #66543c; padding: 14px 0; }
.field-guide section h3 { margin: 0 0 9px; color: #eabf7c; }
.field-guide section p { margin: 0; line-height: 1.9; color: #d2d0ba; white-space: pre-line; }
.manual-navigation { display: flex; flex-wrap: wrap; gap: 8px; margin: 18px 0; }
.manual-navigation button[aria-pressed="true"] { color: #fff0cf; border-color: #d7ac66; background: #4a3824; }
.manual-navigation button:focus-visible { outline: 2px solid #eabf7c; outline-offset: 3px; }
.guide-close { float: right; position: sticky; top: 0; z-index: 2; }
.combat-scene { min-height: 820px; }
.combat-scene .event-scene-copy { width: 32%; min-height: 820px; padding: 28px 20px; }
.combat-scene .event-scene-story { font-size: .8rem; line-height: 1.6; }
.combat-scene .event-scene-copy > h2 { font-size: 1.9rem; }
.combat-scene .combat-panel { padding: 12px; }
.combat-scene .combat-actions { display: flex; flex-wrap: wrap; gap: 7px; }
.combat-scene .combat-actions button { font-size: .8rem; padding: 9px; }
.combat-scene .battle-party { left: 33%; bottom: 38%; width: 34%; height: 38%; }
.combat-scene .battle-player { width: 49%; height: 100%; }
.combat-scene .battle-player.player-2 { left: 51%; top: 0; --fighter-scale: 1; filter: none; }
.combat-scene .battle-enemy { right: 1%; bottom: 17%; width: 30%; height: 48%; }
.combat-scene .battle-combatant { animation: none; }
.battle-turn-banner { right: 1%; width: 65%; }
.enemy-hud { position: absolute; z-index: 4; right: 2%; top: 85px; width: 29%; text-align: center; text-shadow: 0 2px 5px #000, 0 0 12px #000; pointer-events: auto; }
.enemy-hud .enemy-card { justify-content: center; gap: 10px; }
.enemy-hud h3 { margin: 0; color: #f7c391; font-size: 1.3rem; }
.enemy-hud #combat-round { font-size: .75rem; color: #c5b998; }
.enemy-hud > .health-track { display: none; }
.enemy-hud #enemy-stats { margin: 10px 0; }
.enemy-hud .enemy-intent { display: flex; flex-wrap: wrap; justify-content: center; align-items: center; gap: 6px; padding: 0; border: 0; background: none; margin: 10px 0; font-size: .8rem; }
.enemy-intent span { flex-basis: 100%; }
.enemy-intent > .status-icon { color: #ee9b73; width: 25px; height: 25px; }
.fighter-hud { position: absolute; top: 104%; left: 0; width: 100%; text-align: center; pointer-events: auto; }
.fighter-vitals { position: relative; color: #f2dec0; text-shadow: 0 2px 4px #000; }
.status-icon { width: 21px; height: 21px; display: inline-block; vertical-align: middle; flex-shrink: 0; }
.vital-health, .vital-pair, .vital-pair > span { display: flex; justify-content: center; align-items: center; gap: 7px; }
.vital-health { color: #f1b3a3; }
.vital-health b { font: bold 1.2rem ui-monospace, monospace; }
.vital-health small { font-size: .75rem; }
.vital-pair { gap: 22px; margin-top: 6px; }
.vital-pair > span:last-child { color: #aad0d4; }
.vital-track { height: 5px; margin: 6px auto; width: 85%; background: #3e2520; border: 1px solid #1d1410; }
.vital-track i { display: block; height: 100%; background: linear-gradient(90deg, #9d5541, #f0b78c); transition: width .45s ease; }
.effect-strip { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; margin-top: 10px; }
.effect-strip .effect-chip { display: grid; grid-template-columns: 20px auto; gap: 2px 4px; align-items: center; padding: 5px 6px; min-width: 48px; border: 1px solid currentColor; border-radius: 4px; background: #141613e8; box-shadow: 0 3px 8px #0008; pointer-events: auto; }
.effect-chip .status-icon { width: 19px; height: 19px; }
.effect-chip b { font: bold .75rem ui-monospace, monospace; }
.effect-chip small { grid-column: 1/-1; font-size: .62rem; white-space: nowrap; }
.tone-green { color: #a5d98b !important; }
.tone-blue { color: #a0d4df !important; }
.tone-red { color: #ffa28a !important; }
.tone-gold { color: #f4d086 !important; }
.battle-float { position: absolute; z-index: 12; top: 22%; left: 50%; transform: translateX(-50%); font: 900 1.4rem ui-monospace, 'STSong', serif; white-space: nowrap; text-shadow: 0 3px 4px #000, 0 0 8px #000; pointer-events: none; animation: combat-number-rise 1.5s ease-out both; }
.fighter-vitals .battle-float { font-size: .85rem; top: -16px; }
.fighter-vitals .battle-float ~ .battle-float { top: 18px; }
.vital-pulse { animation: vital-glow .75s ease-out; }
.battle-enemy.motion-heal img { animation: healing-glow .65s ease-out; }
/* Phase 26: reused enemy silhouettes become one-hit spectral companions. */
/* Phase 27: a server-backed receipt, not a transient map toast. */
.event-scene.result-scene { min-height: 640px; }
.result-scene .event-scene-copy { width: min(940px, 94%); min-height: 640px; padding: 32px; background: linear-gradient(110deg, #171910f5, #24251cf0); }
.result-scene .event-scene-copy > h2 { font-size: clamp(2rem, 3.5vw, 3.2rem); }
.event-result-panel { padding-top: 12px; border-top: 1px solid #aa8554; }
.result-gains, .result-loot-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(255px, 1fr)); gap: 14px; }
.result-gains article { background: #0d1513bc; border-left: 3px solid #9db393; padding: 10px 18px; }
.result-gains h3 { color: #e6c992; margin: 6px 0 10px; }
.result-gains ul { padding-left: 20px; line-height: 1.9; color: #d7dbc5; }
.result-loot-grid .inventory-item { margin: 0; }
.result-outcome { color: #bcbc9f; line-height: 1.8; padding: 12px 0; }
#confirm-event-result { min-width: 240px; margin: 10px 0; }
#pending-loot-medical { margin-top: 22px; padding-top: 10px; border-top: 1px solid #77684a; }
#pending-loot-medical .item-card { margin: 8px 0; }
.spirit-figure { position: absolute; z-index: 2; left: 52%; top: 26%; width: 65%; height: 68%; pointer-events: none; opacity: .72; filter: grayscale(1) sepia(.8) hue-rotate(105deg) saturate(2) drop-shadow(0 0 9px #8ce6d4); }
.battle-combatant .spirit-figure img { width: 100%; height: 100%; object-fit: contain; transform: none; animation: none; }
.spirit-figure small { display: block; text-align: center; font-size: .65rem; color: #bbffed; white-space: nowrap; text-shadow: 0 2px 5px #000; }
.spirit-figure.guarding { filter: grayscale(1) sepia(.8) hue-rotate(105deg) saturate(2) drop-shadow(0 0 16px #9dffee); }
.spirit-wisp { display: block; width: 60%; height: 65%; margin: 30% auto 0; border-radius: 50% 50% 35% 35%; background: radial-gradient(ellipse at 50% 35%, #effff5, #7ecabd66 40%, transparent 70%); box-shadow: 0 -12px 30px #87e3d144; }
.motion-soul-call > img { animation: lantern-command .78s ease-out; }
.motion-lantern-bolt > img { animation: lantern-command .78s ease-out; }
.lantern-bolt { position: absolute; left: 65%; top: 42%; width: 30px; height: 30px; border-radius: 50%; background: radial-gradient(#fff, #a3eadbcc 25%, #52877600 72%); filter: drop-shadow(0 0 12px #8cffe0); animation: lantern-projectile .78s ease-out both; }
.motion-soul-call .spirit-figure { animation: spirit-strike .78s ease-out; }
.motion-spirit-guard .spirit-figure { animation: spirit-shield .78s ease-out; }
.spirit-figure.spirit-shatter { animation: spirit-break .78s ease-in both; }
.soul-capture { position: absolute; z-index: 8; left: 72%; top: 30%; width: 90px; height: 130px; pointer-events: none; filter: grayscale(1) sepia(.8) hue-rotate(105deg) saturate(2) drop-shadow(0 0 15px #7aedda); animation: soul-to-lantern .75s ease-in both; }
.soul-capture img { width: 100%; height: 100%; object-fit: contain; }
.motion-fall > img { animation: combat-fall .78s ease-in both !important; transform-origin: bottom center; }
.motion-dodge > img { animation: combat-dodge .78s ease-out !important; }
.market-replacement-list { display: grid; gap: 12px; margin-top: 16px; }
.market-replacement-list article { border: 1px solid #7c6748; padding: 12px; }
@keyframes lantern-projectile { 0% { opacity: 0; scale: .1; } 30% { opacity: 1; scale: 1; } 100% { opacity: 0; translate: 240px -10px; } }
@keyframes lantern-command { 25% { transform: rotate(-6deg) translateY(-8px); filter: drop-shadow(0 0 16px #7aedda); } 65% { transform: rotate(4deg); } }
@keyframes spirit-strike { 45% { transform: translateX(45px) scale(1.08); opacity: 1; } }
@keyframes spirit-shield { 50% { transform: translateX(12px) scale(1.22); opacity: 1; } }
@keyframes spirit-break { 25% { opacity: 1; filter: brightness(3); } to { opacity: 0; transform: translateY(-25px) scale(1.4); } }
@keyframes soul-to-lantern { from { opacity: .8; transform: scale(1); } to { opacity: 0; transform: translate(var(--soul-x, -250px), var(--soul-y, 20px)) scale(.06); } }
@keyframes combat-fall { 25% { filter: brightness(1.7); } to { transform: rotate(-28deg) translateY(32px); filter: grayscale(1) brightness(.4); opacity: .4; } }
@keyframes combat-dodge { 35% { transform: translateX(-35px) skewX(-8deg); opacity: .45; } }
@keyframes combat-number-rise { 0% { opacity: 0; translate: 0 10px; scale: .8; } 18% { opacity: 1; scale: 1.14; } 65% { opacity: 1; } 100% { opacity: 0; translate: 0 -52px; scale: 1; } }
@keyframes vital-glow { 20% { filter: brightness(1.8); scale: 1.15; box-shadow: 0 0 14px #d6c084; } 100% { filter: none; scale: 1; box-shadow: none; } }
@keyframes healing-glow { 40% { filter: drop-shadow(0 0 22px #89c28a) brightness(1.3); } }
@media (max-width: 1100px) and (min-width: 761px) {
  .combat-scene, .combat-scene .event-scene-copy { min-height: 940px; }
  .combat-scene .event-scene-copy { padding: 22px 12px; }
  .effect-strip { gap: 3px; }
  .effect-strip .effect-chip { padding: 4px; }
}
@media (max-width: 760px) {
  .combat-scene .battle-stage { height: 690px; }
  .combat-scene .event-scene-copy { width: 100%; min-height: auto; }
  .combat-scene .battle-party { left: 2%; width: 50%; height: 38%; bottom: 28%; }
  .combat-scene .battle-enemy { width: 42%; }
  .enemy-hud { width: 44%; top: 65px; }
  .battle-turn-banner { width: 95%; }
}
