:root {
  color-scheme: dark;
  --bg: #151311;
  --bg-2: #1d1814;
  --ink: #f3eadb;
  --muted: #b9aa96;
  --panel: rgba(32, 28, 24, 0.9);
  --panel-2: rgba(255, 248, 238, 0.08);
  --panel-3: rgba(255, 248, 238, 0.04);
  --line: rgba(255, 214, 168, 0.16);
  --accent: #e55a2b;
  --accent-hover: #ff6d3d;
  --accent-2: #87f542;
  --shadow: 0 28px 72px rgba(0, 0, 0, 0.42);
  font-family: "IBM Plex Sans", "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--ink);
  background:
    radial-gradient(circle at top left, rgba(229, 90, 43, 0.22), transparent 24%),
    radial-gradient(circle at top right, rgba(135, 245, 66, 0.12), transparent 28%),
    linear-gradient(180deg, #1e1914 0%, var(--bg) 42%, #120f0d 100%);
}

input,
select,
button {
  font: inherit;
}

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

button {
  border: 0;
  border-radius: 999px;
  padding: 12px 18px;
  background: linear-gradient(180deg, var(--accent-hover) 0%, var(--accent) 100%);
  color: #fff3e6;
  font-weight: 700;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 14px 28px rgba(229, 90, 43, 0.22);
}

button.secondary {
  background: rgba(255, 248, 238, 0.04);
  color: var(--accent-2);
  border: 1px solid var(--line);
  box-shadow: none;
}

input,
select {
  width: 100%;
  border: 1px solid var(--line);
  background: rgba(255, 248, 238, 0.05);
  color: var(--ink);
  border-radius: 14px;
  padding: 11px 13px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.03);
}

.app-shell {
  width: min(1380px, calc(100vw - 32px));
  margin: 0 auto;
  padding: 12px 0 32px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.page-intro {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 10px 16px;
  background:
    linear-gradient(180deg, rgba(255, 248, 238, 0.06), rgba(255, 248, 238, 0.02)),
    rgba(20, 17, 14, 0.76);
}

.eyebrow {
  margin: 0 0 2px;
  text-transform: uppercase;
  letter-spacing: 0.14em;
  color: var(--accent-2);
  font-size: 0.68rem;
  font-weight: 700;
}

h1 {
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: clamp(1.45rem, 2.2vw, 2.2rem);
  line-height: 0.98;
  margin-bottom: 0;
}

.page-copy {
  max-width: 34ch;
  margin-bottom: 0;
  color: var(--muted);
  text-align: right;
  font-size: 0.84rem;
}

.workspace {
  margin-top: 12px;
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(360px, 420px);
  gap: 16px;
  align-items: start;
}

.stage-panel,
.control-panel,
.dev-panel {
  padding: 20px;
}

.control-panel {
  display: grid;
  gap: 10px;
}

.panel-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 10px;
}

.panel-header p {
  color: var(--muted);
  margin-bottom: 0;
  font-size: 0.85rem;
}

.wallet-card,
.info-card,
.message-log,
.examples-log,
.dev-card {
  border: 1px solid var(--line);
  background:
    linear-gradient(180deg, rgba(255, 248, 238, 0.08), rgba(255, 248, 238, 0.04)),
    var(--panel-3);
  border-radius: 18px;
}

.wallet-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 10px 12px 10px 14px;
  margin-bottom: 8px;
  font-size: 0.98rem;
}

.wallet-balance {
  min-width: 0;
  color: var(--muted);
}

.wallet-balance strong {
  color: #fff4dd;
  font-size: 1.28rem;
  font-weight: 700;
  text-shadow: 0 0 18px rgba(229, 90, 43, 0.18);
}

.icon-button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  min-width: 34px;
  height: 34px;
  padding: 0;
  border-radius: 50%;
  background: rgba(255, 248, 238, 0.06);
  color: var(--accent-2);
  border: 1px solid var(--line);
  font-size: 0.95rem;
  line-height: 1;
  flex: 0 0 auto;
}

.icon-button:hover {
  background: rgba(255, 248, 238, 0.12);
}

