* {
  box-sizing: border-box;
}

button,
.tile,
.cell,
.modal-option,
.hotel-card,
.mode-btn,
.drawer-item,
.buy-count,
.stock-chip {
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

body {
  margin: 0;
  min-height: 100vh;
  padding: 5rem 2rem 2rem;
  background: white;
  color: black;
  font-family: system-ui, sans-serif;
}

body.setup-view {
  background: #2b2b2b;
  color: #f0f0f0;
}

body.splash-view {
  background: #2b2b2b;
  color: #f0f0f0;
  padding: 0;
  overflow: hidden;
}

body.splash-view #game-banner {
  display: none;
}

#splash {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  background: #2b2b2b;
  color: #f0f0f0;
  z-index: 1000;
  animation: splash-fade-in 0.25s ease-out;
}

#splash.fading-out {
  animation: splash-fade-out 0.35s ease-in forwards;
}

#splash-icon {
  width: min(45vw, 192px);
  height: min(45vw, 192px);
  border-radius: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
  background: #444;
}

#splash-title {
  font-size: clamp(1.3rem, 3.5vw, 1.75rem);
  font-weight: bold;
  letter-spacing: 0.02em;
}

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

@keyframes splash-fade-out {
  from { opacity: 1; }
  to { opacity: 0; }
}

.version-badge {
  display: inline-block;
  margin-left: 0.75rem;
  padding: 0.15rem 0.5rem;
  font-size: 0.7em;
  font-weight: normal;
  border: 1px solid currentColor;
  border-radius: 999px;
  vertical-align: middle;
  opacity: 0.75;
  letter-spacing: 0.03em;
}

#setup {
  margin-bottom: 2rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 520px;
}

#mode-chooser { display: flex; gap: 0.5rem; }
#setup-players { display: flex; flex-direction: column; gap: 1rem; min-width: 0; }
#online-lobby { display: flex; flex-direction: column; gap: 0.75rem; }

.mode-btn {
  padding: 0.65rem 1.25rem;
  font-size: 1rem;
  cursor: pointer;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fafafa;
}
.mode-btn.active {
  background: #333;
  color: white;
  border-color: #333;
}

body.setup-view .mode-btn {
  background: #3d3d3d;
  color: #e8e8e8;
  border-color: #555;
  border-radius: 6px;
  padding: 0.6rem 1.4rem;
}
body.setup-view .mode-btn.active {
  background: #2f8f3a;
  color: #ffffff;
  border-color: #2f8f3a;
}
body.setup-view #host-create-btn,
body.setup-view #join-connect-btn {
  background: #2f8f3a;
  border-color: #2f8f3a;
  color: #ffffff;
  border-radius: 6px;
  padding: 0.75rem 1.5rem;
}
body.setup-view #host-create-btn:hover,
body.setup-view #join-connect-btn:hover {
  background: #267a30;
  border-color: #267a30;
}
body.setup-view #host-create-btn:disabled,
body.setup-view #join-connect-btn:disabled {
  background: #666;
  border-color: #666;
  color: #ddd;
}
body.setup-view #host-panel,
body.setup-view #join-panel {
  background: #3a3a3a;
  border-color: #555;
  color: #e8e8e8;
}
body.setup-view #host-panel input,
body.setup-view #join-panel input,
body.setup-view #name-inputs input,
body.setup-view #name-inputs select,
body.setup-view #setup-players select {
  background: #ffffff;
  color: #1a1a1a;
  border: 1px solid #bbb;
  border-radius: 6px;
}
body.setup-view #host-room-info {
  background: #2b2b2b;
  border-color: #555;
  color: #e8e8e8;
}
body.setup-view #instructions {
  background: #3a3a3a;
  border-color: #555;
  color: #e8e8e8;
}
body.setup-view .link-btn {
  color: #7ec8ff;
}
body.setup-view #start-btn {
  background: #2f8f3a;
  color: #ffffff;
  border: 1px solid #2f8f3a;
  border-radius: 6px;
  padding: 0.75rem 1.75rem;
  font-weight: bold;
  font-size: 1.05rem;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
}
body.setup-view #start-btn:hover {
  background: #267a30;
  border-color: #267a30;
}

