:root {
  --ink: #17151f;
  --cabinet: #263238;
  --cabinet-edge: #0d1117;
  --red: #e43d40;
  --yellow: #ffd166;
  --cyan: #2ec4b6;
  --green: #76c043;
  --screen: #101820;
  --screen-glow: #d8ffe8;
  --cell: #29384a;
  --cell-raised: #3d536c;
  --cell-open: #c7d6bf;
  --cell-open-alt: #b3c7ae;
  --white: #f7fff7;
}

* {
  box-sizing: border-box;
}

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

html {
  background: #141921;
}

body {
  align-items: center;
  background:
    radial-gradient(circle at 50% 22%, rgba(255, 209, 102, 0.16), transparent 24rem),
    linear-gradient(135deg, #141921 0%, #1c2430 45%, #120f19 100%);
  color: var(--white);
  display: flex;
  font-family: "Space Mono", Consolas, monospace;
  justify-content: flex-start;
  margin: 0;
  overflow-x: auto;
  padding: 20px;
  width: 100%;
}

[hidden] {
  display: none !important;
}

button {
  font: inherit;
}

.app-shell {
  align-items: flex-start;
  display: flex;
  gap: 20px;
  justify-content: flex-start;
  max-width: 1280px;
  width: min(100%, 1280px);
}

.cabinet {
  background:
    linear-gradient(90deg, transparent 0 16px, rgba(255, 255, 255, 0.08) 17px, transparent 20px),
    linear-gradient(180deg, #34434a, var(--cabinet) 28%, #182027);
  border: 8px solid var(--cabinet-edge);
  border-radius: 8px;
  box-shadow:
    0 28px 50px rgba(0, 0, 0, 0.45),
    inset 0 0 0 5px rgba(255, 255, 255, 0.05);
  flex: 0 0 min(100%, 410px);
  max-width: 410px;
  padding: 16px 16px 20px;
  position: relative;
  width: min(100%, 410px);
}

.cabinet::before,
.cabinet::after {
  background: var(--red);
  border-radius: 2px;
  content: "";
  height: 100%;
  position: absolute;
  top: 0;
  width: 8px;
}

.cabinet::before {
  left: 22px;
}

.cabinet::after {
  right: 22px;
}

.marquee {
  align-items: center;
  background:
    linear-gradient(90deg, rgba(255, 209, 102, 0.95), rgba(255, 244, 143, 0.95), rgba(255, 209, 102, 0.95));
  border: 4px solid var(--ink);
  border-radius: 4px;
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.18);
  color: var(--ink);
  display: flex;
  gap: 12px;
  justify-content: center;
  margin: 0 12px 14px;
  min-height: 62px;
  padding: 10px;
  position: relative;
  z-index: 1;
}

.marquee h1 {
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: clamp(1rem, 5vw, 1.8rem);
  letter-spacing: 0;
  line-height: 1.2;
  margin: 0;
  min-width: 0;
  text-align: center;
  text-shadow: 2px 2px 0 rgba(228, 61, 64, 0.45);
}

.marquee__spark {
  color: var(--red);
  flex: 0 0 auto;
  font-size: 1.1rem;
}

.screen {
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 50%, rgba(0, 0, 0, 0.04) 50%),
    radial-gradient(circle at 50% 20%, rgba(216, 255, 232, 0.13), transparent 68%),
    var(--screen);
  background-size: 100% 4px, auto, auto;
  border: 7px solid #080b10;
  border-radius: 8px;
  box-shadow:
    inset 0 0 30px rgba(216, 255, 232, 0.1),
    0 0 0 3px rgba(255, 255, 255, 0.06);
  padding: 14px;
  position: relative;
  z-index: 1;
}

.hud {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 1fr auto 1fr;
  margin-bottom: 12px;
}

.meter {
  background: #080d13;
  border: 2px solid rgba(216, 255, 232, 0.24);
  border-radius: 4px;
  color: var(--screen-glow);
  min-width: 0;
  padding: 8px;
}

.meter--right {
  text-align: right;
}

.meter__label {
  color: rgba(216, 255, 232, 0.7);
  display: block;
  font-size: 0.68rem;
  line-height: 1;
  text-transform: uppercase;
}

.meter__value {
  display: block;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.4;
  margin-top: 6px;
}