.icon-button svg {
  width: 16px;
  height: 16px;
  display: block;
}

.launch-form {
  display: grid;
  gap: 10px;
  padding: 12px 0 10px;
  border-top: 1px solid rgba(255, 214, 168, 0.12);
  border-bottom: 1px solid rgba(255, 214, 168, 0.12);
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.launch-form label {
  display: grid;
  gap: 5px;
  font-size: 0.88rem;
}

.full-span {
  grid-column: 1 / -1;
}

.action-row {
  display: flex;
  gap: 0;
}

#launch-button {
  width: 100%;
  padding: 13px 18px;
  border-radius: 16px;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.14),
    0 16px 30px rgba(229, 90, 43, 0.28);
}

.inline-status {
  margin: 0;
  min-height: 1.2em;
  color: var(--muted);
  font-size: 0.9rem;
}

.inline-status.is-error {
  color: #b33b2f;
}

.inline-status.is-success {
  color: var(--accent-2);
}

.advanced-settings {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 248, 238, 0.04);
  padding: 12px 14px;
}

.advanced-settings summary,
.dev-tools summary {
  list-style: none;
  cursor: pointer;
}

.advanced-settings summary::-webkit-details-marker,
.dev-tools summary::-webkit-details-marker {
  display: none;
}

.advanced-settings summary {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 700;
  font-size: 0.95rem;
}

.advanced-settings summary::after {
  content: "+";
  color: var(--accent-2);
  font-size: 1.2rem;
  line-height: 1;
}

.advanced-settings[open] summary::after {
  content: "−";
}

.advanced-grid {
  margin-top: 12px;
}

.panel-subgrid {
  display: grid;
  gap: 10px;
  margin-top: 2px;
}

.info-card {
  padding: 12px 14px;
  background: rgba(255, 248, 238, 0.05);
}

.info-card h3 {
  margin-bottom: 8px;
  font-size: 0.92rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.kv-list {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 0.92rem;
}

.kv-list div {
  display: grid;
  grid-template-columns: 110px minmax(0, 1fr);
  gap: 10px;
}

.kv-list span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.frame-shell {
  position: relative;
  width: 100%;
  border-radius: 20px;
  overflow: hidden;
  border: 1px solid rgba(255, 214, 168, 0.18);
  background:
    linear-gradient(135deg, #24170f, #0e1211),
    radial-gradient(circle at top left, rgba(229, 90, 43, 0.16), transparent 40%);
  box-shadow:
    inset 0 0 0 6px rgba(8, 7, 6, 0.42),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
  min-height: min(72vh, 760px);
}

.frame-shell.empty iframe {
  display: none;
}

.frame-shell.is-loading::after,
.frame-shell.is-error::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(7, 9, 8, 0.46);
}

.placeholder {
  position: absolute;
  inset: 50% auto auto 50%;
  transform: translate(-50%, -50%);
  width: min(420px, 80%);
  text-align: center;
  color: rgba(243, 234, 219, 0.66);
  z-index: 1;
}

iframe {
  width: 100%;
  border: 0;
  display: block;
  background: #101010;
}

.dev-panel {
  margin-top: 18px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.game-card {
  position: relative;
  min-height: 126px;
  border: 1px solid rgba(255, 214, 168, 0.2);
  border-radius: 20px;
  padding: 16px;
  overflow: hidden;
  background-color: rgba(18, 22, 20, 0.8);
  background-position: center;
  background-repeat: no-repeat;
  background-size: cover;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 10px 18px rgba(0, 0, 0, 0.18);
  transition: transform 140ms ease, border-color 140ms ease, box-shadow 140ms ease, filter 140ms ease;
}

.game-card:hover,
.game-card.active {
  transform: translateY(-2px);
  border-color: rgba(229, 90, 43, 0.55);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.08),
    0 18px 30px rgba(0, 0, 0, 0.28);
  filter: saturate(1.06);
}

.game-card::before {
  content: "";
  position: absolute;
  inset: 0;
  background:
    linear-gradient(180deg, rgba(7, 9, 8, 0.06), rgba(7, 9, 8, 0.76)),
    repeating-linear-gradient(
      180deg,
      rgba(255, 255, 255, 0.012) 0,
      rgba(255, 255, 255, 0.012) 1px,
      transparent 1px,
      transparent 4px
    );
}

.game-card-label,
.game-card-overlay {
  position: relative;
  z-index: 1;
  color: white;
}

.game-card-label {
  display: inline-flex;
  align-items: end;
  min-height: 94px;
  max-width: 100%;
  font-family: "Space Grotesk", "IBM Plex Sans", sans-serif;
  font-size: 1.12rem;
  font-weight: 700;
  line-height: 1;
  text-shadow: 0 2px 18px rgba(0, 0, 0, 0.56);
}

.game-card-overlay {
  position: absolute;
  inset: auto 0 0;
  display: grid;
  gap: 4px;
  padding: 14px 16px 16px;
  background: linear-gradient(180deg, rgba(7, 9, 8, 0), rgba(7, 9, 8, 0.84) 35%);
  opacity: 0;
  transition: opacity 140ms ease;
  text-align: left;
}

.game-card:hover .game-card-overlay,
.game-card:focus-visible .game-card-overlay,
.game-card.active .game-card-overlay {
  opacity: 1;
}

.game-card-overlay strong,
.game-card-overlay span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.game-card-overlay span {
  color: rgba(255, 255, 255, 0.78);
  font-size: 0.84rem;
}

.sidebar-catalog {
  display: grid;
  gap: 12px;
}

.sidebar-catalog .panel-header {
  margin-bottom: 0;
}

.dev-tools {
  display: grid;
  gap: 16px;
}

.dev-tools summary {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  font-weight: 700;
}

.dev-tools summary small {
  color: var(--muted);
  font-weight: 400;
}

.dev-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
}

