:root {
  color-scheme: dark;
  --bg: #080a08;
  --panel: rgba(20, 23, 20, 0.94);
  --line: rgba(255, 255, 255, 0.13);
  --muted: rgba(226, 232, 240, 0.58);
  --amber: #cbff8c;
  --orange: #a8e063;
  --red: #78a841;
  --violet: #86c947;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: var(--bg);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

button,
a {
  font: inherit;
  -webkit-tap-highlight-color: transparent;
}

button {
  color: inherit;
}

.portal,
.game-mount,
.chooser,
.loading-screen {
  position: fixed;
  inset: 0;
}

.portal {
  isolation: isolate;
  background: var(--bg);
}

.game-mount {
  z-index: 1;
  display: none;
  background: #000;
}

.game-mount iframe {
  width: 100%;
  height: 100%;
  display: block;
  border: 0;
  background: #000;
}

.portal[data-state="loading"] .game-mount,
.portal[data-state="playing"] .game-mount {
  display: block;
}

.chooser {
  z-index: 4;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.portal:not([data-state="select"]) .chooser {
  display: none;
}

.chooser__backdrop {
  position: absolute;
  inset: -28px;
  z-index: -3;
  background:
    linear-gradient(rgba(8, 10, 8, 0.3), rgba(8, 10, 8, 0.72)),
    var(--game-cover, none) center / cover no-repeat;
  filter: blur(14px) saturate(1.12);
  opacity: 0.9;
  transform: scale(1.08);
}

.chooser__glow {
  position: absolute;
  inset: 0;
  z-index: -2;
  background:
    radial-gradient(70% 60% at 50% -5%, rgba(203, 255, 140, 0.1), transparent 68%),
    linear-gradient(180deg, rgba(8, 10, 8, 0.08), rgba(8, 10, 8, 0.62));
}

.mode-card {
  width: min(330px, calc(100% - 34px));
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.mode-art {
  width: clamp(96px, 23vh, 140px);
  display: grid;
  place-items: center;
  aspect-ratio: 1;
  border: 3px solid rgba(255, 255, 255, 0.72);
  border-radius: 12px;
  background:
    linear-gradient(145deg, #343934, #111411) center / cover no-repeat;
  font-size: clamp(48px, 12vh, 82px);
  line-height: 1;
  box-shadow:
    0 18px 38px rgba(0, 0, 0, 0.58),
    0 0 24px rgba(168, 224, 99, 0.14);
}

.mode-heading {
  margin: 12px 0 14px;
  padding: 0;
}

.mode-heading p {
  margin: 0 0 2px;
  color: rgba(255, 255, 255, 0.38);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
}

.mode-heading h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(17px, 4vh, 22px);
  line-height: 1.15;
}

.mode-actions {
  width: 100%;
  display: grid;
  gap: 10px;
}

.mode-button {
  position: relative;
  width: 100%;
  min-height: 55px;
  padding: 8px 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 13px;
  overflow: visible;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  box-shadow:
    0 10px 26px rgba(0, 0, 0, 0.34),
    inset 0 1px 0 rgba(255, 255, 255, 0.24);
  transition:
    transform 180ms ease,
    filter 180ms ease,
    box-shadow 180ms ease;
}

.mode-button:hover,
.mode-button:focus-visible {
  outline: none;
  filter: brightness(1.08);
  transform: translateY(-2px);
}

.mode-button:disabled {
  cursor: wait;
  filter: grayscale(0.4);
  opacity: 0.58;
}

.mode-button:focus-visible {
  box-shadow:
    0 0 0 3px rgba(255, 255, 255, 0.92),
    0 0 0 6px rgba(168, 224, 99, 0.58);
}

.mode-button:active {
  transform: scale(0.98);
}

.mode-button--unblocked {
  background: linear-gradient(145deg, #a855f7, #6d28d9 58%, #4c1d95);
  color: #fff;
}

.mode-button > span:nth-child(2) {
  min-width: 0;
  display: grid;
  text-align: center;
}

.mode-button strong {
  color: #fff;
  font-size: 14px;
  letter-spacing: 0.025em;
}

.mode-button small {
  display: none;
}

.mode-button i {
  position: absolute;
  top: -8px;
  right: 13px;
  padding: 3px 8px;
  border: 1.5px solid var(--amber);
  border-radius: 999px;
  background: #161a15;
  color: var(--amber);
  font-size: 8px;
  font-style: normal;
  font-weight: 850;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.42);
  display: none;
}

.play-mark {
  display: none;
}

.play-mark::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-top: 6px solid transparent;
  border-bottom: 6px solid transparent;
  border-left: 9px solid #fff;
  transform: translate(-38%, -50%);
}

.mode-note {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 9px;
}

.loading-screen {
  z-index: 5;
  display: grid;
  place-items: center;
  background:
    radial-gradient(circle at 50% 16%, rgba(168, 224, 99, 0.14), transparent 42%),
    rgba(8, 10, 8, 0.94);
  backdrop-filter: blur(9px);
}

.loading-screen[hidden] {
  display: none;
}

.loading-card {
  width: min(310px, calc(100% - 36px));
  display: grid;
  justify-items: center;
  color: #fff;
  text-align: center;
}

.loading-ball {
  width: 52px;
  height: 52px;
  border: 3px solid #303530;
  border-top-color: var(--orange);
  border-right-color: var(--amber);
  border-radius: 50%;
  box-shadow: 0 0 28px rgba(168, 224, 99, 0.18);
  animation: spin 780ms linear infinite;
}

.loading-card > p {
  margin: 14px 0 10px;
  font-weight: 750;
}

.progress-track {
  width: 100%;
  height: 5px;
  overflow: hidden;
  border-radius: 99px;
  background: rgba(255, 255, 255, 0.1);
}

.progress-track span {
  width: 0;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--amber), var(--orange), var(--violet));
  transition: width 140ms linear;
}