.reset {
  background: linear-gradient(#ff6d6d, var(--red));
  border: 0;
  border-bottom: 5px solid #8a191e;
  border-radius: 50%;
  color: #fff7d6;
  cursor: pointer;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.58rem;
  height: 68px;
  line-height: 1.2;
  padding: 0;
  text-shadow: 1px 1px 0 #7b171b;
  width: 68px;
}

.reset:active {
  border-bottom-width: 2px;
  transform: translateY(3px);
}

.status {
  color: rgba(247, 255, 247, 0.78);
  font-size: 0.88rem;
  line-height: 1.35;
  margin: 0 0 14px;
  min-height: 2.4em;
  text-align: center;
}

.board {
  aspect-ratio: 5 / 7;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  grid-template-rows: repeat(7, minmax(0, 1fr));
  margin: 0 auto;
  max-height: min(48vh, 410px);
  max-width: min(100%, 340px);
  width: 100%;
}

.board.is-revealing {
  cursor: wait;
}

.cell {
  align-items: center;
  aspect-ratio: 1;
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.18), transparent 35%),
    var(--cell);
  border: 0;
  border-bottom: 4px solid #182330;
  border-radius: 5px;
  box-shadow: inset 0 0 0 2px rgba(255, 255, 255, 0.06);
  color: var(--white);
  cursor: pointer;
  display: flex;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: clamp(0.85rem, 5vw, 1.15rem);
  justify-content: center;
  line-height: 1;
  min-height: 0;
  padding: 0;
  position: relative;
  user-select: none;
}

.cell:not(.is-open):hover:not(:disabled) {
  background:
    linear-gradient(135deg, rgba(255, 255, 255, 0.24), transparent 35%),
    var(--cell-raised);
}

.cell:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

.cell.is-open {
  background: var(--cell-open);
  border-bottom-color: #7b9676;
  box-shadow: inset 0 3px 0 rgba(0, 0, 0, 0.18);
  color: #132015;
  cursor: default;
}

.cell.is-open:nth-child(even) {
  background: var(--cell-open-alt);
}

.cell.is-newly-open {
  animation: tile-reveal 220ms ease-out both;
}

@keyframes tile-reveal {
  from {
    opacity: 0.2;
    transform: scale(0.72);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.cell.is-treasure {
  background: #d9bb63;
  border-bottom-color: #9b7920;
  color: #4f3510;
  text-shadow: 1px 1px 0 rgba(255, 246, 182, 0.6);
}

.treasure-popup {
  animation: treasure-float 900ms ease-out both;
  background: var(--yellow);
  border: 2px solid #8e7115;
  border-radius: 4px;
  color: #3d2b0b;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.56rem;
  left: 50%;
  padding: 5px 6px;
  pointer-events: none;
  position: absolute;
  top: 50%;
  transform: translate(-50%, -50%);
  white-space: nowrap;
  z-index: 3;
}

@keyframes treasure-float {
  0% {
    opacity: 0;
    transform: translate(-50%, -15%);
  }
  18% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -145%);
  }
}

.cell.is-flagged {
  color: var(--yellow);
  text-shadow: 0 0 12px rgba(255, 209, 102, 0.5);
}

.cell.is-mine {
  background: #f0544f;
  color: #1b1111;
}

.cell.is-equipment-target {
  box-shadow:
    inset 0 0 0 2px rgba(255, 255, 255, 0.06),
    0 0 0 2px rgba(255, 209, 102, 0.45);
}

.cell[data-adjacent="1"] {
  color: #0c5ca8;
}

.cell[data-adjacent="2"] {
  color: #1d7d39;
}

.cell[data-adjacent="3"] {
  color: #c11f33;
}

.cell[data-adjacent="4"],
.cell[data-adjacent="5"],
.cell[data-adjacent="6"],
.cell[data-adjacent="7"],
.cell[data-adjacent="8"] {
  color: #5d2c92;
}

.controls {
  align-items: end;
  display: flex;
  justify-content: space-between;
  padding: 20px 42px 0;
  position: relative;
  z-index: 1;
}

.equipment-dock {
  position: relative;
}

.equipment-toggle {
  align-items: center;
  background: linear-gradient(#55d5ca, var(--cyan));
  border: 4px solid #095a55;
  border-bottom-color: #063d3a;
  border-radius: 8px;
  box-shadow: 0 8px 0 #081014;
  color: #062927;
  cursor: pointer;
  display: grid;
  font-family: "Press Start 2P", system-ui, sans-serif;
  gap: 3px;
  height: 58px;
  justify-items: center;
  line-height: 1;
  padding: 5px;
  width: 58px;
}

.equipment-toggle span {
  font-size: 1rem;
}

.equipment-toggle strong {
  background: #081014;
  border-radius: 4px;
  color: var(--screen-glow);
  font-size: 0.54rem;
  line-height: 1.2;
  min-width: 24px;
  padding: 3px 4px;
}

.equipment-toggle:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.48;
}

.equipment-toggle:not(:disabled):active,
.equipment-toggle[aria-expanded="true"] {
  box-shadow: 0 4px 0 #081014;
  transform: translateY(4px);
}

