:root {
  color-scheme: light;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  --ink: #151424;
  --muted: #676070;
  --paper: #fbf8ff;
  --panel: rgba(255, 255, 255, 0.84);
  --line: rgba(21, 20, 36, 0.12);
  --pink: #ff4f9d;
  --violet: #6847f5;
  --blue: #13a9e8;
  --gold: #ffb72c;
  --shadow: 0 20px 60px rgba(48, 32, 86, 0.14);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--ink);
  background:
    radial-gradient(circle at 9% 8%, rgba(255, 79, 157, 0.18), transparent 28rem),
    radial-gradient(circle at 86% 11%, rgba(19, 169, 232, 0.2), transparent 30rem),
    linear-gradient(180deg, #fbf8ff 0%, #f7fbff 48%, #fff9ec 100%);
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  cursor: pointer;
}

a {
  color: inherit;
  text-decoration: none;
}

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  width: min(1240px, calc(100% - 32px));
  margin: 16px auto 0;
  padding: 12px 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.76);
  box-shadow: 0 12px 34px rgba(48, 32, 86, 0.1);
  backdrop-filter: blur(18px);
}

.brand,
nav {
  display: flex;
  align-items: center;
}

.brand {
  gap: 10px;
  font-weight: 950;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--violet));
}

nav {
  gap: 8px;
}

nav a {
  padding: 10px 14px;
  border-radius: 999px;
  color: var(--muted);
  font-size: 0.94rem;
  font-weight: 850;
}

nav a:hover {
  color: var(--ink);
  background: rgba(104, 71, 245, 0.08);
}

.settings-nav-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0 16px;
  border: 1px solid transparent;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  font-size: 0.94rem;
  font-weight: 850;
}

.settings-nav-button:hover {
  filter: brightness(1.05);
}

main {
  width: min(1240px, calc(100% - 32px));
  margin: 0 auto;
}

.hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 0.55fr);
  gap: 32px;
  align-items: end;
  padding: 68px 0 34px;
}

.eyebrow {
  margin: 0 0 10px;
  color: var(--pink);
  font-size: 0.76rem;
  font-weight: 950;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  max-width: 880px;
  margin-bottom: 18px;
  font-size: clamp(2.6rem, 6vw, 5.4rem);
  line-height: 0.96;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 0;
  font-size: clamp(1.35rem, 2.3vw, 2rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.hero p:not(.eyebrow) {
  max-width: 720px;
  color: var(--muted);
  font-size: clamp(1rem, 1.5vw, 1.18rem);
  line-height: 1.7;
}

.hero-panel {
  display: grid;
  gap: 1px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 24px;
  background: var(--line);
  box-shadow: var(--shadow);
}

.hero-panel div {
  padding: 22px;
  background: rgba(255, 255, 255, 0.8);
}

.hero-panel span {
  display: block;
  margin-bottom: 7px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 850;
  text-transform: uppercase;
}

.hero-panel strong {
  font-size: 1.22rem;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(360px, 0.78fr) minmax(420px, 1fr);
  gap: 22px;
  align-items: start;
  padding: 24px 0 54px;
}

.builder,
.preview-panel {
  display: grid;
  gap: 18px;
}

.panel,
.preview-panel {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 24px;
  background: var(--panel);
  box-shadow: var(--shadow);
}

.panel {
  padding: 22px;
}

.panel-heading,
.preview-toolbar,
.game-row,
.actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
}

.panel-heading {
  margin-bottom: 18px;
}

.panel-heading.split {
  align-items: start;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 14px;
  color: var(--ink);
  font-size: 0.93rem;
  font-weight: 850;
}

.switch-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
}

.switch-row span {
  display: grid;
  gap: 4px;
}

.switch-row small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
  line-height: 1.4;
}

.switch-row input {
  flex: 0 0 auto;
  width: 48px;
  height: 28px;
  min-height: 28px;
  padding: 0;
  border-radius: 999px;
  appearance: none;
  background: rgba(21, 20, 36, 0.16);
  transition: background 160ms ease;
}

.switch-row input::before {
  content: "";
  display: block;
  width: 22px;
  height: 22px;
  margin: 2px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(21, 20, 36, 0.22);
  transition: transform 160ms ease;
}

.switch-row input:checked {
  background: linear-gradient(135deg, var(--pink), var(--violet));
}

.switch-row input:checked::before {
  transform: translateX(20px);
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #fff;
  color: var(--ink);
  outline: none;
}

input {
  min-height: 48px;
  padding: 0 14px;
}

