:root {
  color-scheme: dark;
  --ocean-950: #061f31;
  --ocean-900: #082b45;
  --ocean-800: #0b3b5c;
  --ocean-700: #0f527c;
  --ocean-600: #176b9c;
  --ocean-500: #2186bd;
  --ink: #eef8ff;
  --muted: #94b5c9;
  --line: rgba(132, 198, 231, 0.22);
  --line-strong: rgba(151, 216, 248, 0.42);
  --panel: rgba(6, 31, 49, 0.93);
  --panel-soft: rgba(10, 54, 82, 0.84);
  --orange: #f08b2d;
  --orange-strong: #ff9f3f;
  --blue: #2798dc;
  --green: #5ecb7a;
  --danger: #ff746c;
  --shadow: 0 18px 44px rgba(0, 16, 27, 0.3);
}

* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  overflow: hidden;
  background: var(--ocean-950);
  color: var(--ink);
  font-family:
    "Trebuchet MS",
    "Microsoft YaHei",
    "Segoe UI",
    sans-serif;
}

button,
input,
select {
  font: inherit;
}

button {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--panel-soft);
  color: var(--ink);
  padding: 0.62rem 0.78rem;
  cursor: pointer;
  transition:
    transform 120ms ease,
    border-color 120ms ease,
    background-color 120ms ease;
}

button:hover:not(:disabled) {
  border-color: var(--line-strong);
  background: rgba(22, 87, 124, 0.92);
}

button:active:not(:disabled) {
  transform: translateY(1px);
}

button:focus-visible,
input:focus-visible,
select:focus-visible,
summary:focus-visible {
  outline: 3px solid rgba(240, 139, 45, 0.65);
  outline-offset: 2px;
}

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

button.primary {
  border-color: #ffb165;
  background: var(--orange);
  color: #241304;
  font-weight: 800;
}

button.primary:hover:not(:disabled) {
  background: var(--orange-strong);
}

h1,
h2,
p {
  margin-top: 0;
}

.hidden {
  display: none !important;
}

.app-header {
  position: relative;
  z-index: 20;
  display: grid;
  grid-template-columns: 14rem minmax(20rem, 1fr) auto;
  align-items: center;
  gap: 1rem;
  min-height: 4.7rem;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 24, 38, 0.96);
  padding: 0.65rem 1rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  color: inherit;
  text-decoration: none;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 2.7rem;
  height: 2.7rem;
  border: 1px solid #ffc076;
  border-radius: 8px;
  background: #bd5f16;
  color: #fff5e8;
  font-size: 1.35rem;
  font-weight: 900;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.12);
}

.brand strong,
.brand small {
  display: block;
}

.brand strong {
  font-size: 1.05rem;
}

.brand small {
  color: var(--muted);
  font-size: 0.65rem;
  line-height: 1.2;
}

.header-status {
  display: grid;
  grid-template-columns: repeat(3, minmax(7rem, 1fr));
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--line);
}

.header-status > div {
  min-width: 0;
  background: rgba(9, 44, 68, 0.94);
  padding: 0.52rem 0.72rem;
}

.header-status span,
.header-status strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.header-status span {
  color: var(--muted);
  font-size: 0.64rem;
}

.header-status strong {
  margin-top: 0.12rem;
  font-size: 0.84rem;
}

.new-game {
  display: flex;
  align-items: end;
  gap: 0.55rem;
}

.new-game label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.65rem;
}

.new-game input,
.new-game select,
.online-form input,
.trade-form select,
.trade-form input {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(2, 20, 33, 0.82);
  color: var(--ink);
  padding: 0.58rem 0.66rem;
}

.new-game input {
  width: 8.8rem;
}

.app-header .new-game {
  justify-content: end;
}

.game-shell {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(21rem, 24rem);
  height: calc(100vh - 4.7rem);
  min-height: 0;
  background:
    linear-gradient(rgba(15, 82, 124, 0.22), rgba(6, 31, 49, 0.42)),
    var(--ocean-800);
}

