:root {
  --ink: #06141b;
  --panel: rgba(22, 105, 130, .90);
  --panel-solid: #166982;
  --panel-dark: rgba(16, 78, 99, .90);
  --line: #06141b;
  --cream: #f3eee2;
  --gold: #f6c64a;
  --wet: rgba(182, 0, 0, .90);
  --dry: rgba(0, 111, 179, .90);
  --green: rgba(0, 184, 92, .94);
  --muted: #d8e3e8;
  --road: rgba(34, 43, 47, .16);
  --dev: rgba(255,255,255,.08);
  --grass: rgba(38,126,28,.10);
  --grid-offset-x: 0px;
  --grid-offset-y: 0px;
  --grid-scale-x: 1;
  --grid-scale-y: 1;
}

* { box-sizing: border-box; }

/* Ensure the settings / card modal stays hidden until JavaScript opens it. */
[hidden], .modal[hidden], .card-preview[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  font-family: Arial, Helvetica, sans-serif;
  background: #111 url("../assets/background/prohibition-background.png") center center / cover fixed no-repeat;
}

button, select, input { font: inherit; }
.screen { display: none; }
.screen.active { display: block; }

.load-card {
  max-width: 920px;
  margin: 36px auto;
  background: rgba(255,255,255,.93);
  border: 4px solid var(--line);
  box-shadow: 10px 10px 0 rgba(0,0,0,.34);
  padding: 28px;
}