.dev-card {
  padding: 16px;
}

.message-log {
  min-height: 180px;
  margin-top: 14px;
  padding: 16px;
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  white-space: pre-wrap;
}

.examples-log {
  min-height: 260px;
  margin-top: 14px;
  padding: 16px;
  overflow: auto;
  font-family: "IBM Plex Mono", "SFMono-Regular", monospace;
  white-space: pre-wrap;
}

.charge-panel {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 20;
  width: min(420px, calc(100vw - 24px));
}

.charge-card {
  border: 1px solid var(--line);
  border-radius: 22px;
  background:
    linear-gradient(180deg, rgba(255, 248, 238, 0.1), rgba(255, 248, 238, 0.04)),
    rgba(24, 20, 17, 0.96);
  box-shadow: var(--shadow);
  padding: 18px;
  display: grid;
  gap: 14px;
}

.charge-eyebrow {
  margin: 0 0 6px;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  color: var(--accent-2);
  font-weight: 700;
}

.charge-copy h3 {
  margin-bottom: 8px;
}

.charge-copy p:last-child {
  margin-bottom: 0;
  color: var(--muted);
}

.charge-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.charge-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--accent);
  color: white;
  text-decoration: none;
  font-weight: 700;
}

.charge-link.is-disabled {
  opacity: 0.45;
  pointer-events: none;
}

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

  .frame-shell {
    min-height: 56vh;
  }

  .game-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 900px) {
  .app-shell {
    width: min(100vw - 20px, 1380px);
  }

  .page-intro {
    flex-direction: column;
    align-items: start;
  }

  .page-copy {
    text-align: left;
  }

  .form-grid,
  .dev-grid {
    grid-template-columns: 1fr;
  }

  .game-grid {
    grid-template-columns: 1fr;
  }

  .kv-list div {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .charge-panel {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
  }
}

@media (max-width: 640px) {
  .app-shell {
    width: min(100vw - 16px, 1380px);
  }

  .panel,
  .page-intro,
  .stage-panel,
  .control-panel,
  .dev-panel {
    border-radius: 18px;
  }

  .app-shell {
    padding: 12px 0 28px;
  }

  .page-intro,
  .stage-panel,
  .control-panel,
  .dev-panel {
    padding: 16px;
  }

  .game-grid {
    grid-template-columns: 1fr;
  }

  .frame-shell {
    min-height: 48vh;
  }
}
