:root {
  color-scheme: dark;
  --ink: #172d36;
  --paper: #e9dfc8;
  --gold: #c7a969;
  --muted: #b9b9a7;
}
* {
  box-sizing: border-box;
}
body {
  margin: 0;
  background: var(--ink);
  color: var(--paper);
  font:
    15px "Noto Sans",
    sans-serif;
}
button,
input,
select {
  font: inherit;
}
button {
  min-height: 44px;
  border: 1px solid #bd9e6066;
  border-radius: 5px;
  color: var(--paper);
  background: #233e48;
  padding: 10px 18px;
  cursor: pointer;
  transition:
    background 0.15s,
    transform 0.15s;
}
button:hover:not(:disabled) {
  background: #35515b;
  border-color: var(--gold);
}
button:active {
  transform: translateY(1px);
}
button:disabled {
  opacity: 0.45;
  cursor: default;
}
button.primary {
  background: linear-gradient(#ddc18a, #b7975e);
  color: #172d36;
  font-weight: 600;
  border-color: #eddaa9;
  box-shadow: 0 4px 15px #080f1738;
}
button.danger {
  border-color: #b86a6a;
  color: #f5bbbb;
}
button.ghost {
  background: transparent;
}
button:focus-visible,
a:focus-visible,
input:focus-visible,
select:focus-visible,
canvas:focus-visible {
  outline: 2px solid #f0ce83;
  outline-offset: 3px;
}
h1,
h2,
h3 {
  font-family: "Noto Serif Display", Georgia, serif;
  font-weight: 600;
}
h1 {
  font-size: clamp(38px, 4.4vw, 66px);
  line-height: 1.08;
  margin: 14px 0 20px;
}
h2 {
  font-size: 32px;
  margin: 0 0 20px;
}
h3 {
  font-size: 23px;
  margin: 8px 0;
}
p {
  line-height: 1.6;
}
.eyebrow {
  letter-spacing: 0.22em;
  color: var(--gold);
  text-transform: uppercase;
  font-size: 12px;
}
.muted,
small {
  color: var(--muted);
}
.row {
  display: flex;
  gap: 10px;
  align-items: center;
  flex-wrap: wrap;
}
.between {
  justify-content: space-between;
}
.stack {
  display: grid;
  gap: 10px;
}
.panel {
  background: linear-gradient(135deg, #1e3741f5, #122831f5);
  border: 1px solid #b99b5c66;
  border-radius: 9px;
  padding: 24px;
  box-shadow: 0 15px 50px #050f2433;
}
.screen {
  min-height: 100dvh;
  padding: clamp(18px, 4vw, 56px);
  background: radial-gradient(at 70% 10%, #345158, #172d36 70%);
}
.menu {
  min-height: 100dvh;
  background: #172d36 url("./assets/menu.png") center/cover no-repeat;
  display: flex;
  align-items: center;
  padding: 5vw;
}
.menu-content {
  width: min(430px, 100%);
  background: linear-gradient(90deg, #172d36ed, #172d3655);
  padding: 24px;
}
.menu .primary {
  font-size: 19px;
  min-height: 58px;
}
.menu-footer {
  margin-top: 28px;
}
.profile-chip {
  padding: 12px 0;
  border-bottom: 1px solid #bb9d5c55;
  margin-bottom: 20px;
}
.rank {
  color: var(--gold);
}
.badge {
  border: 1px solid #b99b5c66;
  padding: 4px 9px;
  border-radius: 4px;
  font-size: 12px;
}
.center-screen {
  display: grid;
  place-items: center;
  min-height: 100dvh;
  background: #172d36 url("./assets/menu.png") center/cover;
}
.center-screen > .panel {
  width: min(530px, calc(100vw - 32px));
  text-align: center;
}
.spinner {
  width: 70px;
  height: 70px;
  border: 2px solid #bb9d5c44;
  border-top-color: var(--gold);
  border-radius: 50%;
  animation: spin 2s linear infinite;
  margin: 25px auto;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
#board {
  display: none;
  position: fixed;
  inset: 0;
  touch-action: none;
}
.playing #board {
  display: block;
}
.hud {
  position: fixed;
  inset: 14px 18px auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 13px 20px;
  background: #142c36ed;
  border: 1px solid #b99b5c80;
  border-radius: 7px;
  box-shadow: 0 5px 18px #0c182833;
  pointer-events: auto;
}
.player {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 160px;
}
.crest {
  font-size: 28px;
  color: #74a9d1;
}
.crest.red {
  color: #d58e95;
}
.player-name {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.clock {
  font-variant-numeric: tabular-nums;
  font-size: 24px;
  color: #eee4cb;
}
.clock.urgent {
  color: #ffb3a1;
}
.turn {
  text-align: center;
}
.turn strong {
  font-size: 17px;
}
.objective {
  position: fixed;
  top: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: #17313be8;
  padding: 10px 20px;
  border-radius: 5px;
  max-width: 90vw;
  text-align: center;
  font-size: 13px;
}
.board-bottom {
  position: fixed;
  bottom: max(18px, env(safe-area-inset-bottom));
  left: 18px;
  right: 18px;
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}
.board-bottom > * {
  pointer-events: auto;
}
.selection {
  width: min(430px, 100%);
  padding: 13px 18px;
}
.toolbar {
  display: flex;
  gap: 5px;
  flex-wrap: wrap;
  max-width: 260px;
}
.toolbar button {
  padding: 8px 12px;
}
.campaign-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 20px;
  margin-top: 24px;
}
.map-wrap {
  overflow: auto;
  border: 1px solid #ba9a66;
  border-radius: 8px;
  background: #cdc4a4;
}
.map {
  position: relative;
  min-width: 700px;
  aspect-ratio: 5/3;
  background: url("./assets/map.png") center/100% 100%;
  color: #172d36;
}
.map svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.node {
  position: absolute;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 50%;
  border: 2px solid #ebd7a4;
  background: #274955;
  box-shadow: 0 3px 7px #152a3380;
}
.node.selected {
  outline: 3px solid #8b6439;
  outline-offset: 3px;
}
.node small {
  position: absolute;
  top: 43px;
  left: 50%;
  transform: translateX(-50%);
  white-space: nowrap;
  color: #754b15;
  font-size: 12px;
}
.node:disabled {
  opacity: 1;
  background: #7f806e;
  color: #d6d4bd;
}
.settings {
  max-width: 720px;
  margin: auto;
}
.setting {
  display: flex;
  justify-content: space-between;
  gap: 20px;
  padding: 14px 0;
  border-bottom: 1px solid #cab17133;
}
.setting input[type="range"] {
  width: 180px;
}
.setting input[type="checkbox"] {
  width: 24px;
  height: 24px;
  accent-color: var(--gold);
}
input,
select {
  background: #142b34;
  color: var(--paper);
  border: 1px solid #ad925c;
  padding: 10px;
  border-radius: 4px;
  max-width: 100%;
}
input.code {
  font-size: 24px;
  letter-spacing: 0.15em;
  width: 100%;
  text-transform: uppercase;
}
.code-display {
  font-size: 36px;
  letter-spacing: 0.13em;
  color: var(--gold);
  font-variant-numeric: tabular-nums;
}
.history-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 13px 0;
  border-bottom: 1px solid #cab17133;
}
.stars {
  color: #ecd18b;
  font-size: 25px;
  letter-spacing: 8px;
}
.replay-controls {
  max-width: 600px;
  width: 100%;
  margin: auto;
}
.replay-controls input {
  width: 100%;
}
#toast {
  position: fixed;
  z-index: 30;
  bottom: 120px;
  left: 50%;
  transform: translateX(-50%);
  max-width: min(550px, 90vw);
  padding: 12px 20px;
  background: #142831f5;
  border: 1px solid #d6b974;
  border-radius: 6px;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s;
}
#toast.show {
  opacity: 1;
}
dialog {
  background: #1a333e;
  color: var(--paper);
  border: 1px solid #c3a36c;
  border-radius: 9px;
  padding: 28px;
  width: min(600px, calc(100vw - 30px));
  max-height: calc(100dvh - 30px);
  overflow: auto;
  box-shadow: 0 20px 80px #0009;
}
dialog::backdrop {
  background: #08162099;
  backdrop-filter: blur(3px);
}
dialog .row {
  margin-top: 20px;
}
.error {
  color: #eeb4a5;
}
.stat {
  font-size: 36px;
  font-family: "Noto Serif Display", serif;
  color: var(--gold);
}
.result {
  animation: rise 0.3s ease-out;
}
@keyframes rise {
  from {
    opacity: 0;
    transform: translateY(15px);
  }
}
body.reduce *,
body.reduce *:before {
  animation: none !important;
  transition: none !important;
}
.high-contrast {
  --muted: #eeeece;
  --gold: #ffe1a1;
}
.high-contrast .hud,
.high-contrast .panel {
  background: #081c26;
}
a {
  color: var(--gold);
}
@media (max-width: 700px) {
  .menu {
    align-items: end;
    padding: 18px;
    background-position: 62% center;
  }
  .menu-content {
    padding: 22px;
    background: #142c36ed;
    border: 1px solid #c0a26755;
    border-radius: 8px;
  }
  .menu h1 {
    font-size: 38px;
  }
  .menu-footer {
    margin-top: 16px;
  }
  .screen {
    padding: 18px;
  }
  .campaign-layout {
    grid-template-columns: 1fr;
  }
  .campaign-layout > .panel {
    padding: 18px;
  }
  .map-wrap {
    max-height: 50vh;
  }
  .hud {
    inset: 6px 6px auto;
    padding: 9px;
    gap: 6px;
    flex-wrap: wrap;
  }
  .player {
    min-width: 0;
    flex: 1;
  }
  .player-name {
    max-width: 95px;
    font-size: 12px;
  }
  .clock {
    font-size: 20px;
  }
  .crest {
    font-size: 22px;
  }
  .turn {
    order: 3;
    width: 100%;
    display: flex;
    justify-content: center;
    gap: 12px;
    font-size: 12px;
  }
  .turn strong {
    font-size: 14px;
  }
  .objective {
    top: 112px;
    padding: 8px 10px;
    width: max-content;
    max-width: 95vw;
    font-size: 12px;
  }
  .board-bottom {
    left: 8px;
    right: 8px;
    bottom: 8px;
    flex-wrap: wrap;
  }
  .toolbar {
    max-width: none;
    flex: 1;
  }
  .selection {
    width: 100%;
    order: -1;
  }
  .setting input[type="range"] {
    width: 120px;
  }
  h2 {
    font-size: 28px;
  }
  .center-screen > .panel {
    padding: 22px;
  }
  .badge {
    font-size: 11px;
  }
  .panel {
    padding: 20px;
  }
}