#online-role-chooser {
  display: flex;
  gap: 0.75rem;
}

#online-role-chooser .mode-btn {
  padding: 1.1rem 1.75rem;
  font-size: 1.2rem;
  font-weight: bold;
  flex: 1 1 auto;
}

#host-panel, #join-panel {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem;
  border: 1px solid #ccc;
  border-radius: 4px;
  background: #fafafa;
}

#host-create-btn, #join-connect-btn {
  padding: 0.9rem 1.5rem;
  font-size: 1.15rem;
  font-weight: bold;
  cursor: pointer;
  border: 1px solid #333;
  border-radius: 4px;
  background: #333;
  color: white;
  margin-top: 0.25rem;
}
#host-create-btn:disabled, #join-connect-btn:disabled {
  background: #999;
  border-color: #999;
  cursor: not-allowed;
}

#host-panel label, #join-panel label {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  font-size: 0.9rem;
}
#host-panel input, #join-panel input {
  padding: 0.5rem;
  font-size: 1rem;
}

#host-room-info {
  margin-top: 0.5rem;
  padding: 0.75rem;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
#host-room-code-line {
  font-size: 1rem;
}
#host-room-code {
  font-family: monospace;
  font-size: 1.35rem;
  font-weight: bold;
  padding: 0.15rem 0.4rem;
  background: #333;
  color: white;
  border-radius: 4px;
  letter-spacing: 0.1em;
}
#host-guest-list, #join-status {
  font-size: 0.95rem;
}
#join-status.error {
  color: #a00;
  font-weight: bold;
}

.host-bots-label {
  font-weight: bold;
  margin-top: 0.35rem;
  font-size: 0.95rem;
}
.host-bot-row {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  margin: 0.25rem 0;
}
.host-bot-row input {
  padding: 0.3rem 0.4rem;
  font-size: 0.9rem;
  width: 8rem;
}
.host-bot-row select {
  padding: 0.3rem 0.25rem;
  font-size: 0.9rem;
}
.host-bot-remove {
  border: none;
  background: transparent;
  color: #a00;
  font-size: 1.2rem;
  cursor: pointer;
}
#host-add-bot-btn {
  padding: 0.35rem 0.75rem;
  font-size: 0.9rem;
  align-self: flex-start;
  cursor: pointer;
}
#host-start-btn {
  padding: 0.6rem 1rem;
  margin-top: 0.5rem;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
  background: #2f8f3a;
  color: white;
  border: none;
  border-radius: 4px;
}
#host-start-btn:disabled {
  background: #999;
  cursor: not-allowed;
}

.link-btn {
  background: none;
  border: none;
  color: #06c;
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
  align-self: flex-start;
}
.variant-label { margin-top: 1.5rem; }

#name-inputs {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

#name-inputs input {
  padding: 0.5rem;
  font-size: 1rem;
  min-width: 220px;
}

#start-btn {
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  cursor: pointer;
  width: fit-content;
}

#instructions {
  border: 1px solid #ccc;
  border-radius: 4px;
  padding: 0.5rem 0.75rem;
  background: #fafafa;
}

#instructions > summary {
  cursor: pointer;
  font-weight: bold;
  font-size: 1.05rem;
  padding: 0.25rem 0;
}

#instructions[open] > summary {
  margin-bottom: 0.5rem;
}

.instructions-body h2 {
  font-size: 1.05rem;
  margin: 1rem 0 0.35rem;
}

.instructions-body p,
.instructions-body ul,
.instructions-body ol {
  margin: 0.35rem 0;
}

.instructions-body ul ul,
.instructions-body ol ul {
  margin: 0.15rem 0;
}

.hidden {
  display: none !important;
}

#game {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  position: relative;
}

#game-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: #333;
  color: white;
  border-bottom: 1px solid #222;
  z-index: 15;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