.equipment-inventory {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06), transparent 18px),
    linear-gradient(180deg, #202a32, #080d13);
  border: 4px solid #080b10;
  border-radius: 8px;
  bottom: 74px;
  box-shadow: 0 16px 34px rgba(0, 0, 0, 0.52);
  color: var(--white);
  left: 0;
  padding: 10px;
  position: absolute;
  width: min(72vw, 260px);
  z-index: 10;
}

.equipment-inventory__header {
  display: grid;
  gap: 3px;
  margin-bottom: 8px;
}

.equipment-inventory__header strong {
  color: var(--yellow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.58rem;
  line-height: 1.35;
}

.equipment-inventory__list {
  display: grid;
  gap: 6px;
}

.equipment-inventory__item {
  align-items: center;
  background: #111820;
  border: 2px solid rgba(216, 255, 232, 0.14);
  border-radius: 5px;
  color: var(--white);
  cursor: pointer;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  min-height: 42px;
  padding: 7px 8px;
  position: relative;
  text-align: left;
}

.equipment-inventory__item::after {
  background: #05080c;
  border: 3px solid var(--yellow);
  border-radius: 5px;
  bottom: calc(100% + 8px);
  box-shadow:
    0 0 0 1px rgba(255, 209, 102, 0.35),
    0 10px 24px rgba(0, 0, 0, 0.52);
  color: rgba(247, 255, 247, 0.9);
  content: attr(data-tooltip);
  font-size: 0.62rem;
  left: 0;
  line-height: 1.35;
  max-width: min(230px, 76vw);
  opacity: 0;
  padding: 8px 9px;
  pointer-events: none;
  position: absolute;
  text-align: left;
  transform: translateY(4px);
  transition: opacity 120ms ease, transform 120ms ease;
  visibility: hidden;
  width: max-content;
  z-index: 30;
}

.equipment-inventory__item::before {
  border-color: var(--yellow) transparent transparent;
  border-style: solid;
  border-width: 8px 7px 0;
  bottom: calc(100% + 1px);
  content: "";
  left: 14px;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transition: opacity 120ms ease;
  visibility: hidden;
  z-index: 31;
}

.equipment-inventory__item:hover::after,
.equipment-inventory__item:hover::before,
.equipment-inventory__item:focus-visible::after,
.equipment-inventory__item:focus-visible::before {
  opacity: 1;
  visibility: visible;
}

.equipment-inventory__item:hover::after,
.equipment-inventory__item:focus-visible::after {
  transform: translateY(0);
}

.equipment-inventory__item strong {
  color: var(--screen-glow);
  display: block;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.5rem;
  line-height: 1.3;
}

.equipment-inventory__item small {
  color: rgba(247, 255, 247, 0.68);
  display: block;
  font-size: 0.58rem;
  line-height: 1.25;
  margin-top: 2px;
}

.equipment-inventory__item b {
  color: var(--yellow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.56rem;
}

.equipment-inventory__item.is-selected {
  border-color: var(--yellow);
}

.equipment-inventory__item:hover,
.equipment-inventory__item:focus-visible {
  border-color: var(--yellow);
}

.equipment-inventory__item:disabled {
  border-color: rgba(216, 255, 232, 0.08);
  color: rgba(247, 255, 247, 0.58);
  cursor: not-allowed;
}

.equipment-inventory__item:disabled:hover {
  border-color: var(--yellow);
}

.equipment-inventory__item:disabled strong,
.equipment-inventory__item:disabled small,
.equipment-inventory__item:disabled b {
  opacity: 0.55;
}

.buttons {
  display: flex;
  gap: 16px;
  padding-bottom: 6px;
}

.buttons span {
  background: linear-gradient(#ffe78f, var(--yellow));
  border: 4px solid #7d6617;
  border-radius: 50%;
  box-shadow: 0 8px 0 #10141a;
  display: block;
  height: 42px;
  width: 42px;
}

.buttons span:last-child {
  background: linear-gradient(#9be35e, var(--green));
  border-color: #376c1e;
}

.settings-panel {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05), transparent 18px),
    linear-gradient(180deg, #202a32, #111820);
  border: 6px solid #080b10;
  border-radius: 8px;
  box-shadow:
    0 22px 42px rgba(0, 0, 0, 0.35),
    inset 0 0 0 2px rgba(255, 255, 255, 0.05);
  color: var(--white);
  flex: 1 1 310px;
  max-width: 350px;
  min-width: 270px;
  padding: 18px;
}

.curio-panel {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05), transparent 18px),
    linear-gradient(180deg, #2c2935, #141721);
  border: 6px solid #080b10;
  border-radius: 8px;
  box-shadow:
    0 22px 42px rgba(0, 0, 0, 0.35),
    inset 0 0 0 2px rgba(255, 255, 255, 0.05);
  color: var(--white);
  flex: 1 1 250px;
  max-width: 280px;
  min-width: 240px;
  padding: 18px;
}

.contracts-panel {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05), transparent 18px),
    linear-gradient(180deg, #273039, #12191f);
  border: 6px solid #080b10;
  border-radius: 8px;
  box-shadow:
    0 22px 42px rgba(0, 0, 0, 0.35),
    inset 0 0 0 2px rgba(255, 255, 255, 0.05);
  color: var(--white);
  flex: 1 1 270px;
  max-width: 306px;
  min-width: 250px;
  padding: 18px;
}

.quartermaster-panel {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.05), transparent 18px),
    linear-gradient(180deg, #28333a, #141d23);
  border: 6px solid #080b10;
  border-radius: 8px;
  box-shadow:
    0 22px 42px rgba(0, 0, 0, 0.35),
    inset 0 0 0 2px rgba(255, 255, 255, 0.05);
  color: var(--white);
  flex: 1 1 310px;
  max-width: 330px;
  min-width: 270px;
  padding: 18px;
}