.loading-card > small {
  margin-top: 7px;
  color: var(--muted);
  font-size: 10px;
}

.loading-help {
  margin-top: 14px;
  padding-top: 13px;
  border-top: 1px solid var(--line);
}

.loading-help[hidden] {
  display: none;
}

.loading-help p {
  margin: 0 0 10px;
  color: #cbd5e1;
  font-size: 11px;
}

.loading-help button,
.loading-help a {
  min-height: 34px;
  margin: 0 3px;
  padding: 0 12px;
  display: inline-flex;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
  font-size: 10px;
  font-weight: 750;
  text-decoration: none;
  cursor: pointer;
}

.game-toolbar {
  position: fixed;
  z-index: 8;
  top: 10px;
  right: 10px;
  display: flex;
  gap: 6px;
  padding: 5px;
  border: 1px solid var(--line);
  border-radius: 10px;
  background: rgba(8, 10, 8, 0.86);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.32);
  backdrop-filter: blur(10px);
  opacity: 0.38;
  transition: opacity 180ms ease;
}

.game-toolbar[hidden] {
  display: none;
}

.game-toolbar:hover,
.game-toolbar:focus-within {
  opacity: 1;
}

.game-toolbar button,
.game-toolbar a {
  min-height: 34px;
  padding: 0 10px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  border: 0;
  border-radius: 7px;
  background: rgba(255, 255, 255, 0.08);
  color: #eef4ea;
  font-size: 11px;
  text-decoration: none;
  cursor: pointer;
}

.game-toolbar button:hover,
.game-toolbar a:hover,
.game-toolbar button:focus-visible,
.game-toolbar a:focus-visible {
  outline: none;
  background: rgba(168, 224, 99, 0.3);
}

.game-toolbar span {
  font-size: 15px;
}

.noscript-message {
  position: fixed;
  inset: 0;
  margin: 0;
  display: grid;
  place-items: center;
  color: #fff;
  background: var(--bg);
}

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

@media (max-height: 360px), (max-width: 520px) and (orientation: landscape) {
  .mode-card {
    width: min(590px, calc(100% - 28px));
    display: grid;
    grid-template-columns: 76px minmax(0, 1fr);
    grid-template-areas:
      "art heading"
      "art actions";
    gap: 7px 14px;
    text-align: left;
  }

  .mode-art {
    grid-area: art;
    width: 76px;
    align-self: center;
  }

  .mode-heading {
    grid-area: heading;
    margin: 0;
  }

  .mode-heading h1 {
    font-size: 16px;
  }

  .mode-actions {
    grid-area: actions;
    grid-template-columns: 1fr;
    gap: 8px;
  }

  .mode-button {
    min-height: 48px;
    padding: 6px 10px;
    gap: 8px;
  }

  .mode-button strong {
    font-size: 11px;
  }

  .mode-button small,
  .mode-note {
    display: none;
  }

  .play-mark {
    width: 29px;
    height: 29px;
    flex-basis: 29px;
  }
}

@media (max-width: 520px) and (orientation: portrait) {
  .chooser__backdrop {
    background-position: center;
  }

  .mode-card {
    width: min(310px, calc(100% - 26px));
  }

  .mode-art {
    width: min(116px, 22vh);
  }

  .mode-heading {
    margin: 6px 0 9px;
  }

  .mode-button {
    min-height: 49px;
  }

  .mode-note {
    display: none;
  }

  .game-toolbar {
    top: 7px;
    right: 7px;
    max-width: calc(100% - 14px);
  }

  .game-toolbar b {
    display: none;
  }

  .game-toolbar button,
  .game-toolbar a {
    width: 34px;
    padding: 0;
    justify-content: center;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