#update-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0.75rem;
  background: #2f8f3a;
  color: white;
  z-index: 25;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.25);
  font-size: 0.95rem;
}
#update-banner-message {
  flex: 1;
  min-width: 0;
}
#update-banner-reload {
  background: white;
  color: #1f5f28;
  border: none;
  border-radius: 4px;
  padding: 0.4rem 0.9rem;
  font-weight: bold;
  cursor: pointer;
  white-space: nowrap;
}
#update-banner-reload:hover {
  background: #e6f4e8;
}
#update-banner-dismiss {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.35rem;
  line-height: 1;
  width: 32px;
  height: 32px;
  cursor: pointer;
  border-radius: 999px;
  -webkit-tap-highlight-color: transparent;
}
#update-banner-dismiss:hover,
#update-banner-dismiss:focus {
  background: rgba(0, 0, 0, 0.15);
  outline: none;
}

body.update-banner-visible #game-banner {
  top: 44px;
}
body.update-banner-visible {
  padding-top: 8rem;
}
body.splash-view #update-banner {
  display: none;
}

#ios-install-hint {
  position: fixed;
  left: 0.5rem;
  right: 0.5rem;
  bottom: calc(0.5rem + env(safe-area-inset-bottom, 0px));
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.6rem 0.75rem;
  background: #333;
  color: white;
  border-radius: 8px;
  z-index: 30;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  font-size: 0.9rem;
}
#ios-install-hint-message {
  flex: 1;
  min-width: 0;
  line-height: 1.3;
}
#ios-install-hint-dismiss {
  background: transparent;
  border: none;
  color: white;
  font-size: 1.35rem;
  line-height: 1;
  width: 32px;
  height: 32px;
  cursor: pointer;
  border-radius: 999px;
  flex-shrink: 0;
  -webkit-tap-highlight-color: transparent;
}
#ios-install-hint-dismiss:hover,
#ios-install-hint-dismiss:focus {
  background: rgba(255, 255, 255, 0.15);
  outline: none;
}
body.splash-view #ios-install-hint,
body:has(#modal-overlay:not(.hidden)) #ios-install-hint {
  display: none;
}

#drawer-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: transparent;
  border: 1px solid #666;
  border-radius: 4px;
  color: white;
  cursor: pointer;
}
#drawer-toggle:hover {
  background: #444;
}

.hamburger-icon {
  position: relative;
  display: block;
  width: 20px;
  height: 2px;
  background: currentColor;
}
.hamburger-icon::before,
.hamburger-icon::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 2px;
  background: currentColor;
}
.hamburger-icon::before { top: -6px; }
.hamburger-icon::after  { top:  6px; }

#game-banner-title {
  font-weight: bold;
  font-size: 1rem;
  letter-spacing: 0.02em;
}

#drawer-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  z-index: 20;
}

#drawer {
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  width: min(280px, 80vw);
  background: #2b2b2b;
  color: #f0f0f0;
  z-index: 21;
  box-shadow: 4px 0 16px rgba(0, 0, 0, 0.35);
  transform: translateX(0);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
}
#drawer.hidden {
  display: flex !important;
  transform: translateX(-100%);
  pointer-events: none;
}

#drawer-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #444;
}
#drawer-title {
  font-weight: bold;
  font-size: 1.05rem;
}
#drawer-close {
  background: transparent;
  border: none;
  color: #f0f0f0;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 0.25rem;
}

#drawer-body {
  display: flex;
  flex-direction: column;
  padding: 0.5rem 0;
}

.drawer-item {
  padding: 0.75rem 1rem;
  font-size: 1rem;
  color: #f0f0f0;
  text-align: left;
}

.drawer-version {
  color: #bbb;
  font-size: 0.9rem;
  border-bottom: 1px solid #3a3a3a;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.drawer-check-update {
  background: transparent;
  color: #7fdcff;
  border: 1px solid #7fdcff;
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  font-size: 0.8rem;
  cursor: pointer;
}
.drawer-check-update:hover {
  background: rgba(127, 220, 255, 0.1);
}
.drawer-check-update:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.drawer-check-update-status {
  font-size: 0.8rem;
  color: #bbb;
  flex-basis: 100%;
}

.drawer-action {
  background: transparent;
  border: none;
  cursor: pointer;
  font-weight: bold;
}
.drawer-action:hover {
  background: #3a3a3a;
}

