:root {
  --papper: #faf7f2;
  --ink: #14181f;
  --dampad: #4a5260;
  --farg: #2f6f9f;
  --farg-mork: #235577;
  --guld: #e9b62f;
  --kant: rgba(20, 24, 31, 0.1);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--papper);
  color: var(--ink);
  font-family: Fredoka, Nunito, system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

body {
  overflow: hidden;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#app {
  height: 100dvh;
  height: 100vh;
  display: grid;
  grid-template-rows: auto 1fr auto;
  padding: max(8px, env(safe-area-inset-top)) max(10px, env(safe-area-inset-right))
    max(6px, env(safe-area-inset-bottom)) max(10px, env(safe-area-inset-left));
  gap: 4px;
}

/* ---------- toppen ---------- */
.topp {
  display: grid;
  grid-template-columns: 1fr auto auto;
  grid-template-areas: "namn steg knappar";
  align-items: center;
  gap: 10px;
  padding: 2px 2px 0;
}

.namn {
  margin: 0;
  font-size: clamp(13px, 1.9vmin, 17px);
  font-weight: 600;
  letter-spacing: 0.01em;
  color: var(--dampad);
}

.namn::after {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  margin-left: 7px;
  border-radius: 50%;
  background: var(--guld);
  vertical-align: 1px;
}

.vanster {
  grid-area: namn;
  display: flex;
  align-items: baseline;
  gap: 9px;
  min-width: 0;
}

.niva {
  margin: 0;
  font-size: clamp(12px, 1.7vmin, 15px);
  font-weight: 600;
  color: var(--dampad);
  opacity: 0.75;
}

.steg {
  grid-area: steg;
  display: flex;
  gap: 6px;
  align-items: center;
}

.steg i {
  display: block;
  width: clamp(9px, 1.6vmin, 13px);
  height: clamp(9px, 1.6vmin, 13px);
  border-radius: 50%;
  background: var(--farg);
  opacity: 0.85;
}

.ljudknappar {
  grid-area: knappar;
  display: flex;
  gap: 6px;
}

.liten {
  width: clamp(30px, 4.6vmin, 38px);
  height: clamp(30px, 4.6vmin, 38px);
  display: grid;
  place-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: rgba(20, 24, 31, 0.055);
  color: var(--ink);
  cursor: pointer;
  transition: opacity 0.15s ease, background 0.15s ease;
}

.liten svg {
  width: 58%;
  height: 58%;
  fill: none;
  stroke: currentColor;
  stroke-width: 1.9;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.liten svg path:first-child { fill: currentColor; stroke: none; }
.liten.av { opacity: 0.4; }
.liten.av::after {
  content: "";
  position: absolute;
  width: 62%;
  height: 2px;
  background: currentColor;
  transform: rotate(-45deg);
  border-radius: 2px;
}
.liten { position: relative; }

/* ---------- planen ---------- */
#scen {
  position: relative;
  min-height: 0;
  border-radius: clamp(16px, 2.4vmin, 24px);
  background:
    radial-gradient(120% 90% at 50% 0%, #fffdf9 0%, #f6f1e8 60%, #f1ebdf 100%);
  box-shadow: inset 0 0 0 1px var(--kant), 0 18px 40px -34px rgba(20, 24, 31, 0.5);
  overflow: hidden;
  touch-action: none;
}

#duk {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.nasta {
  position: absolute;
  left: 50%;
  bottom: clamp(10px, 2.4vmin, 22px);
  transform: translateX(-50%);
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: clamp(12px, 1.9vmin, 17px) clamp(24px, 4vmin, 38px);
  border: 0;
  border-radius: 999px;
  background: var(--farg);
  color: #fff;
  font: inherit;
  font-size: clamp(15px, 2.1vmin, 20px);
  font-weight: 600;
  letter-spacing: -0.01em;
  cursor: pointer;
  box-shadow: 0 16px 30px -16px rgba(47, 111, 159, 0.8);
  animation: kom-in 0.3s ease both;
}

.nasta::after {
  content: "";
  width: 0.55em;
  height: 0.55em;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(-45deg) translateY(-1px);
}

.nasta:active { transform: translateX(-50%) scale(0.985); }
.nasta[hidden] { display: none; }

@keyframes kom-in {
  from { opacity: 0; transform: translate(-50%, 10px); }
  to { opacity: 1; transform: translate(-50%, 0); }
}

/* ---------- botten ---------- */
.botten {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 0;
  padding: 0 2px 2px;
}

.hylla {
  display: flex;
  align-items: center;
  gap: 4px;
  flex: 0 0 auto;
  min-width: 0;
  min-height: clamp(26px, 4.2vmin, 36px);
}

.hyllobjekt {
  width: clamp(24px, 3.8vmin, 34px);
  height: clamp(24px, 3.8vmin, 34px);
  opacity: 0.9;
}

.tips {
  margin: 0 0 0 auto;
  font-size: clamp(11px, 1.55vmin, 14px);
  line-height: 1.3;
  color: var(--dampad);
  opacity: 0.62;
  text-align: right;
  max-width: 46ch;
}

/* på höjden: tipsen får inte tränga ut planen */
@media (max-height: 560px) {
  .tips { display: none; }
}

@media (max-width: 520px) {
  .tips { display: none; }
  .namn { font-size: 12px; }
}

@media (prefers-reduced-motion: reduce) {
  .nasta { animation: none; }
}