:root {
  --ink: #241d18;
  --muted: #6b5b4f;
  --paper: #f6ead4;
  --panel: #fff8ea;
  --line: #d2b98f;
  --red: #a33a2f;
  --green: #3f7652;
  --blue: #2e637a;
  --gold: #b47d24;
  --dark: #31251d;
  --asset-map-bg: url("/assets/map/map-parchment-bg.png");
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(rgba(44, 32, 24, 0.08) 1px, transparent 1px),
    linear-gradient(90deg, rgba(44, 32, 24, 0.08) 1px, transparent 1px),
    linear-gradient(135deg, #d9b16d 0%, #efe0bf 38%, #b6c7b3 100%);
  background-size: 28px 28px, 28px 28px, cover;
}

button,
input,
select {
  font: inherit;
}

button,
select,
input {
  border-radius: 8px;
}

button {
  min-height: 40px;
  border: 1px solid #8e7148;
  background: #fbf0d8;
  color: var(--ink);
  cursor: pointer;
  font-weight: 700;
}

button.primary {
  border-color: #612a22;
  background: var(--red);
  color: #fff8ea;
}

button.danger-button,
.danger-button {
  border-color: #612a22;
  background: #7f241e;
  color: #fff8ea;
}

button:hover {
  filter: brightness(0.98);
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

input,
select {
  width: 100%;
  min-height: 40px;
  border: 1px solid var(--line);
  padding: 0 10px;
  background: #fffdf7;
  color: var(--ink);
}

.app {
  display: grid;
  gap: 14px;
  grid-template-columns: 1fr;
  min-height: 100vh;
  padding: 14px;
}

.home-app {
  align-content: center;
}

.home-screen {
  display: grid;
  gap: 14px;
  width: min(980px, 100%);
  margin: 0 auto;
}

.home-hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  padding: 20px;
  border: 1px solid rgba(69, 48, 31, 0.24);
  border-radius: 8px;
  background: rgba(255, 248, 234, 0.94);
}

.home-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
  align-items: start;
}

.home-card {
  display: grid;
  gap: 10px;
}

.restore-card {
  grid-column: 1 / -1;
}

.app-top,
.game-layout {
  display: grid;
  gap: 12px;
}

.game-layout {
  grid-template-columns: minmax(620px, 1fr) 410px;
  align-items: start;
}

.game-table {
  display: grid;
  grid-template-columns: minmax(640px, 1fr) 380px;
  gap: 12px;
  align-items: start;
}

.table-main,
.table-side {
  display: grid;
  gap: 12px;
  align-content: start;
}

.party-hud {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 10px;
  border: 1px solid rgba(69, 48, 31, 0.24);
  border-radius: 8px;
  background: rgba(255, 248, 234, 0.94);
}

.coop-grid {
  display: grid;
  grid-template-columns: 1.2fr 1fr 1.1fr 1fr;
  gap: 12px;
  align-items: stretch;
}

.coop-card {
  min-height: 158px;
}

.activity-title {
  margin: 6px 0 4px;
  font-weight: 950;
}

.shared-roll {
  display: grid;
  gap: 3px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  background: #fffdf7;
  font-size: 12px;
}

.night-attack-card {
  display: grid;
  gap: 3px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--red);
  border-radius: 8px;
  background: #ffe5df;
  color: #6b2a24;
  font-size: 12px;
  font-weight: 800;
}

.night-attack-card b {
  color: var(--red);
}

.shared-roll.success {
  border-color: var(--green);
  background: #f5fff0;
}

.shared-roll.failure {
  border-color: var(--red);
  background: #ffe5df;
}

.shared-roll span {
  color: var(--muted);
  font-weight: 800;
}

