:root {
  color-scheme: dark;
  --ink: #071d20;
  --basalt: #102f32;
  --basalt-soft: rgba(9, 34, 37, 0.88);
  --paper: #f5f0e6;
  --paper-ink: #10282a;
  --muted: #a8c3c0;
  --line: rgba(232, 245, 240, 0.22);
  --red: #e34b45;
  --red-dark: #a62d35;
  --cyan: #2fc8d2;
  --gold: #f2bd4a;
  --green: #79a84b;
  --shadow: rgba(3, 15, 17, 0.46);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  letter-spacing: 0;
  overscroll-behavior: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

button {
  font: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100dvh;
  min-height: 520px;
  overflow: hidden;
  isolation: isolate;
  background: #0c4851;
  color: var(--paper);
}

.sea-backdrop {
  position: absolute;
  inset: 0;
  z-index: -2;
  background-image: url("assets/faroese-sea.png");
  background-size: max(165vw, 165vh);
  background-position: center;
  transform: scale(1.025);
}

.sea-backdrop::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(4, 31, 36, 0.24);
  box-shadow: inset 0 0 180px rgba(2, 18, 21, 0.45);
}

#battlefield {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  touch-action: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  cursor: crosshair;
}

.topbar {
  position: absolute;
  z-index: 5;
  top: 0;
  left: 0;
  right: 0;
  min-height: 84px;
  padding: max(16px, env(safe-area-inset-top)) max(18px, env(safe-area-inset-right)) 12px max(18px, env(safe-area-inset-left));
  display: grid;
  grid-template-columns: minmax(132px, 1fr) auto minmax(132px, 1fr);
  align-items: center;
  gap: 16px;
  pointer-events: none;
}

.brand,
.top-actions,
.level-readout,
.faction-legend,
.command-dock {
  filter: drop-shadow(0 3px 10px var(--shadow));
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
}

.flag-mark {
  position: relative;
  width: 42px;
  height: 28px;
  flex: 0 0 auto;
  overflow: hidden;
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 3px;
  background: #f7f4eb;
  box-shadow: 0 2px 0 rgba(0, 0, 0, 0.18);
}

.flag-mark::before,
.flag-mark::after,
.flag-mark i::before,
.flag-mark i::after {
  content: "";
  position: absolute;
}

.flag-mark::before {
  left: 12px;
  top: 0;
  width: 9px;
  height: 100%;
  background: #245894;
}

.flag-mark::after {
  left: 0;
  top: 9px;
  width: 100%;
  height: 9px;
  background: #245894;
}

.flag-mark i::before {
  left: 15px;
  top: 0;
  width: 3px;
  height: 100%;
  z-index: 1;
  background: var(--red);
}

.flag-mark i::after {
  left: 0;
  top: 12px;
  width: 100%;
  height: 3px;
  z-index: 1;
  background: var(--red);
}

.brand-copy {
  display: flex;
  flex-direction: column;
  line-height: 0.9;
  font-size: 13px;
}

.brand-copy strong {
  color: var(--paper);
  font-size: 16px;
}

.brand-copy span {
  color: var(--cyan);
  font-weight: 800;
}

.level-readout {
  min-width: 182px;
  padding: 9px 20px 10px;
  text-align: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--basalt-soft);
  backdrop-filter: blur(9px);
}

.level-readout span,
.chapter-kicker {
  display: block;
  color: var(--cyan);
  font-size: 10px;
  font-weight: 850;
  text-transform: uppercase;
}

.level-readout strong {
  display: block;
  margin-top: 2px;
  overflow: hidden;
  color: var(--paper);
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.top-actions {
  justify-self: end;
  display: flex;
  align-items: center;
  gap: 9px;
  pointer-events: auto;
}

.coin-readout {
  height: 42px;
  min-width: 84px;
  padding: 0 13px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 5px;
  background: var(--basalt-soft);
  backdrop-filter: blur(9px);
}

.coin {
  width: 18px;
  height: 18px;
  display: inline-block;
  flex: 0 0 auto;
  border: 3px solid #ffe59a;
  border-radius: 50%;
  background: var(--gold);
  box-shadow: 0 2px 0 #9d6d1f;
}

.icon-button {
  width: 42px;
  height: 42px;
  padding: 0;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--paper);
  background: var(--basalt-soft);
  cursor: pointer;
  backdrop-filter: blur(9px);
}