.modal-close-x {
  position: sticky;
  top: 0;
  float: right;
  width: 44px;
  height: 44px;
  margin: -0.75rem -0.75rem 0 0.5rem;
  background: white;
  border: none;
  color: #444;
  font-size: 1.75rem;
  line-height: 1;
  cursor: pointer;
  border-radius: 999px;
  z-index: 2;
  -webkit-tap-highlight-color: transparent;
}
.modal-close-x:hover,
.modal-close-x:focus {
  background: rgba(0, 0, 0, 0.08);
  outline: none;
}

#rules-modal-body {
  max-width: 640px;
  clear: both;
}
#rules-modal-body h2:first-child {
  margin-top: 0;
}
#rules-modal-body h2 {
  font-size: 1.05rem;
  margin: 1rem 0 0.35rem;
}
#rules-modal-body p,
#rules-modal-body ul,
#rules-modal-body ol {
  margin: 0.35rem 0;
}
#rules-modal-body ul ul,
#rules-modal-body ol ul {
  margin: 0.15rem 0;
}

#game-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
}

#header-right {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

#hello-pill {
  display: inline-block;
  font-weight: bold;
  font-size: 1rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid #2f8f3a;
  border-radius: 4px;
  background: #2f8f3a;
  color: white;
}

#mobile-turn {
  display: inline-block;
  font-weight: bold;
  font-size: 1rem;
  padding: 0.35rem 0.6rem;
  border: 1px solid #333;
  border-radius: 4px;
  background: #444;
  color: white;
}

#mobile-turn:empty {
  display: none;
}

#online-exit-btn {
  padding: 0.4rem 0.75rem;
  font-size: 0.9rem;
  font-weight: bold;
  border: 1px solid #a00;
  border-radius: 4px;
  background: white;
  color: #a00;
  cursor: pointer;
}
#online-exit-btn:hover {
  background: #a00;
  color: white;
}

.kick-btn {
  padding: 0.2rem 0.5rem;
  font-size: 0.8rem;
  font-weight: normal;
  border: 1px solid #a00;
  border-radius: 3px;
  background: white;
  color: #a00;
  cursor: pointer;
  margin-left: 0.5rem;
}
.kick-btn:hover {
  background: #a00;
  color: white;
}

#net-toast {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%) translateY(-120%);
  padding: 0.6rem 1rem;
  background: #333;
  color: white;
  border-radius: 4px;
  font-size: 0.95rem;
  z-index: 10000;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.25s ease;
  pointer-events: none;
  max-width: 90vw;
  text-align: center;
}
#net-toast.visible {
  transform: translateX(-50%) translateY(0);
}

#game-over-buttons {
  display: flex;
  gap: 0.5rem;
  align-self: flex-start;
}

#new-game-btn {
  padding: 0.5rem 1rem;
  background: #333;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

#results-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  color: #333;
  border: 1px solid #333;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

#top-row {
  display: flex;
  flex-direction: row;
  align-items: flex-start;
  gap: 2rem;
}

#left-column {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  flex-shrink: 0;
}

#board {
  flex-shrink: 0;
  width: min(60vw, 1024px);
  aspect-ratio: 12 / 9;
  display: grid;
  grid-template-columns: repeat(12, 1fr);
  grid-template-rows: repeat(9, 1fr);
  background: black;
  border: clamp(6px, 2.5vw, 30px) solid #333;
}

.cell {
  border: 1px solid white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.6rem, 1.4vw, 1.2rem);
  background: black;
  color: white;
}

.cell.placed {
  background: lightgrey;
  color: black;
}

.cell.playable-tile {
  background: #7fdcff;
  color: black;
  outline: 2px solid #0288d1;
  outline-offset: -2px;
  cursor: pointer;
}

.cell.hover-highlight {
  background: #01579b;
  color: white;
  z-index: 1;
}

#players {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.player {
  border: 2px solid #ccc;
  border-radius: 6px;
  padding: 0.75rem;
  min-width: 200px;
}

.player.active {
  border-color: #333;
  box-shadow: 0 0 0 2px #333;
}

