/* Kattastrofen – samma serietidningsgrund som de andra spelen. Själva huset ritas i canvas. */

:root {
  --paper: #fff3cf;
  --paper-dot: rgba(255, 95, 0, 0.16);
  --ink: #141010;
  --white: #fffdf6;
  --accent: #ff5f00;
  --caption: #ffe14d;
  --danger: #ff3b3b;
  --title: "Bangers", Impact, "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);
  color: var(--ink);
  background-color: var(--paper);
  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);
}
body.in-room { overflow: hidden; }

.page { max-width: 760px; margin: 0 auto; padding: 18px 16px 48px; }

/* ---------------------------------------------------------------- startsidan */

.caption {
  display: inline-block;
  background: var(--caption);
  border: var(--line) solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 6px 12px;
  font-weight: 700;
}
.tilt-l { transform: rotate(-1.5deg); }
.caption.voice { display: block; margin: 20px 0; font-weight: 400; }

.logo {
  font-family: var(--title);
  font-weight: 400;
  font-size: clamp(48px, 11vw, 96px);
  letter-spacing: 2px;
  margin: 14px 0;
  line-height: 1;
}
.logo span {
  color: var(--accent);
  -webkit-text-stroke: 3px var(--ink);
  paint-order: stroke fill;
  text-shadow: 5px 5px 0 var(--ink);
}

.frame {
  background: var(--white);
  border: var(--line) solid var(--ink);
  box-shadow: var(--shadow);
  padding: 18px;
}
.bubble {
  display: inline-block;
  background: var(--white);
  border: var(--line) solid var(--ink);
  border-radius: 20px;
  padding: 8px 14px;
  font-weight: 700;
  margin: 0 0 12px;
}
.lead { font-size: 19px; margin: 0; }

kbd {
  display: inline-block;
  font-family: var(--hand);
  font-weight: 700;
  font-size: 0.9em;
  background: var(--white);
  border: 2px solid var(--ink);
  border-radius: 5px;
  box-shadow: 2px 2px 0 var(--ink);
  padding: 0 6px;
  margin: 0 2px;
}

.actions { display: flex; flex-wrap: wrap; gap: 14px; align-items: center; }
.join { display: flex; gap: 8px; }
.join input {
  font: 700 18px var(--hand);
  width: 140px;
  padding: 10px;
  border: var(--line) solid var(--ink);
  text-transform: uppercase;
  background: var(--white);
}

.btn {
  font: 400 20px var(--title);
  letter-spacing: 1px;
  background: var(--white);
  color: var(--ink);
  border: var(--line) solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 8px 16px;
  cursor: pointer;
}
.btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--ink); }
.btn.big { font-size: 28px; background: var(--accent); color: var(--white); -webkit-text-stroke: 1px var(--ink); }
.btn.small { font-size: 16px; padding: 4px 10px; }
.error { color: var(--danger); font-weight: 700; }

/* ---------------------------------------------------------------- rummet */

#room {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--panikbar-h, 0px));
  height: calc(100dvh - var(--panikbar-h, 0px));
}

.room-head {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
  border-bottom: var(--line) solid var(--ink);
  background: var(--white);
}
.code-box { display: flex; align-items: baseline; gap: 6px; }
.code-box strong { font: 400 26px var(--title); letter-spacing: 2px; color: var(--accent); }
.share { display: flex; gap: 6px; }
.share input { font: 14px var(--hand); width: 230px; padding: 4px 8px; border: 2px solid var(--ink); }

.players { display: flex; flex-wrap: wrap; gap: 12px; list-style: none; margin: 0 0 0 auto; padding: 0; font-weight: 700; }
.players li { display: flex; align-items: center; gap: 5px; }
.players li.watching { font-weight: 400; font-style: italic; }
.players .dot { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--ink); background: #ccc; }

/* Spelvyn är en serieruta på sidan: tjock tusch, hård skugga och papper runt om. */
.stage {
  position: relative;
  flex: 1;
  min-height: 0;
  margin: 10px 16px 18px 10px;
  border: 4px solid var(--ink);
  box-shadow: 7px 7px 0 var(--ink);
  background: var(--paper);
  overflow: hidden;
}
#view { position: absolute; inset: 0; width: 100%; height: 100%; display: block; outline: none; cursor: crosshair; }

.status {
  position: absolute;
  top: 14px;
  left: 50%;
  transform: translateX(-50%);
  margin: 0;
  background: var(--caption);
  border: var(--line) solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 6px 12px;
  font-weight: 700;
}

.hud { position: absolute; left: 12px; bottom: 12px; display: flex; gap: 10px; pointer-events: none; }
.where-box, .stamina-box {
  background: var(--white);
  border: var(--line) solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
}
.hud small { font-size: 11px; font-weight: 700; letter-spacing: 1px; }
.where-box strong { font: 400 22px var(--title); letter-spacing: 1px; min-width: 130px; }
.stamina { width: 140px; height: 14px; border: 2px solid var(--ink); background: var(--paper); margin: 4px 0 2px; }
.stamina-fill { height: 100%; width: 100%; background: var(--accent); }
.stamina-fill.tired { background: var(--danger); }

.keys-help {
  position: absolute;
  left: 12px;
  top: 12px;
  max-width: calc(100% - 310px);
  margin: 0;
  background: var(--white);
  border: 2px solid var(--ink);
  padding: 4px 8px;
  font-size: 14px;
  pointer-events: none;
}

/* ---------------------------------------------------------------- skadekvittot */