.icon-button:hover,
.icon-button:focus-visible {
  background: #1a4749;
}

.icon-button svg,
.button svg {
  width: 20px;
  height: 20px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.icon-button.light {
  color: var(--paper-ink);
  border-color: rgba(16, 40, 42, 0.18);
  background: rgba(16, 40, 42, 0.08);
  backdrop-filter: none;
}

.faction-legend {
  position: absolute;
  z-index: 4;
  top: 104px;
  left: max(18px, env(safe-area-inset-left));
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
}

.faction-row {
  width: 118px;
  padding: 6px 9px;
  display: grid;
  grid-template-columns: 10px 1fr auto;
  align-items: center;
  gap: 7px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  background: rgba(7, 29, 32, 0.74);
  color: var(--paper);
  font-size: 11px;
  backdrop-filter: blur(7px);
}

.faction-power {
  font-variant-numeric: tabular-nums;
}

.faction-share {
  grid-column: 1 / -1;
  width: 100%;
  height: 4px;
  overflow: hidden;
  border-radius: 2px;
  background: rgba(255, 255, 255, 0.13);
}

.faction-share-fill {
  width: var(--faction-share, 0%);
  height: 100%;
  display: block;
  border-radius: inherit;
  background: var(--faction-color);
  transition: width 180ms linear;
}

.faction-row.is-out {
  opacity: 0.4;
}

.faction-dot,
.intro-dot {
  width: 9px;
  height: 9px;
  display: inline-block;
  border: 2px solid rgba(255, 255, 255, 0.6);
  border-radius: 50%;
  background: var(--faction-color);
}

.faction-row strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.command-dock {
  position: absolute;
  z-index: 5;
  left: 50%;
  bottom: max(18px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  min-width: 350px;
  height: 56px;
  padding: 7px;
  display: flex;
  align-items: stretch;
  gap: 9px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(7, 29, 32, 0.88);
  box-shadow: 0 8px 28px var(--shadow);
  pointer-events: auto;
  backdrop-filter: blur(10px);
}

.send-control {
  display: grid;
  grid-template-columns: repeat(3, minmax(55px, 1fr));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 4px;
}

.send-control button {
  min-width: 0;
  padding: 0 10px;
  border: 0;
  border-right: 1px solid rgba(255, 255, 255, 0.14);
  color: var(--muted);
  background: transparent;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.send-control button:last-child {
  border-right: 0;
}

.send-control button.is-active {
  color: var(--ink);
  background: var(--paper);
}

.surge-button {
  position: relative;
  width: 42px;
  height: 42px;
  flex: 0 0 auto;
  padding: 0;
  border: 0;
  border-left: 1px solid var(--line);
  color: var(--cyan);
  background: transparent;
  cursor: pointer;
}

.surge-button.is-locked {
  display: none;
}

.surge-button:disabled {
  cursor: default;
}

.surge-button svg {
  width: 38px;
  height: 38px;
  overflow: visible;
}

.surge-track,
.surge-progress {
  fill: none;
  stroke-width: 3;
}

.surge-track {
  stroke: rgba(255, 255, 255, 0.16);
}

.surge-progress {
  stroke: currentColor;
  stroke-dasharray: 100;
  stroke-dashoffset: 100;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 20px 20px;
  transition: stroke-dashoffset 160ms linear;
}

.surge-bolt {
  fill: currentColor;
  stroke: none;
  opacity: 0.45;
}

.surge-button.is-ready {
  color: var(--gold);
  animation: surge-ready 1.1s ease-in-out infinite;
}

.surge-button.is-ready .surge-bolt,
.surge-button.is-active .surge-bolt {
  opacity: 1;
}

.surge-button.is-active {
  color: var(--paper);
  background: var(--red);
  border-left-color: transparent;
  border-radius: 4px;
}

.surge-button[data-tooltip]::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 11px);
  padding: 6px 8px;
  border-radius: 3px;
  color: var(--paper);
  background: rgba(7, 29, 32, 0.94);
  font-size: 10px;
  font-weight: 750;
  white-space: nowrap;
  opacity: 0;
  transform: translate(-50%, 4px);
  transition: opacity 120ms ease, transform 120ms ease;
  pointer-events: none;
}

.surge-button[data-tooltip]:hover::after,
.surge-button[data-tooltip]:focus-visible::after {
  opacity: 1;
  transform: translate(-50%, 0);
}

@keyframes surge-ready {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.power-meter {
  width: 72px;
  padding: 2px 8px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border-left: 1px solid var(--line);
  color: var(--paper);
}

.power-meter span {
  font-size: 18px;
  font-weight: 850;
  line-height: 1;
  font-variant-numeric: tabular-nums;
}

.power-meter small {
  margin-top: 3px;
  color: var(--cyan);
  font-size: 8px;
  font-weight: 850;
}

.overlay {
  position: absolute;
  z-index: 20;
  inset: 0;
  padding: max(88px, env(safe-area-inset-top)) 18px max(82px, env(safe-area-inset-bottom));
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(3, 20, 23, 0.62);
  backdrop-filter: blur(4px);
}

.overlay.is-visible {
  display: flex;
  animation: overlay-in 180ms ease-out both;
}

@keyframes overlay-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  width: min(430px, 100%);
  max-height: 100%;
  overflow: auto;
  padding: 30px;
  border: 1px solid rgba(255, 255, 255, 0.7);
  border-radius: 7px;
  color: var(--paper-ink);
  background: var(--paper);
  box-shadow: 0 18px 60px rgba(3, 17, 19, 0.5), 0 5px 0 rgba(6, 26, 29, 0.28);
  text-align: center;
}

.modal h1,
.modal h2 {
  margin: 6px 0;
  color: var(--paper-ink);
  font-size: clamp(28px, 5vw, 42px);
  line-height: 1.02;
}

.modal p {
  margin: 8px 0 0;
  color: #526567;
}

.modal .chapter-kicker {
  color: var(--red-dark);
}

.intro-factions {
  min-height: 26px;
  margin: 22px 0 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
}

.intro-factions .intro-dot {
  width: 14px;
  height: 14px;
  border-color: rgba(16, 40, 42, 0.25);
}

.player-summary {
  margin-top: 16px;
  padding: 10px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid rgba(16, 40, 42, 0.15);
  border-bottom: 1px solid rgba(16, 40, 42, 0.15);
  color: var(--paper-ink);
}

.player-summary > strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-summary > span {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--red-dark);
  font-variant-numeric: tabular-nums;
}