.player-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.5rem;
  font-size: 1.15rem;
}

.player-name {
  font-weight: bold;
}

.name-row {
  display: flex;
  gap: 0.5rem;
  min-width: 0;
}

.name-row input {
  flex: 1;
  min-width: 0;
}

.name-row select {
  min-width: 0;
}

.ai-badge {
  display: inline-block;
  padding: 0.1rem 0.35rem;
  background: #eee;
  border-radius: 3px;
  font-size: 0.7rem;
  font-weight: normal;
  color: #333;
  vertical-align: middle;
}

.player-cash {
  color: #2a7a2a;
  font-variant-numeric: tabular-nums;
  text-align: right;
  font-weight: bold;
}

.player-body {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 0.75rem 2.5rem;
}

.player-stocks {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.2rem;
  flex: 1 1 0;
  min-width: 0;
  width: 100%;
  align-content: flex-start;
}

.stock-chip {
  display: flex;
  align-items: stretch;
  flex: 1 1 0;
  min-width: 0;
  height: 44px;
  border: 1px solid black;
  border-radius: 3px;
  font-size: clamp(0.7rem, 1vw, 0.9rem);
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  overflow: hidden;
}

.stock-swatch {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 0 0 auto;
  padding: 0 0.4rem;
  color: white;
  font-weight: bold;
  font-size: clamp(0.75rem, 1.1vw, 1rem);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.stock-count {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  padding: 0 0.4rem;
  min-width: 0;
}

.hand {
  display: flex;
  flex-wrap: nowrap;
  gap: 0.2rem;
  min-width: 0;
  width: 100%;
  container-type: inline-size;
}

.hand:not(:has(.tile:not(.hidden-tile))) {
  display: none;
}

.tile {
  flex: 1 1 0;
  width: auto;
  height: auto;
  aspect-ratio: 1 / 1;
  min-width: 30px;
  background: lightgrey;
  border: 1px solid #888;
  border-radius: 3px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(0.85rem, 7cqi, 1.5rem);
  font-weight: 600;
  color: black;
  cursor: pointer;
  user-select: none;
}

.player:not(.active) .tile {
  cursor: not-allowed;
  opacity: 0.6;
}

.tile.dead {
  border: 2px solid #8b0000;
}

.tile.hidden-tile {
  display: none;
}

.tile.empty-tile {
  background: white;
  border-color: #ccc;
  cursor: default;
  pointer-events: none;
}

.end-game-btn {
  margin-bottom: 0.5rem;
  padding: 0.4rem 0.75rem;
  background: #8b0000;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

.end-note {
  margin-bottom: 0.5rem;
  color: #8b0000;
  font-style: italic;
}

#bottom-row {
  display: flex;
  flex-wrap: wrap;
  gap: 1.5rem;
  align-items: stretch;
}

#hotels {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 0.5rem;
  width: min(60vw, 1024px);
  align-self: flex-start;
}

.hotel-card {
  border: 1px solid #ccc;
  border-radius: 4px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.hotel-swatch {
  padding: 0.5rem;
  color: white;
  font-weight: bold;
  font-size: clamp(0.75rem, 2.2vw, 1.1rem);
  text-align: center;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  overflow-wrap: break-word;
}

.hotel-info {
  padding: 0.4rem 0.5rem;
  font-size: 0.8rem;
}

.hotel-size,
.hotel-price,
.hotel-stocks {
  margin-top: 0.25rem;
  font-variant-numeric: tabular-nums;
}

.safe-mark {
  color: #2a7a2a;
  font-weight: bold;
  cursor: help;
}

#price-chart {
  width: 70%;
  margin: 0 auto;
  align-self: stretch;
}

.chart-table {
  border-collapse: collapse;
  font-size: 0.85rem;
  font-variant-numeric: tabular-nums;
  width: 100%;
}

.chart-table th,
.chart-table td {
  border: 1px solid #ccc;
  padding: 0.35rem 0.6rem;
  text-align: center;
}

.chart-table th {
  font-size: 1rem;
}

.chart-table td {
  white-space: nowrap;
}

.chart-table thead th {
  background: #f4f4f4;
  text-align: center;
}