.minimap {
  width: 128px;
  height: 96px;
  display: block;
  flex-basis: 100%;
  cursor: crosshair;
  max-width: 128px;
  overflow: hidden;
  border-radius: 4px;
}
.move-journal {
  max-height: 240px;
  overflow: auto;
  line-height: 1.9;
}
.menu {
  background-size: cover;
}
.panel,
dialog[open] {
  animation: rise 0.18s ease-out;
}
.playing .toolbar {
  max-width: 330px;
  align-items: center;
}
@media (max-width: 700px) {
  .minimap {
    width: 80px;
    height: 60px;
    max-width: 80px;
    flex-basis: auto;
  }
  .playing .toolbar {
    max-width: none;
  }
}

.icon {
  width: 24px;
  height: 24px;
  vertical-align: middle;
  display: inline-block;
  pointer-events: none;
}
button:has(> .icon) {
  min-width: 44px;
}
.row button .icon {
  margin-right: 2px;
}
.mp-screen .settings { max-width: 820px; }
.mp-screen .row { flex-wrap: wrap; }
.mp-screen details { line-height:1.65; margin:20px 0; }
.mp-leaderboard { padding-left:28px; }
.mp-leaderboard li { padding:8px 0; }
.mp-leaderboard li strong { float:right; }
.mp-leaderboard li span { overflow-wrap:anywhere; }
.light {
  color-scheme:light; --ink:#eee6d5; --paper:#20343b; --gold:#73551c; --muted:#4e5d5d;
}
.light .panel,.light dialog,.light .hud,.light .objective,.light .profile-chip {
  background:#f8f1e4; color:#20343b; border-color:#907747;
}
.light button,.light input,.light select { background:#f8f1e4;color:#20343b;border-color:#907747; }
.light button.primary { background:#72551e;color:#fff8e8; }
.light button.danger { background:#883941;color:white; }
.light .menu-content { background:#f8f1e4f2;padding:24px;border-radius:12px; }
.light .menu .muted,.light .menu small { color:#42535a; }
.light .clock {color:#263d43;}
.light .rank {color:#745016;}
.light .node {background:#edf0df;color:#16313c;}
.light .node:disabled {background:#dedbcf;color:#4c5149;}
.light .error {color:#942e35;}
@media(max-width:500px){.mp-screen .setting {flex-wrap:wrap;gap:8px;}.mp-screen select{width:100%;}.mp-screen .row button{flex:1 1 130px;}.light .menu-content{padding:16px;}}
.light .screen { background:radial-gradient(at 70% 10%,#fff8e8,#e6dcc5 70%); }
.light .center-screen { background:linear-gradient(#eee6d5e8,#d9cdb4ed); }
.light .mp-screen h2 {color:#20343b;}
.mp-screen h2 {overflow-wrap:anywhere;}
