/* Lobbyn – samma serietidningsestetik som spelen (se games/bomben/public/style.css).
   Papper med rasterpunkter, tjock tusch, hårda skuggor och Bangers/Comic Neue. */

:root {
  --paper: #fff3cf;
  --paper-dot: rgba(255, 95, 0, 0.16);
  --ink: #141010;
  --white: #fffdf6;
  --accent: #ff5f00;
  --caption: #ffe14d;
  --sky: #8fd6ff;
  --good: #2ecc71;
  --danger: #ff3b3b;
  --title: "Bangers", Impact, Haettenschweiler, "Arial Narrow Bold", "Arial Black", sans-serif;
  --hand: "Comic Neue", "Comic Sans MS", "Chalkboard SE", system-ui, sans-serif;
  --line: 3px;
  --shadow: 5px 5px 0 var(--ink);
  color-scheme: light;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; min-height: 100%; }

body {
  font-family: var(--hand);
  font-size: 17px;
  color: var(--ink);
  background-color: var(--paper);
  /* Rasterpunkter, som i tryckta serietidningar. */
  background-image:
    radial-gradient(circle, var(--paper-dot) 1.4px, transparent 1.8px),
    radial-gradient(circle, var(--paper-dot) 1.4px, transparent 1.8px);
  background-size: 12px 12px;
  background-position: 0 0, 6px 6px;
  padding-top: var(--panikbar-h, 0);
  overflow-x: hidden;
}

.defs { position: absolute; width: 0; height: 0; overflow: hidden; }

h1, h2, h3 { margin: 0 0 12px; font-family: var(--title); font-weight: 400; letter-spacing: 0.05em; }
h2 { font-size: 26px; display: flex; align-items: center; gap: 10px; }

/* ---------------------------------------------------------------- tusch */