.chart-table tbody tr:hover th,
.chart-table tbody tr:hover td {
  background: #bbb;
}

.chart-tier-head {
  vertical-align: bottom;
  padding: 0 !important;
}

.bonus-title {
  font-size: 1rem;
}

.chart-hotel-band {
  color: white;
  font-weight: bold;
  font-size: 1rem;
  text-align: center;
  padding: 0.35rem 0.25rem;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
}

.chart-hotel-band .hotel-name-abbr {
  display: none;
}

.chart-hotel-band + .chart-hotel-band {
  border-top: 1px solid white;
}

#modal-overlay {
  position: fixed;
  inset: 0;
  height: 100dvh;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

#modal-overlay #modal {
  cursor: auto;
}

#modal {
  position: relative;
  background: white;
  color: #111;
  border-radius: 6px;
  padding: 1.5rem;
  min-width: 320px;
  max-width: 90vw;
  max-height: 85vh;
  overflow-y: auto;
  -webkit-tap-highlight-color: transparent;
}

#modal,
#modal * {
  -webkit-user-select: none;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}
#modal input,
#modal textarea {
  -webkit-user-select: text;
  user-select: text;
}

#modal-title {
  font-size: 1.1rem;
  font-weight: bold;
  margin-bottom: 1rem;
}

#modal-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.modal-option {
  padding: 0.5rem 0.75rem;
  border: none;
  border-radius: 4px;
  color: white;
  font-weight: bold;
  cursor: pointer;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.4);
  font-size: 0.95rem;
}

#modal-body {
  margin-top: 0.75rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.buy-row {
  display: grid;
  grid-template-columns: 24px 1fr auto auto auto;
  align-items: center;
  gap: 0.5rem;
  padding: 0.35rem 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
}

.buy-swatch {
  width: 20px;
  height: 20px;
  border-radius: 3px;
}

.buy-name {
  font-weight: bold;
}

.buy-owned {
  font-weight: normal;
}

.buy-meta {
  font-size: 0.8rem;
  color: #555;
  font-variant-numeric: tabular-nums;
}

.buy-controls {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.buy-controls button {
  width: 26px;
  height: 26px;
  border: 1px solid #999;
  background: white;
  border-radius: 3px;
  cursor: pointer;
  font-weight: bold;
}

.buy-controls button:active:not(:disabled) {
  background: #ddd;
}

.buy-controls button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.buy-count {
  min-width: 20px;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

#modal-footer {
  margin-top: 1rem;
}

#modal-footer-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

#modal-summary {
  font-variant-numeric: tabular-nums;
}

#modal-warning {
  margin-top: 0.5rem;
  color: #8b0000;
  font-weight: bold;
}

.modal-buttons {
  display: flex;
  gap: 0.5rem;
}

#modal-confirm,
#modal-secondary {
  padding: 0.5rem 1rem;
  background: #333;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: bold;
}

#modal-secondary {
  background: #666;
}

#modal-confirm:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.hotel-tag {
  display: inline-block;
  padding: 0 0.35rem;
  border: 2px solid #333;
  border-radius: 3px;
  font-weight: bold;
  line-height: 1.2;
}

.defunct-block {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  margin-top: 0.5rem;
}

.final-standings {
  margin-top: 0.35rem;
  border-collapse: collapse;
  font-variant-numeric: tabular-nums;
  width: 100%;
  table-layout: auto;
}

.final-standings td {
  padding: 0.15rem 0;
  white-space: nowrap;
}

.final-standings .rank-col {
  width: 1%;
  padding-right: 0.35rem;
  text-align: right;
}

.final-standings .name-col {
  width: auto;
}

.final-standings .cash-col {
  width: 1%;
  text-align: right;
  padding-left: 1.5rem;
}

.final-standings tr.winner td {
  font-weight: bold;
  color: #2a7a2a;
  font-size: 1.15rem;
}

#modal.wide-modal {
  min-width: min(720px, 90vw);
}

#modal-body hr {
  border: 0;
  border-top: 2px solid #333;
  margin: 0.75rem 0;
}