.board-stage {
  position: relative;
  min-width: 0;
  overflow: hidden;
  background:
    linear-gradient(120deg, rgba(255, 255, 255, 0.025) 25%, transparent 25%) 0 0 / 2rem 2rem,
    linear-gradient(300deg, rgba(255, 255, 255, 0.02) 25%, transparent 25%) 0 0 / 2rem 2rem,
    radial-gradient(circle at 50% 43%, #176993 0, #0c4569 55%, #082c45 100%);
}

.board-stage::before {
  position: absolute;
  inset: 0;
  background: linear-gradient(180deg, rgba(4, 24, 38, 0.16), transparent 20%, transparent 78%, rgba(4, 24, 38, 0.42));
  content: "";
  pointer-events: none;
}

.board-toolbar {
  position: absolute;
  z-index: 7;
  top: 1rem;
  right: 1rem;
  left: 1rem;
  display: grid;
  grid-template-columns: minmax(11rem, 1fr) minmax(18rem, 2fr) minmax(8rem, 1fr);
  align-items: center;
  gap: 0.8rem;
  pointer-events: none;
}

.turn-pill,
.action-banner {
  pointer-events: none;
}

.board-tools {
  pointer-events: auto;
}

.turn-pill {
  justify-self: start;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(5, 29, 46, 0.86);
  padding: 0.48rem 0.7rem;
  box-shadow: var(--shadow);
}

.turn-pill span,
.turn-pill strong {
  display: block;
}

.turn-pill span {
  color: var(--muted);
  font-size: 0.62rem;
}

.turn-pill strong {
  margin-top: 0.08rem;
  font-size: 0.82rem;
}

.turn-timer {
  display: block;
  margin-top: 0.12rem;
  color: #9fe5b3;
  font-size: 0.66rem;
  font-variant-numeric: tabular-nums;
  font-weight: 800;
}

.turn-timer.warning {
  color: #ffd18c;
}

.turn-timer.danger {
  color: #ff8b82;
}

.action-banner {
  justify-self: center;
  min-width: min(100%, 24rem);
  border: 1px solid rgba(240, 139, 45, 0.52);
  border-radius: 6px;
  background: rgba(9, 46, 70, 0.93);
  padding: 0.62rem 1rem;
  color: #fff0d8;
  font-size: 0.82rem;
  font-weight: 750;
  text-align: center;
  box-shadow: var(--shadow);
}

.board-tools {
  display: flex;
  justify-self: end;
  align-items: center;
  gap: 0.4rem;
}

.board-tools button {
  background: rgba(5, 29, 46, 0.86);
  padding: 0.52rem 0.72rem;
  font-size: 0.72rem;
}

.zoom-level {
  min-width: 3rem;
  color: var(--muted);
  font-size: 0.68rem;
  text-align: center;
}

.board-canvas {
  position: absolute;
  inset: 4.7rem 0 13.5rem;
  display: grid;
  place-items: center;
  min-height: 0;
  overflow: hidden;
  padding: 0.5rem 1rem;
}

#board {
  display: block;
  width: 100%;
  height: 100%;
  min-width: 0;
  min-height: 0;
  max-width: 100%;
  max-height: 100%;
  overflow: visible;
  filter: drop-shadow(0 26px 30px rgba(0, 14, 24, 0.28));
}

.hex-terrain {
  stroke: rgba(255, 245, 208, 0.64);
  stroke-width: 0.035;
  stroke-linejoin: round;
}

.terrain-motif {
  opacity: 0.9;
  pointer-events: none;
}

.terrain-motif .motif-fill {
  stroke: rgba(21, 49, 35, 0.38);
  stroke-width: 0.018;
  stroke-linejoin: round;
}

