* {
  box-sizing: border-box;
}

:root {
  --page-top: #b9c8d3;
  --page-bottom: #596773;
  --panel: #eef3f6;
  --panel-warm: #dce5eb;
  --line: #607687;
  --text: #1d2a33;
  --muted: #536673;
  --brown: #243847;
  --red: #b64b4b;
  --green: #347d59;
  --gold: #f1c84b;
  --blue: #2d75a5;
  --money: #2d6f4e;
  --anthracite: #26323a;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(255,255,255,.72), transparent 34%),
    linear-gradient(155deg, var(--page-top), var(--page-bottom));
  font-family: Arial, Helvetica, sans-serif;
}

a:link, a:visited {color: var(--text);}

button,
input {
  font: inherit;
}

.game {
  width: min(1380px, calc(100% - 16px));
  margin: 0 auto;
  padding: 12px 0 28px;
}

.topbar,
.panel,
.statusBar,
.wealthBar {
  border: 1px solid rgba(52, 78, 96, .35);
  border-radius: 16px;
  background: rgba(238, 243, 246, .97);
  box-shadow: 0 14px 30px rgba(25, 42, 54, .22);
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 14px;
  padding: 15px 18px;
  flex-wrap: wrap;
}

.topbar h1 {
  margin: 0;
  color: var(--brown);
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(2.2rem, 5vw, 3.4rem);
}

.topbar p {
  margin: 4px 0 0;
  color: var(--muted);
}

.topActions {
  display: flex;
  gap: 9px;
  align-items: end;
  flex-wrap: wrap;
}

.numberControl {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 3px 5px;
  align-items: center;
  padding: 8px 10px;
  border: 1px solid rgba(112, 72, 46, .28);
  border-radius: 10px;
  background: #dce6ec;
}

.numberControl span:first-child {
  grid-column: 1 / -1;
  color: var(--muted);
  font-size: .76rem;
  font-weight: 800;
}

.numberControl input {
  width: 100px;
  padding: 6px;
  border: 1px solid #6f899b;
  border-radius: 7px;
  font-weight: 900;
}

.wealthBar {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 12px;
  padding: 10px;
}

.wealthItem {
  position: relative;
  overflow: hidden;
  padding: 12px 12px 12px 18px;
  border-radius: 12px;
  background: linear-gradient(#f8fbfd, #d7e2e9);
}

.wealthItem.active {
  outline: 3px solid var(--gold);
}

.wealthItem.out {
  opacity: .42;
  filter: grayscale(.8);
}

.wealthStripe {
  position: absolute;
  inset: 0 auto 0 0;
  width: 7px;
}

.wealthName {
  font-weight: 900;
}

.wealthValue {
  margin-top: 4px;
  color: var(--money);
  font-size: 1.42rem;
  font-weight: 900;
}

.wealthMeta {
  color: var(--muted);
  font-size: .82rem;
}

.layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 370px;
  gap: 15px;
  margin-top: 15px;
  align-items: start;
}

.panel {
  padding: 12px;
}

.boardPanel {
  overflow: hidden;
}

.board {
  position: relative;
  left: 5%;
  width: 100%;
  aspect-ratio: 1;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  border: 4px solid #263943;
  background: #8899a5;
  transform: scale(.9);
  transform-origin: top left;
  margin-bottom: -10%;
}