@media (min-width: 801px) and (max-width: 1366px) {
  #setup {
    grid-template-columns: minmax(340px, 440px) minmax(0, 1fr);
    column-gap: 1.25rem;
  }

  #name-inputs {
    gap: 0.9rem;
  }

  #name-inputs .name-row {
    gap: 0.9rem;
  }

  .stock-chip {
    flex-direction: column;
    height: auto;
  }

  .stock-swatch {
    padding: 0.3rem 0.4rem;
  }

  .stock-count {
    padding: 0.3rem 0.4rem;
  }

  #hotels .hotel-swatch {
    font-size: 0.85rem;
    padding: 0.3rem 0.2rem;
  }
}

@media (min-width: 801px) and (max-width: 1366px) and (orientation: landscape) {
  .hand {
    flex-wrap: nowrap;
    gap: 0.2rem;
  }

  .tile {
    flex: 0 1 44px;
    width: 44px;
    height: 44px;
    min-width: 32px;
  }

  .tile.dead {
    border-width: 1px;
    outline: 2px solid #8b0000;
    outline-offset: -2px;
  }
}

@media (min-width: 801px) and (max-width: 1024px) and (orientation: portrait) {
  #hotels {
    grid-template-columns: repeat(7, 1fr);
    gap: 0.35rem;
  }

  #hotels .hotel-swatch {
    font-size: clamp(0.55rem, 1.3vw, 0.8rem);
    padding: 0.3rem 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  #hotels .hotel-info {
    font-size: 0.7rem;
    padding: 0.3rem 0.35rem;
  }
}

