:root {
  color-scheme: dark;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #050605;
  font-synthesis: none;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  min-width: 320px;
  margin: 0;
  overflow: hidden;
  background: #050605;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.client-stage,
.runtime-frame {
  width: 100%;
  height: 100%;
}

.runtime-frame {
  position: relative;
  display: grid;
  place-items: center;
  overflow: hidden;
  background: #050605;
}

.runtime-placeholder {
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgb(3 12 12 / 18%), rgb(3 9 8 / 48%)),
    url("./assets/park-background-ai.png") center / cover no-repeat;
}

.background-credit {
  position: absolute;
  top: 14px;
  right: 16px;
  z-index: 2;
  display: grid;
  width: 20px;
  height: 20px;
  place-items: center;
  border: 1px solid rgb(255 255 255 / 48%);
  border-radius: 50%;
  color: rgb(255 255 255 / 88%);
  background: rgb(5 9 6 / 42%);
  box-shadow: 0 2px 10px rgb(0 0 0 / 24%);
  font: 700 13px/1 system-ui, sans-serif;
  cursor: help;
}

.background-credit-tooltip {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  width: max-content;
  max-width: min(260px, calc(100vw - 32px));
  padding: 7px 9px;
  border: 1px solid rgb(255 255 255 / 16%);
  border-radius: 4px;
  color: #f4f6f1;
  background: rgb(7 11 8 / 92%);
  box-shadow: 0 8px 24px rgb(0 0 0 / 34%);
  font: 500 11px/1.3 system-ui, sans-serif;
  letter-spacing: 0;
  opacity: 0;
  pointer-events: none;
  transform: translateY(-3px);
  transition: opacity 140ms ease, transform 140ms ease;
}

.background-credit:hover .background-credit-tooltip,
.background-credit:focus-visible .background-credit-tooltip {
  opacity: 1;
  transform: translateY(0);
}

#openrct2-screen {
  display: none;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 100%;
  background: #000;
  image-rendering: pixelated;
  outline: none;
  touch-action: none;
  user-select: none;
}

.runtime-frame.running #openrct2-screen {
  display: block;
}

.runtime-frame.running .runtime-placeholder {
  display: none;
}

.runtime-frame.running .background-credit {
  display: none;
}

.runtime-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  justify-items: center;
  gap: 12px;
  color: #f5f7f2;
  background: rgb(5 7 5 / 82%);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 12px;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.runtime-overlay.hidden {
  display: none;
}

.runtime-overlay span {
  color: #aab6a9;
  font-size: 10px;
  letter-spacing: 0.04em;
}

.client-toolbar {
  position: fixed;
  top: 14px;
  right: 48px;
  z-index: 8;
  display: flex;
  gap: 8px;
  align-items: center;
}

.client-tool-button {
  min-height: 32px;
  padding: 0 11px;
  border: 1px solid rgb(219 238 210 / 24%);
  border-radius: 5px;
  color: #e8f3e4;
  background: rgb(9 17 12 / 78%);
  box-shadow: 0 5px 18px rgb(0 0 0 / 24%);
  font: 700 11px/1 system-ui, sans-serif;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  backdrop-filter: blur(10px);
}

.client-tool-button:hover {
  border-color: rgb(219 238 210 / 58%);
  background: rgb(25 45 31 / 92%);
}

.peer-tool-button {
  max-width: 220px;
  overflow: hidden;
  color: #f4d58a;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.peer-dialog {
  width: min(440px, calc(100vw - 28px));
  padding: 0;
  border: 1px solid rgb(212 236 201 / 25%);
  border-radius: 8px;
  color: #edf5e9;
  background: #111b14;
  box-shadow: 0 24px 80px rgb(0 0 0 / 60%);
}

.peer-dialog::backdrop {
  background: rgb(0 0 0 / 62%);
  backdrop-filter: blur(4px);
}

.peer-dialog-card {
  position: relative;
  display: grid;
  gap: 12px;
  padding: 25px;
}