select {
  min-height: 48px;
  padding: 0 14px;
  appearance: none;
  background:
    linear-gradient(45deg, transparent 50%, var(--muted) 50%) calc(100% - 20px) 52% / 7px 7px no-repeat,
    linear-gradient(135deg, var(--muted) 50%, transparent 50%) calc(100% - 15px) 52% / 7px 7px no-repeat,
    #fff;
}

textarea {
  resize: vertical;
  padding: 13px 14px;
  line-height: 1.5;
}

input:focus,
select:focus,
textarea:focus {
  border-color: rgba(104, 71, 245, 0.55);
  box-shadow: 0 0 0 4px rgba(104, 71, 245, 0.1);
}

.games-list {
  display: grid;
  gap: 14px;
}

.game-item {
  padding: 16px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.72);
}

.game-row {
  align-items: end;
}

.game-row label {
  flex: 1;
}

.icon-button,
.remove-game {
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--ink);
  font-weight: 950;
}

.icon-button {
  width: 44px;
  height: 44px;
  font-size: 1.35rem;
}

.remove-game {
  min-height: 48px;
  padding: 0 14px;
}

.upload-label {
  margin-bottom: 8px;
}

.dropzone {
  position: relative;
  display: grid;
  place-items: center;
  gap: 6px;
  min-height: 132px;
  margin-bottom: 14px;
  padding: 18px;
  border: 2px dashed rgba(104, 71, 245, 0.34);
  border-radius: 18px;
  background:
    linear-gradient(135deg, rgba(255, 79, 157, 0.08), rgba(19, 169, 232, 0.08)),
    rgba(255, 255, 255, 0.72);
  color: var(--muted);
  text-align: center;
  transition: border-color 160ms ease, background 160ms ease, transform 160ms ease;
}

.dropzone strong {
  color: var(--ink);
  font-size: 1rem;
}

.dropzone span {
  font-size: 0.88rem;
}

.dropzone input {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: pointer;
  opacity: 0;
}

.dropzone.is-dragging,
.dropzone:focus-within {
  border-color: var(--violet);
  background:
    linear-gradient(135deg, rgba(255, 79, 157, 0.16), rgba(19, 169, 232, 0.15)),
    #fff;
  transform: translateY(-2px);
}

.upload-count {
  margin: -2px 0 12px;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.upload-count.has-files {
  color: #116047;
  font-weight: 850;
}

.thumbs {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(64px, 1fr));
  gap: 8px;
}

.thumbs img {
  width: 100%;
  aspect-ratio: 9 / 16;
  object-fit: cover;
  border: 3px solid #fff;
  border-radius: 10px;
  box-shadow: 0 8px 20px rgba(48, 32, 86, 0.14);
}

.actions {
  position: sticky;
  bottom: 16px;
  z-index: 5;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.84);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 50px;
  padding: 0 18px;
  border: 1px solid var(--line);
  border-radius: 14px;
  font-weight: 950;
}

.button.primary {
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  box-shadow: 0 14px 32px rgba(255, 79, 157, 0.28);
}

.button.secondary {
  background: #fff;
}

.button:disabled,
.icon-button:disabled,
.remove-game:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.preview-panel {
  position: sticky;
  top: 96px;
  padding: 18px;
}

.preview-toolbar {
  align-items: start;
}

.preview-tools {
  display: flex;
  align-items: center;
  gap: 10px;
}

.preview-pill-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 34px;
  padding: 0 12px;
  border: 0;
  border-radius: 999px;
  color: #fff;
  background: linear-gradient(135deg, var(--blue), var(--violet));
  font-size: 0.85rem;
  font-weight: 950;
}

.preview-pill-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(21, 20, 36, 0.5);
  backdrop-filter: blur(8px);
}

.modal-overlay[hidden] {
  display: none !important;
}

.modal {
  display: grid;
  gap: 16px;
  width: min(560px, 100%);
  max-height: calc(100vh - 40px);
  overflow-y: auto;
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 24px;
  background: rgba(255, 255, 255, 0.98);
  box-shadow: 0 30px 80px rgba(21, 20, 36, 0.3);
}

.modal-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 14px;
}

.modal-close {
  display: grid;
  place-items: center;
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: #fff;
  color: var(--muted);
  font-size: 1.5rem;
  line-height: 1;
}

.modal-close:hover {
  color: var(--ink);
  background: rgba(104, 71, 245, 0.06);
}

.modal-note {
  margin: 0;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: #fff;
  font-size: 0.88rem;
  line-height: 1.5;
}