@media (max-width: 800px) {
  body {
    padding: 4.5rem 1rem 1rem;
  }

  body.update-banner-visible {
    padding-top: 7.5rem;
  }

  #update-banner {
    flex-wrap: wrap;
    padding: 0.5rem;
  }
  #update-banner-message {
    flex: 1 1 100%;
    order: -1;
  }

  #setup {
    grid-template-columns: 1fr;
    grid-template-areas:
      "title"
      "mode"
      "players"
      "online"
      "instructions";
  }

  #mode-chooser {
    flex-wrap: wrap;
  }
  .mode-btn {
    flex: 1 1 auto;
    min-width: 44%;
  }

  #online-role-chooser {
    flex-wrap: wrap;
  }
  #online-role-chooser .mode-btn {
    flex: 1 1 100%;
  }

  #host-panel input, #join-panel input {
    font-size: 16px;
    width: 100%;
  }

  #host-room-code {
    font-size: 1.5rem;
  }

  .host-bot-row {
    flex-wrap: wrap;
  }
  .host-bot-row input {
    flex: 1 1 100%;
    width: auto;
  }
  .host-bot-row select {
    flex: 1 1 auto;
    min-width: 8rem;
    font-size: 16px;
  }
  .host-bot-remove {
    margin-left: auto;
  }

  #host-start-btn {
    width: 100%;
  }

  #hello-pill,
  #mobile-turn,
  #online-exit-btn {
    font-size: 0.9rem;
    padding: 0.35rem 0.6rem;
    line-height: 1.2;
  }

  #header-right {
    align-items: center;
    justify-content: flex-end;
    width: 100%;
    flex-wrap: nowrap;
    overflow-x: auto;
  }

  #game-header {
    flex-direction: column;
    align-items: stretch;
    gap: 0.5rem;
  }

  #game-title {
    margin-bottom: 0;
  }

  #net-toast {
    top: 0.5rem;
    font-size: 1rem;
    padding: 0.7rem 1rem;
    max-width: 94vw;
  }

  .kick-btn {
    padding: 0.15rem 0.4rem;
    font-size: 0.7rem;
    margin-left: 0.35rem;
  }

  #name-inputs {
    gap: 1.25rem;
  }

  .name-row {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .name-row input {
    flex: 1 1 100%;
  }

  .name-row select {
    flex: 1 1 auto;
    padding: 0.35rem 1.75rem 0.35rem 0.5rem;
  }

  #game {
    gap: 1rem;
  }

  #game-title {
    font-size: 1.25rem;
    margin: 0;
  }

  #top-row,
  #bottom-row,
  #left-column {
    display: contents;
  }

  #board {
    width: 100%;
    order: 1;
  }

  #board .cell {
    font-size: clamp(0.7rem, 2.2vw, 1rem);
  }

  #hotels {
    width: 100%;
    order: 2;
    grid-template-columns: repeat(4, 1fr);
    gap: 0.35rem;
  }

  #hotels .hotel-swatch {
    font-size: 0.65rem;
    padding: 0.25rem 0.15rem;
  }

  #hotels .hotel-info {
    padding: 0.3rem 0.35rem;
    font-size: 0.7rem;
  }

  #players {
    width: 100%;
    order: 3;
  }

  body {
    padding-bottom: 15rem;
  }

  .player.you-active {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    margin: 0;
    padding: 0.5rem 0.75rem calc(0.5rem + env(safe-area-inset-bottom, 0px));
    background: rgba(255, 255, 255, 0.97);
    border: none;
    border-top: 2px solid #333;
    border-radius: 0;
    box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.2);
    z-index: 12;
    backdrop-filter: blur(6px);
    max-height: 45vh;
    overflow-y: auto;
  }

  .player.you-active.active {
    box-shadow: 0 -3px 10px rgba(0, 0, 0, 0.2), inset 0 3px 0 0 #2f8f3a;
  }

  body:has(#modal-overlay:not(.hidden)) .player.you-active,
  body:has(#game-over-buttons:not(.hidden)) .player.you-active {
    display: none;
  }

  body:has(#modal-overlay:not(.hidden)),
  body:has(#game-over-buttons:not(.hidden)) {
    padding-bottom: 1rem;
  }

  #price-chart {
    width: 100%;
    min-width: 0;
    order: 4;
    overflow-x: auto;
  }

  #price-chart .chart-hotel-band .hotel-name-full {
    display: none;
  }

  #price-chart .chart-hotel-band .hotel-name-abbr {
    display: inline;
  }

  #price-chart .chart-table th,
  #price-chart .chart-table td {
    padding: 0.15rem 0.25rem;
  }

  #price-chart .chart-table th {
    font-size: 0.7rem;
  }

  #price-chart .chart-table td {
    font-size: 0.75rem;
  }

  #price-chart .chart-hotel-band {
    font-size: 0.75rem;
    padding: 0.25rem 0.15rem;
  }

  #price-chart .bonus-title {
    font-size: 0.75rem;
  }

  .hand,
  .player-stocks {
    width: 100%;
    flex-basis: 100%;
    justify-content: space-between;
  }

  .stock-chip {
    flex-direction: column;
    height: auto;
    font-size: 0.75rem;
  }

  .stock-swatch {
    padding: 0.3rem 0.4rem;
    font-size: 0.8rem;
  }

  .stock-count {
    padding: 0.3rem 0.4rem;
  }

  .player {
    padding: 0.5rem;
  }

  .player-header {
    font-size: 0.95rem;
    margin-bottom: 0.35rem;
  }

  .player-cash {
    font-size: 0.9rem;
  }

  .ai-badge {
    font-size: 0.6rem;
  }

  .end-game-btn,
  .end-note {
    font-size: 0.8rem;
  }
}

@media (max-height: 500px) and (orientation: landscape) {
  .hand {
    flex-wrap: nowrap !important;
    gap: 0.35rem;
    width: 100%;
  }

  .tile {
    flex: 1 1 0 !important;
    width: auto !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    min-width: 0;
    font-size: clamp(0.7rem, 1.6vw, 1rem) !important;
  }

  #hotels {
    grid-template-columns: repeat(7, minmax(0, 1fr)) !important;
    gap: 0.35rem;
  }

  #hotels .hotel-card {
    min-width: 0;
  }

  #hotels .hotel-swatch {
    display: block;
    min-width: 0;
    white-space: nowrap !important;
    overflow: hidden;
    text-overflow: ellipsis;
    overflow-wrap: normal !important;
    word-break: keep-all;
    font-size: clamp(0.7rem, 2.4vh, 1rem);
    padding: 0.3rem 0.2rem;
  }
}
