:root {
  color-scheme: light;
  --ink: #263033;
  --muted: #627171;
  --panel: rgba(255, 250, 239, 0.94);
  --panel-strong: #fff8e8;
  --line: rgba(72, 66, 50, 0.2);
  --shadow: 0 18px 46px rgba(31, 42, 38, 0.18);
  --coral: #e8664f;
  --teal: #129e91;
  --mint: #74c690;
  --gold: #f3b545;
  --plum: #8d5aa7;
  --sky: #75bdd6;
  --cream: #fff2ce;
  --radius: 8px;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #bde3d8;
  color: var(--ink);
}

button {
  border: 0;
  font: inherit;
  color: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background:
    linear-gradient(180deg, rgba(255, 253, 234, 0.25), rgba(89, 187, 173, 0.2)),
    #a8dccf;
}

#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: grab;
  touch-action: none;
  contain: strict;
}

#game.is-building {
  cursor: crosshair;
}

#game.is-dragging {
  cursor: grabbing;
}

.topbar,
.tool-panel,
.inspector,
.bottom-dock,
.placement-badge,
.pause-badge {
  position: absolute;
  z-index: 2;
  backdrop-filter: blur(10px) saturate(1.08);
  -webkit-backdrop-filter: blur(10px) saturate(1.08);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  contain: layout paint;
}

.topbar {
  top: 14px;
  left: 16px;
  right: 16px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  padding: 10px 14px;
  border-radius: var(--radius);
  background: rgba(255, 249, 229, 0.88);
}

.brand-lockup {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 230px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 7px;
  background:
    radial-gradient(circle at 50% 31%, #fff4c1 0 18%, transparent 19%),
    conic-gradient(from 45deg, var(--coral), var(--gold), var(--teal), var(--plum), var(--coral));
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, 0.55), 0 8px 18px rgba(117, 78, 52, 0.18);
}

.brand-lockup h1,
.brand-lockup p,
.panel-title,
.selection-panel h2,
.ride-list h2 {
  margin: 0;
}

.brand-lockup h1 {
  font-size: 18px;
  line-height: 1.05;
}

.brand-lockup p {
  margin-top: 2px;
  font-size: 12px;
  color: var(--muted);
}

.stat-strip {
  display: grid;
  grid-template-columns: repeat(5, minmax(86px, 1fr));
  gap: 8px;
  flex: 1;
  max-width: 760px;
}

.stat {
  min-width: 0;
  padding: 8px 10px;
  border: 1px solid rgba(70, 64, 48, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 248, 0.62);
}

.stat span,
.meter-row span,
.ride-card span,
.tool-button small,
.object-meta {
  display: block;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.1;
}

.stat strong {
  display: block;
  margin-top: 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 17px;
}

.tool-panel {
  top: 104px;
  left: 16px;
  width: 190px;
  max-height: calc(100vh - 222px);
  overflow: hidden;
  padding: 12px;
  border-radius: var(--radius);
  background: var(--panel);
}

.panel-title {
  margin-bottom: 10px;
  color: #51615d;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.tool-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  max-height: calc(100vh - 270px);
  overflow: auto;
  padding-right: 2px;
}

.tool-button {
  display: grid;
  grid-template-rows: 42px auto;
  align-items: center;
  justify-items: center;
  min-height: 74px;
  padding: 7px 5px 6px;
  border: 1px solid rgba(68, 62, 48, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 249, 0.76);
  cursor: pointer;
  transition: transform 120ms ease, border-color 120ms ease, background 120ms ease;
}

.tool-button:hover,
.tool-button:focus-visible {
  transform: translateY(-1px);
  border-color: rgba(18, 158, 145, 0.5);
  outline: 0;
}

.tool-button.active {
  border-color: rgba(232, 102, 79, 0.65);
  background: #fff2ce;
  box-shadow: inset 0 0 0 2px rgba(232, 102, 79, 0.12);
}

.tool-button[disabled] {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.tool-icon,
.action-icon {
  width: 36px;
  height: 36px;
  image-rendering: auto;
}

.tool-button b {
  max-width: 100%;
  overflow-wrap: anywhere;
  font-size: 12px;
  line-height: 1.05;
}

.tool-button small {
  margin-top: 2px;
  font-size: 10px;
}

.inspector {
  top: 104px;
  right: 16px;
  width: 310px;
  max-height: calc(100vh - 222px);
  overflow: auto;
  padding: 14px;
  border-radius: var(--radius);
  background: var(--panel);
}

.selection-panel {
  padding: 12px;
  border: 1px solid rgba(68, 62, 48, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 249, 0.68);
}

.selection-panel h2,
.ride-list h2 {
  font-size: 15px;
}

.selection-panel p {
  margin: 7px 0 0;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.35;
}

.object-meta {
  margin-top: 8px;
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}

.object-meta b {
  display: block;
  margin-top: 2px;
  color: var(--ink);
  font-size: 13px;
}

.meters {
  margin-top: 12px;
  display: grid;
  gap: 9px;
}

.meter-row {
  display: grid;
  grid-template-columns: 64px 1fr;
  align-items: center;
  gap: 8px;
}

.meter {
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(43, 56, 53, 0.11);
}

.meter i {
  display: block;
  width: 0%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--teal), var(--gold), var(--coral));
  transition: width 160ms ease;
}