/* .ink: tuschkontur som darrar lite. Konturen ligger i ::before så att texten inte förvrängs. */
.ink { position: relative; isolation: isolate; }
.ink::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: -1;
  border: var(--line) solid var(--ink);
  border-radius: inherit;
  background: var(--fill, var(--white));
  box-shadow: var(--shadow);
  filter: url(#rough0);
  animation: boil 0.36s steps(1) infinite;
}
@keyframes boil {
  0% { filter: url(#rough0); }
  33% { filter: url(#rough1); }
  66% { filter: url(#rough2); }
}
@media (prefers-reduced-motion: reduce) { .ink::before { animation: none; } }

.frame { padding: 18px; border-radius: 4px; }

.caption {
  display: inline-block;
  background: var(--caption);
  border: var(--line) solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 6px 14px;
  font-family: var(--title);
  font-weight: 400;
  font-size: 20px;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0 0 16px;
}
.tilt-l { transform: rotate(-1.5deg); }
.tilt-r { transform: rotate(1deg); }

/* ---------------------------------------------------------------- knappar och fält */

button, .btn {
  font-family: var(--title);
  font-weight: 400;
  font-size: 20px;
  letter-spacing: 0.05em;
  color: var(--ink);
  background: var(--white);
  border: var(--line) solid var(--ink);
  border-radius: 6px;
  box-shadow: 4px 4px 0 var(--ink);
  padding: 8px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
  transition: transform 0.06s, box-shadow 0.06s;
}
button:active, .btn:active { transform: translate(3px, 3px); box-shadow: 1px 1px 0 var(--ink); }
button:focus-visible, .btn:focus-visible, input:focus-visible, select:focus-visible, a:focus-visible {
  outline: 3px solid var(--accent);
  outline-offset: 3px;
}
.btn.primary { background: var(--accent); color: var(--white); text-shadow: 2px 2px 0 var(--ink); }
.btn.small { font-size: 17px; padding: 5px 12px; box-shadow: 3px 3px 0 var(--ink); }
button:disabled { opacity: 0.55; cursor: progress; }

input, select {
  font: inherit;
  font-size: 18px;
  color: var(--ink);
  background: var(--white);
  border: var(--line) solid var(--ink);
  border-radius: 6px;
  padding: 8px 12px;
  min-width: 0;
}
input::placeholder { color: #8a7a6a; }

.small { font-size: 15px; line-height: 1.35; margin: 12px 0 0; }
.error {
  display: inline-block;
  color: var(--white);
  background: var(--danger);
  border: var(--line) solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 6px 12px;
  font-weight: 700;
}
.row { display: flex; gap: 10px; flex-wrap: wrap; }
.row input { flex: 1; }
.pill {
  font-family: var(--hand);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0;
  background: var(--good);
  border: 2px solid var(--ink);
  border-radius: 999px;
  padding: 0 9px;
}

/* ---------------------------------------------------------------- hero */

.hero { text-align: center; padding: 40px 16px 28px; }
.logo {
  margin: 0 0 18px;
  line-height: 0.9;
  font-size: clamp(72px, 20vw, 150px);
  letter-spacing: 0.03em;
  color: var(--white);
  -webkit-text-stroke: 4px var(--ink);
  paint-order: stroke fill;
  text-shadow: 7px 7px 0 var(--ink);
  transform: rotate(-3deg);
  animation: jitter 3s infinite;
}
.logo span { color: var(--accent); }
@keyframes jitter {
  0%, 92%, 100% { transform: rotate(-3deg); }
  93% { transform: translate(-3px, 1px) rotate(-4deg); }
  95% { transform: translate(3px, -1px) rotate(-2deg); }
  97% { transform: translate(-2px, 0) rotate(-3deg); }
}
@media (prefers-reduced-motion: reduce) { .logo { animation: none; } }
.hero .caption { font-size: clamp(16px, 4.2vw, 20px); max-width: 100%; }

.join { display: flex; gap: 10px; max-width: 380px; margin: 8px auto 0; }
.join input { flex: 1; text-transform: uppercase; font-family: var(--title); letter-spacing: 0.15em; text-align: center; font-size: 22px; }
.hero .error { margin: 18px 0 0; }

/* ---------------------------------------------------------------- layout */

.layout {
  max-width: 1120px;
  margin: 0 auto;
  padding: 8px 16px 56px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 28px 24px;
  align-items: start;
}
.wide { grid-column: 1 / -1; }
@media (max-width: 860px) { .layout { grid-template-columns: minmax(0, 1fr); } }

.side { display: flex; flex-direction: column; gap: 24px; padding-top: 58px; }
@media (max-width: 860px) { .side { padding-top: 0; } }

.list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.list li { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; font-weight: 700; }
.list li small { font-weight: 400; font-style: italic; font-size: 14px; text-align: right; }

/* ---------------------------------------------------------------- spelkort */

.games { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 24px; }

/* Varje spel får en egen färg. Okända spel faller tillbaka på orange. */
.game { --game: var(--accent); --fill: var(--white); border-radius: 4px; display: flex; flex-direction: column; transition: transform 0.12s; }
.game[data-game="paniktangenten"] { --game: var(--caption); }
.game[data-game="kontrollrummet"] { --game: var(--sky); }
.game[data-game="bomben"] { --game: var(--accent); }
.game[data-game="kattastrofen"] { --game: #c9a7ff; }
.game:hover { transform: translate(-2px, -3px) rotate(-0.5deg); }
@media (prefers-reduced-motion: reduce) { .game, .game:hover { transition: none; transform: none; } }

.game .art {
  position: relative;
  height: 150px;
  margin: var(--line) var(--line) 0;
  border-bottom: var(--line) solid var(--ink);
  background-color: var(--game);
  background-image: radial-gradient(circle, rgba(20, 16, 16, 0.18) 1.6px, transparent 2px);
  background-size: 10px 10px;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.game .art svg { width: 150px; height: 130px; overflow: visible; }
.game .players {
  position: absolute; top: 10px; right: 10px;
  font-family: var(--title); font-size: 17px; letter-spacing: 0.05em;
  background: var(--white); border: 2px solid var(--ink); box-shadow: 2px 2px 0 var(--ink);
  padding: 1px 8px; transform: rotate(3deg);
}
.game .body { padding: 14px 16px 18px; display: flex; flex-direction: column; gap: 10px; flex: 1; }
.game h3 { font-size: 32px; margin: 0; line-height: 1; }
.game p { margin: 0; font-size: 17px; line-height: 1.3; flex: 1; }
.game .foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; margin-top: 4px; }

/* Hela kortet är en länk till spelets sida ("stretched link"); knappen ligger ovanpå. */
.game .more-link { font-weight: 700; color: var(--ink); text-decoration: underline; text-decoration-thickness: 2px; text-underline-offset: 3px; }
.game .more-link::after { content: ""; position: absolute; inset: 0; z-index: 1; }
.game .create { position: relative; z-index: 2; }

/* ---------------------------------------------------------------- topplista */

.top { --fill: var(--white); }
.lb-head { display: flex; flex-wrap: wrap; gap: 12px; align-items: center; margin-bottom: 20px; }
.lb-head h2 { margin: 0; flex: 1 1 auto; font-size: 32px; }
.lb-head select { font-size: 16px; padding: 6px 10px; }
.tabs { display: flex; gap: 8px; }
.tabs button { font-size: 17px; padding: 4px 12px; box-shadow: 3px 3px 0 var(--ink); }
.tabs button.active { background: var(--caption); }

/* Pallen: 2–1–3, med ettan högst. */
.podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  align-items: end;
  gap: 10px;
  max-width: 560px;
  margin: 0 auto 18px;
}
.podium:empty { display: none; }
.step { display: flex; flex-direction: column; align-items: center; text-align: center; gap: 6px; min-width: 0; }
.step .who { font-weight: 700; font-size: 16px; line-height: 1.15; overflow-wrap: anywhere; }
.step .score { font-family: var(--title); font-size: 22px; letter-spacing: 0.04em; }
.step .block {
  width: 100%;
  display: grid; place-items: center;
  border: var(--line) solid var(--ink);
  box-shadow: 4px 4px 0 var(--ink);
  font-family: var(--title); font-size: 44px; color: var(--white);
  -webkit-text-stroke: 2px var(--ink); paint-order: stroke fill;
}
.step.r1 { order: 2; } .step.r1 .block { height: 110px; background: #ffc72c; }
.step.r2 { order: 1; } .step.r2 .block { height: 80px; background: #c9d1d9; }
.step.r3 { order: 3; } .step.r3 .block { height: 60px; background: #e08a4f; }
.step.me .who { background: var(--caption); border: 2px solid var(--ink); padding: 0 6px; }

.leaderboard { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 6px; }
.leaderboard li {
  display: grid; grid-template-columns: 44px minmax(0, 1fr) auto; gap: 8px; align-items: center;
  padding: 6px 12px; border: 2px solid var(--ink); border-radius: 4px; background: var(--white);
}
.leaderboard li.me { background: var(--caption); box-shadow: 3px 3px 0 var(--ink); }
.leaderboard li.gap { border: 0; background: none; padding: 0 12px; font-family: var(--title); font-size: 20px; letter-spacing: 0.3em; display: block; }
.leaderboard li.empty { display: block; font-style: italic; }
.leaderboard .rank { font-family: var(--title); font-size: 22px; }
.leaderboard .name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.leaderboard .score { font-variant-numeric: tabular-nums; font-weight: 700; }
.more { display: block; margin: 16px auto 0; }