.terrain-motif .motif-line {
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.terrain-motif .motif-light {
  opacity: 0.9;
}

.motif-forest .motif-fill {
  fill: #1f6035;
}

.motif-forest .motif-line {
  stroke: #5d3c20;
  stroke-width: 0.035;
}

.motif-hills .motif-fill {
  fill: #8f4d33;
}

.motif-hills .motif-light {
  fill: #d68b60;
}

.motif-pasture .motif-fill {
  fill: #f2f0df;
}

.motif-pasture .motif-line {
  stroke: #315d2e;
  stroke-width: 0.028;
}

.motif-fields .motif-line {
  stroke: #8b6d19;
  stroke-width: 0.03;
}

.motif-fields .motif-fill {
  fill: #f7d85f;
}

.motif-mountains .motif-fill {
  fill: #5f6871;
}

.motif-mountains .motif-light {
  fill: #edf4f4;
}

.motif-desert .motif-line {
  stroke: #b28745;
  stroke-width: 0.04;
}

.number-token {
  fill: #f4e6c7;
  stroke: rgba(67, 48, 27, 0.55);
  stroke-width: 0.025;
  pointer-events: none;
}

.number-token.high {
  fill: #fff0d2;
  stroke: rgba(153, 35, 30, 0.68);
}

.hex-number {
  fill: #2a2118;
  font-size: 0.28px;
  font-weight: 900;
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: central;
}

.hex-number.high {
  fill: #b42b24;
}

.resource-mark {
  fill: #5f4d35;
  font-size: 0.13px;
  font-weight: 850;
  pointer-events: none;
  text-anchor: middle;
  dominant-baseline: central;
}

.resource-mark.high {
  fill: #9f2f28;
}

.harbor-label {
  fill: #fff5d4;
  font-size: 0.22px;
  font-weight: 800;
  paint-order: stroke;
  pointer-events: none;
  stroke: #123247;
  stroke-width: 0.06;
  text-anchor: middle;
  dominant-baseline: central;
}

.road {
  stroke-linecap: round;
  stroke-width: 0.105;
}

.road-shadow {
  stroke: rgba(3, 18, 25, 0.82);
  stroke-linecap: round;
  stroke-width: 0.16;
  pointer-events: none;
}

.settlement {
  pointer-events: none;
}

.building-shell {
  transform-box: fill-box;
  transform-origin: center;
}

.building-shape {
  stroke: rgba(255, 255, 255, 0.94);
  stroke-linejoin: round;
  stroke-width: 0.028;
}

.building-detail {
  fill: rgba(24, 30, 34, 0.82);
  pointer-events: none;
}

.building-shadow {
  fill: rgba(1, 16, 24, 0.34);
  pointer-events: none;
}

.valid-target {
  cursor: pointer;
  opacity: 0.82;
}

.valid-target:hover {
  opacity: 1;
}

.valid-road {
  cursor: pointer;
  opacity: 0.45;
  pointer-events: none;
  stroke: #ffd36d;
  stroke-linecap: round;
  stroke-width: 0.16;
}

.valid-road-target {
  cursor: pointer;
  fill: #ffd36d;
  opacity: 0.28;
}

.valid-road-target:hover {
  opacity: 0.95;
}

.robber {
  fill: #11151b;
  stroke: #fff3dc;
  stroke-width: 0.04;
  pointer-events: none;
  transform-box: fill-box;
  transform-origin: center;
}

.robber-target {
  cursor: pointer;
  fill: rgba(240, 139, 45, 0.18);
  stroke: #ffb45d;
  stroke-width: 0.04;
}

.robber-target:hover {
  fill: rgba(240, 139, 45, 0.46);
}

.bottom-dock {
  position: absolute;
  z-index: 8;
  right: 1rem;
  bottom: 1rem;
  left: 1rem;
  display: grid;
  grid-template-columns: minmax(13rem, 0.8fr) minmax(22rem, 1.55fr) minmax(15rem, 1fr);
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.dock-section {
  min-width: 0;
  background: rgba(5, 30, 47, 0.95);
  padding: 0.72rem;
}

.dice-section {
  display: grid;
  grid-template-columns: minmax(7rem, 0.9fr) minmax(8rem, 1fr);
  gap: 0.55rem;
  align-items: center;
}

.dice-display {
  display: grid;
  place-items: center;
  min-height: 3.35rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #041a2a;
  color: #ffbd68;
  font-size: 1.25rem;
  font-variant-numeric: tabular-nums;
  font-weight: 900;
}

.turn-actions {
  display: grid;
  gap: 0.45rem;
}

.dock-label {
  margin-bottom: 0.38rem;
  color: var(--muted);
  font-size: 0.63rem;
}

.build-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.42rem;
}

.build-actions button {
  display: grid;
  gap: 0.16rem;
  min-height: 3.1rem;
  padding: 0.45rem;
}

.build-actions button span {
  font-size: 0.78rem;
  font-weight: 800;
}

.build-actions button small {
  color: var(--muted);
  font-size: 0.59rem;
  white-space: nowrap;
}

.build-actions button.selected {
  border-color: #ffb05a;
  background: rgba(240, 139, 45, 0.22);
}

.build-hint {
  min-height: 1rem;
  margin-top: 0.34rem;
  color: var(--muted);
  font-size: 0.65rem;
}

.hand-dock {
  display: flex;
  gap: 0.35rem;
  min-width: 0;
}

.hand-tile {
  display: grid;
  flex: 1 1 0;
  min-width: 0;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(11, 59, 92, 0.62);
  padding: 0.42rem 0.2rem;
}

.hand-tile span {
  font-size: 1rem;
  line-height: 1;
}

.hand-tile strong {
  margin-top: 0.18rem;
  font-size: 0.86rem;
}

.hand-tile small {
  overflow: hidden;
  color: var(--muted);
  font-size: 0.56rem;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.hand-tile.spectator-tile {
  flex: 1 1 auto;
  color: #c9f3d1;
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0;
}

.side-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  overflow: hidden;
  border-left: 1px solid var(--line);
  background: #061f31;
}

.side-close {
  display: none;
}

.side-tabs {
  position: sticky;
  z-index: 5;
  top: 0;
  display: grid;
  flex: 0 0 auto;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.35rem;
  border-bottom: 1px solid var(--line);
  background: rgba(4, 24, 38, 0.98);
  padding: 0.55rem;
}

.side-tab {
  min-width: 0;
  border-color: transparent;
  background: transparent;
  padding: 0.52rem 0.25rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
}

.side-tab:hover:not(:disabled) {
  border-color: var(--line);
  background: rgba(17, 73, 105, 0.58);
}

.side-tab.active {
  border-color: rgba(240, 139, 45, 0.55);
  background: rgba(240, 139, 45, 0.16);
  color: #fff0d8;
}

.side-section {
  border-bottom: 1px solid var(--line);
  padding: 0.9rem;
}

.side-view {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  border-bottom: 0;
  padding: 1rem;
}

.side-heading,
.online-panel summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.side-heading {
  margin-bottom: 0.72rem;
}

.side-heading h2,
.online-panel summary span {
  margin: 0;
  font-size: 0.88rem;
  font-weight: 850;
}

.side-heading span,
.online-panel summary small {
  color: var(--muted);
  font-size: 0.66rem;
}

.side-heading-actions {
  display: flex;
  gap: 0.35rem;
}

.side-heading-actions button {
  padding: 0.3rem 0.48rem;
  font-size: 0.64rem;
}

.online-panel summary {
  cursor: pointer;
  list-style: none;
}

.online-panel summary::-webkit-details-marker {
  display: none;
}

.side-section-body {
  padding-top: 0.75rem;
}

.online-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.5rem;
}