.boardCenter {
  grid-column: 2 / 7;
  grid-row: 2 / 7;
  display: grid;
  place-items: center;
  padding: 18px;
  border: 2px solid #607888;
  text-align: center;
  background:
    linear-gradient(rgba(231,239,244,.94), rgba(182,199,210,.96)),
    repeating-linear-gradient(45deg, #dbe5eb 0 24px, #c2d0d9 24px 48px);
}

.boardCenter h2 {
  margin: 8px 0 10px;
  color: #263d4c;
  font-family: Georgia, "Times New Roman", serif;
  font-size: clamp(1.7rem, 5.4vw, 4.2rem);
  line-height: .96;
}

.boardCenter p {
  color: #455d6c;
  line-height: 1.45;
}

.marketBadge {
  display: inline-block;
  padding: 6px 10px;
  border: 1px solid rgba(241, 200, 75, .72);
  border-radius: 999px;
  color: #273844;
  background: rgba(241, 200, 75, .25);
  font-size: .78rem;
  font-weight: 900;
}

.targetHint {
  font-weight: 900;
  color: var(--money) !important;
}

.field {
  position: relative;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  overflow: hidden;
  padding: 4px;
  border: 1px solid #617887;
  background: #f1f6f9;
}

.field.corner {
  justify-content: center;
  text-align: center;
  font-weight: 900;
  background: #cbd8df;
}

.fieldBand {
  height: 14px;
  margin: -4px -4px 3px;
  border-bottom: 1px solid rgba(38, 57, 69, .30);
}

.fieldIcon {
  text-align: center;
  font-size: clamp(1rem, 2vw, 1.65rem);
}

.fieldName {
  text-align: center;
  font-size: clamp(.48rem, 1vw, .78rem);
  font-weight: 900;
  line-height: 1.05;
}

.fieldText {
  color: var(--muted);
  text-align: center;
  font-size: clamp(.4rem, .8vw, .66rem);
}

.tokens {
  position: absolute;
  right: 2px;
  bottom: 2px;
  left: 2px;
  display: flex;
  justify-content: center;
  gap: 3px;
  flex-wrap: wrap;
  z-index: 4;
}

.token {
  width: 24px;
  aspect-ratio: 1;
  border: 2px solid white;
  border-radius: 50%;
  box-shadow: 0 3px 7px rgba(0,0,0,.4);
}

.sidePanel h2,
.sidePanel h3 {
  margin-top: 0;
  color: var(--brown);
  font-family: Georgia, "Times New Roman", serif;
}

.manualOption {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 10px;
  border: 1px solid rgba(112, 72, 46, .28);
  border-radius: 10px;
  background: var(--panel-warm);
  font-weight: 800;
  cursor: pointer;
}

.manualOption input {
  width: 19px;
  height: 19px;
  margin: 0;
}

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

.button {
  min-height: 44px;
  padding: 10px 13px;
  border: 0;
  border-radius: 10px;
  font-weight: 900;
  cursor: pointer;
}

.button:disabled {
  opacity: .42;
  cursor: not-allowed;
}

.button--primary {
  color: white;
  background: linear-gradient(#558eb3, #386b8d);
}

.button--buy {
  color: white;
  background: linear-gradient(#58a570, #367a4d);
}

.button--offer {
  color: #3f2e20;
  background: linear-gradient(#ffe37a, #e4b92f);
}

.button--neutral {
  color: white;
  background: #7c6b5e;
}

.button--dark {
  color: white;
  background: #283b47;
}

.dealerCard,
.negotiationPanel,
.inventoryCard {
  margin-top: 12px;
  padding: 12px;
  border: 1px solid rgba(112, 72, 46, .28);
  border-radius: 11px;
  background: linear-gradient(#f7fbfd, #dce7ed);
}

.dealerCard p,
.inventoryCard p {
  color: var(--muted);
  line-height: 1.45;
}

.itemName {
  font-size: 1.08rem;
  font-weight: 900;
}

.itemMeta {
  margin-top: 4px;
  color: var(--muted);
  font-size: .84rem;
}

.offerRow {
  display: grid;
  grid-template-columns: 44px 1fr 44px;
  gap: 7px;
  margin-top: 6px;
}

.offerRow input {
  min-width: 0;
  width: 100%;
  padding: 9px;
  border: 1px solid #718a9a;
  border-radius: 8px;
  text-align: center;
  font-weight: 900;
}

.offerAdjust {
  border: 0;
  border-radius: 8px;
  color: white;
  background: #405e72;
  font-size: 1.35rem;
  font-weight: 900;
  cursor: pointer;
}

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

.negotiationButtons .button--neutral {
  grid-column: 1 / -1;
}

.inventoryList {
  display: grid;
  gap: 7px;
}

.inventoryRow {
  padding: 8px;
  border-radius: 8px;
  background: rgba(157, 113, 72, .1);
  font-size: .85rem;
}

.inventoryValue {
  color: var(--money);
  font-weight: 900;
}

.log {
  max-height: 280px;
  margin-top: 12px;
  overflow: auto;
  padding: 9px;
  border-radius: 10px;
  color: #edf6fb;
  background: #263a47;
  font-size: .85rem;
  line-height: 1.4;
}

.log div {
  padding: 4px;
  border-bottom: 1px solid rgba(255,255,255,.12);
}

.statusBar {
  min-height: 52px;
  margin-top: 14px;
  padding: 14px 17px;
  color: #263d4b;
  font-weight: 900;
  line-height: 1.45;
}

.diceRow {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 18px 0 8px;
}

.die {
  width: 70px;
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  border: 3px solid #536d7d;
  border-radius: 14px;
  color: #22323d;
  background: white;
  font-size: 2.8rem;
  box-shadow: inset 0 0 12px rgba(0,0,0,.1), 0 7px 15px rgba(27,48,61,.28);
}

.overlay {
  position: fixed;
  inset: 0;
  display: none;
  place-items: center;
  padding: 20px;
  background: rgba(24, 35, 43, .82);
  z-index: 100;
}

.overlay.show {
  display: grid;
}

.dialog {
  width: min(460px, 100%);
  padding: 25px;
  border: 2px solid var(--gold);
  border-radius: 18px;
  background: #f1f6f9;
  text-align: center;
}

.dialog h2 {
  color: var(--brown);
}

@media (max-width: 940px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .sidePanel {
    order: -1;
  }
}

@media (max-width: 650px) {
  .wealthBar {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 520px) {
  .game {
    width: calc(100% - 6px);
  }

  .panel {
    padding: 5px;
  }

  .board {
    border-width: 2px;
  }

  .field {
    padding: 1px;
  }

  .fieldBand {
    height: 7px;
    margin: -1px -1px 1px;
  }

  .fieldIcon {
    font-size: .8rem;
  }

  .fieldName {
    font-size: .38rem;
  }

  .fieldText {
    font-size: .32rem;
  }

  .token {
    width: 16px;
    border-width: 1px;
  }

  .die {
    width: 52px;
    font-size: 2rem;
  }

  .boardCenter p {
    font-size: .7rem;
  }
}