.message-board-list {
  display: grid;
  gap: 8px;
}

.message-board-status {
  align-items: center;
  background: #080d13;
  border: 2px solid rgba(255, 209, 102, 0.42);
  border-radius: 5px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 12px;
  padding: 10px 12px;
}

.message-board-status__label {
  color: rgba(247, 255, 247, 0.72);
  font-size: 0.66rem;
  text-transform: uppercase;
}

.message-board-status__value {
  color: var(--yellow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.58rem;
  line-height: 1.35;
  text-align: right;
}

.message-tile {
  background: #080d13;
  border: 2px solid rgba(255, 209, 102, 0.3);
  border-radius: 5px;
  display: grid;
  gap: 8px;
  padding: 9px 10px;
}

.message-tile--contract {
  border-color: rgba(46, 196, 182, 0.42);
}

.message-tile p {
  color: rgba(247, 255, 247, 0.72);
  font-size: 0.68rem;
  line-height: 1.4;
  margin: 0;
}

.contract-button {
  background: linear-gradient(#ffd166, #e5a82f);
  border: 0;
  border-bottom: 4px solid #7c5616;
  border-radius: 5px;
  color: #17110a;
  cursor: pointer;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.58rem;
  line-height: 1.3;
  min-height: 38px;
  padding: 9px 12px;
  text-transform: uppercase;
}

.contract-button:disabled {
  cursor: not-allowed;
  filter: grayscale(1);
  opacity: 0.48;
}

.contract-button:not(:disabled):active {
  border-bottom-width: 2px;
  transform: translateY(2px);
}

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

.message-tile__topline div {
  display: grid;
  gap: 4px;
}

.message-tile__topline strong {
  color: var(--screen-glow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.58rem;
  line-height: 1.35;
}

.message-tile__kind {
  color: var(--cyan);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.48rem;
  line-height: 1.25;
  text-transform: uppercase;
}

.message-tile__topline > span {
  color: var(--yellow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.48rem;
  line-height: 1.35;
  white-space: nowrap;
}

.message-tile__properties {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.message-tile__properties span {
  background: rgba(216, 255, 232, 0.08);
  border: 1px solid rgba(216, 255, 232, 0.14);
  border-radius: 4px;
  color: rgba(247, 255, 247, 0.82);
  font-size: 0.56rem;
  line-height: 1.35;
  padding: 4px 5px;
}

.message-tile__properties strong {
  color: var(--cyan);
  display: block;
  font-size: 0.48rem;
  line-height: 1.25;
  text-transform: uppercase;
}

.message-tile__button {
  justify-self: stretch;
}

.contract-modal {
  align-items: center;
  backdrop-filter: blur(8px);
  background: rgba(8, 11, 16, 0.72);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 20px;
  position: fixed;
  z-index: 20;
}

.contract-modal__window {
  background:
    linear-gradient(90deg, rgba(255, 255, 255, 0.06), transparent 22px),
    linear-gradient(180deg, #25313a, #111820);
  border: 6px solid #080b10;
  border-radius: 8px;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.62);
  color: var(--white);
  max-width: 470px;
  padding: 22px;
  width: min(100%, 470px);
}

.contract-modal__window h2 {
  color: var(--yellow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 1rem;
  line-height: 1.35;
  margin: 0 0 12px;
  text-shadow: 2px 2px 0 rgba(228, 61, 64, 0.45);
}

.contract-modal__window p {
  color: rgba(247, 255, 247, 0.78);
  font-size: 0.78rem;
  line-height: 1.45;
  margin: 0 0 16px;
}

.contract-modal__specs {
  display: grid;
  gap: 8px;
  margin: 0 0 18px;
}

.contract-modal__specs div {
  align-items: center;
  border-bottom: 1px solid rgba(216, 255, 232, 0.12);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  padding-bottom: 6px;
}

.contract-modal__specs dt,
.contract-modal__specs dd {
  font-size: 0.68rem;
  margin: 0;
}

.contract-modal__specs dt {
  color: rgba(247, 255, 247, 0.7);
  text-transform: uppercase;
}

.contract-modal__specs dd {
  color: var(--screen-glow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.56rem;
  line-height: 1.35;
  text-align: right;
}

.contract-button--large {
  width: 100%;
}

body.is-contract-running .quartermaster-panel,
body.is-contract-running .contracts-panel,
body.is-contract-running .curio-panel,
body.is-contract-running .settings-panel {
  filter: blur(3px) grayscale(0.2);
  opacity: 0.38;
  pointer-events: none;
}

body.is-contract-running .cabinet {
  box-shadow:
    0 0 0 5px rgba(255, 209, 102, 0.34),
    0 28px 50px rgba(0, 0, 0, 0.45),
    inset 0 0 0 5px rgba(255, 255, 255, 0.05);
}

.curio-status {
  align-items: center;
  background: #080d13;
  border: 2px solid rgba(46, 196, 182, 0.38);
  border-radius: 5px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.curio-status__label {
  color: rgba(247, 255, 247, 0.72);
  font-size: 0.66rem;
  text-transform: uppercase;
}

.curio-status__value {
  color: var(--screen-glow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.66rem;
}

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

.curio-slot {
  align-items: center;
  aspect-ratio: 1;
  background: #080d13;
  border: 2px solid rgba(216, 255, 232, 0.14);
  border-radius: 5px;
  color: rgba(247, 255, 247, 0.32);
  display: flex;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.68rem;
  justify-content: center;
  line-height: 1;
  min-width: 0;
  position: relative;
}

.curio-slot.is-found {
  background:
    linear-gradient(135deg, rgba(255, 209, 102, 0.3), transparent 48%),
    #12202a;
  border-color: rgba(255, 209, 102, 0.72);
  color: var(--yellow);
  text-shadow: 0 0 10px rgba(255, 209, 102, 0.42);
}

.curio-slot__count {
  background: var(--cyan);
  border-radius: 3px;
  bottom: 2px;
  color: #08201d;
  font-family: "Space Mono", Consolas, monospace;
  font-size: 0.55rem;
  font-weight: 700;
  line-height: 1;
  padding: 1px 3px;
  position: absolute;
  right: 2px;
}

.curio-note {
  color: rgba(216, 255, 232, 0.72);
  font-size: 0.72rem;
  line-height: 1.4;
  margin: 10px 0 0;
}

.panel-header {
  border-bottom: 2px solid rgba(255, 209, 102, 0.38);
  margin-bottom: 14px;
  padding-bottom: 14px;
}

.panel-header__eyebrow,
.store__eyebrow {
  color: var(--cyan);
  display: block;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.58rem;
  line-height: 1.4;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.panel-header h2,
.store h3 {
  color: var(--yellow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 1.14rem;
  letter-spacing: 0;
  line-height: 1.35;
  margin: 0;
  text-shadow: 2px 2px 0 rgba(228, 61, 64, 0.45);
}

.coin-display {
  align-items: center;
  background: #080d13;
  border: 2px solid rgba(255, 209, 102, 0.45);
  border-radius: 5px;
  display: flex;
  justify-content: space-between;
  margin-bottom: 12px;
  padding: 10px 12px;
}

.coin-display__label {
  color: rgba(247, 255, 247, 0.72);
  font-size: 0.74rem;
  text-transform: uppercase;
}

.coin-display__value {
  color: var(--yellow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.88rem;
}

.resource-grid {
  display: grid;
  gap: 7px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  overflow: visible;
}

.resource-card {
  align-items: center;
  background: #080d13;
  border: 2px solid rgba(216, 255, 232, 0.16);
  border-radius: 5px;
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 9px 4px 8px;
  position: relative;
  text-align: center;
  cursor: help;
}

.resource-card::after {
  background: #101821;
  border: 2px solid rgba(255, 209, 102, 0.72);
  border-radius: 5px;
  bottom: calc(100% + 8px);
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.34);
  color: rgba(247, 255, 247, 0.9);
  content: attr(data-tooltip);
  font-size: 0.62rem;
  left: 50%;
  line-height: 1.35;
  max-width: min(210px, 76vw);
  opacity: 0;
  padding: 8px 9px;
  pointer-events: none;
  position: absolute;
  text-align: left;
  transform: translate(-50%, 4px);
  transition: opacity 120ms ease, transform 120ms ease;
  visibility: hidden;
  width: max-content;
  z-index: 20;
}

.resource-card::before {
  border-color: rgba(255, 209, 102, 0.72) transparent transparent;
  border-style: solid;
  border-width: 7px 6px 0;
  bottom: calc(100% + 2px);
  content: "";
  left: 50%;
  opacity: 0;
  pointer-events: none;
  position: absolute;
  transform: translateX(-50%);
  transition: opacity 120ms ease;
  visibility: hidden;
  z-index: 21;
}

.resource-card:hover::after,
.resource-card:hover::before {
  opacity: 1;
  visibility: visible;
}

.resource-card:hover::after {
  transform: translate(-50%, 0);
}

.resource-card:first-child::after {
  left: 0;
  transform: translate(0, 4px);
}

.resource-card:first-child:hover::after {
  transform: translate(0, 0);
}

.resource-card:first-child::before {
  left: 24px;
}

.resource-card:last-child::after {
  left: auto;
  right: 0;
  transform: translate(0, 4px);
}

.resource-card:last-child:hover::after {
  transform: translate(0, 0);
}

.resource-card:last-child::before {
  left: auto;
  right: 24px;
  transform: none;
}

.resource-card__icon {
  color: var(--yellow);
  font-size: 1.05rem;
  height: 22px;
  line-height: 1;
}

.resource-card__label {
  color: rgba(247, 255, 247, 0.72);
  font-size: 0.58rem;
  line-height: 1.2;
  margin-top: 5px;
  text-transform: uppercase;
}

.resource-card__value {
  color: var(--screen-glow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.86rem;
  line-height: 1.35;
  margin-top: 5px;
}

.resource-card__detail {
  color: rgba(216, 255, 232, 0.56);
  font-size: 0.58rem;
  line-height: 1.2;
  margin-top: 4px;
  white-space: nowrap;
}

.store-note {
  color: rgba(216, 255, 232, 0.72);
  font-size: 0.72rem;
  line-height: 1.4;
  margin: 10px 0 0;
}

.store {
  border-top: 1px solid rgba(216, 255, 232, 0.18);
  margin-top: 16px;
  padding-top: 14px;
}

.store__header {
  margin-bottom: 12px;
}

.store__subheader {
  border-top: 1px solid rgba(216, 255, 232, 0.12);
  display: grid;
  gap: 2px;
  margin: 12px 0 8px;
  padding-top: 10px;
}

.store__subheader strong {
  color: rgba(247, 255, 247, 0.78);
  font-size: 0.68rem;
  line-height: 1.35;
}

.store__eyebrow {
  margin-bottom: 5px;
}

.store h3 {
  font-size: 0.94rem;
}

.store-item {
  align-items: center;
  background: #080d13;
  border: 2px solid rgba(216, 255, 232, 0.18);
  border-radius: 5px;
  color: var(--white);
  cursor: pointer;
  display: flex;
  gap: 8px;
  justify-content: space-between;
  margin-top: 8px;
  min-height: 54px;
  min-width: 214px;
  padding: 8px 10px;
  text-align: left;
  transition: border-color 120ms ease, background 120ms ease, transform 120ms ease;
  width: 100%;
}

.store-item:hover:not(:disabled) {
  background: #101b22;
  border-color: var(--cyan);
  transform: translateY(-1px);
}

.store-item:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

.store-item:active:not(:disabled) {
  transform: translateY(1px);
}

.store-item:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.store-item__copy {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}

.store-item__copy strong {
  color: var(--screen-glow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.58rem;
  line-height: 1.35;
  text-transform: uppercase;
}

.store-item__copy small {
  color: rgba(247, 255, 247, 0.64);
  font-size: 0.68rem;
  line-height: 1.25;
}

.store-item__cost {
  color: var(--yellow);
  flex: 0 0 auto;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.66rem;
}

.settings-panel__header {
  border-bottom: 2px solid rgba(255, 209, 102, 0.38);
  margin-bottom: 18px;
  padding-bottom: 14px;
}

.settings-panel__eyebrow {
  color: var(--cyan);
  display: block;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.62rem;
  line-height: 1.4;
  margin-bottom: 8px;
  text-transform: uppercase;
}

.settings-panel h2 {
  color: var(--yellow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 1.25rem;
  letter-spacing: 0;
  line-height: 1.2;
  margin: 0;
  text-shadow: 2px 2px 0 rgba(228, 61, 64, 0.45);
}

.setting-group {
  border: 0;
  border-top: 1px solid rgba(216, 255, 232, 0.18);
  margin: 0;
  padding: 16px 0 2px;
}

.setting-group + .setting-group {
  margin-top: 12px;
}

.setting-group legend {
  color: rgba(216, 255, 232, 0.82);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.66rem;
  line-height: 1.4;
  padding-right: 10px;
  text-transform: uppercase;
}

.setting-row {
  align-items: center;
  display: flex;
  gap: 12px;
  margin-top: 12px;
}

.setting-row--split {
  justify-content: space-between;
}

.setting-row label,
.settings-note {
  color: rgba(247, 255, 247, 0.8);
  font-size: 0.88rem;
  line-height: 1.35;
}

.setting-row input[type="number"] {
  background: #080d13;
  border: 2px solid rgba(216, 255, 232, 0.22);
  border-radius: 5px;
  color: var(--screen-glow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.82rem;
  height: 42px;
  padding: 0 8px;
  text-align: center;
  width: 82px;
}

.setting-row input[type="number"]:focus,
.mine-slider:focus-visible,
.safety-option:focus-within,
.dev-button:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

.safety-options {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}

.safety-option {
  align-items: center;
  background: #080d13;
  border: 2px solid rgba(216, 255, 232, 0.16);
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  gap: 10px;
  min-height: 44px;
  padding: 9px 10px;
}

.safety-option:has(input:checked) {
  border-color: var(--cyan);
  box-shadow: inset 0 0 0 1px rgba(46, 196, 182, 0.3);
  color: var(--screen-glow);
}

.safety-option input {
  accent-color: var(--cyan);
  height: 18px;
  margin: 0;
  width: 18px;
}

.safety-option span {
  font-size: 0.86rem;
  line-height: 1.25;
}

.mine-slider {
  accent-color: var(--yellow);
  display: block;
  margin-top: 14px;
  width: 100%;
}

.settings-note {
  color: rgba(216, 255, 232, 0.72);
  margin: 12px 0 0;
}

.message-board-controls {
  display: grid;
  gap: 0;
}

.dev-buttons {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 12px;
}

.dev-button {
  background: linear-gradient(#2ec4b6, #15998f);
  border: 0;
  border-bottom: 4px solid #08625e;
  border-radius: 5px;
  color: #061312;
  cursor: pointer;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.5rem;
  line-height: 1.35;
  min-height: 38px;
  padding: 9px 8px;
  text-transform: uppercase;
}

.dev-button:active {
  border-bottom-width: 2px;
  transform: translateY(2px);
}

.progress-reset {
  align-items: center;
  background: #080d13;
  border: 2px solid rgba(228, 61, 64, 0.45);
  border-radius: 5px;
  display: flex;
  gap: 12px;
  justify-content: space-between;
  margin-top: 18px;
  padding: 12px;
}

.progress-reset strong {
  color: var(--screen-glow);
  display: block;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.58rem;
  line-height: 1.35;
  text-transform: uppercase;
}

.progress-reset span {
  color: rgba(247, 255, 247, 0.64);
  display: block;
  font-size: 0.68rem;
  line-height: 1.3;
  margin-top: 5px;
}

.progress-reset__button {
  background: linear-gradient(#ff6d6d, var(--red));
  border: 0;
  border-bottom: 4px solid #8a191e;
  border-radius: 5px;
  color: #fff7d6;
  cursor: pointer;
  flex: 0 0 auto;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.56rem;
  line-height: 1;
  min-height: 42px;
  padding: 0 10px;
  text-shadow: 1px 1px 0 #7b171b;
  text-transform: uppercase;
}

.progress-reset__button:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

.progress-reset__button:active {
  border-bottom-width: 2px;
  transform: translateY(2px);
}

@media (max-width: 700px) {
  body {
    align-items: flex-start;
    justify-content: center;
  }

  .app-shell {
    align-items: center;
    flex-direction: column;
  }

  .quartermaster-panel,
  .contracts-panel,
  .curio-panel {
    max-width: 430px;
    min-width: 0;
    width: min(100%, 430px);
  }

  .settings-panel {
    max-width: 430px;
    min-width: 0;
    width: min(100%, 430px);
  }

  .store-item {
    min-width: 0;
  }
}

@media (min-width: 701px) and (max-width: 1120px) {
  .app-shell {
    flex-wrap: wrap;
    justify-content: center;
    width: min(100%, 900px);
  }

  .cabinet {
    flex-basis: 430px;
  }

  .quartermaster-panel,
  .contracts-panel,
  .curio-panel,
  .settings-panel {
    flex-basis: min(330px, calc(50% - 10px));
  }
}

@media (max-width: 420px) {
  body {
    padding: 12px;
  }

  .cabinet {
    padding: 14px 12px 18px;
  }

  .marquee {
    gap: 8px;
    margin-inline: 8px;
  }

  .marquee h1 {
    font-size: 0.82rem;
  }

  .marquee__spark {
    font-size: 0.8rem;
  }

  .screen {
    padding: 12px;
  }

  .hud {
    gap: 8px;
  }

  .meter {
    padding: 7px 6px;
  }

  .meter__label {
    font-size: 0.58rem;
  }

  .meter__value {
    font-size: 0.8rem;
  }

  .reset {
    font-size: 0.5rem;
    height: 54px;
    width: 54px;
  }

  .board {
    gap: 5px;
  }

  .controls {
    padding-inline: 28px;
  }
}

select {
  appearance: none;
  background: #080d13;
  border: 2px solid rgba(216, 255, 232, 0.22);
  border-radius: 5px;
  color: var(--screen-glow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.62rem;
  min-height: 42px;
  min-width: 116px;
  padding: 0 28px 0 8px;
  text-align: center;
}

select:focus-visible {
  outline: 3px solid var(--yellow);
  outline-offset: 2px;
}

select:disabled {
  cursor: not-allowed;
  opacity: 0.5;
}

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

.store-list .store-item {
  margin-top: 0;
}

.cell.is-chordable {
  cursor: pointer;
  outline: 2px dashed rgba(46, 196, 182, 0.7);
  outline-offset: -4px;
}

.stats-section {
  border-top: 1px solid rgba(216, 255, 232, 0.18);
  margin-top: 18px;
  padding-top: 14px;
}

.stats-grid {
  display: grid;
  gap: 6px 10px;
  grid-template-columns: minmax(0, 1fr) auto;
  margin: 0;
}

.stats-grid dt,
.stats-grid dd {
  border-bottom: 1px solid rgba(216, 255, 232, 0.08);
  font-size: 0.68rem;
  line-height: 1.35;
  margin: 0;
  padding: 3px 0;
}

.stats-grid dt {
  color: rgba(247, 255, 247, 0.7);
}

.stats-grid dd {
  color: var(--screen-glow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.56rem;
  text-align: right;
}

.fastest-section {
  margin-top: 14px;
}

.stats-label {
  color: rgba(216, 255, 232, 0.72);
  display: block;
  font-size: 0.68rem;
  line-height: 1.35;
  margin-bottom: 6px;
}

.fastest-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.fastest-list li {
  align-items: center;
  border-bottom: 1px solid rgba(216, 255, 232, 0.08);
  display: flex;
  font-size: 0.62rem;
  gap: 8px;
  justify-content: space-between;
  line-height: 1.35;
  padding: 4px 0;
}

.fastest-list li span {
  color: rgba(247, 255, 247, 0.72);
}

.fastest-list li strong {
  color: var(--yellow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.54rem;
  white-space: nowrap;
}

.fastest-list .fastest-empty {
  color: rgba(247, 255, 247, 0.5);
  display: block;
}

.settings-panel .setting-row label {
  min-width: 0;
}

.cabinet {
  position: sticky;
  top: 20px;
}

.quartermaster-panel {
  max-height: calc(100vh - 40px);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: var(--cyan) #080d13;
}

.contracts-panel {
  max-height: calc(100vh - 40px);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: var(--cyan) #080d13;
}

.curio-panel {
  max-height: calc(100vh - 40px);
  overflow-x: hidden;
  overflow-y: auto;
  scrollbar-color: var(--cyan) #080d13;
}

.quartermaster-panel .store-item__copy,
.quartermaster-panel .store-item__cost,
.quartermaster-panel .resource-card__detail {
  overflow-wrap: anywhere;
}

.store-item--compact {
  min-height: 28px;
  padding: 5px 8px;
}

.store-item--compact .store-item__copy {
  gap: 2px;
}

.store-item--compact .store-item__copy strong {
  font-size: 0.5rem;
}

.store-item--compact .store-item__copy small,
.store-item--compact .store-item__cost {
  font-size: 0.58rem;
}

.stats-section summary {
  cursor: pointer;
  list-style: none;
}

.stats-section summary::-webkit-details-marker {
  display: none;
}

.stats-section summary::after {
  color: var(--cyan);
  content: "+";
  float: right;
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.78rem;
}

.stats-section[open] summary::after {
  content: "−";
}

.stats-section summary h3 {
  color: var(--yellow);
  font-family: "Press Start 2P", system-ui, sans-serif;
  font-size: 0.94rem;
  line-height: 1.35;
  margin: 0;
  text-shadow: 2px 2px 0 rgba(228, 61, 64, 0.45);
}

.stats-section summary .store__eyebrow {
  margin-bottom: 5px;
}

@media (max-width: 420px) {
  select {
    font-size: 0.54rem;
    min-width: 98px;
  }

  .dev-buttons {
    grid-template-columns: 1fr;
  }

  .quartermaster-panel,
  .contracts-panel,
  .curio-panel {
    max-height: calc(100vh - 24px);
  }
}

@media (max-width: 700px) {
  .cabinet {
    position: sticky;
    top: 12px;
  }
}

@media (min-width: 1121px) {
  body {
    height: 100vh;
    overflow-x: auto;
    overflow-y: hidden;
  }

  .app-shell {
    max-width: none;
    min-width: max-content;
    width: max-content;
  }
}
