:root {
  --bg: #07090c;
  --bg-2: #0d1116;
  --panel: #12171d;
  --panel-2: #181f27;
  --line: rgba(214, 255, 75, 0.16);
  --line-strong: rgba(214, 255, 75, 0.38);
  --accent: #d6ff4b;
  --accent-ink: #12180a;
  --warn: #ff6b4a;
  --text: #eef2e6;
  --muted: #8d9680;
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.45);
  --radius: 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--text);
  font-family: Manrope, system-ui, sans-serif;
}

body {
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 80% -10%, rgba(214, 255, 75, 0.08), transparent 55%),
    radial-gradient(900px 500px at -10% 110%, rgba(90, 180, 255, 0.08), transparent 50%),
    var(--bg);
}

.grain {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 8;
  opacity: 0.09;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='140' height='140'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='.85' numOctaves='2' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='140' height='140' filter='url(%23n)' opacity='.55'/%3E%3C/svg%3E");
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.screen {
  min-height: 100vh;
}

.screen[hidden] {
  display: none;
}

.gate {
  display: grid;
  place-items: center;
  padding: 32px 20px;
}

.gate-frame {
  position: relative;
  width: min(460px, 100%);
  padding: 48px 36px 40px;
  background: linear-gradient(180deg, rgba(18, 23, 29, 0.92), rgba(10, 13, 16, 0.96));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  text-align: center;
}

.corner {
  position: absolute;
  width: 14px;
  height: 14px;
  border: 2px solid var(--accent);
}

.corner.tl { top: 10px; left: 10px; border-right: 0; border-bottom: 0; }
.corner.tr { top: 10px; right: 10px; border-left: 0; border-bottom: 0; }
.corner.bl { bottom: 10px; left: 10px; border-right: 0; border-top: 0; }
.corner.br { bottom: 10px; right: 10px; border-left: 0; border-top: 0; }

.kicker {
  margin: 0 0 12px;
  color: var(--accent);
  letter-spacing: 0.28em;
  text-transform: uppercase;
  font-size: 11px;
  font-weight: 700;
}

.logo {
  margin: 0;
  font-family: "Chakra Petch", sans-serif;
  font-size: clamp(36px, 8vw, 52px);
  font-weight: 700;
  letter-spacing: 0.04em;
  line-height: 0.95;
}

.logo span {
  color: var(--accent);
}

.tagline {
  margin: 12px 0 28px;
  color: var(--muted);
}

.gate-form {
  display: grid;
  gap: 12px;
}

input,
textarea,
button {
  font: inherit;
}

#key-input,
#code-input,
button {
  border-radius: 12px;
}

#key-input {
  width: 100%;
  height: 50px;
  padding: 0 16px;
  border: 1px solid var(--line-strong);
  background: #0b0e12;
  color: var(--text);
  letter-spacing: 0.12em;
}

#key-input:focus,
#code-input:focus,
button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

button {
  cursor: pointer;
  border: 1px solid var(--line);
  background: var(--panel-2);
  color: var(--text);
  height: 46px;
  padding: 0 18px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

button.primary,
#continue-btn {
  background: var(--accent);
  color: var(--accent-ink);
  border-color: var(--accent);
}

button.ghost {
  height: 36px;
  background: transparent;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.gate-error {
  margin: 14px 0 0;
  color: var(--warn);
  font-size: 14px;
}

.gate-frame.shake {
  animation: shake 0.38s ease;
}

@keyframes shake {
  20%, 80% { transform: translateX(-6px); }
  40%, 60% { transform: translateX(6px); }
}

.console {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  padding: 18px 22px;
  border-bottom: 1px solid var(--line);
  background: rgba(7, 9, 12, 0.78);
  backdrop-filter: blur(12px);
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.mark {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 10px;
  background: var(--accent);
  color: var(--accent-ink);
  font-family: "Chakra Petch", sans-serif;
  font-weight: 700;
}

.brand strong {
  display: block;
  font-family: "Chakra Petch", sans-serif;
  letter-spacing: 0.04em;
}

.brand small,
.panel-note,
.active-game,
.count {
  color: var(--muted);
}

.topbar-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--muted);
  font-size: 13px;
}

.led {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent);
}

.workspace {
  flex: 1;
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 18px;
  padding: 18px;
}

.games-panel,
.editor-panel {
  background: linear-gradient(180deg, rgba(18, 23, 29, 0.94), rgba(10, 13, 16, 0.98));
  border: 1px solid var(--line);
  border-radius: var(--radius);
  min-height: 0;
}

.games-panel {
  padding: 18px;
  display: flex;
  flex-direction: column;
}

.editor-panel {
  padding: 18px;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 12px;
}

.panel-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.panel-head h2 {
  margin: 0;
  font-family: "Chakra Petch", sans-serif;
  font-size: 20px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.count {
  min-width: 28px;
  height: 22px;
  display: grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 12px;
}

.panel-note {
  margin: 8px 0 14px;
  font-size: 13px;
}

.games-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  gap: 8px;
  overflow: auto;
}

.games-list li button {
  width: 100%;
  height: auto;
  min-height: 64px;
  text-align: left;
  text-transform: none;
  letter-spacing: 0;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 12px;
  padding: 8px 10px;
}

.game-thumb {
  width: 48px;
  height: 48px;
  border-radius: 8px;
  object-fit: cover;
  background: #0b0e12;
  border: 1px solid var(--line);
  flex-shrink: 0;
}

.game-copy {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  min-width: 0;
  gap: 2px;
}

.game-copy strong {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 170px;
}

.games-list li button span {
  color: var(--muted);
  font-size: 12px;
  font-weight: 500;
}

.games-list li button:disabled {
  opacity: 0.55;
  cursor: default;
}

.empty-game {
  border: 1px dashed var(--line);
  border-radius: 12px;
  padding: 18px 14px;
  color: var(--muted);
  font-size: 13px;
}

#code-input {
  width: 100%;
  min-height: 320px;
  resize: none;
  padding: 16px;
  border: 1px solid var(--line);
  background: #0b0e12;
  color: #dce7c8;
  font-family: "IBM Plex Mono", ui-monospace, monospace;
  font-size: 13.5px;
  line-height: 1.55;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.actions button {
  min-width: 110px;
}

.toasts {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 20;
  display: grid;
  gap: 8px;
}

.toast {
  min-width: 220px;
  max-width: 320px;
  padding: 12px 14px;
  border-radius: 12px;
  background: #161d14;
  border: 1px solid var(--line-strong);
  color: var(--text);
  box-shadow: var(--shadow);
}

.toast.error {
  background: #231410;
  border-color: rgba(255, 107, 74, 0.45);
}

@media (max-width: 860px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .games-panel {
    max-height: 280px;
  }
}
