/* Arkadstil: pixeltypsnitt i rubriker och mätare, hårda skuggor, knappar som trycks ner. */
@font-face { font-family: "Press Start 2P"; src: url("/fonts/press-start-2p.woff2") format("woff2"); font-display: swap; }
@font-face { font-family: "Lilita One"; src: url("/fonts/lilita-one.woff2") format("woff2"); font-display: swap; }

:root {
  --bg: #130b2e;
  --panel: #24155a;
  --panel-2: #301d78;
  --line: #4d37ad;
  --ink: #0a0618;
  --text: #fff8ee;
  --muted: #bdb2ea;
  --yellow: #ffd23f;
  --pink: #ff4f9a;
  --cyan: #3ee6ff;
  --lime: #8dff5a;
  --pixel: "Press Start 2P", ui-monospace, monospace;
  --display: "Lilita One", "Arial Black", system-ui, sans-serif;
  --radius: 14px;
}
* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; }
body {
  color: var(--text);
  font: 17px/1.5 ui-rounded, "SF Pro Rounded", "Nunito", "Segoe UI", system-ui, sans-serif;
  display: flex; flex-direction: column; min-height: 100vh;
  background:
    radial-gradient(900px 520px at 12% -10%, rgb(255 79 154 / 0.24), transparent 60%),
    radial-gradient(820px 520px at 92% 0%, rgb(62 230 255 / 0.2), transparent 60%),
    linear-gradient(rgb(255 255 255 / 0.04) 1px, transparent 1px) 0 0 / 32px 32px,
    linear-gradient(90deg, rgb(255 255 255 / 0.04) 1px, transparent 1px) 0 0 / 32px 32px,
    var(--bg);
  background-attachment: fixed;
}
body.fullscreen { height: 100vh; }
a { color: inherit; }
h1, h2, p { margin: 0; }

/* Sidhuvud */
.top { display: flex; align-items: center; gap: 28px; padding: 12px 24px; border-bottom: 3px solid var(--ink); background: rgb(19 11 46 / 0.85); }
.brand { font: 16px var(--pixel); text-decoration: none; display: flex; align-items: center; text-shadow: 3px 3px 0 var(--ink); }
.brand img { width: 28px; height: 28px; margin-right: 10px; }
.brand span:first-of-type { color: var(--yellow); }
.brand span:last-of-type { color: var(--cyan); }
.top nav { display: flex; gap: 20px; }
.top nav a { text-decoration: none; color: var(--muted); font-weight: 700; padding: 4px 0; border-bottom: 4px solid transparent; }
.top nav a.active, .top nav a:hover { color: var(--text); border-color: var(--pink); }

/* Mätare för krediter */
#budget { margin-left: auto; display: flex; gap: 8px; }
.hud { display: flex; align-items: center; gap: 8px; padding: 6px 10px; background: var(--ink); border: 2px solid var(--line); border-radius: 10px; font: 11px var(--pixel); }
.hud b { font-weight: normal; }
.hud.build b { color: var(--yellow); }
.hud.play b { color: var(--cyan); }
.hud.coins b { color: var(--lime); }
.hud small { font: 600 12px/1 ui-rounded, system-ui, sans-serif; color: var(--muted); }

/* Knappar: hård skugga som trycks ner */
button, select, .button {
  font: inherit; font-weight: 700; color: var(--text); background: var(--panel-2);
  border: 3px solid var(--ink); border-radius: 12px; padding: 8px 16px; cursor: pointer;
  text-decoration: none; white-space: nowrap; box-shadow: 0 4px 0 var(--ink);
  transition: transform 0.06s, box-shadow 0.06s, background 0.12s;
}
button:hover, .button:hover, select:hover { background: var(--line); transform: translateY(-1px); box-shadow: 0 5px 0 var(--ink); }
button:active, .button:active { transform: translateY(4px); box-shadow: 0 0 0 var(--ink); }
button:disabled { opacity: 0.55; cursor: wait; transform: none; }
button.primary { background: var(--yellow); color: var(--ink); }
button.primary:hover { background: #ffe07a; }
button.active { background: var(--pink); color: var(--ink); }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }
textarea { width: 100%; font: inherit; color: var(--text); background: transparent; border: 0; resize: none; padding: 4px; }
textarea:focus { outline: none; }
textarea::placeholder { color: var(--muted); }