.player-summary small {
  color: #526567;
  font-size: 8px;
  font-weight: 850;
}

.player-summary i {
  color: #b77b16;
  font-style: normal;
}

.leaderboard-launch {
  width: 100%;
  min-height: 42px;
  margin-top: 10px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  border: 0;
  border-radius: 4px;
  color: var(--paper-ink);
  background: rgba(16, 40, 42, 0.08);
  font-size: 11px;
  font-weight: 850;
  cursor: pointer;
}

.leaderboard-launch:hover,
.leaderboard-launch:focus-visible {
  background: rgba(16, 40, 42, 0.15);
}

.leaderboard-launch svg {
  width: 18px;
  height: 18px;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

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

.intro-modal .modal-actions {
  grid-template-columns: 1fr 50px 1.4fr;
}

.intro-modal .modal-actions .icon-button {
  width: 50px;
  height: 50px;
}

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

.button {
  min-height: 50px;
  padding: 12px 18px;
  border: 0;
  border-radius: 5px;
  font-weight: 850;
  cursor: pointer;
}

.button:disabled {
  cursor: default;
  opacity: 0.45;
}

.button-primary {
  color: #fff;
  background: var(--red);
  box-shadow: inset 0 -3px 0 rgba(110, 25, 31, 0.35);
}

.button-primary:hover,
.button-primary:focus-visible {
  background: #c93c3b;
}

.button-secondary {
  color: var(--paper-ink);
  border: 1px solid rgba(16, 40, 42, 0.25);
  background: rgba(16, 40, 42, 0.06);
}

.button-secondary:hover,
.button-secondary:focus-visible {
  background: rgba(16, 40, 42, 0.12);
}

.icon-text {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
}

.pause-modal {
  width: min(470px, 100%);
  text-align: left;
}

.settings-list {
  margin-top: 20px;
  border-top: 1px solid rgba(16, 40, 42, 0.15);
}

.nickname-setting,
.audio-setting,
.toggle-setting {
  padding: 12px 0;
  border-bottom: 1px solid rgba(16, 40, 42, 0.15);
}

.nickname-setting {
  display: grid;
  grid-template-columns: 112px 1fr;
  align-items: center;
  gap: 8px 12px;
  color: var(--paper-ink);
  font-weight: 750;
}

.nickname-setting input {
  min-width: 0;
  height: 40px;
  padding: 0 10px;
  border: 1px solid rgba(16, 40, 42, 0.3);
  border-radius: 4px;
  color: var(--paper-ink);
  background: #fff;
  font: inherit;
}

.nickname-setting small {
  min-height: 14px;
  grid-column: 2;
  color: var(--red-dark);
  font-size: 10px;
  font-weight: 650;
}

.setting-heading,
.setting-control-row,
.track-row,
.toggle-setting {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.setting-heading {
  margin-bottom: 8px;
  color: var(--paper-ink);
}

.setting-heading output {
  color: #526567;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
}

.setting-control-row input[type="range"] {
  min-width: 0;
  flex: 1;
  accent-color: var(--red);
}

.setting-control-row .icon-button {
  width: 38px;
  height: 38px;
  flex: 0 0 auto;
}

.track-row {
  margin-top: 7px;
  color: #526567;
  font-size: 11px;
}

.track-row span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.track-row button {
  padding: 4px 0 4px 10px;
  border: 0;
  color: var(--red-dark);
  background: transparent;
  font-size: 10px;
  font-weight: 850;
  cursor: pointer;
}

.toggle-setting {
  color: var(--paper-ink);
}

.toggle-setting > span {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.toggle-setting small {
  color: #526567;
  font-size: 10px;
  font-weight: 500;
}

.toggle-setting input {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
  accent-color: var(--red);
}

.sound-off {
  display: none;
}

.is-muted .sound-on {
  display: none;
}

.is-muted .sound-off {
  display: block;
}

.result-emblem {
  width: 74px;
  height: 74px;
  margin: 0 auto 14px;
  display: grid;
  place-items: center;
  border: 4px solid #ffdfa0;
  border-radius: 50%;
  color: #fff;
  background: var(--red);
  box-shadow: 0 5px 0 #9c3033;
  font-size: 34px;
}

.result-modal.is-defeat .result-emblem {
  color: var(--paper);
  border-color: #aac0be;
  background: #365254;
  box-shadow: 0 5px 0 #1d3537;
}

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

.village-spotlight {
  margin-top: 18px;
  padding-top: 16px;
  display: grid;
  grid-template-columns: minmax(180px, 0.72fr) minmax(0, 1.28fr);
  gap: 18px;
  border-top: 1px solid rgba(16, 40, 42, 0.16);
  text-align: left;
}

.village-spotlight.no-image {
  grid-template-columns: 1fr;
}

.spotlight-media {
  min-width: 0;
  margin: 0;
}

.spotlight-media img {
  width: 100%;
  height: 154px;
  display: block;
  object-fit: cover;
  border-radius: 4px;
}

.spotlight-media figcaption {
  margin-top: 5px;
  font-size: 9px;
  line-height: 1.25;
}

.spotlight-media a,
.spotlight-sources a {
  color: var(--red-dark);
}

.spotlight-copy {
  min-width: 0;
}

.spotlight-heading {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.spotlight-heading span,
.spotlight-heading > strong {
  color: var(--red-dark);
  font-size: 9px;
  font-weight: 850;
}

.spotlight-heading h3 {
  margin: 2px 0 0;
  color: var(--paper-ink);
  font-size: 22px;
  line-height: 1.05;
}

.spotlight-population {
  margin-top: 9px;
  display: flex;
  align-items: baseline;
  gap: 7px;
  color: #526567;
  font-size: 11px;
}

.spotlight-population strong {
  color: var(--paper-ink);
  font-size: 20px;
  font-variant-numeric: tabular-nums;
}

.spotlight-copy p {
  margin-top: 8px;
  color: #405759;
  font-size: 12px;
  line-height: 1.38;
}

.spotlight-copy p b {
  color: var(--paper-ink);
}

.spotlight-sponsor {
  margin-top: 11px;
  padding: 9px 0 9px 11px;
  border-left: 3px solid var(--gold);
  background: rgba(199, 151, 45, .08);
}

.spotlight-sponsor > span {
  display: block;
  margin-bottom: 5px;
  color: #84621d;
  font-size: 8px;
  font-weight: 900;
}

.spotlight-sponsor a {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: var(--paper-ink);
  text-decoration: none;
}

.spotlight-sponsor a > span {
  min-width: 0;
  display: grid;
  gap: 2px;
}

.spotlight-sponsor strong {
  font-size: 12px;
}

.spotlight-sponsor small {
  color: #526567;
  font-size: 10px;
  line-height: 1.3;
}

.spotlight-sponsor a > b {
  flex: 0 0 auto;
  color: var(--red-dark);
  font-size: 9px;
}

.spotlight-sources {
  margin-top: 9px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 14px;
  font-size: 10px;
  font-weight: 750;
}

.reward-line {
  margin: 22px auto 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 9px;
  color: var(--paper-ink);
  font-size: 22px;
}

.score-line {
  margin-top: 14px;
  padding-top: 12px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-top: 1px solid rgba(16, 40, 42, 0.15);
  color: var(--paper-ink);
}

.score-line span {
  color: var(--red-dark);
  font-size: 10px;
  font-weight: 850;
}

.score-line strong {
  font-size: 24px;
  font-variant-numeric: tabular-nums;
}

.run-score-line {
  margin-top: 7px;
  padding: 8px 10px;
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  border-left: 3px solid #b77b16;
  color: var(--paper-ink);
  background: rgba(183, 123, 22, 0.09);
}

.run-score-line span {
  color: #745917;
  font-size: 9px;
  font-weight: 850;
}

.run-score-line strong {
  font-size: 18px;
  font-variant-numeric: tabular-nums;
}

.score-breakdown {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 5px 14px;
  color: #526567;
  font-size: 10px;
}

.score-breakdown span {
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.score-breakdown b {
  color: var(--paper-ink);
  font-variant-numeric: tabular-nums;
}

.card-modal {
  width: min(850px, 100%);
}

.card-choices {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
}

.blessing-card {
  min-height: 188px;
  padding: 20px 15px 17px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  border: 2px solid rgba(16, 40, 42, 0.16);
  border-radius: 6px;
  color: var(--paper-ink);
  background: #fffdf6;
  cursor: pointer;
  box-shadow: 0 4px 0 rgba(16, 40, 42, 0.15);
}

.blessing-card:hover,
.blessing-card:focus-visible {
  border-color: var(--red);
  transform: translateY(-2px);
}

.card-icon,
.upgrade-icon {
  width: 52px;
  height: 52px;
  margin-bottom: 13px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  color: #fff;
  background: var(--card-color, var(--red));
  font-size: 26px;
  font-weight: 850;
}

.blessing-card strong {
  font-size: 17px;
}

.blessing-card span:last-child {
  margin-top: 7px;
  color: #5b6c6e;
  font-size: 13px;
  line-height: 1.35;
}

.modal-heading-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
  text-align: left;
}

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

.harbor-heading-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.harbor-wallet {
  min-height: 38px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid rgba(16, 40, 42, 0.18);
  border-radius: 4px;
  color: #66787a;
  background: rgba(16, 40, 42, 0.05);
  font-size: 9px;
  font-weight: 850;
}

.harbor-wallet strong {
  color: var(--paper-ink);
  font-size: 14px;
  font-variant-numeric: tabular-nums;
}

.harbor-wallet .coin {
  width: 16px;
  height: 16px;
  border-width: 2px;
}

.leaderboard-modal {
  width: min(620px, 100%);
  text-align: left;
}

.nickname-overlay {
  z-index: 30;
}

.nickname-modal {
  width: min(420px, 100%);
}

.nickname-modal form {
  margin-top: 22px;
  display: grid;
  gap: 8px;
  text-align: left;
}

.nickname-modal label {
  color: #526567;
  font-size: 11px;
  font-weight: 850;
}

.nickname-modal input {
  width: 100%;
  min-height: 50px;
  padding: 11px 13px;
  border: 1px solid rgba(16, 40, 42, 0.28);
  border-radius: 5px;
  color: var(--paper-ink);
  background: #fffdf8;
  font: inherit;
  font-size: 17px;
  font-weight: 750;
  -webkit-user-select: text;
  user-select: text;
}

.nickname-modal input:focus {
  border-color: var(--red-dark);
  outline: 2px solid rgba(166, 45, 53, 0.16);
  outline-offset: 1px;
}

.nickname-modal small {
  min-height: 18px;
  color: var(--red-dark);
  font-size: 11px;
}

.nickname-modal .button {
  width: 100%;
  margin-top: 4px;
}

.leaderboard-controls {
  margin-top: 20px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 10px;
}

.leaderboard-tabs {
  min-width: 0;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: hidden;
  border: 1px solid rgba(16, 40, 42, 0.22);
  border-radius: 5px;
}

.leaderboard-tabs button {
  min-width: 0;
  min-height: 42px;
  padding: 8px 11px;
  border: 0;
  border-right: 1px solid rgba(16, 40, 42, 0.18);
  color: #526567;
  background: transparent;
  font-size: 10px;
  font-weight: 850;
  cursor: pointer;
}

.leaderboard-tabs button:last-child {
  border-right: 0;
}

.leaderboard-tabs button.is-active {
  color: #fff;
  background: var(--red-dark);
}

.leaderboard-level-field {
  display: none;
}

.leaderboard-level-field.is-visible {
  display: block;
}

.leaderboard-level-field select {
  max-width: 170px;
  min-height: 42px;
  padding: 7px 30px 7px 10px;
  border: 1px solid rgba(16, 40, 42, 0.22);
  border-radius: 5px;
  color: var(--paper-ink);
  background: #fffdf8;
  font: inherit;
  font-size: 12px;
  font-weight: 750;
}

.leaderboard-meta {
  min-height: 38px;
  padding: 14px 0 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  color: #526567;
  font-size: 10px;
  font-weight: 850;
}

.leaderboard-meta strong {
  padding: 4px 7px;
  border-radius: 3px;
  color: #2f6260;
  background: rgba(72, 142, 119, 0.13);
  font-size: 9px;
}

.leaderboard-meta strong.is-local {
  color: #745917;
  background: rgba(183, 123, 22, 0.14);
}

.leaderboard-heading,
.leaderboard-row {
  display: grid;
  grid-template-columns: 42px minmax(0, 1fr) minmax(82px, auto);
  align-items: center;
  gap: 10px;
}

.leaderboard-heading {
  padding: 8px 10px;
  border-top: 1px solid rgba(16, 40, 42, 0.18);
  border-bottom: 1px solid rgba(16, 40, 42, 0.18);
  color: #66787a;
  font-size: 9px;
  font-weight: 850;
}

.leaderboard-heading span:last-child,
.leaderboard-score {
  text-align: right;
}

.leaderboard-rows {
  min-height: 184px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.leaderboard-row {
  min-height: 52px;
  padding: 8px 10px;
  border-bottom: 1px solid rgba(16, 40, 42, 0.11);
  color: var(--paper-ink);
}

.leaderboard-row.is-player {
  background: rgba(47, 200, 210, 0.09);
}

.leaderboard-rank {
  color: #647779;
  font-size: 12px;
  font-weight: 850;
  font-variant-numeric: tabular-nums;
}

.leaderboard-name {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 14px;
  font-weight: 780;
}

.leaderboard-name small {
  margin-left: 7px;
  padding: 2px 4px;
  border-radius: 2px;
  color: #745917;
  background: rgba(183, 123, 22, 0.14);
  font-size: 8px;
  font-weight: 850;
  vertical-align: 1px;
}

.leaderboard-score {
  color: var(--red-dark);
  font-size: 15px;
  font-weight: 900;
  font-variant-numeric: tabular-nums;
}

.leaderboard-empty {
  min-height: 184px;
  display: grid;
  place-items: center;
  padding: 24px;
  color: #687a7c;
  text-align: center;
  font-size: 13px;
}

.leaderboard-note {
  min-height: 18px;
  margin-top: 12px !important;
  font-size: 11px;
  text-align: center;
}

.leaderboard-share {
  width: 100%;
  margin-top: 10px;
}

.harbor-upgrades {
  margin-top: 18px;
  display: grid;
  gap: 10px;
}

.upgrade-row {
  padding: 12px;
  display: grid;
  grid-template-columns: 48px minmax(0, 1fr) auto;
  align-items: center;
  gap: 12px;
  border-top: 1px solid rgba(16, 40, 42, 0.16);
  text-align: left;
}

.upgrade-row:first-child {
  border-top: 0;
}

.upgrade-icon {
  width: 44px;
  height: 44px;
  margin: 0;
  font-size: 20px;
}

.upgrade-copy {
  min-width: 0;
}

.upgrade-copy strong,
.upgrade-copy span {
  display: block;
}

.upgrade-copy span {
  margin-top: 3px;
  color: #5b6c6e;
  font-size: 12px;
}

.buy-button {
  min-width: 92px;
  min-height: 42px;
  padding: 8px 12px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border: 0;
  border-radius: 4px;
  color: #fff;
  background: var(--red);
  font-size: 12px;
  font-weight: 850;
  cursor: pointer;
}

.buy-button .coin {
  width: 14px;
  height: 14px;
  border-width: 2px;
}

.buy-button:disabled {
  color: #708183;
  background: rgba(16, 40, 42, 0.09);
  cursor: default;
}

.gesture-cue {
  position: absolute;
  z-index: 7;
  width: 140px;
  height: 80px;
  display: none;
  transform-origin: 0 50%;
  pointer-events: none;
}

.gesture-cue.is-visible {
  display: block;
}

.gesture-line {
  position: absolute;
  left: 10px;
  top: 38px;
  width: 116px;
  height: 3px;
  background: rgba(255, 255, 255, 0.78);
  transform-origin: 0 50%;
}

.gesture-line::after {
  content: "";
  position: absolute;
  right: -2px;
  top: -5px;
  width: 10px;
  height: 10px;
  border-top: 3px solid #fff;
  border-right: 3px solid #fff;
  transform: rotate(45deg);
}

.gesture-hand {
  position: absolute;
  left: 4px;
  top: 29px;
  width: 20px;
  height: 20px;
  border: 4px solid var(--paper);
  border-radius: 50%;
  background: rgba(47, 200, 210, 0.65);
  box-shadow: 0 0 0 7px rgba(47, 200, 210, 0.22);
  animation: gesture-swipe 1.55s ease-in-out infinite;
}

@keyframes gesture-swipe {
  0%, 12% { transform: translateX(0) scale(0.86); opacity: 0; }
  22% { opacity: 1; }
  76% { transform: translateX(105px) scale(1); opacity: 1; }
  90%, 100% { transform: translateX(105px) scale(1); opacity: 0; }
}

.toast {
  position: absolute;
  z-index: 30;
  left: 50%;
  bottom: 92px;
  max-width: min(360px, calc(100% - 36px));
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 4px;
  color: var(--paper);
  background: rgba(7, 29, 32, 0.92);
  box-shadow: 0 8px 22px var(--shadow);
  opacity: 0;
  transform: translate(-50%, 10px);
  transition: opacity 160ms ease, transform 160ms ease;
  pointer-events: none;
  font-size: 13px;
  font-weight: 700;
}

.toast.is-visible {
  opacity: 1;
  transform: translate(-50%, 0);
}

.map-credit {
  position: absolute;
  z-index: 6;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(18px, env(safe-area-inset-bottom));
  color: rgba(245, 240, 230, 0.72);
  font-size: 9px;
  text-decoration: none;
  text-shadow: 0 1px 3px #071d20;
}

.map-credit:hover,
.map-credit:focus-visible {
  color: var(--paper);
  text-decoration: underline;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 700px) {
  .game-shell {
    min-height: 430px;
  }

  .topbar {
    min-height: 70px;
    padding-top: max(10px, env(safe-area-inset-top));
    grid-template-columns: 74px minmax(110px, 1fr) 74px;
    gap: 7px;
  }

  .brand-copy,
  .coin-readout strong {
    display: none;
  }

  .flag-mark {
    width: 37px;
    height: 25px;
  }

  .flag-mark::before { left: 10px; width: 8px; }
  .flag-mark::after { top: 8px; height: 8px; }
  .flag-mark i::before { left: 13px; }
  .flag-mark i::after { top: 11px; }

  .level-readout {
    min-width: 0;
    padding: 7px 10px 8px;
  }

  .level-readout strong {
    font-size: 12px;
  }

  .coin-readout {
    min-width: 34px;
    width: 34px;
    height: 38px;
    padding: 0;
    border: 0;
    background: transparent;
    backdrop-filter: none;
  }

  .icon-button {
    width: 38px;
    height: 38px;
  }

  .top-actions {
    gap: 1px;
  }

  .faction-legend {
    top: 78px;
    left: max(8px, env(safe-area-inset-left));
  }

  .faction-row {
    width: 94px;
    padding: 5px 7px;
    grid-template-columns: 8px 1fr auto;
    gap: 5px;
    font-size: 9px;
  }

  .command-dock {
    min-width: min(310px, calc(100% - 20px));
    height: 50px;
    bottom: max(9px, env(safe-area-inset-bottom));
    padding: 5px;
  }

  .send-control {
    flex: 1;
    grid-template-columns: repeat(3, 1fr);
  }

  .surge-button {
    width: 38px;
  }

  .surge-button svg {
    width: 35px;
    height: 35px;
  }

  .send-control button {
    padding: 0 5px;
  }

  .power-meter {
    width: 60px;
  }

  .power-meter span {
    font-size: 16px;
  }

  .map-credit {
    right: 8px;
    bottom: calc(max(9px, env(safe-area-inset-bottom)) + 57px);
    font-size: 8px;
  }

  .overlay {
    padding: max(72px, env(safe-area-inset-top)) 12px max(64px, env(safe-area-inset-bottom));
  }

  .modal {
    padding: 24px 18px;
  }

  .modal h1,
  .modal h2 {
    font-size: 30px;
  }

  .card-choices {
    grid-template-columns: 1fr;
  }

  .intro-modal .modal-actions {
    grid-template-columns: minmax(0, 1fr) 44px minmax(0, 1fr);
    gap: 6px;
  }

  .intro-modal .modal-actions .icon-button {
    width: 44px;
    height: 50px;
  }

  .intro-modal .modal-actions .button {
    min-width: 0;
    padding: 10px 7px;
    font-size: 11px;
  }

  .intro-modal .modal-actions .button svg {
    display: none;
  }

  .leaderboard-controls {
    grid-template-columns: 1fr;
  }

  .leaderboard-tabs button {
    padding-inline: 6px;
    font-size: 9px;
  }

  .harbor-heading-actions {
    align-items: flex-start;
  }

  .harbor-wallet {
    padding-left: 7px;
    padding-right: 7px;
  }

  .harbor-wallet > span:nth-child(2) {
    display: none;
  }

  .leaderboard-level-field select {
    width: 100%;
    max-width: none;
  }

  .leaderboard-heading,
  .leaderboard-row {
    grid-template-columns: 34px minmax(0, 1fr) minmax(70px, auto);
    gap: 7px;
  }

  .leaderboard-heading,
  .leaderboard-row {
    padding-left: 7px;
    padding-right: 7px;
  }

  .village-spotlight {
    grid-template-columns: 1fr;
    gap: 10px;
  }

  .spotlight-media img {
    height: 128px;
  }

  .blessing-card {
    min-height: 0;
    padding: 13px;
    display: grid;
    grid-template-columns: 46px minmax(0, 1fr);
    column-gap: 12px;
    text-align: left;
  }

  .card-icon {
    width: 44px;
    height: 44px;
    margin: 0;
    grid-row: span 2;
    font-size: 20px;
  }

  .blessing-card span:last-child {
    margin-top: 2px;
  }

  .upgrade-row {
    grid-template-columns: 40px minmax(0, 1fr) auto;
    gap: 8px;
    padding: 10px 0;
  }

  .upgrade-icon {
    width: 38px;
    height: 38px;
  }

  .buy-button {
    min-width: 78px;
    padding: 6px 8px;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .topbar {
    min-height: 60px;
    padding-top: max(8px, env(safe-area-inset-top));
  }

  .brand-copy {
    display: none;
  }

  .faction-legend {
    top: 68px;
  }

  .command-dock {
    bottom: 8px;
  }

  .overlay {
    padding-top: 64px;
    padding-bottom: 62px;
  }

  .modal {
    padding: 20px;
  }

  .modal h1,
  .modal h2 {
    font-size: 28px;
  }

  .intro-factions {
    margin-top: 12px;
  }

  .modal-actions {
    margin-top: 14px;
  }
}

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