.turn-timeline {
  display: grid;
  gap: 5px;
  margin: 8px 0 0;
  padding-left: 20px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.mini-status-list {
  display: grid;
  gap: 7px;
}

.mini-player {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 2px 8px;
  align-items: center;
  padding: 6px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  background: #fffdf7;
}

.mini-player b,
.mini-player small {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mini-player small {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.mini-player.is-me {
  border-color: var(--blue);
}

.mini-player.is-active {
  box-shadow: inset 0 0 0 2px rgba(63, 118, 82, 0.16);
}

.mini-player.is-offline {
  opacity: 0.58;
}

.player-token,
.legend-token {
  display: inline-grid;
  place-items: center;
  min-width: 30px;
  min-height: 30px;
  padding: 3px 5px;
  border: 2px solid rgba(49, 37, 29, 0.42);
  border-radius: 8px;
  color: #fffdf7;
  font-size: 11px;
  font-weight: 950;
}

.color-0 { background: #a33a2f; }
.color-1 { background: #2e637a; }
.color-2 { background: #3f7652; }
.color-3 { background: #8d5a1f; }
.color-4 { background: #684b8f; }
.color-5 { background: #6d6a27; }

.hud-badge {
  display: grid;
  gap: 1px;
  min-height: 40px;
  padding: 6px 9px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  background: #fffdf7;
}

.hud-badge small {
  color: var(--muted);
  font-size: 10px;
  font-weight: 900;
  text-transform: uppercase;
}

.hud-badge b {
  font-size: 13px;
  line-height: 1.1;
}

.left,
.right {
  display: grid;
  gap: 12px;
  align-content: start;
}

.top {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: stretch;
  padding: 16px;
  border: 1px solid rgba(69, 48, 31, 0.24);
  border-radius: 8px;
  background: rgba(255, 248, 234, 0.94);
}

.top-actions {
  display: grid;
  grid-template-columns: auto auto;
  gap: 8px;
  align-items: stretch;
}

.room-chip {
  display: grid;
  gap: 2px;
  min-width: 132px;
  padding: 7px 10px;
  border: 1px solid var(--dark);
  border-radius: 8px;
  background: #fffdf7;
}

.room-chip span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}

.room-chip b {
  font-size: 16px;
}

.help-button {
  min-width: 116px;
  border-color: var(--blue);
  background: #e9f2f5;
  color: var(--blue);
}

h1,
h2,
h3,
p {
  margin: 0;
}

h1 {
  font-size: clamp(28px, 3.5vw, 48px);
  line-height: 0.95;
}

h2 {
  font-size: 16px;
}

h3 {
  font-size: 15px;
}

.subtitle {
  margin-top: 8px;
  color: var(--muted);
}

.panel-title {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: start;
  margin-bottom: 10px;
}

.panel-title.compact {
  align-items: center;
}

.action-hint {
  margin-top: 7px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.tip {
  display: inline-grid;
  place-items: center;
  width: 18px;
  height: 18px;
  margin-left: 4px;
  border: 1px solid #8e7148;
  border-radius: 999px;
  background: #fffdf7;
  color: var(--blue);
  font-size: 11px;
  font-weight: 900;
  text-transform: none;
  cursor: help;
}

.code {
  display: grid;
  place-items: center;
  min-width: 132px;
  padding: 8px 12px;
  border: 2px solid var(--dark);
  border-radius: 8px;
  background: #fffdf7;
  font-size: 20px;
  font-weight: 900;
}

.state-message,
.lobby-screen {
  width: min(1180px, 100%);
  margin: 0 auto;
}

.lobby-screen {
  display: grid;
  gap: 12px;
}

.lobby-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
}

.invite-box {
  display: grid;
  gap: 5px;
  min-width: 260px;
}

.invite-box span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.invite-box b {
  font-size: 24px;
}

.lobby-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 360px;
  gap: 12px;
  align-items: start;
}

.lobby-main,
.lobby-side {
  display: grid;
  gap: 12px;
}

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

.character-card {
  display: grid;
  gap: 8px;
}

.character-card.is-taken {
  opacity: 0.62;
}

.selected-character {
  border-color: var(--red);
}

.ready-badge,
.wait-badge {
  display: inline-grid;
  place-items: center;
  min-height: 26px;
  padding: 4px 8px;
  border-radius: 999px;
  color: #fff8ea;
  font-size: 12px;
}

.ready-badge {
  background: var(--green);
}

.wait-badge {
  background: var(--gold);
}

.panel {
  border: 1px solid rgba(69, 48, 31, 0.24);
  border-radius: 8px;
  background: rgba(255, 248, 234, 0.94);
  box-shadow: 0 18px 38px rgba(62, 42, 23, 0.12);
}

.panel.pad {
  padding: 14px;
}

.view-controls {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 10px;
}

.view-controls button {
  min-height: 34px;
  font-size: 12px;
}

.collapsible {
  padding: 0;
  overflow: hidden;
}

.collapse-head {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  width: 100%;
  min-height: 58px;
  padding: 12px;
  border: 0;
  border-radius: 0;
  background: #fffdf7;
  text-align: left;
}

.collapse-head span {
  display: grid;
  gap: 4px;
}

.collapse-head small {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.collapse-head i {
  color: var(--blue);
  font-size: 12px;
  font-style: normal;
  white-space: nowrap;
}

.collapse-body {
  padding: 0 12px 12px;
  border-top: 1px solid #ead8b7;
}

.accent-economy .collapse-head,
.accent-contact .secondary-tabs button.active {
  background: #fff3cf;
}

.party-state {
  border-color: rgba(49, 37, 29, 0.42);
}

.active-goal {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(63, 118, 82, 0.1), 0 18px 38px rgba(62, 42, 23, 0.12);
}

.primary-mission-actions {
  margin-top: 10px;
}

.check-button {
  display: grid;
  gap: 3px;
  min-height: 66px;
  padding: 9px;
  text-align: left;
}

.check-button span,
.check-button small {
  color: var(--muted);
  font-weight: 800;
}

.check-button small {
  font-size: 11px;
}

.check-button .action-missing {
  color: var(--red);
  font-weight: 900;
}

.danger-note {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid var(--red);
  border-radius: 8px;
  background: #ffe5df;
  color: var(--red);
  font-size: 12px;
  font-weight: 900;
}

.danger-card,
.delete-room-zone,
.delete-warning {
  display: grid;
  gap: 8px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid var(--red);
  border-radius: 8px;
  background: #ffe5df;
}

.danger-card p,
.delete-warning p {
  color: #6b2a24;
  font-size: 13px;
  line-height: 1.35;
}

.danger-pill {
  display: inline-grid;
  place-items: center;
  min-height: 24px;
  padding: 3px 8px;
  border-radius: 999px;
  background: var(--red);
  color: #fff8ea;
  font-size: 11px;
  font-weight: 950;
}

.item-chip-row {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}

.item-chip-row button {
  min-height: 32px;
  font-size: 12px;
}

.compact-shop {
  margin-bottom: 0;
}

.action-panel.is-current {
  border-color: var(--green);
  box-shadow: 0 0 0 3px rgba(63, 118, 82, 0.12), 0 18px 38px rgba(62, 42, 23, 0.12);
}

.action-panel.is-muted {
  opacity: 0.86;
}

.phase-note {
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  background: #fffdf7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.join {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  gap: 10px;
  align-items: end;
}

label {
  display: grid;
  gap: 5px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.metrics {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.compact-metrics {
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-bottom: 10px;
}

.compact-metrics .metric {
  min-height: 62px;
}

.compact-metrics .metric b {
  font-size: 20px;
}

.metric {
  min-height: 74px;
  padding: 10px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  background: #fffdf7;
}

.metric.active-turn {
  border-color: var(--green);
  box-shadow: inset 0 0 0 2px rgba(63, 118, 82, 0.12);
}

.metric.danger-mid {
  border-color: var(--gold);
  background: #fff4d8;
}

.metric.danger-high {
  border-color: var(--red);
  background: #ffe5df;
}

.metric b {
  display: block;
  font-size: 24px;
  line-height: 1.08;
}

.metric span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.phase,
.goal-count {
  display: inline-grid;
  place-items: center;
  min-height: 30px;
  padding: 5px 10px;
  border-radius: 999px;
  background: var(--dark);
  color: #fff8ea;
  font-size: 12px;
  font-weight: 900;
  white-space: nowrap;
}

.phase-day {
  background: var(--green);
}

.phase-event,
.phase-finale {
  background: var(--red);
}

.phase-lobby,
.phase-night {
  background: var(--blue);
}

.next-step {
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  background: #fffdf7;
}

.next-step.inline {
  margin: 0 0 10px;
}

.next-step p {
  margin-top: 4px;
  color: var(--muted);
}

.goal-count {
  background: var(--gold);
}

.map-panel {
  padding-bottom: 14px;
}

.map {
  position: relative;
  min-height: 680px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  overflow: hidden;
  background:
    radial-gradient(circle at 70% 14%, rgba(120, 90, 55, 0.22), transparent 18%),
    radial-gradient(circle at 22% 77%, rgba(49, 99, 86, 0.22), transparent 22%),
    #e6c98f;
}

.roads {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.road {
  stroke: rgba(75, 54, 34, 0.45);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 9 8;
}

.loc {
  position: absolute;
  width: 138px;
  min-height: 78px;
  transform: translate(-50%, -50%);
  padding: 9px;
  border: 2px solid #5c3f29;
  border-radius: 8px;
  background: #fff6df;
  box-shadow: 0 8px 20px rgba(51, 35, 22, 0.18);
}

.loc.current {
  border-color: var(--red);
  box-shadow: 0 0 0 4px rgba(163, 58, 47, 0.16), 0 8px 20px rgba(51, 35, 22, 0.18);
}

.loc.reachable {
  border-color: var(--green);
}

.loc.objective {
  border-color: var(--green);
  background: #eff8e8;
  box-shadow: 0 0 0 4px rgba(63, 118, 82, 0.18), 0 8px 20px rgba(51, 35, 22, 0.18);
}

.loc.near-danger {
  box-shadow: 0 0 0 4px rgba(180, 125, 36, 0.2), 0 8px 20px rgba(51, 35, 22, 0.18);
}

.loc button {
  width: 100%;
  min-height: 28px;
  margin-top: 7px;
  font-size: 12px;
}

.region {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.tokens,
.pieces,
.enemies {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 5px;
}

.piece,
.enemy,
.token,
.marker {
  display: inline-grid;
  place-items: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  color: white;
  font-size: 11px;
  font-weight: 900;
}

.piece {
  background: var(--blue);
}

.enemy {
  background: var(--red);
}

.enemy-map-chip {
  width: auto;
  height: auto;
  min-height: 24px;
  max-width: 100%;
  padding: 3px 7px;
  border-radius: 8px;
  text-align: left;
}

.enemy-card.danger-here {
  border-color: var(--red);
  background: #ffe5df;
}

.token {
  background: var(--gold);
}

.marker {
  width: auto;
  background: var(--green);
}

.player-chip {
  display: inline-grid;
  grid-template-columns: auto;
  gap: 1px;
  align-items: center;
  min-width: 34px;
  min-height: 28px;
  padding: 3px 5px;
  border: 2px solid rgba(49, 37, 29, 0.42);
  border-radius: 8px;
  color: #fffdf7;
  line-height: 1;
  box-shadow: 0 4px 9px rgba(51, 35, 22, 0.18);
}

.player-chip b {
  font-size: 11px;
}

.player-chip small {
  font-size: 8px;
  font-weight: 900;
}

.player-chip.is-me {
  border-color: #fffdf7;
  box-shadow: 0 0 0 2px var(--blue), 0 4px 9px rgba(51, 35, 22, 0.18);
}

.player-chip.is-active {
  outline: 2px solid var(--green);
}

.player-chip.is-offline {
  opacity: 0.55;
  filter: grayscale(0.5);
}

.map-legend,
.map-roster {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
  padding: 8px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  background: #fffdf7;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.map-legend span,
.map-roster span {
  display: inline-flex;
  gap: 4px;
  align-items: center;
}

.legend-token {
  min-width: 24px;
  min-height: 22px;
  border-radius: 6px;
  font-size: 10px;
}

.cards {
  display: grid;
  gap: 8px;
}

.card {
  padding: 12px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  background: #fffdf7;
}

.card.selected {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(163, 58, 47, 0.12);
}

.card.active-player {
  border-color: var(--green);
}

.card-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: start;
}

.muted {
  color: var(--muted);
}

.stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 5px;
  margin-top: 8px;
  font-size: 12px;
}

.bar {
  height: 9px;
  overflow: hidden;
  border-radius: 999px;
  background: #ead8b7;
}

.bar i {
  display: block;
  height: 100%;
  background: var(--green);
}

.bar.red i {
  background: var(--red);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  margin-top: 10px;
}

.inventory,
.shop {
  display: grid;
  gap: 8px;
  margin: 12px 0;
}

.item,
.shop-item {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  padding: 9px;
  border: 1px solid #ead8b7;
  border-radius: 8px;
  background: #fffaf0;
}

.item .action-hint {
  grid-column: 1 / -1;
}

.item-actions {
  display: grid;
  grid-template-columns: auto minmax(92px, 1fr) auto;
  gap: 5px;
  align-items: center;
}

.item-actions button,
.item-actions select,
.shop-item button {
  min-height: 32px;
  font-size: 12px;
}

.section-title {
  margin-top: 12px;
}

.section-split {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid #ead8b7;
}

.missions {
  display: grid;
  gap: 8px;
}

.mission {
  display: grid;
  gap: 8px;
}

.mission.done {
  opacity: 0.6;
}

.mission.current-mission {
  border-color: var(--green);
  background: #f5fff0;
}

.mission-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.method {
  display: grid;
  gap: 5px;
  padding: 9px;
  border: 1px dashed #d9bf8f;
  border-radius: 8px;
  background: #fffaf0;
}

.method + .method {
  margin-top: 7px;
}

.economy-actions {
  grid-template-columns: 1fr 1fr;
}

.event {
  border: 2px solid var(--dark);
  background: #fff3cf;
}

.secondary-panel {
  display: grid;
  gap: 12px;
}

.secondary-tabs {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 8px;
}

.secondary-tabs button {
  display: grid;
  gap: 4px;
  min-height: 58px;
  padding: 8px;
  text-align: left;
}

.secondary-tabs button.active {
  border-color: var(--red);
  background: #fff3cf;
}

.secondary-tabs span {
  overflow: hidden;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.secondary-body > .embedded-panel {
  padding: 12px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  background: #fffdf7;
}

.secondary-body > .event {
  border: 2px solid var(--dark);
  background: #fff3cf;
}

.log {
  display: grid;
  gap: 7px;
  max-height: 280px;
  overflow: auto;
  font-size: 13px;
}

.log div {
  padding-bottom: 7px;
  border-bottom: 1px solid #ead8b7;
}

.table-chat {
  display: grid;
  gap: 10px;
}

.chat-feed {
  display: flex;
  flex-direction: column;
  gap: 7px;
  min-height: 330px;
  max-height: min(52vh, 560px);
  overflow: auto;
  padding: 8px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  background: rgba(255, 253, 247, 0.62);
}

.feed-entry {
  display: grid;
  gap: 3px;
  padding: 8px;
  border: 1px solid #ead8b7;
  border-radius: 8px;
  background: #fffdf7;
}

.feed-entry > div {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.feed-entry b {
  font-size: 12px;
}

.feed-entry span {
  color: var(--muted);
  font-size: 11px;
  font-weight: 800;
}

.feed-entry p {
  color: var(--ink);
  font-size: 13px;
  line-height: 1.3;
}

.feed-entry.system {
  border-color: #dac49a;
  background: #f4ead5;
}

.feed-entry.system b {
  color: #7b4323;
}

.feed-entry.chat {
  border-color: rgba(46, 99, 122, 0.38);
}

.feed-entry.chat b {
  color: var(--blue);
}

.chat-form {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.chat-form button {
  min-width: 64px;
}

.last-result,
.result-card {
  display: grid;
  gap: 5px;
  margin-top: 10px;
  padding: 10px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  background: #fffdf7;
}

.last-result.success,
.result-card.success {
  border-color: var(--green);
  background: #f5fff0;
}

.last-result.failure,
.result-card.failure {
  border-color: var(--red);
  background: #ffe5df;
}

.last-result span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.roll-modal {
  width: min(620px, 100%);
}

.roll-preview {
  display: grid;
  gap: 10px;
  padding: 14px;
}

.formula {
  padding: 10px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  background: #fffdf7;
}

.roll-outcomes {
  display: grid;
  gap: 6px;
}

.roll-outcomes p {
  padding: 8px;
  border: 1px solid #ead8b7;
  border-radius: 8px;
  background: #fffdf7;
  color: var(--muted);
  font-size: 13px;
}

.roll-dice {
  display: flex;
  justify-content: center;
  gap: 14px;
  padding: 18px 14px;
}

.roll-dice span {
  display: grid;
  place-items: center;
  width: 76px;
  height: 76px;
  border: 2px solid var(--dark);
  border-radius: 14px;
  background: #fffdf7;
  color: var(--dark);
  font-size: 34px;
  font-weight: 950;
  box-shadow: 0 10px 22px rgba(62, 42, 23, 0.18);
}

.roll-dice.rolling span {
  animation: dicePulse 0.18s linear infinite alternate;
}

.roll-breakdown {
  display: grid;
  gap: 6px;
  padding: 0 14px 14px;
}

.roll-breakdown p {
  padding: 8px;
  border: 1px solid #ead8b7;
  border-radius: 8px;
  background: #fffdf7;
}

.log-modal {
  width: min(760px, 100%);
}

.delete-modal {
  width: min(560px, 100%);
}

.full-log {
  max-height: min(62vh, 620px);
}

@keyframes dicePulse {
  from {
    transform: rotate(-3deg) scale(0.98);
  }
  to {
    transform: rotate(3deg) scale(1.03);
  }
}

.final {
  padding: 24px;
  border: 2px solid var(--dark);
  border-radius: 8px;
  background: #fff8ea;
  text-align: center;
}

.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(31, 23, 18, 0.5);
}

.modal {
  width: min(940px, 100%);
  max-height: min(86vh, 860px);
  overflow: auto;
  border: 2px solid var(--dark);
  border-radius: 8px;
  background: #fff8ea;
  box-shadow: 0 28px 80px rgba(27, 19, 13, 0.35);
}

.modal-head,
.modal-actions {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: center;
  padding: 14px;
  border-bottom: 1px solid #ead8b7;
}

.modal-actions {
  border-top: 1px solid #ead8b7;
  border-bottom: 0;
  justify-content: end;
}

.help-tabs {
  display: flex;
  gap: 6px;
  padding: 10px 14px;
  border-bottom: 1px solid #ead8b7;
  overflow-x: auto;
}

.help-tabs button {
  min-height: 34px;
  white-space: nowrap;
}

.help-tabs button.active {
  border-color: var(--red);
  background: var(--red);
  color: #fff8ea;
}

.help-body {
  padding: 14px;
}

.help-stack,
.help-grid,
.glossary {
  display: grid;
  gap: 10px;
}

.help-grid {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.help-section {
  padding: 12px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  background: #fffdf7;
}

.help-section summary {
  cursor: pointer;
  font-weight: 900;
}

.help-section p,
.help-section li {
  margin-top: 7px;
  color: var(--muted);
}

.help-section ol,
.help-section ul {
  margin: 8px 0 0;
  padding-left: 22px;
}

.glossary {
  grid-template-columns: repeat(3, minmax(0, 1fr));
}

.glossary article {
  padding: 10px;
  border: 1px solid #ead8b7;
  border-radius: 8px;
  background: #fffdf7;
}

.glossary p {
  margin-top: 5px;
  color: var(--muted);
  font-size: 13px;
}

.tutorial-modal {
  width: min(620px, 100%);
}

.tutorial-card {
  display: grid;
  gap: 12px;
  margin: 14px;
  padding: 18px;
  border: 1px solid #dec89e;
  border-radius: 8px;
  background: #fffdf7;
}

.tutorial-card p {
  color: var(--muted);
  font-size: 16px;
  line-height: 1.45;
}

.check-row {
  display: flex;
  grid-template-columns: none;
  gap: 8px;
  align-items: center;
  padding: 0 14px 14px;
  color: var(--ink);
}

.check-row input {
  width: auto;
  min-height: auto;
}

/* Asset pack v0 visual layer */
body {
  color: var(--ink);
  background:
    radial-gradient(circle at 16% 8%, rgba(180, 125, 36, 0.22), transparent 24%),
    radial-gradient(circle at 88% 86%, rgba(63, 118, 82, 0.14), transparent 28%),
    linear-gradient(135deg, #7d5633 0%, #d4b176 42%, #8f9d76 100%);
  background-size: cover;
}

body::before {
  display: none;
}

button {
  border: 1px solid #6f4a2a;
  border-radius: 7px;
  background:
    linear-gradient(180deg, rgba(255, 248, 234, 0.18), rgba(62, 42, 23, 0.12)),
    #7a4a24;
  color: #fff8ea;
  box-shadow: 0 4px 10px rgba(36, 23, 15, 0.16);
  text-shadow: none;
}

button:hover:not(:disabled) {
  filter: brightness(1.04);
  transform: translateY(-1px);
  box-shadow: 0 7px 16px rgba(36, 23, 15, 0.18);
}

button:active:not(:disabled) {
  transform: translateY(0);
  box-shadow: 0 3px 8px rgba(36, 23, 15, 0.15);
}

button:disabled {
  background:
    linear-gradient(180deg, rgba(255, 248, 234, 0.64), rgba(180, 164, 136, 0.5)),
    #d7ccb7;
  color: #55483b;
  box-shadow: none;
  filter: none;
  opacity: 1;
}

button.primary,
.help-tabs button.active {
  border-color: #612a22;
  background:
    linear-gradient(180deg, rgba(255, 248, 234, 0.14), rgba(62, 42, 23, 0.1)),
    var(--red);
}

button.danger-button,
.danger-button {
  border-color: #612a22;
  background:
    linear-gradient(180deg, rgba(255, 248, 234, 0.12), rgba(62, 42, 23, 0.18)),
    #7f241e;
}

input,
select {
  border: 1px solid #b99a6b;
  border-radius: 7px;
  background: #fff8ea;
  box-shadow: inset 0 1px 3px rgba(61, 38, 24, 0.08);
}

.panel,
.home-hero,
.top,
.party-hud {
  border: 1px solid rgba(61, 38, 24, 0.32);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 248, 234, 0.9), rgba(243, 217, 164, 0.76)),
    var(--panel);
  box-shadow: 0 18px 38px rgba(62, 42, 23, 0.16);
}

.card,
.metric,
.hud-badge,
.shared-roll,
.mini-player,
.room-chip,
.invite-box,
.next-step,
.phase-note,
.formula,
.roll-outcomes p,
.roll-breakdown p,
.help-section,
.glossary article,
.tutorial-card,
.secondary-body > .embedded-panel,
.item,
.shop-item,
.method {
  border: 1px solid rgba(111, 74, 42, 0.46);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 253, 247, 0.88), rgba(243, 217, 164, 0.7)),
    #fff8ea;
  box-shadow: 0 8px 20px rgba(36, 23, 15, 0.1);
}

.collapse-head {
  border-bottom: 1px solid rgba(61, 38, 24, 0.24);
  border-radius: 0;
  background:
    linear-gradient(180deg, rgba(255, 248, 234, 0.92), rgba(243, 217, 164, 0.72)),
    #f3d9a4;
  color: var(--ink);
}

.collapse-head h2,
.collapse-head small,
.collapse-head i {
  color: var(--ink);
  text-shadow: none;
}

.collapse-head small {
  color: var(--muted);
}

.secondary-tabs button,
.secondary-tabs button b,
.secondary-tabs span,
.secondary-tabs button.active,
.secondary-tabs button.active span {
  text-shadow: none;
}

.secondary-tabs button:not(.active) b {
  color: #fff8ea;
}

.secondary-tabs button:not(.active) span {
  color: #f2dfc2;
}

.secondary-tabs button.active {
  background:
    linear-gradient(135deg, rgba(255, 253, 247, 0.96), rgba(255, 232, 183, 0.86)),
    #fff3cf;
}

.secondary-tabs button.active b {
  color: var(--red);
}

.secondary-tabs button.active span {
  color: #5f4d3f;
}

.check-button b {
  color: #fff8ea;
}

.check-button span,
.check-button small {
  color: #f0dcc1;
}

.check-button:disabled b,
.check-button:disabled span,
.check-button:disabled small {
  color: #4f4438;
}

.check-button:disabled .action-missing {
  color: #9e2f27;
}

.active-goal,
.action-panel.is-current,
.mission.current-mission {
  border-color: var(--green);
  background:
    linear-gradient(135deg, rgba(255, 248, 234, 0.9), rgba(63, 118, 82, 0.16)),
    var(--panel);
  box-shadow: 0 0 0 3px rgba(63, 118, 82, 0.14), 0 18px 38px rgba(62, 42, 23, 0.14);
}

.danger-card,
.danger-note,
.delete-room-zone,
.delete-warning,
.enemy-card.danger-here,
.metric.danger-high,
.night-attack-card {
  border: 1px solid rgba(127, 36, 30, 0.7);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 248, 234, 0.84), rgba(163, 58, 47, 0.18)),
    #ffe5df;
  color: #5a1f18;
  box-shadow: 0 8px 22px rgba(83, 27, 21, 0.16);
}

.ready-badge,
.wait-badge,
.phase,
.goal-count,
.danger-pill,
.token,
.marker {
  border: 1px solid rgba(61, 38, 24, 0.28);
  border-radius: 999px;
  box-shadow: 0 3px 8px rgba(36, 23, 15, 0.13);
  text-transform: none;
}

.map {
  border: 2px solid #4e331f;
  border-radius: 8px;
  background:
    linear-gradient(rgba(255, 248, 234, 0.12), rgba(78, 51, 31, 0.1)),
    var(--asset-map-bg) center / cover no-repeat,
    #d8a95f;
  image-rendering: auto;
  box-shadow: inset 0 0 0 1px rgba(255, 243, 207, 0.34), 0 18px 40px rgba(36, 23, 15, 0.18);
}

.road {
  stroke: rgba(69, 48, 31, 0.38);
  stroke-width: 4;
  stroke-dasharray: 9 8;
}

.loc {
  border: 1px solid rgba(61, 38, 24, 0.58);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 248, 234, 0.92), rgba(243, 217, 164, 0.78)),
    #fff6df;
  box-shadow: 0 10px 22px rgba(36, 23, 15, 0.18);
}

.loc h3 {
  border-bottom: 1px solid rgba(61, 38, 24, 0.18);
}

.loc.current {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(163, 58, 47, 0.18), 0 10px 22px rgba(36, 23, 15, 0.18);
}

.loc.reachable {
  border-color: var(--green);
}

.loc.objective {
  background:
    linear-gradient(180deg, rgba(255, 248, 234, 0.92), rgba(63, 118, 82, 0.16)),
    #eff8e8;
}

.loc.near-danger:not(.current) {
  box-shadow: 0 0 0 3px rgba(180, 125, 36, 0.2), 0 10px 22px rgba(36, 23, 15, 0.18);
}

.piece,
.enemy,
.token,
.marker,
.player-token,
.legend-token,
.player-chip {
  border-radius: 999px;
  image-rendering: auto;
}

.marker {
  min-height: 24px;
  padding-left: 8px;
  background: var(--green);
}

.player-token,
.legend-token,
.player-chip {
  border: 1px solid rgba(49, 37, 29, 0.42);
  box-shadow: 0 4px 10px rgba(36, 23, 15, 0.15);
}

.player-chip {
  min-width: 36px;
  min-height: 30px;
  padding: 4px 6px;
}

.player-chip::before {
  content: none;
}

.player-chip.is-me {
  border-color: #fffdf7;
  box-shadow: 0 0 0 2px var(--blue), 0 4px 10px rgba(36, 23, 15, 0.15);
}

.player-chip.is-active {
  outline: 2px solid var(--green);
  outline-offset: 2px;
}

.enemy,
.enemy-map-chip {
  border: 1px solid #621c17;
  background: var(--red);
  color: #fff8ea;
}

.enemy-map-chip {
  min-height: 26px;
  padding: 4px 7px;
  border-radius: 8px;
  text-shadow: none;
}

.map-legend,
.map-roster {
  border: 1px solid rgba(111, 74, 42, 0.38);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 253, 247, 0.9), rgba(243, 217, 164, 0.72)),
    #fff8ea;
  box-shadow: 0 8px 20px rgba(36, 23, 15, 0.08);
}

.modal {
  border: 1px solid rgba(61, 38, 24, 0.42);
  border-radius: 8px;
  background:
    linear-gradient(135deg, rgba(255, 248, 234, 0.94), rgba(243, 217, 164, 0.82)),
    var(--panel);
  box-shadow: 0 28px 80px rgba(27, 19, 13, 0.35);
}

.roll-modal {
  image-rendering: auto;
}

.roll-preview {
  background:
    linear-gradient(rgba(255, 248, 234, 0.82), rgba(243, 217, 164, 0.52)),
    #f3d9a4;
}

.roll-dice span {
  border: 2px solid #4e331f;
  border-radius: 12px;
  background:
    radial-gradient(circle at 30% 24%, rgba(255, 255, 255, 0.42), transparent 24%),
    linear-gradient(135deg, #fff8ea, #e7c98d);
  color: var(--ink);
  box-shadow: 0 10px 22px rgba(36, 23, 15, 0.2);
}

.roll-dice span::after {
  inset: 8px;
  border: 1px solid rgba(36, 23, 15, 0.12);
  border-radius: 8px;
}

.result-card {
  border-width: 1px;
  border-radius: 8px;
}

.result-card h3 {
  display: block;
  width: auto;
  padding: 0;
  border: 0;
  font-size: 18px;
  transform: none;
  text-transform: none;
}

.result-card h3::before {
  content: none;
}

@media (max-width: 1050px) {
  .coop-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .game-layout,
  .game-table {
    grid-template-columns: 1fr;
  }

  .lobby-grid {
    grid-template-columns: 1fr;
  }

  .map {
    min-height: 680px;
  }
}

@media (max-width: 720px) {
  .app {
    padding: 8px;
  }

  .join,
  .metrics,
  .actions,
  .top-actions,
  .home-grid,
  .home-hero,
  .lobby-head,
  .character-grid,
  .view-controls,
  .help-grid,
  .glossary {
    grid-template-columns: 1fr;
  }

  .party-hud {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .coop-grid {
    grid-template-columns: 1fr;
  }

  .hud-badge {
    min-height: 36px;
  }

  .map {
    min-height: 560px;
  }

  .home-hero,
  .lobby-head,
  .top {
    display: grid;
  }

  .invite-box {
    min-width: 0;
  }

  .secondary-tabs {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .secondary-tabs button {
    min-height: 46px;
  }

  .panel-title {
    display: grid;
  }

  .loc {
    width: 122px;
  }
}