.online-form label,
.trade-form label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.66rem;
}

.online-form button,
.online-actions button {
  grid-column: auto;
}

.online-full-field {
  grid-column: 1 / 3;
}

.copy-status {
  min-height: 1rem;
  margin-top: 0.42rem;
  color: var(--green);
  font-size: 0.66rem;
}

.online-seats {
  display: grid;
  gap: 1px;
  margin: 0.65rem 0;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--line);
}

.online-seat {
  display: flex;
  justify-content: space-between;
  gap: 0.75rem;
  background: rgba(8, 43, 69, 0.84);
  padding: 0.46rem 0.58rem;
  color: var(--muted);
  font-size: 0.68rem;
}

.online-spectators {
  display: flex;
  flex-wrap: wrap;
  gap: 0.32rem;
  min-height: 0;
  margin-bottom: 0.65rem;
}

.spectator-chip {
  border: 1px solid rgba(94, 203, 122, 0.34);
  border-radius: 999px;
  background: rgba(32, 91, 58, 0.34);
  padding: 0.22rem 0.48rem;
  color: #c9f3d1;
  font-size: 0.64rem;
}

.spectator-chip.empty {
  border-color: var(--line);
  background: rgba(6, 31, 49, 0.56);
  color: var(--muted);
}

.online-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.42rem;
}