.composer { display: flex; align-items: flex-end; gap: 10px; background: var(--panel); border: 3px solid var(--ink); border-radius: var(--radius); padding: 10px; box-shadow: 0 5px 0 var(--ink); }
.composer:focus-within { border-color: var(--yellow); }
.composer.big { padding: 16px; border-radius: 20px; box-shadow: 0 8px 0 var(--ink), 0 0 60px rgb(255 79 154 / 0.25); }
.composer.big textarea { font-size: 19px; }
.composer.big button { font-size: 18px; padding: 10px 20px; }
.note { color: var(--muted); font-size: 13px; }
.meta { color: var(--muted); font-size: 14px; font-weight: 600; }
.empty { color: var(--muted); text-align: center; padding: 32px 0; }
.spacer { flex: 1; }

/* Startsida */
main { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.hero { position: relative; padding: 56px 24px 36px; max-width: 800px; width: 100%; margin: 0 auto; text-align: center; display: grid; gap: 20px; }
.kicker { font: 11px var(--pixel); color: var(--lime); letter-spacing: 0.08em; animation: blink 1.2s steps(2) infinite; }
.hero h1 { font: 400 clamp(36px, 6.4vw, 64px) / 1.05 var(--display); letter-spacing: 0.01em; text-shadow: 3px 3px 0 var(--pink), 6px 6px 0 var(--ink); }
.hero h1 .hl { color: var(--yellow); }
.hero > p { color: var(--muted); font-size: 19px; }
.hero > p.note { font-size: 13px; }
.hero .composer { text-align: left; }
/* Pixelkonfetti vid sidan av rubriken */
.hero::before, .hero::after { content: ""; position: absolute; top: 70px; width: 12px; height: 12px; animation: float 3s steps(3) infinite; }
.hero::before { left: -90px; background: var(--cyan); box-shadow: 36px 60px 0 var(--pink), -24px 130px 0 var(--yellow), 60px 190px 0 var(--lime), 12px 280px 0 var(--cyan); }
.hero::after { right: -90px; background: var(--yellow); box-shadow: -36px 72px 0 var(--lime), 24px 150px 0 var(--pink), -60px 210px 0 var(--cyan), -12px 290px 0 var(--yellow); animation-delay: -1.5s; }

.chips { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.chip { font-size: 14px; font-weight: 600; padding: 6px 12px; color: var(--text); background: var(--panel); white-space: normal; text-align: left; border-width: 2px; box-shadow: 0 3px 0 var(--ink); border-left-width: 8px; }
.chips .chip:nth-child(4n + 1) { border-left-color: var(--pink); }
.chips .chip:nth-child(4n + 2) { border-left-color: var(--cyan); }
.chips .chip:nth-child(4n + 3) { border-left-color: var(--lime); }
.chips .chip:nth-child(4n + 4) { border-left-color: var(--yellow); }
.section-head .chip { border-left-width: 2px; }
.chip.active { background: var(--pink); color: var(--ink); }

.community { padding: 24px; max-width: 1200px; width: 100%; margin: 0 auto; }
.section-head { display: flex; align-items: center; gap: 10px; margin-bottom: 18px; }
.section-head h2 { font: 15px var(--pixel); margin-right: auto; text-shadow: 3px 3px 0 var(--ink); }
.section-head h2::before { content: "▶ "; color: var(--yellow); }

/* Spelkort som kassetter */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 20px; }
.card { background: var(--panel); border: 3px solid var(--ink); border-radius: var(--radius); overflow: hidden; text-decoration: none; display: flex; flex-direction: column; box-shadow: 0 6px 0 var(--ink); transition: transform 0.1s, box-shadow 0.1s; }
.card:hover { transform: translateY(-5px) rotate(-1deg); box-shadow: 0 11px 0 var(--ink); }
.card:active { transform: translateY(3px); box-shadow: 0 3px 0 var(--ink); }
.cover { position: relative; aspect-ratio: 16 / 9; display: grid; place-items: center; font: 40px var(--pixel); color: #fff; text-shadow: 4px 4px 0 rgb(10 6 24 / 0.55); border-bottom: 3px solid var(--ink); }
.cover::after { content: ""; position: absolute; inset: 0; background: linear-gradient(rgb(255 255 255 / 0.12) 2px, transparent 2px) 0 0 / 100% 8px, linear-gradient(160deg, rgb(255 255 255 / 0.28), transparent 40%); }
.card-body { padding: 10px 12px 12px; display: grid; gap: 6px; }
.card-body strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.tag { justify-self: start; font: 9px var(--pixel); padding: 5px 7px; border-radius: 6px; background: var(--line); color: var(--text); }
.tag.pending { background: var(--yellow); color: var(--ink); }
.tag.approved { background: var(--lime); color: var(--ink); }
.tag.rejected { background: var(--pink); color: var(--ink); }

/* Byggvy och spelsida */
.builder { flex: 1; min-height: 0; display: grid; grid-template-columns: minmax(300px, 410px) 1fr; }
.chat { display: flex; flex-direction: column; gap: 12px; padding: 16px; border-right: 3px solid var(--ink); min-height: 0; background: rgb(19 11 46 / 0.6); }
.log { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 14px; padding: 2px 6px 6px 2px; }
.bubble { max-width: 92%; padding: 10px 14px; border: 3px solid var(--ink); border-radius: 16px; box-shadow: 0 4px 0 var(--ink); white-space: pre-wrap; overflow-wrap: anywhere; }
.bubble.user { align-self: flex-end; background: var(--yellow); color: var(--ink); font-weight: 600; border-bottom-right-radius: 4px; }
.bubble.assistant { align-self: flex-start; background: var(--panel-2); border-bottom-left-radius: 4px; }
.bubble.error { background: var(--pink); color: var(--ink); font-weight: 600; }
/* Tre hoppande block medan spelet byggs */
.bubble.waiting::after { content: ""; display: inline-block; width: 8px; height: 8px; margin: 0 34px 0 10px; background: var(--yellow); box-shadow: 14px 0 0 var(--pink), 28px 0 0 var(--cyan); animation: hop 0.5s steps(2) infinite; }

.preview, .player { display: flex; flex-direction: column; min-width: 0; min-height: 0; flex: 1; }
.bar { display: flex; align-items: center; gap: 12px; padding: 10px 16px; border-bottom: 3px solid var(--ink); background: var(--panel); flex-wrap: wrap; }
.bar strong { font: 400 20px var(--display); letter-spacing: 0.02em; }
.actions { display: flex; gap: 10px; }
/* Skärmen: mörk ram med svaga linjer runt spelet */
.stage { flex: 1; min-height: 0; display: grid; place-items: center; padding: 14px; background: repeating-linear-gradient(#07040f 0 3px, #0d0820 3px 6px); }
.stage .empty { padding: 0; font: 12px var(--pixel); line-height: 2; }
iframe { width: 100%; height: 100%; border: 3px solid var(--ink); border-radius: 12px; background: #000; box-shadow: 0 0 0 3px var(--line), 0 0 40px rgb(62 230 255 / 0.18); }

@keyframes blink { 50% { opacity: 0.35; } }
@keyframes float { 50% { transform: translateY(-10px); } }
@keyframes hop { 50% { transform: translateY(-5px); } }

@media (max-width: 1040px) { .hero::before, .hero::after { display: none; } }
@media (max-width: 800px) {
  .top { flex-wrap: wrap; gap: 12px; }
  .hud small { display: none; }
  .hero { padding-top: 36px; }
  body.fullscreen { height: auto; }
  .builder { grid-template-columns: 1fr; }
  .chat { border-right: 0; border-bottom: 3px solid var(--ink); max-height: 50vh; }
  .stage { min-height: 60vh; }
}
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation: none !important; transition: none !important; }
}

/* Hur många som spelar just nu */
.live { font: 10px var(--pixel); color: var(--lime); }
.live::before { content: ""; display: inline-block; width: 8px; height: 8px; margin-right: 8px; background: var(--lime); animation: blink 1s steps(2) infinite; }

/* Byggstenar och demospel */
.lead { color: var(--muted); max-width: 720px; margin-bottom: 18px; }
.blocks { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 12px; margin-bottom: 36px; }
.block { display: grid; gap: 4px; padding: 12px 14px; background: var(--panel); border: 3px solid var(--ink); border-radius: var(--radius); box-shadow: 0 4px 0 var(--ink); }
.block:nth-child(4n + 1) { border-top-color: var(--pink); }
.block:nth-child(4n + 2) { border-top-color: var(--cyan); }
.block:nth-child(4n + 3) { border-top-color: var(--lime); }
.block:nth-child(4n + 4) { border-top-color: var(--yellow); }
.block span { color: var(--muted); font-size: 14px; }
.demo { border: 3px solid var(--ink); border-radius: var(--radius); overflow: hidden; box-shadow: 0 6px 0 var(--ink); background: var(--panel); }
.demo .stage { height: min(62vh, 560px); }
.demo .note { padding: 10px 16px; }
a.chip { text-decoration: none; }

.bubble-actions { margin-top: 10px; }

/* Val för stort bygge under idérutan */
.bigbuild { display: flex; gap: 10px; align-items: flex-start; text-align: left; color: var(--muted); font-size: 14px; cursor: pointer; justify-self: center; max-width: 620px; }
.bigbuild input { width: 20px; height: 20px; margin-top: 1px; accent-color: var(--yellow); flex: none; }
.bigbuild strong { color: var(--text); }