.ride-list {
  margin-top: 14px;
}

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 8px;
}

.small-button {
  padding: 6px 10px;
  border-radius: 6px;
  background: #e9fff5;
  color: #237b6f;
  font-size: 12px;
  font-weight: 800;
  cursor: pointer;
}

.small-button:hover,
.small-button:focus-visible {
  outline: 0;
  background: #d7faec;
}

#rideList {
  display: grid;
  gap: 7px;
}

.ride-card {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 7px;
  align-items: center;
  padding: 9px;
  border: 1px solid rgba(68, 62, 48, 0.13);
  border-radius: 7px;
  background: rgba(255, 255, 249, 0.66);
}

.ride-card strong {
  font-size: 13px;
}

.status-pill {
  padding: 4px 7px;
  border-radius: 999px;
  background: #ecf7ff;
  color: #2b668f;
  font-size: 11px;
  font-weight: 800;
}

.status-pill.closed {
  background: #fff1e9;
  color: #a74e3d;
}

.bottom-dock {
  left: 50%;
  bottom: 16px;
  width: min(760px, calc(100vw - 32px));
  min-height: 72px;
  display: grid;
  grid-template-columns: auto 1fr minmax(190px, 260px);
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: var(--radius);
  background: rgba(255, 249, 229, 0.9);
  transform: translateX(-50%);
}

.speed-control {
  display: inline-flex;
  overflow: hidden;
  border: 1px solid rgba(68, 62, 48, 0.16);
  border-radius: 7px;
  background: rgba(255, 255, 249, 0.72);
}

.seg {
  min-width: 42px;
  padding: 8px 10px;
  background: transparent;
  cursor: pointer;
  font-weight: 800;
}

.seg.active {
  background: var(--ink);
  color: white;
}

.action-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.action-button {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 7px 11px;
  border: 1px solid rgba(68, 62, 48, 0.14);
  border-radius: 7px;
  background: rgba(255, 255, 249, 0.78);
  cursor: pointer;
  font-weight: 800;
}

.action-button:hover,
.action-button:focus-visible {
  outline: 0;
  border-color: rgba(18, 158, 145, 0.5);
}

.toast-log {
  min-height: 40px;
  display: grid;
  align-content: center;
  color: #52605e;
  font-size: 12px;
  line-height: 1.28;
}

.placement-badge,
.pause-badge {
  pointer-events: none;
  padding: 8px 10px;
  border-radius: 7px;
  background: rgba(38, 48, 51, 0.84);
  color: white;
  font-size: 12px;
  font-weight: 800;
}

.placement-badge.invalid {
  background: rgba(171, 70, 52, 0.9);
}

.pause-badge {
  left: 50%;
  top: 92px;
  transform: translateX(-50%);
}

@media (max-width: 980px) {
  .topbar {
    height: auto;
    align-items: flex-start;
    flex-direction: column;
  }

  .stat-strip {
    width: 100%;
    max-width: none;
    grid-template-columns: repeat(5, minmax(64px, 1fr));
  }

  .tool-panel {
    top: auto;
    left: 10px;
    right: 10px;
    bottom: 96px;
    width: auto;
    max-height: 170px;
  }

  .tool-grid {
    grid-template-columns: repeat(8, minmax(76px, 1fr));
    max-height: 112px;
  }

  .inspector {
    display: none;
  }

  .bottom-dock {
    bottom: 10px;
    grid-template-columns: auto 1fr;
  }

  .toast-log {
    display: none;
  }
}

@media (max-width: 620px) {
  .brand-lockup {
    min-width: 0;
  }

  .brand-lockup h1 {
    font-size: 16px;
  }

  .stat-strip {
    grid-template-columns: repeat(3, 1fr);
  }

  .tool-grid {
    grid-template-columns: repeat(5, minmax(74px, 1fr));
  }

  .bottom-dock {
    grid-template-columns: 1fr;
    gap: 8px;
  }
}
