:root {
  color-scheme: dark;
  --bg: #101116;
  --panel: rgba(25, 27, 34, 0.88);
  --line: rgba(255, 255, 255, 0.12);
  --ink: #f6f7fb;
  --muted: #a6a9b5;
  --accent: #c9ff35;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 20% 15%, rgba(145, 119, 255, 0.18), transparent 34rem),
    radial-gradient(circle at 85% 80%, rgba(109, 225, 215, 0.12), transparent 30rem),
    var(--bg);
  color: var(--ink);
  font-family: "Noto Sans SC", system-ui, -apple-system, BlinkMacSystemFont, sans-serif;
}

body {
  display: flex;
  flex-direction: column;
}

button,
a {
  color: inherit;
  font: inherit;
}

button {
  border: 0;
}

.game-toolbar {
  position: relative;
  flex: 0 0 auto;
  z-index: 20;
  margin:
    max(8px, env(safe-area-inset-top))
    max(8px, env(safe-area-inset-right))
    8px
    max(8px, env(safe-area-inset-left));
  min-height: 58px;
  padding: 8px;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  gap: 14px;
  border: 1px solid var(--line);
  border-radius: 19px;
  background: rgba(12, 13, 17, 0.76);
  box-shadow: 0 16px 45px rgba(0, 0, 0, 0.24);
  backdrop-filter: blur(18px);
}

.toolbar-button {
  width: max-content;
  min-height: 40px;
  padding: 0 14px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.07);
  text-decoration: none;
  cursor: pointer;
  transition: transform 160ms ease, background 160ms ease, opacity 160ms ease;
}

.toolbar-button:hover:not(:disabled) {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.13);
}

.toolbar-button:disabled {
  cursor: not-allowed;
  opacity: 0.42;
}

.game-identity {
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  line-height: 1.2;
}

.game-identity strong {
  max-width: min(38vw, 420px);
  overflow: hidden;
  font-size: 14px;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-identity span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 11px;
}

.toolbar-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.game-stage,
#partner-frame {
  width: 100%;
}

.game-stage {
  position: relative;
  flex: 1 1 auto;
  min-height: 0;
}

#partner-frame {
  height: 100%;
  display: block;
  border: 0;
  background: #08090c;
}

#partner-frame[hidden] {
  display: none;
}

.game-stage:fullscreen {
  width: 100%;
  height: 100%;
}

.status-panel {
  position: absolute;
  inset: 0;
  width: min(520px, calc(100% - 40px));
  height: max-content;
  margin: auto;
  padding: 44px 32px;
  border: 1px solid var(--line);
  border-radius: 28px;
  background: var(--panel);
  box-shadow: 0 28px 90px rgba(0, 0, 0, 0.3);
  text-align: center;
  backdrop-filter: blur(22px);
}

.status-mark {
  width: 54px;
  height: 54px;
  margin: 0 auto 22px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: var(--accent);
  color: #17190f;
  font-size: 28px;
  font-weight: 800;
}

body[data-state="loading"] .status-mark {
  animation: pulse 1s ease-in-out infinite alternate;
}

.status-label {
  margin: 0 0 10px;
  color: var(--accent);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.16em;
}

.status-panel h1 {
  margin: 0;
  font-size: clamp(25px, 5vw, 38px);
  letter-spacing: -0.04em;
}

.status-copy {
  max-width: 390px;
  margin: 16px auto 0;
  color: var(--muted);
  font-size: 14px;
  line-height: 1.75;
}

.retry-button {
  min-height: 44px;
  margin-top: 24px;
  padding: 0 20px;
  border-radius: 14px;
  background: var(--accent);
  color: #17190f;
  cursor: pointer;
  font-weight: 700;
}

body[data-state="ready"] .status-panel {
  display: none;
}

@keyframes pulse {
  from {
    transform: scale(0.92);
    opacity: 0.65;
  }

  to {
    transform: scale(1.04);
    opacity: 1;
  }
}

@media (max-width: 680px) {
  .game-toolbar {
    grid-template-columns: auto 1fr auto;
  }

  .game-identity {
    align-items: flex-start;
  }

  .game-identity strong {
    max-width: 32vw;
  }

  .game-identity span,
  #official-link,
  .back-button span:last-child {
    display: none;
  }

  .toolbar-button {
    padding: 0 12px;
  }

  .status-panel {
    padding: 34px 22px;
  }
}

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