.modal-note code {
  padding: 2px 5px;
  border-radius: 6px;
  background: rgba(104, 71, 245, 0.1);
  color: var(--violet);
  font-weight: 850;
}

.config-status {
  min-height: 42px;
  padding: 11px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  font-size: 0.9rem;
  line-height: 1.5;
}

.config-status.ok {
  color: #116047;
  background: rgba(40, 196, 139, 0.12);
}

.config-status.warn {
  color: #8f3d14;
  background: rgba(255, 160, 60, 0.14);
}

.field-hint {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
  line-height: 1.45;
}

.secret-field {
  position: relative;
  display: block;
}

.secret-field input {
  width: 100%;
  padding-right: 46px;
}

.secret-toggle {
  position: absolute;
  top: 50%;
  right: 8px;
  transform: translateY(-50%);
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
}

.secret-toggle:hover {
  color: var(--ink);
  background: rgba(104, 71, 245, 0.08);
}

.secret-toggle svg {
  display: block;
}

.modal-actions {
  display: flex;
  gap: 12px;
  margin-top: 4px;
}

.modal-actions .button {
  flex: 1;
}

.button.danger {
  color: #8f162d;
  border-color: rgba(143, 22, 45, 0.3);
  background: #fff;
  box-shadow: none;
}

.button.danger:hover:not(:disabled) {
  background: rgba(255, 79, 110, 0.1);
}

.modal-msg {
  min-height: 20px;
  margin: 0;
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.4;
}

.modal-msg.ok {
  color: #116047;
  font-weight: 850;
}

.modal-msg.err {
  color: #8f162d;
  font-weight: 850;
}

.status {
  min-height: 44px;
  padding: 12px 14px;
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  background: rgba(255, 255, 255, 0.72);
  line-height: 1.4;
}

.status.error {
  color: #8f162d;
  background: rgba(255, 79, 110, 0.1);
}

.status.success {
  color: #116047;
  background: rgba(40, 196, 139, 0.12);
}

iframe {
  width: 100%;
  height: 620px;
  border: 1px solid var(--line);
  border-radius: 18px;
  background: #fff;
}

.preview-frame-wrap {
  position: relative;
}

.preview-loading {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(10px);
}

.preview-loading[hidden] {
  display: none !important;
}

.loader-card {
  width: min(420px, 100%);
  padding: 24px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.94);
  box-shadow: var(--shadow);
  text-align: center;
}

.loader-dot {
  display: inline-block;
  width: 18px;
  height: 18px;
  margin-bottom: 12px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--pink), var(--violet));
  animation: pulse 900ms ease-in-out infinite alternate;
}

.loader-card strong {
  display: block;
  margin-bottom: 8px;
  font-size: 1.1rem;
}

.loader-card p {
  margin-bottom: 16px;
  color: var(--muted);
  line-height: 1.5;
}

.loader-card .elapsed-time {
  margin-top: -8px;
  color: var(--ink);
  font-size: 0.92rem;
  font-weight: 850;
}

.loader-bar {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: rgba(21, 20, 36, 0.1);
}

.loader-bar span {
  display: block;
  width: 42%;
  height: 100%;
  border-radius: inherit;
  background: linear-gradient(90deg, var(--pink), var(--blue), var(--violet));
  animation: loading-slide 1.2s ease-in-out infinite;
}

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

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

@keyframes loading-slide {
  from {
    transform: translateX(-105%);
  }

  to {
    transform: translateX(245%);
  }
}

.revision-box {
  display: grid;
  gap: 12px;
}

.final-elapsed {
  margin: 0;
  color: #a0a7b4;
  font-size: 0.86rem;
  line-height: 1.4;
}

.revision-box label {
  margin-bottom: 0;
}

.revision-box .button {
  width: 100%;
}

@media (max-width: 980px) {
  .hero,
  .workspace {
    grid-template-columns: 1fr;
  }

  .preview-panel {
    position: static;
  }
}

@media (max-width: 620px) {
  .topbar {
    align-items: stretch;
    flex-direction: column;
    border-radius: 22px;
  }

  nav a {
    flex: 1;
    text-align: center;
  }

  .settings-nav-button {
    flex: 1;
    min-height: 44px;
  }

  .hero {
    padding-top: 44px;
  }

  .game-row,
  .actions,
  .preview-toolbar {
    align-items: stretch;
    flex-direction: column;
  }

  .button,
  .remove-game {
    width: 100%;
  }

  .modal-actions {
    flex-direction: column;
  }

  iframe {
    height: 540px;
  }
}