.receipt {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 270px;
  background: #fffdf6;
  border: 2px solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 8px 12px 6px;
  font-family: "Courier New", Courier, monospace;
  font-size: 13px;
  pointer-events: none;
  /* Kvittopapperets taggiga underkant. */
  clip-path: polygon(0 0, 100% 0, 100% calc(100% - 6px), 95% 100%, 90% calc(100% - 6px), 85% 100%, 80% calc(100% - 6px), 75% 100%, 70% calc(100% - 6px), 65% 100%, 60% calc(100% - 6px), 55% 100%, 50% calc(100% - 6px), 45% 100%, 40% calc(100% - 6px), 35% 100%, 30% calc(100% - 6px), 25% 100%, 20% calc(100% - 6px), 15% 100%, 10% calc(100% - 6px), 5% 100%, 0 calc(100% - 6px));
}
.receipt h2 { margin: 0 0 4px; font-size: 14px; letter-spacing: 3px; text-align: center; border-bottom: 1px dashed var(--ink); padding-bottom: 4px; }
.receipt ol { list-style: none; margin: 0; padding: 0; }
.receipt li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.receipt li .kr { white-space: nowrap; }
.receipt li small { font-size: 11px; }
.receipt li.empty { font-style: italic; justify-content: center; }
.receipt .total { display: flex; justify-content: space-between; margin: 6px 0 6px; padding-top: 4px; border-top: 1px dashed var(--ink); font-weight: 700; }
.receipt .total strong { color: var(--danger); font-size: 16px; }
.receipt.bump { animation: bump 0.35s ease-out; }
@keyframes bump { 0% { transform: scale(1) rotate(0); } 40% { transform: scale(1.06) rotate(-1.5deg); } 100% { transform: scale(1) rotate(0); } }
@media (prefers-reduced-motion: reduce) { .receipt.bump { animation: none; } }

/* ---------------------------------------------------------------- verktyg och tips */

.tool-box {
  background: var(--white);
  border: var(--line) solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 4px 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 70px;
}
.tool-box strong { font: 400 22px var(--title); letter-spacing: 1px; color: #2f80ed; }
#nej-box strong { color: var(--accent); }
.tool-box.empty strong, .tool-box.cooling strong { color: #aaa; }

.hint {
  position: absolute;
  left: 50%;
  bottom: 70px;
  transform: translateX(-50%);
  margin: 0;
  background: var(--caption);
  border: var(--line) solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 6px 14px;
  font-weight: 700;
  pointer-events: none;
  white-space: nowrap;
}

.secure-bar, .twist {
  position: absolute;
  left: 50%;
  top: 40%;
  transform: translate(-50%, -50%);
  background: var(--white);
  border: var(--line) solid var(--ink);
  box-shadow: var(--shadow);
  padding: 8px 16px;
  text-align: center;
  pointer-events: none;
}
.secure-bar small, .twist small { display: block; font-weight: 700; letter-spacing: 1px; }
.bar { width: 160px; height: 12px; border: 2px solid var(--ink); background: var(--paper); margin-top: 6px; }
.bar .fill { height: 100%; width: 0; background: #2ecc71; }
.twist { top: 30%; background: var(--caption); animation: shake 0.15s infinite alternate; }
.twist strong { display: block; font: 400 52px var(--title); line-height: 1; color: var(--accent); -webkit-text-stroke: 2px var(--ink); }
.twist .fill { background: var(--danger); }
@keyframes shake { from { transform: translate(-50%, -50%) rotate(-2deg); } to { transform: translate(-50%, -50%) rotate(2deg); } }
@media (prefers-reduced-motion: reduce) { .twist { animation: none; } }

/* ---------------------------------------------------------------- klocka och paneler */

.receipt .all { display: flex; justify-content: space-between; margin: 0 0 6px; font-size: 11px; }

.clock {
  position: absolute;
  top: 52px;
  left: 50%;
  transform: translateX(-50%) rotate(-1deg);
  margin: 0;
  background: var(--caption);
  border: var(--line) solid var(--ink);
  box-shadow: 3px 3px 0 var(--ink);
  padding: 2px 14px;
  font: 400 24px var(--title);
  letter-spacing: 2px;
  pointer-events: none;
}

.panel {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: min(460px, calc(100% - 32px));
  max-height: calc(100% - 120px);
  overflow-y: auto;
  background: var(--white);
  border: var(--line) solid var(--ink);
  box-shadow: var(--shadow);
  padding: 16px 20px;
}
.panel h2 { font: 400 34px var(--title); letter-spacing: 1px; margin: 0 0 8px; color: var(--accent); -webkit-text-stroke: 1px var(--ink); }
.panel p { margin: 6px 0; }
.panel .cats { padding-left: 18px; margin: 8px 0; }
.panel .items { list-style: none; padding: 0; margin: 8px 0; font-family: "Courier New", Courier, monospace; font-size: 14px; border-top: 1px dashed var(--ink); border-bottom: 1px dashed var(--ink); }
.panel .items li { display: flex; justify-content: space-between; gap: 8px; padding: 2px 0; }
.panel .sum b, .panel .score b { color: var(--danger); }
.panel .score { font: 400 28px var(--title); letter-spacing: 1px; }
.panel .stats { width: 100%; border-collapse: collapse; margin: 10px 0; font-size: 14px; }
.panel .stats th, .panel .stats td { border-bottom: 1px solid var(--ink); padding: 3px 4px; text-align: center; }
.panel .stats td:first-child { text-align: left; font-weight: 700; }
.panel .empty { font-style: italic; }
.panel .btn.big { margin-top: 10px; }
.cat-name { margin: 10px 0; }
.cat-name label { font-weight: 700; margin-right: 6px; }
.cat-name input { font: 700 16px var(--hand); width: 160px; padding: 4px 8px; border: 2px solid var(--ink); }
.hint-text { font-style: italic; }