.host-settings {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
  margin-top: 0.75rem;
  border-top: 1px solid var(--line);
  padding-top: 0.75rem;
}

.host-settings-title {
  grid-column: 1 / 3;
  color: #ffd18c;
  font-size: 0.72rem;
  font-weight: 800;
}

.host-settings label {
  display: grid;
  gap: 0.25rem;
  color: var(--muted);
  font-size: 0.66rem;
}

.host-settings select,
.host-settings input[type="number"] {
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(2, 20, 33, 0.82);
  color: var(--ink);
  padding: 0.48rem 0.5rem;
}

.host-settings .host-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding-top: 0.45rem;
}

.host-settings button {
  min-width: 0;
}

.online-control-list {
  display: grid;
  gap: 0.35rem;
  margin-top: 0.55rem;
}

.online-control-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(6, 31, 49, 0.56);
  padding: 0.38rem 0.48rem;
  color: var(--muted);
  font-size: 0.66rem;
}

.online-control-row button {
  padding: 0.3rem 0.48rem;
  font-size: 0.64rem;
}

.special-controls {
  display: grid;
  gap: 0.55rem;
  border-top: 1px solid var(--line);
  padding-top: 0.7rem;
}

.special-controls:first-child {
  border-top: 0;
  padding-top: 0;
}

.special-summary {
  color: #ffd18c;
  font-size: 0.72rem;
}

.resource-choice-list,
.choice-list {
  display: grid;
  gap: 0.42rem;
}

.resource-choice {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto auto;
  gap: 0.32rem;
  align-items: center;
}

.resource-choice span {
  color: var(--muted);
  font-size: 0.68rem;
}

.resource-choice button {
  min-width: 1.9rem;
  padding: 0.32rem;
}

.choice-list button {
  text-align: left;
}

.development-card-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.35rem;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(7, 40, 63, 0.7);
  padding: 0.48rem 0.55rem;
}

.development-card-row > div {
  display: grid;
  gap: 0.12rem;
}

.development-card-row strong {
  font-size: 0.74rem;
}

.development-card-row span {
  color: var(--muted);
  font-size: 0.63rem;
}

.development-card-row button {
  padding: 0.33rem 0.5rem;
  font-size: 0.68rem;
}

.trade-form {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.45rem;
}

.trade-form button {
  grid-column: 1 / 3;
}

.trade-builder-head,
.trade-builder-row {
  grid-column: 1 / 3;
  display: grid;
  grid-template-columns: minmax(5rem, 1fr) auto auto;
  gap: 0.35rem;
  align-items: center;
}

.trade-builder-head {
  color: var(--muted);
  font-size: 0.62rem;
}

.trade-builder-head span:nth-child(2),
.trade-builder-head span:nth-child(3) {
  text-align: center;
}

.trade-builder {
  grid-column: 1 / 3;
  display: grid;
  gap: 0.35rem;
}

.trade-builder-row span {
  color: #dcecf5;
  font-size: 0.68rem;
}

.trade-stepper {
  display: grid;
  width: 5.9rem;
  grid-template-columns: 1.4rem minmax(2.3rem, 1fr) 1.4rem;
  gap: 0.2rem;
  align-items: center;
}

.trade-stepper button {
  width: 100%;
  min-width: 0;
  grid-column: auto;
  padding: 0.32rem 0;
}

.trade-builder-row input {
  width: 100%;
  min-width: 0;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(2, 20, 33, 0.82);
  color: var(--ink);
  padding: 0.38rem 0.3rem;
  text-align: center;
}

.trade-builder-row input::-webkit-outer-spin-button,
.trade-builder-row input::-webkit-inner-spin-button {
  margin: 0;
  appearance: none;
}

.empty-state {
  color: var(--muted);
  font-size: 0.7rem;
}

.players {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: var(--line);
}

