:root {
  --bg-0: #071014;
  --bg-1: #0b1820;
  --bg-2: #10252b;
  --panel: rgba(8, 19, 23, 0.88);
  --panel-strong: rgba(6, 14, 17, 0.95);
  --grid: rgba(87, 255, 186, 0.11);
  --line: rgba(104, 255, 196, 0.28);
  --neon: #6bffbe;
  --neon-strong: #c4ffe4;
  --amber: #ffcf70;
  --rose: #ff6f91;
  --cyan: #77f1ff;
  --text: #d9ffee;
  --muted: #8eb7a4;
  --danger: #ff8f8f;
  --shadow: 0 0 30px rgba(71, 241, 170, 0.16);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  font-family: "JetBrains Mono", "IBM Plex Mono", "Fira Code", monospace;
  color: var(--text);
  background:
    radial-gradient(circle at top, rgba(94, 255, 191, 0.12), transparent 28%),
    linear-gradient(135deg, var(--bg-0), var(--bg-1) 52%, var(--bg-2));
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px),
    linear-gradient(90deg, var(--grid) 1px, transparent 1px);
  background-size: 22px 22px;
  opacity: 0.33;
}

.app-shell {
  display: grid;
  grid-template-columns: minmax(260px, 360px) minmax(320px, 1fr) minmax(320px, 420px);
  gap: 22px;
  min-height: 100vh;
  padding: 24px;
}

.app-shell.editor-hidden {
  grid-template-columns: minmax(260px, 360px) minmax(320px, 1fr);
}

body.fullscreen-mode .app-shell {
  grid-template-columns: 1fr;
  gap: 16px;
  min-height: 100vh;
  padding: 12px;
}

body.fullscreen-mode .panel-left,
body.fullscreen-mode .panel-right {
  display: none;
}

.landing-body {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.landing-shell {
  width: min(100%, 860px);
}

.landing-card {
  padding: 42px;
}

.landing-actions {
  margin: 24px 0 0;
}

.landing-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 14px 18px;
  border: 1px solid rgba(119, 241, 255, 0.28);
  border-radius: 14px;
  color: #061316;
  text-decoration: none;
  font-weight: 700;
  background: linear-gradient(135deg, var(--neon), var(--cyan));
  transition:
    transform 140ms ease,
    box-shadow 140ms ease;
}

.landing-link:hover,
.landing-link:focus-visible {
  transform: translateY(-1px);
  box-shadow: 0 0 20px rgba(107, 255, 190, 0.16);
  outline: none;
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.brand-block {
  padding: 18px 20px 6px;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--amber);
  font-size: 0.8rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

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

h1 {
  margin-bottom: 10px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 0.95;
  text-transform: uppercase;
  text-shadow: 0 0 20px rgba(107, 255, 190, 0.25);
}

h2 {
  margin-bottom: 12px;
  font-size: 1rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.lede {
  color: var(--muted);
  line-height: 1.6;
}

.card {
  position: relative;
  overflow: hidden;
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(10, 28, 33, 0.92), var(--panel-strong));
  box-shadow: var(--shadow);
}

.card::after {
  content: "";
  position: absolute;
  inset: auto -20% 0;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(107, 255, 190, 0.55), transparent);
}

.editor-feedback {
  margin: 14px 0 0;
  color: var(--amber);
  line-height: 1.5;
}

.mini-list {
  margin: 0;
  padding-left: 18px;
  color: var(--muted);
  line-height: 1.8;
}

.board-area {
  display: flex;
  align-items: center;
  justify-content: center;
}

.board-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  width: 100%;
}

.player-bar {
  width: min(100%, 940px);
  padding: 14px 16px;
}

.player-bar-row {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.player-bar-ad {
  margin: 0 0 0 auto;
  flex: 0 0 auto;
  gap: 0.4rem;
}

.mobile-top-ad {
  display: none;
}

.ad-banner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
}

.ad-banner__label {
  margin: 0;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.18em;
  text-transform: uppercase;
}

.ad-banner__frame {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(100%, 320px);
  min-height: 116px;
  padding: 8px;
  border: 1px solid rgba(119, 241, 255, 0.18);
  border-radius: 16px;
  background: rgba(6, 18, 20, 0.82);
}

.ad-banner__frame > div {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  min-width: 300px;
  min-height: 100px;
}