.brand-block h1, .title-box h1 { margin: 0; font-size: 34px; line-height: .95; letter-spacing: -.04em; }
.brand-block p, .title-box p { margin: 6px 0 0; font-weight: 700; letter-spacing: -.02em; }
.load-card h2 { margin: 24px 0 6px; }
.muted { color: #50626a; }
.player-setup { display: grid; grid-template-columns: repeat(3, minmax(180px, 1fr)); gap: 12px; margin: 22px 0; }
.setup-slot { border: 2px solid var(--line); background: rgba(247,250,251,.93); padding: 12px; }
.setup-slot label { display: grid; gap: 8px; font-weight: 700; }
.setup-slot select { width: 100%; border: 2px solid var(--line); padding: 8px; background: rgba(255,255,255,.94); }
.check-row { display: flex; align-items: center; gap: 10px; margin: 10px 0; }
.load-actions { display: flex; justify-content: flex-end; gap: 12px; margin-top: 22px; }

.btn {
  cursor: pointer;
  border: 3px solid var(--line);
  border-radius: 12px;
  padding: 12px 18px;
  font-weight: 800;
  color: #fff;
  background: var(--green);
  box-shadow: 0 2px 0 rgba(0,0,0,.25);
}
.btn:hover { transform: translateY(-1px); }
.btn:disabled { cursor: not-allowed; opacity: .45; transform: none; }
.btn.primary { background: var(--green); }
.btn.secondary { background: var(--panel); }

.game-shell.active {
  display: grid;
  grid-template-columns: 250px minmax(760px, 1fr) 230px;
  gap: 14px;
  min-height: 100vh;
  padding: 10px 12px;
}

.left-rail { display: flex; flex-direction: column; gap: 10px; min-height: 0; }
.title-box { text-align: center; padding: 12px 0 6px; background: rgba(255,255,255,.80); border: 3px solid rgba(6,20,27,.75); }
.title-box h1 { font-size: 31px; }
.small-label { font-size: 10px; font-weight: 800; margin: 0 0 6px 4px; color: #fff; text-shadow: 0 1px 2px #000; }
.player-badges { display: grid; grid-template-columns: repeat(6, 1fr); gap: 6px; }
.player-badge {
  border: 3px solid var(--line);
  background: rgba(119,130,138,.90);
  color: #fff;
  font-size: 21px;
  font-weight: 900;
  height: 34px;
  display: grid;
  place-items: center;
  position: relative;
}
.player-badge.dry { background: var(--dry); }
.player-badge.wet { background: var(--wet); }
.player-badge.inactive { background: rgba(122,122,122,.85); opacity: .55; }
.player-badge.active-turn { border-color: var(--gold); box-shadow: 0 0 0 3px rgba(246,198,74,.55); }
.player-badge.computer::after { content: "CPU"; position: absolute; bottom: -14px; left: 50%; transform: translateX(-50%); color: #fff; text-shadow: 0 1px 2px #000; font-size: 8px; font-weight: 900; }

.money-display {
  min-height: 59px;
  border: 3px solid var(--line);
  background: var(--panel);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 31px;
  letter-spacing: .02em;
}
.dice-row { display: grid; grid-template-columns: 72px 1fr; gap: 8px; }
.dice-face {
  height: 74px;
  border: 3px solid var(--line);
  background: var(--panel);
  color: #fff;
  display: grid;
  place-items: center;
  text-align: center;
  font-weight: 900;
  font-size: 14px;
}
.dice-face.rolled { font-size: 48px; line-height: 1; background: rgba(255,255,255,.93); color: var(--ink); }
.roll-btn {
  border: 3px solid var(--line);
  border-radius: 12px;
  background: var(--green);
  color: #fff;
  font-weight: 900;
  font-size: 18px;
}
.roll-btn:disabled { opacity: .45; }

.turn-buttons { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.left-turn-buttons { margin-top: -2px; }
.btn.control { min-height: 54px; padding: 7px; font-size: 11px; line-height: 1.08; }

.active-card-panel {
  flex: 1 1 285px;
  min-height: 235px;
  border: 3px solid var(--line);
  background: var(--panel);
  padding: 10px;
  display: grid;
  min-width: 0;
}
.active-character-card.placeholder { display: grid; place-items: center; color: #fff; font-size: 27px; text-align: center; line-height: 1.2; }
.active-character-card img { width: 100%; height: 100%; object-fit: contain; display: block; }

.right-area { display: grid; grid-template-rows: minmax(360px, 1fr) 215px; gap: 12px; min-width: 0; min-height: 0; }
.board-panel { border: 3px solid var(--line); background: var(--panel); padding: 8px; display: grid; min-height: 0; }
.board-wrap {
  position: relative;
  width: 100%;
  max-height: 100%;
  aspect-ratio: 1672 / 941;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #0d2229;
  --grid-offset-x: 0px;
  --grid-offset-y: 0px;
  --grid-scale-x: 1;
  --grid-scale-y: 1;
}
.board-wrap img { width: 100%; height: 100%; object-fit: fill; user-select: none; pointer-events: none; }
.piece-layer, .grid-overlay {
  position: absolute;
  inset: 0;
  margin: auto;
  pointer-events: none;
  transform: translate(var(--grid-offset-x), var(--grid-offset-y)) scale(var(--grid-scale-x), var(--grid-scale-y));
  transform-origin: top left;
}
.grid-overlay { display: grid; grid-template-columns: repeat(26, 1fr); grid-template-rows: repeat(15, 1fr); opacity: 0; }
.grid-overlay.show-grid { opacity: 1; }
.grid-cell { border: 1px solid transparent; background: transparent; }
.grid-overlay.show-grid .grid-cell { border-color: rgba(255,255,255,.42); }
.grid-overlay.show-grid .grid-cell.start { background: rgba(246,198,74,.18); }
.grid-overlay.show-grid .grid-cell.road { background: rgba(80,80,80,.10); }
.grid-overlay.show-grid .grid-cell.dev { background: rgba(255,255,255,.08); }
.grid-overlay.show-grid .grid-cell.grass { background: rgba(38,126,28,.08); }

.highlight { position: absolute; border: 3px solid var(--gold); background: rgba(246,198,74,.22); border-radius: 8px; pointer-events: auto; cursor: pointer; }
.highlight.invalid { border-color: #f34f4f; background: rgba(243,79,79,.18); }
.token {
  position: absolute;
  width: min(30px, 2.1vw);
  height: min(30px, 2.1vw);
  border: 3px solid #fff;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-weight: 900;
  color: #fff;
  text-shadow: 0 1px 2px #000;
  transform: translate(-50%, -50%);
  box-shadow: 0 2px 6px rgba(0,0,0,.55);
  pointer-events: none;
  z-index: 30;
}
.token.dry { background: var(--dry); }
.token.wet { background: var(--wet); }
.token.arrested { opacity: .25; filter: grayscale(1); }
.placed-building {
  position: absolute;
  z-index: 20;
  border: 2px solid rgba(8,16,21,.95);
  border-radius: 6px;
  background: linear-gradient(135deg, rgba(168,141,92,.94) 0%, rgba(93,74,48,.94) 100%);
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.14), 0 5px 10px rgba(0,0,0,.45);
  overflow: hidden;
  pointer-events: none;
}
.placed-building::before {
  content: "";
  position: absolute;
  inset: 7%;
  border: 2px solid rgba(255,255,255,.34);
  background:
    repeating-linear-gradient(90deg, rgba(0,0,0,.18) 0 4px, transparent 4px 11px),
    radial-gradient(circle at 50% 50%, rgba(246,198,74,.28), transparent 45%);
}
.placed-building.wet { outline: 4px solid rgba(182,0,0,.72); }
.placed-building.dry { outline: 4px solid rgba(0,111,179,.72); }
.placed-building.speakeasy { box-shadow: inset 0 0 0 2px rgba(255,255,255,.14), 0 0 0 5px rgba(182,0,0,.42), 0 5px 10px rgba(0,0,0,.45); }
.placed-building .building-label {
  position: absolute;
  inset: auto 4px 4px 4px;
  background: rgba(6,20,27,.78);
  color: #fff;
  font-size: 10px;
  font-weight: 900;
  text-align: center;
  padding: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.fire-marker { position: absolute; top: 2px; right: 3px; font-size: 18px; z-index: 2; }

.action-hand-panel, .building-hand-panel {
  border: 3px solid var(--line);
  background: var(--panel);
  color: #fff;
  padding: 10px;
  min-width: 0;
  overflow: visible;
}
.action-hand-panel header, .building-hand-panel header { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.action-hand-panel h2, .building-hand-panel h2 { margin: 0; font-size: 29px; font-weight: 500; text-align: center; flex: 1; }
.left-card-deck { flex: 0 0 165px; display: grid; grid-template-rows: auto 1fr; }
.left-card-deck h2 { font-size: 16px; line-height: 1.12; }
.pill { border: 2px solid #fff; border-radius: 999px; padding: 3px 8px; font-weight: 800; font-size: 12px; white-space: nowrap; }
.card-strip { display: flex; gap: 8px; overflow-x: auto; padding: 10px 2px 8px; min-height: 118px; }
.action-strip { height: 165px; overflow-y: visible; align-items: flex-start; }
.building-strip { height: 126px; align-items: flex-start; }
.hand-card {
  flex: 0 0 66px;
  height: 96px;
  border: 2px solid #041015;
  border-radius: 6px;
  background: #f6efe4;
  color: var(--ink);
  cursor: pointer;
  overflow: hidden;
  position: relative;
  box-shadow: 0 3px 5px rgba(0,0,0,.28);
}
.action-strip .hand-card { flex-basis: 104px; height: 150px; }
.building-strip .hand-card { flex-basis: 76px; height: 110px; }
.hand-card:hover { transform: translateY(-3px); }
.hand-card img { width: 100%; height: 100%; object-fit: cover; display: block; }
.hand-card .fallback-title { display: grid; place-items: center; text-align: center; font-size: 9px; font-weight: 900; padding: 4px; height: 100%; }
.hand-card .mini-badge { position: absolute; left: 2px; right: 2px; bottom: 2px; background: rgba(6,20,27,.78); color: #fff; text-align: center; font-size: 8px; padding: 2px; font-weight: 900; }
.action-strip .hand-card .mini-badge { font-size: 9px; }

.card-preview {
  position: fixed;
  z-index: 2000;
  pointer-events: none;
  width: 416px;
  max-width: min(416px, 92vw);
  filter: drop-shadow(0 12px 22px rgba(0,0,0,.55));
}
.card-preview img {
  width: 100%;
  max-height: 82vh;
  object-fit: contain;
  border: 3px solid var(--line);
  border-radius: 10px;
  background: #f6efe4;
}

.log-panel { border: 3px solid var(--line); background: rgba(249,251,252,.90); min-width: 0; max-height: calc(100vh - 20px); overflow: hidden; display: flex; flex-direction: column; }
.log-title { background: var(--panel); color: #fff; padding: 10px; font-weight: 900; border-bottom: 3px solid var(--line); }
#game-log { padding: 10px; overflow-y: auto; font-size: 12px; line-height: 1.4; }
.log-entry { border-bottom: 1px solid #d9e1e4; padding: 6px 0; }
.log-entry strong { color: var(--panel-solid); }

.modal { position: fixed; inset: 0; background: rgba(0,0,0,.48); display: grid; place-items: center; z-index: 999; padding: 22px; }
.modal-card { background: rgba(255,255,255,.96); border: 4px solid var(--line); max-width: 760px; width: min(760px, 100%); max-height: 88vh; overflow-y: auto; padding: 22px; position: relative; box-shadow: 12px 12px 0 rgba(0,0,0,.24); }
.modal-close { position: absolute; right: 10px; top: 8px; background: transparent; border: 0; font-size: 34px; cursor: pointer; }
.modal-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 18px; }
.modal-card table { width: 100%; border-collapse: collapse; margin-top: 10px; }
.modal-card td, .modal-card th { border: 1px solid #cbd5da; padding: 7px; text-align: left; vertical-align: top; }
.choice-list { display: grid; gap: 8px; margin-top: 10px; }
.choice-list button { text-align: left; border: 2px solid var(--line); background: #f7fafb; padding: 10px; cursor: pointer; }
.choice-list button:hover { background: #e8f2f5; }

.grid-settings { margin-top: 14px; padding: 12px; border: 2px solid var(--line); background: rgba(247,250,251,.92); }
.grid-settings h3 { margin: 0 0 10px; }
.grid-settings .check-row { margin: 8px 0 12px; }
.grid-controls { display: grid; grid-template-columns: repeat(3, minmax(120px, 1fr)); gap: 10px; margin-bottom: 12px; }
.grid-controls label { display: grid; gap: 5px; font-weight: 700; }
.grid-controls input { border: 2px solid var(--line); padding: 7px; }
.grid-nudge { display: grid; grid-template-columns: repeat(5, 1fr); gap: 8px; }
.grid-nudge button { border: 2px solid var(--line); background: var(--panel); color: #fff; padding: 8px; font-weight: 900; cursor: pointer; }
.grid-nudge button:hover { filter: brightness(1.1); }

.rules-btn {
  margin: 10px;
  min-height: 42px;
  background: var(--green);
  color: #fff;
  border: 3px solid var(--line);
  font-weight: 900;
}
.rules-btn:hover { filter: brightness(1.06); }
.rules-content h3 { margin: 16px 0 6px; }
.rules-content ul { margin: 6px 0 10px 20px; padding: 0; }
.rules-content li { margin: 4px 0; line-height: 1.35; }
.card-modal-image {
  max-width: 190px;
  float: right;
  margin: 0 0 12px 12px;
  border: 2px solid #06141b;
  border-radius: 8px;
}
.recycle-warning {
  margin-top: 12px;
  padding: 9px 10px;
  border-left: 4px solid var(--gold);
  background: rgba(246,198,74,.18);
  font-weight: 700;
}

@media (max-width: 1180px) {
  .game-shell.active { grid-template-columns: 225px 1fr; }
  .log-panel { display: none; }
  .right-area { grid-template-rows: minmax(340px, 1fr) 205px; }
  .action-hand-panel h2 { font-size: 22px; }
  .left-card-deck h2 { font-size: 14px; }
  .action-strip .hand-card { flex-basis: 94px; height: 136px; }
  .card-preview { width: 376px; }
}

/* V6 asset polish */
.logo-block,
.logo-box {
  display: grid;
  place-items: center;
  overflow: visible;
}
.logo-block img {
  display: block;
  width: min(640px, 100%);
  height: auto;
  margin: 0 auto 4px;
}
.logo-box {
  padding: 6px 4px;
  background: rgba(255,255,255,.68);
}
.logo-box img {
  display: block;
  width: 100%;
  max-height: 74px;
  object-fit: contain;
}
.dice-face {
  padding: 0;
  overflow: hidden;
  background: transparent;
}
.dice-face img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.dice-face.rolled {
  background: transparent;
}
.image-button {
  font-size: 0;
  line-height: 0;
  border: 0;
  background-color: transparent;
  background-repeat: no-repeat;
  background-position: center;
  background-size: contain;
  box-shadow: none;
  border-radius: 0;
  padding: 0;
  min-width: 0;
}
.image-button span {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
.image-button:hover,
.image-button:active {
  transform: none;
  filter: brightness(1.03);
}
.roll-image-button {
  min-height: 74px;
  background-image: url('../assets/ui/Button_Roll_Dice.png');
}
.roll-image-button:hover,
.roll-image-button:active {
  background-image: url('../assets/ui/Button_Roll_Dice_Hover.png');
}
.turn-buttons {
  grid-template-columns: 1fr;
  gap: 6px;
}
.btn.control.image-button {
  min-height: 54px;
  width: 100%;
}
.end-image-button { background-image: url('../assets/ui/Button_End_Turn.png'); }
.end-image-button:hover,
.end-image-button:active { background-image: url('../assets/ui/Button_End_Turn_Hover.png'); }
.automate-image-button { background-image: url('../assets/ui/Button_Automate_Turn.png'); }
.automate-image-button:hover,
.automate-image-button:active { background-image: url('../assets/ui/Button_Automate_Turn_Hover.png'); }
.settings-image-button { background-image: url('../assets/ui/Button_Settings.png'); }
.settings-image-button:hover,
.settings-image-button:active { background-image: url('../assets/ui/Button_Settings_Hover.png'); }
.image-button:disabled {
  opacity: .45;
  filter: grayscale(.35);
}
.placed-building.town-hall {
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  overflow: visible;
  outline: 0;
  z-index: 18;
}
.placed-building.town-hall::before,
.placed-building.town-hall .building-label {
  display: none;
}
.placed-building.town-hall img {
  position: absolute;
  left: 50%;
  top: 50%;
  width: 132%;
  height: 160%;
  object-fit: contain;
  transform: translate(-50%, -58%);
  filter: drop-shadow(0 7px 10px rgba(0,0,0,.45));
}
.image-button { position: relative; }


/* V7 layout and alignment refinements */
.title-box.logo-box {
  background: transparent;
  border: 0;
  padding: 0;
}
.logo-box {
  background: transparent;
}
.logo-box img {
  filter: drop-shadow(0 4px 8px rgba(0,0,0,.45));
}

.left-turn-buttons {
  grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  gap: 6px;
}
.btn.control.image-button {
  min-height: 46px;
  height: 46px;
  width: 100%;
  background-size: contain;
}

.board-panel {
  border: 0;
  background: transparent;
  padding: 0;
  display: block;
  align-self: start;
}
.board-wrap {
  border: 3px solid var(--line);
  background: var(--panel);
  width: 100%;
  height: auto;
  max-height: none;
}
.board-wrap img {
  display: block;
}

.grid-controls {
  grid-template-columns: repeat(4, minmax(120px, 1fr));
}
@media (max-width: 1180px) {
  .left-turn-buttons {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
  }
  .btn.control.image-button {
    min-height: 42px;
    height: 42px;
  }
  .grid-controls {
    grid-template-columns: repeat(2, minmax(120px, 1fr));
  }
}


/* V8 money, targeting, and purchase controls */
.money-display {
  min-height: 72px;
  padding: 4px 8px;
  overflow: hidden;
}
.money-display.frozen {
  box-shadow: inset 0 0 0 2px rgba(200,236,255,.35), 0 0 0 2px rgba(255,255,255,.08);
}
.money-glyphs {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 2px;
  flex-wrap: nowrap;
}
.money-glyph {
  height: 58px;
  width: auto;
  display: block;
  object-fit: contain;
  filter: drop-shadow(0 2px 4px rgba(0,0,0,.35));
}
.money-glyph.symbol, .money-glyph.comma {
  height: 52px;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.deck-plus-button {
  width: 34px;
  height: 34px;
  border: 2px solid rgba(255,255,255,.92);
  border-radius: 8px;
  background: linear-gradient(180deg, rgba(246,198,74,.96), rgba(189,135,32,.96));
  color: #1d1003;
  font-size: 24px;
  line-height: 1;
  font-weight: 900;
  cursor: pointer;
  box-shadow: 0 2px 5px rgba(0,0,0,.25);
}
.deck-plus-button:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.03);
}
.deck-plus-button:disabled {
  opacity: .45;
  cursor: not-allowed;
}
.token.selectable-target, .placed-building.selectable-target {
  pointer-events: auto;
  cursor: pointer;
}
.token.selectable-target {
  box-shadow: 0 0 0 4px rgba(246,198,74,.55), 0 2px 8px rgba(0,0,0,.55);
  animation: pulse-target 1s infinite alternate;
}
.placed-building.selectable-target {
  outline: 5px solid rgba(246,198,74,.85) !important;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.14), 0 0 0 6px rgba(246,198,74,.38), 0 5px 10px rgba(0,0,0,.45);
}
.target-help {
  margin-top: 8px;
  color: #fff;
  text-align: center;
  font-size: 13px;
  font-weight: 800;
  text-shadow: 0 1px 2px rgba(0,0,0,.8);
}
.speakeasy-marker {
  position: absolute;
  top: 3px;
  left: 4px;
  font-size: 18px;
  z-index: 3;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,.5));
}
@keyframes pulse-target {
  from { transform: translate(-50%, -50%) scale(1); }
  to { transform: translate(-50%, -50%) scale(1.08); }
}
.purchase-card-list {
  display: grid;
  gap: 8px;
  margin-top: 12px;
}
.purchase-card-option {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 8px 10px;
  border: 1px solid #cbd5da;
  background: #f8fbfc;
}
.purchase-card-option input {
  margin-top: 2px;
}
.purchase-card-option strong {
  display: block;
}
.purchase-card-option span {
  display: block;
  font-size: 12px;
  color: #34444b;
}
.purchase-help {
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(246,198,74,.16);
  border-left: 4px solid var(--gold);
}
@media (max-width: 1180px) {
  .money-glyph { height: 48px; }
  .money-glyph.symbol, .money-glyph.comma { height: 42px; }
  .deck-plus-button { width: 30px; height: 30px; font-size: 21px; }
}