.player-row {
  display: grid;
  grid-template-columns: 0.68rem minmax(0, 1fr) auto;
  gap: 0.58rem;
  align-items: start;
  background: rgba(7, 40, 63, 0.76);
  padding: 0.62rem;
}

.player-row.current {
  background: rgba(21, 100, 142, 0.52);
  box-shadow: inset 3px 0 0 var(--orange);
}

.swatch {
  width: 0.68rem;
  height: 0.68rem;
  margin-top: 0.16rem;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 50%;
}

.player-name {
  min-width: 0;
  overflow: hidden;
  font-size: 0.78rem;
  font-weight: 850;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-meta {
  color: var(--muted);
  font-size: 0.62rem;
  line-height: 1.35;
}

.resource-row {
  grid-column: 2 / 4;
  display: flex;
  flex-wrap: wrap;
  gap: 0.28rem;
}

.resource-chip {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(6, 31, 49, 0.72);
  padding: 0.16rem 0.38rem;
  color: #dcecf5;
  font-size: 0.63rem;
}

.log-panel {
  min-height: 18rem;
}

.event-log {
  display: grid;
  gap: 0.48rem;
  max-height: 25rem;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.event-log li {
  display: grid;
  grid-template-columns: 2rem 1fr;
  gap: 0.55rem;
  color: #d6e9f4;
  font-size: 0.68rem;
}

.event-log time {
  color: var(--muted);
  font-variant-numeric: tabular-nums;
}

.match-history-summary {
  display: grid;
  gap: 0.4rem;
  margin-bottom: 0.75rem;
}

.history-status {
  min-height: 1rem;
  margin-bottom: 0.55rem;
  color: var(--muted);
  font-size: 0.66rem;
}

.match-history-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(7, 40, 63, 0.58);
  padding: 0.5rem 0.58rem;
}

.match-history-row strong,
.match-history-row span {
  display: block;
}

.match-history-row strong {
  font-size: 0.72rem;
}

.match-history-row span {
  margin-top: 0.15rem;
  color: var(--muted);
  font-size: 0.63rem;
}

.completion {
  position: absolute;
  z-index: 12;
  top: 50%;
  left: 50%;
  width: min(30rem, calc(100% - 2rem));
  transform: translate(-50%, -50%);
  border: 1px solid #ffc076;
  border-radius: 8px;
  background: rgba(5, 30, 47, 0.96);
  box-shadow: var(--shadow);
  padding: 1rem 1.2rem;
  color: #fff2da;
  font-weight: 800;
  text-align: center;
}

.modal {
  position: fixed;
  z-index: 50;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(1, 14, 23, 0.72);
  padding: 1rem;
}

.modal-content {
  width: min(30rem, 100%);
  border: 1px solid var(--line-strong);
  border-radius: 8px;
  background: #082b45;
  box-shadow: var(--shadow);
  padding: 1rem;
}

.modal-content ul {
  margin: 0;
  padding-left: 1.2rem;
  color: #d8ebf5;
  font-size: 0.78rem;
  line-height: 1.7;
}

.replay-modal-content {
  width: min(44rem, 100%);
}

.replay-meta {
  display: block;
  margin-top: 0.2rem;
  color: var(--muted);
  font-size: 0.66rem;
}

.replay-event-detail {
  min-height: 4.2rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(2, 20, 33, 0.72);
  padding: 0.75rem;
  color: #f7e2b8;
  font-size: 0.78rem;
  line-height: 1.5;
}

.replay-controls {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 0.45rem;
  margin-top: 0.6rem;
}

.replay-range {
  width: 100%;
  margin: 0.65rem 0;
}

.replay-event-list {
  display: grid;
  gap: 0.3rem;
  max-height: 18rem;
  margin: 0;
  padding: 0;
  overflow: auto;
  list-style: none;
}

.replay-event-list li {
  border-left: 2px solid transparent;
  padding: 0.3rem 0.45rem;
  color: var(--muted);
  font-size: 0.65rem;
}

.replay-event-list li.active {
  border-left-color: var(--orange);
  background: rgba(240, 139, 45, 0.12);
  color: #fff0d8;
}

body.sidebar-collapsed .game-shell {
  grid-template-columns: minmax(0, 1fr) 0;
}

body.sidebar-collapsed .side-panel {
  visibility: hidden;
  opacity: 0;
  overflow: hidden;
}

.side-panel {
  transition:
    opacity 160ms ease,
    visibility 160ms ease;
}

.dice-display.rolling {
  animation: dice-roll 520ms ease;
}

.hand-dock.receiving .hand-tile {
  animation: resource-receive 420ms ease;
}

.board-stage.board-fx-road .road-color {
  animation: road-draw 380ms ease;
}

.board-stage.board-fx-build .building-shell {
  animation: build-pop 320ms ease;
}

.board-stage.board-fx-robber .robber {
  animation: robber-move 360ms ease;
}

@keyframes dice-roll {
  0% {
    transform: rotate(0deg) scale(1);
  }
  35% {
    transform: rotate(-8deg) scale(1.08);
  }
  70% {
    transform: rotate(7deg) scale(0.96);
  }
  100% {
    transform: rotate(0deg) scale(1);
  }
}

@keyframes resource-receive {
  0% {
    transform: translateY(8px);
    opacity: 0.35;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

@keyframes road-draw {
  from {
    stroke-dasharray: 0.6;
    stroke-dashoffset: 0.6;
  }
  to {
    stroke-dasharray: 0.6;
    stroke-dashoffset: 0;
  }
}

@keyframes build-pop {
  0% {
    transform: scale(0.55);
  }
  75% {
    transform: scale(1.12);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes robber-move {
  0% {
    /* 这里的 px 是 SVG 用户单位：棋盘 viewBox 只有 10 个单位宽，
       写 -6px 等于往上飞 6 个单位，整块棋盘都跨过去了。 */
    transform: translateY(-0.25px) scale(0.82);
  }
  100% {
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 1200px) {
  .app-header {
    grid-template-columns: 11rem minmax(16rem, 1fr) auto;
  }

  .game-shell {
    grid-template-columns: minmax(0, 1fr) 18rem;
  }

  .bottom-dock {
    grid-template-columns: 7.5rem minmax(12rem, 1fr) 8.5rem;
  }

  .dice-section {
    grid-template-columns: 1fr;
  }

  .dice-display {
    min-height: 2.7rem;
  }
}

@media (max-width: 640px) {
  body {
    overflow: hidden;
  }

  .app-header {
    position: static;
    grid-template-columns: 1fr auto;
    min-height: auto;
  }

  .header-status {
    grid-column: 1 / 3;
    order: unset;
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }

  .new-game {
    grid-column: 1 / 3;
    flex-wrap: wrap;
    justify-content: start;
  }

  .game-shell {
    display: block;
    height: calc(100vh - 9rem);
    min-height: 0;
  }

  .board-stage {
    height: 100%;
    min-height: 0;
  }

  .side-panel {
    position: fixed;
    z-index: 45;
    top: 13rem;
    right: 0;
    bottom: 0;
    width: min(22rem, calc(100vw - 1.5rem));
    border-left: 1px solid var(--line);
    box-shadow: -20px 0 50px rgba(0, 12, 22, 0.42);
    overflow-y: auto;
    padding-top: 0;
  }

  .side-close {
    position: sticky;
    z-index: 2;
    top: 0.65rem;
    display: block;
    width: calc(100% - 1.2rem);
    margin: 0.6rem;
  }

  .bottom-dock {
    grid-template-columns: 7rem minmax(12rem, 1fr) 8rem;
  }
}

@media (max-width: 680px) {
  .app-header {
    padding: 0.7rem;
  }

  .board-toolbar {
    grid-template-columns: 1fr;
    align-items: stretch;
  }

  .turn-pill,
  .action-banner,
  .board-tools {
    justify-self: stretch;
  }

  .board-tools {
    justify-content: end;
  }

  .board-canvas {
    inset: 9.5rem 0 13rem;
  }

  .bottom-dock {
    right: 0.55rem;
    bottom: 0.55rem;
    left: 0.55rem;
    grid-template-columns: 7rem minmax(12rem, 1fr) 8rem;
  }

  .side-panel {
    font-size: 0.95rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
  }
}