.player-label {
  color: var(--muted);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.board-frame {
  position: relative;
  width: min(100%, 760px, calc((100vh - 48px) * 9 / 14));
  aspect-ratio: 9 / 14;
  padding: 14px;
  border-radius: 28px;
  border: 1px solid rgba(119, 241, 255, 0.3);
  background:
    linear-gradient(180deg, rgba(118, 241, 255, 0.08), rgba(255, 111, 145, 0.06)),
    rgba(7, 18, 22, 0.92);
  box-shadow:
    0 0 40px rgba(0, 0, 0, 0.35),
    0 0 40px rgba(119, 241, 255, 0.12);
}

.app-shell.editor-hidden .board-frame {
  width: min(100%, 860px, calc((100vh - 48px) * 9 / 14));
}

body.fullscreen-mode .board-area {
  align-items: flex-start;
}

body.fullscreen-mode .board-frame {
  width: min(92vw, calc((100vh - 190px) * 9 / 14));
}

#gameCanvas,
#editorOverlay,
.crt-overlay {
  position: absolute;
  inset: 14px;
  width: calc(100% - 28px);
  height: calc(100% - 28px);
  border-radius: 20px;
}

#gameCanvas {
  display: block;
  background:
    radial-gradient(circle at 50% 20%, rgba(119, 241, 255, 0.05), transparent 30%),
    linear-gradient(180deg, rgba(3, 12, 17, 0.92), rgba(5, 18, 20, 0.98));
}

#editorOverlay {
  z-index: 1;
  touch-action: none;
}

.app-shell.editor-hidden #editorOverlay {
  opacity: 0;
  pointer-events: none;
}

.app-shell.editor-hidden .panel-right {
  display: none;
}

body.fullscreen-mode #editorOverlay {
  opacity: 0;
  pointer-events: none;
}

.crt-overlay {
  pointer-events: none;
  z-index: 2;
  background:
    linear-gradient(rgba(255, 255, 255, 0.025) 50%, transparent 50%),
    linear-gradient(90deg, rgba(107, 255, 190, 0.03), rgba(255, 255, 255, 0.01), rgba(119, 241, 255, 0.03));
  background-size: 100% 5px, 7px 100%;
  mix-blend-mode: screen;
  opacity: 0.5;
}

.editor-card {
  height: 100%;
  min-height: 0;
}

.editor-header,
.button-row {
  display: flex;
  gap: 10px;
  align-items: center;
}

.editor-header {
  justify-content: space-between;
}

.button-row {
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.button-row-tight button {
  flex: 1 1 120px;
}

button,
select,
textarea {
  font: inherit;
}

button,
select {
  border: 1px solid rgba(119, 241, 255, 0.25);
  border-radius: 12px;
  color: var(--text);
  background: rgba(9, 27, 31, 0.94);
}

button {
  padding: 10px 13px;
  cursor: pointer;
  transition:
    transform 140ms ease,
    border-color 140ms ease,
    box-shadow 140ms ease;
}

button:hover,
button:focus-visible,
select:focus-visible {
  outline: none;
  transform: translateY(-1px);
  border-color: rgba(107, 255, 190, 0.65);
  box-shadow: 0 0 16px rgba(107, 255, 190, 0.14);
}

button.accent {
  color: #061316;
  background: linear-gradient(135deg, var(--neon), var(--cyan));
}

select {
  min-width: 130px;
  padding: 10px 12px;
}

textarea {
  width: 100%;
  min-height: min(56vh, 820px);
  padding: 16px;
  border: 1px solid rgba(107, 255, 190, 0.16);
  border-radius: 16px;
  color: var(--neon-strong);
  background: rgba(3, 12, 14, 0.96);
  resize: vertical;
  line-height: 1.5;
  tab-size: 2;
}

textarea:focus-visible {
  outline: none;
  border-color: rgba(107, 255, 190, 0.5);
  box-shadow: inset 0 0 0 1px rgba(107, 255, 190, 0.2);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

code {
  color: var(--cyan);
}

@media (max-width: 1280px) {
  .app-shell {
    grid-template-columns: 1fr;
  }

  .panel-left,
  .panel-right {
    order: 2;
  }

  .board-area {
    order: 1;
  }

  .editor-card textarea {
    min-height: 420px;
  }
}

@media (max-width: 820px) {
  .player-bar-ad {
    display: none;
  }

  .mobile-top-ad {
    display: flex;
    width: min(100%, 320px);
    align-self: center;
  }

  .player-bar {
    width: min(100%, 760px);
  }
}