.peer-dialog-card h1 {
  margin: -4px 0 0;
  font-size: 22px;
  letter-spacing: -0.02em;
}

.peer-kicker {
  margin: 0;
  color: #f4d58a;
  font: 800 10px/1 system-ui, sans-serif;
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.peer-copy {
  margin: 0 0 6px;
  color: #aab8ab;
  font-size: 12px;
  line-height: 1.5;
}

.peer-status {
  margin: 0;
  padding: 8px 10px;
  border: 1px solid rgb(244 213 138 / 24%);
  border-radius: 4px;
  color: #f4d58a;
  background: rgb(244 213 138 / 6%);
  font: 700 10px/1.2 system-ui, sans-serif;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.peer-dialog-close {
  position: absolute;
  top: 9px;
  right: 11px;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 50%;
  color: #afbdaf;
  background: transparent;
  font-size: 22px;
  line-height: 1;
}

.peer-dialog-close:hover {
  color: #fff;
  background: rgb(255 255 255 / 9%);
}

.peer-field {
  display: grid;
  gap: 6px;
  color: #b8c8b7;
  font: 700 10px/1 system-ui, sans-serif;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.peer-field input {
  min-width: 0;
  min-height: 37px;
  padding: 0 10px;
  border: 1px solid rgb(219 238 210 / 18%);
  border-radius: 4px;
  outline: none;
  color: #f2f7ef;
  background: rgb(0 0 0 / 22%);
  font: 12px/1 ui-monospace, SFMono-Regular, Menlo, monospace;
  letter-spacing: 0;
  text-transform: none;
}

.peer-field input:focus {
  border-color: #f4d58a;
}

.peer-actions {
  display: flex;
  gap: 8px;
}

.peer-actions .client-tool-button,
.peer-join-button {
  flex: 1;
}

.peer-join-button {
  color: #1b241b;
  background: #f4d58a;
}

.peer-join-button:hover {
  color: #141b14;
  background: #ffe4a4;
}

@media (max-width: 620px) {
  .client-toolbar {
    top: 10px;
    right: 38px;
    left: 10px;
  }

  .client-toolbar .client-tool-button {
    flex: 1;
    min-width: 0;
  }

  .peer-tool-button {
    max-width: none;
  }
}

.overlay-spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgb(255 255 255 / 22%);
  border-top-color: #ef6654;
  border-radius: 50%;
  animation: spin 700ms linear infinite;
}

.compatibility-ui {
  display: none !important;
}

.toast-stack {
  position: fixed;
  top: 22px;
  left: 50%;
  z-index: 10;
  display: grid;
  gap: 10px;
  width: min(390px, calc(100% - 28px));
  transform: translateX(-50%);
  pointer-events: none;
}

.toast-stack.data-prompt-active {
  inset: 0;
  display: grid;
  place-items: center;
  width: 100%;
  transform: none;
}

.toast-stack.data-prompt-active > .toast:not(.data-requirement-toast) {
  position: fixed;
  top: 16px;
  left: 50%;
  z-index: 20;
  width: min(390px, calc(100% - 28px));
  margin: 0;
  transform: translateX(-50%);
  animation: none;
}

.toast {
  display: grid;
  gap: 13px;
  padding: 15px 16px;
  border: 1px solid rgb(181 206 181 / 26%);
  border-left: 3px solid #ef6654;
  border-radius: 6px;
  color: #f1f4ed;
  background: rgb(20 26 21 / 94%);
  box-shadow: 0 14px 40px rgb(0 0 0 / 35%);
  font-size: 13px;
  line-height: 1.4;
  backdrop-filter: blur(14px);
  animation: toast-in 220ms ease both;
  pointer-events: auto;
}

.data-requirement-toast {
  position: relative;
  width: min(460px, calc(100vw - 32px));
  min-height: 204px;
  padding: 54px 24px 22px;
  overflow: hidden;
  border: 3px solid #291b12;
  border-radius: 3px;
  outline: 1px solid #d09a4e;
  color: #f7e9c8;
  background:
    linear-gradient(180deg, rgb(39 73 57 / 78%), rgb(18 39 30 / 72%)),
    repeating-linear-gradient(0deg, rgb(255 255 255 / 3%) 0 1px, transparent 1px 3px);
  box-shadow:
    0 26px 70px rgb(0 0 0 / 48%),
    inset 0 0 0 2px rgb(240 194 111 / 28%),
    inset 0 0 0 5px rgb(8 22 17 / 76%);
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 14px;
  line-height: 1.35;
  text-align: center;
  backdrop-filter: blur(8px) saturate(115%);
  animation: none;
}

.data-requirement-toast::before {
  position: absolute;
  inset: 0 0 auto;
  height: 36px;
  padding: 9px 14px;
  border-bottom: 2px solid #8b5f2c;
  color: #2a1b0d;
  background:
    linear-gradient(180deg, rgb(229 184 100 / 92%), rgb(185 123 54 / 88%)),
    repeating-linear-gradient(90deg, rgb(70 35 9 / 12%) 0 2px, transparent 2px 5px);
  box-shadow: inset 0 1px rgb(255 240 180 / 72%);
  content: "OPENRCT2  •  PARK SETUP";
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.1em;
  line-height: 18px;
  text-shadow: 0 1px rgb(255 226 153 / 40%);
}

.data-requirement-toast .toast-copy {
  max-width: 390px;
  margin: 0 auto;
  color: #fff2d1;
  font-size: clamp(13px, 1.5vw, 15px);
  font-weight: 700;
  letter-spacing: 0.015em;
  text-shadow: 0 2px 0 rgb(5 18 12 / 65%);
}

.toast-actions {
  display: flex;
  gap: 8px;
}

.data-requirement-toast .toast-actions {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
  margin-top: 1px;
}

.toast-action {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  min-height: 34px;
  padding: 0 12px;
  border: 1px solid rgb(220 235 217 / 27%);
  border-radius: 4px;
  color: #eaf2e7;
  background: rgb(255 255 255 / 7%);
  font-size: 12px;
}

.toast-action.loading {
  cursor: wait;
  opacity: 0.78;
}

.toast-action.loading::before {
  width: 12px;
  height: 12px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  content: "";
  animation: spin 700ms linear infinite;
}

.data-requirement-toast .toast-action {
  min-height: 44px;
  padding: 0 12px;
  border: 2px solid #8b5f2c;
  border-radius: 2px;
  color: #ffe7b0;
  background: linear-gradient(180deg, #426d53, #294b3a);
  box-shadow: inset 0 1px rgb(255 255 255 / 17%), 0 2px 0 #111f17;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.toast-action:hover {
  border-color: rgb(220 235 217 / 55%);
  background: rgb(255 255 255 / 14%);
}

.data-requirement-toast .toast-action:hover {
  border-color: #f1c873;
  color: #fff8e8;
  background: linear-gradient(180deg, #568563, #39634a);
}

.toast-action.primary {
  border-color: #ef6654;
  color: #fff;
  background: #c94d3e;
}

.data-requirement-toast .toast-action.primary {
  border-color: #f2c36d;
  color: #2d1b0b;
  background: linear-gradient(180deg, #f2c96f, #bd7e35);
  box-shadow: inset 0 1px rgb(255 247 197 / 78%), 0 2px 0 #111f17;
  text-shadow: 0 1px rgb(255 236 172 / 35%);
}

.toast-action.primary:hover {
  background: #ef6654;
}

.data-requirement-toast .toast-action.primary:hover {
  border-color: #fff0a7;
  color: #2d1b0b;
  background: linear-gradient(180deg, #ffdc83, #d59343);
}

@media (max-width: 400px) {
  .data-requirement-toast {
    min-height: 0;
    padding: 52px 18px 19px;
  }

  .data-requirement-toast .toast-actions {
    grid-template-columns: 1fr;
  }
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes setup-card-in {
  from {
    opacity: 0;
    transform: translateY(10px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes toast-in {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
