@font-face {
  font-family: 'Fredoka';
  src: url('/fonts/fredoka-latin-wght-normal.woff2') format('woff2');
  font-weight: 300 700;
  font-display: swap;
}

@font-face {
  font-family: 'Nunito';
  src: url('/fonts/nunito-latin-wght-normal.woff2') format('woff2');
  font-weight: 200 1000;
  font-display: swap;
}

:root {
  --cream: #FBF6EC;
  --navy: #1F2A44;
  --blue: #2F5DA8;
  --green: #2E7D5B;
  --brick: #C4461F;
  --yellow: #E0A93B;
  --light-blue: #DCE7F7;
  --light-green: #DDF0E6;
  --beige: #F3EEE3;
  --line: #E8DFCC;

  --radius: 18px;
  --tap: 52px;
  --heading: 'Fredoka', 'Nunito', system-ui, sans-serif;
  --body: 'Nunito', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--cream);
  color: var(--navy);
  font-family: var(--body);
  font-size: 18px;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

h1,
h2,
.brand,
.code,
.player-name,
.success-title {
  font-family: var(--heading);
  font-weight: 600;
  line-height: 1.2;
}

h1 {
  font-size: clamp(1.7rem, 5vw, 2.2rem);
  margin: 0.25rem 0 0.75rem;
}

h1:focus {
  outline: none;
}

h2 {
  font-size: 1.35rem;
  margin: 0 0 0.5rem;
}

p {
  margin: 0 0 1rem;
}

[hidden] {
  display: none !important;
}

:focus-visible {
  outline: 3px solid var(--blue);
  outline-offset: 3px;
}

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

.screen {
  width: 100%;
  max-width: 34rem;
  margin: 0 auto;
  padding: max(24px, env(safe-area-inset-top)) 20px 32px;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.screen--center {
  align-items: center;
  text-align: center;
  padding-top: 12vh;
}

.screen--center .btn {
  align-self: stretch;
}

.room {
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.room > .screen {
  flex: 1;
}

.stack {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin: 0.5rem 0 1.5rem;
}

.lead {
  font-size: 1.1rem;
}

.small {
  font-size: 0.95rem;
  margin: 0;
}

.label {
  display: block;
  font-family: var(--heading);
  font-weight: 600;
  font-size: 1.1rem;
  margin: 1rem 0 0.5rem;
}

/* ------------------------------------------------------------ buttons */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  min-height: var(--tap);
  padding: 12px 20px;
  border: 2px solid transparent;
  border-radius: var(--radius);
  font: inherit;
  font-weight: 800;
  font-size: 1.05rem;
  cursor: pointer;
  text-align: center;
  transition: transform 0.1s ease, background-color 0.15s ease;
}

.btn:active:not(:disabled) {
  transform: scale(0.98);
}

.btn:disabled {
  opacity: 0.55;
  cursor: default;
}

.btn--primary {
  background: var(--green);
  color: #fff;
  margin-top: 1rem;
}

.btn--primary:hover:not(:disabled) {
  background: #276B4E;
}

.btn--secondary {
  background: var(--light-blue);
  color: var(--navy);
}

.btn--secondary:hover:not(:disabled) {
  background: #CCDBF2;
}

.btn--ghost {
  background: transparent;
  color: var(--blue);
  border-color: var(--line);
}

.btn--danger {
  background: var(--brick);
  color: #fff;
}

.btn--danger-outline {
  background: #fff;
  color: var(--brick);
  border-color: #EBC3B5;
}

.btn--big {
  min-height: 64px;
  font-size: 1.2rem;
  width: 100%;
  margin-top: 0;
}

.badge {
  font-size: 0.8rem;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 2px 10px;
}

.back {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  min-height: 44px;
  padding: 0 12px 0 4px;
  margin-bottom: 0.5rem;
  background: none;
  border: none;
  border-radius: 12px;
  color: var(--blue);
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

/* ------------------------------------------------------------ home */

.hero {
  text-align: center;
  margin: 2vh 0 1.5rem;
}

.brand {
  font-size: clamp(2.6rem, 10vw, 3.4rem);
  margin: 0.25rem 0 0.5rem;
  color: var(--green);
}

.tagline {
  font-family: var(--heading);
  font-size: 1.35rem;
  font-weight: 500;
  line-height: 1.3;
  margin-bottom: 0.5rem;
}

.subline {
  color: #4A5670;
}

.promise {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  margin-top: 1.75rem;
  padding: 14px 16px;
  background: var(--light-green);
  border-radius: var(--radius);
  font-size: 0.98rem;
}

.promise .icon {
  flex: none;
  color: var(--green);
  margin-top: 2px;
}

/* ------------------------------------------------------------ create */

.game-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: #fff;
  border: 3px solid var(--green);
  border-radius: var(--radius);
}

.game-card p {
  margin: 0;
  font-size: 0.95rem;
}

.game-card > .icon {
  flex: none;
  margin-left: auto;
  color: var(--green);
}

.options {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.option {
  min-height: var(--tap);
  border: 2px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--navy);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.option[aria-pressed='true'] {
  border-color: var(--green);
  background: var(--light-green);
  box-shadow: inset 0 0 0 1px var(--green);
}

/* ------------------------------------------------------------ code */

.code {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin: 0.5rem 0;
  font-size: clamp(2rem, 11vw, 3rem);
}

.code .char {
  display: inline-grid;
  place-items: center;
  width: 1.25em;
  height: 1.5em;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: 12px;
  color: var(--navy);
}

.code .gap {
  width: 0.35em;
}

.timer {
  display: flex;
  gap: 8px;
  justify-content: center;
  align-items: center;
  color: #4A5670;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.warning {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  padding: 14px 16px;
  margin: 0.5rem 0;
  background: #FBE9E2;
  border-left: 5px solid var(--brick);
  border-radius: 12px;
  font-weight: 700;
}

.warning .icon {
  flex: none;
  color: var(--brick);
  margin-top: 2px;
}

.waiting {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  background: var(--beige);
  border-radius: var(--radius);
}

.waiting p {
  margin: 0;
  font-family: var(--heading);
  font-size: 1.2rem;
  font-weight: 500;
}

.dots span {
  animation: blink 1.4s infinite both;
}

.dots span:nth-child(2) {
  animation-delay: 0.2s;
}

.dots span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%, 80%, 100% { opacity: 0; }
  40% { opacity: 1; }
}

/* ------------------------------------------------------------ join */

.code-input {
  width: 100%;
  min-height: 72px;
  padding: 8px 16px;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--navy);
  font-family: var(--heading);
  font-size: 2.2rem;
  font-weight: 600;
  letter-spacing: 0.3em;
  text-align: center;
  text-transform: uppercase;
}

.code-input:focus {
  border-color: var(--blue);
  outline: none;
}

.error {
  color: var(--brick);
  font-weight: 700;
  margin: 0.5rem 0 0;
}

/* ------------------------------------------------------------ figure */

.success {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 16px;
  margin-bottom: 1rem;
  background: var(--light-green);
  border: 2px solid var(--green);
  border-radius: var(--radius);
}

.success .icon {
  flex: none;
  color: var(--green);
}

.success p {
  margin: 0;
}

.success-title {
  font-size: 1.35rem;
}

.figures {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

@media (min-width: 560px) {
  .figures {
    grid-template-columns: repeat(4, 1fr);
  }
}

.figure-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-height: 120px;
  padding: 14px 8px;
  border: 3px solid var(--line);
  border-radius: var(--radius);
  background: #fff;
  color: var(--navy);
  font: inherit;
  font-weight: 800;
  cursor: pointer;
}

.figure-btn[aria-pressed='true'] {
  border-color: var(--green);
  background: var(--light-green);
}

.me {
  text-align: center;
  margin-top: 1.25rem;
}

.me .btn {
  margin-top: 0.5rem;
}

.player-name {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  font-size: 1.8rem;
  margin: 0;
}

.peer {
  display: flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  margin-top: 1rem;
  color: #4A5670;
  font-weight: 700;
}

.notice {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 12px 14px;
  background: #FFF4DC;
  border-left: 5px solid var(--yellow);
  border-radius: 12px;
  font-weight: 700;
}

/* ------------------------------------------------------------ room footer */

.room-footer {
  position: sticky;
  bottom: 0;
  background: #fff;
  border-top: 2px solid var(--line);
  padding: 10px 12px max(10px, env(safe-area-inset-bottom));
}

.cheers {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  align-items: center;
  margin-bottom: 10px;
}

.chip {
  min-height: 44px;
  padding: 6px 14px;
  border: 2px solid var(--line);
  border-radius: 999px;
  background: var(--beige);
  color: var(--navy);
  font: inherit;
  font-weight: 800;
  font-size: 0.95rem;
  cursor: pointer;
}

.chip:disabled {
  opacity: 0.45;
  cursor: default;
}

.chip--icon {
  width: 48px;
  padding: 0;
  display: inline-grid;
  place-items: center;
}

.chip--tumme_upp,
.cheer-icon--tumme_upp {
  color: var(--blue);
}

.chip--stjarna,
.cheer-icon--stjarna {
  color: var(--yellow);
}

.chip--hjarta,
.cheer-icon--hjarta {
  color: var(--brick);
}

.cheer-sent {
  min-width: 4.5em;
  font-weight: 800;
  color: var(--green);
  font-size: 0.9rem;
}

.room-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  justify-content: space-between;
  align-items: center;
  max-width: 34rem;
  margin: 0 auto;
}

.lock-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--light-green);
  color: var(--green);
  font-weight: 800;
  font-size: 0.9rem;
}

.bar-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  min-height: 44px;
  padding: 0 10px;
  border: none;
  border-radius: 12px;
  background: none;
  color: var(--navy);
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  cursor: pointer;
}

.bar-btn:hover {
  background: var(--beige);
}

.bar-btn--danger {
  color: var(--brick);
}

/* ------------------------------------------------------------ overlays */

.banner {
  position: sticky;
  top: 0;
  z-index: 10;
  display: flex;
  gap: 10px;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
  background: var(--yellow);
  color: var(--navy);
  font-weight: 800;
}

.toasts {
  position: fixed;
  top: max(16px, env(safe-area-inset-top));
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: min(92vw, 26rem);
  pointer-events: none;
}

.toast {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 14px 18px;
  background: var(--navy);
  color: #fff;
  border-radius: var(--radius);
  font-weight: 800;
  box-shadow: 0 8px 24px rgba(31, 42, 68, 0.25);
  animation: toast-in 0.25s ease-out;
  transition: opacity 0.4s ease;
}

.toast--out {
  opacity: 0;
}

@keyframes toast-in {
  from { transform: translateY(-12px); opacity: 0; }
}

.dialog {
  width: min(92vw, 28rem);
  padding: 24px 20px 20px;
  border: none;
  border-radius: 24px;
  background: var(--cream);
  color: var(--navy);
}

.dialog::backdrop {
  background: rgba(31, 42, 68, 0.5);
}

.dialog .btn {
  width: 100%;
  margin-top: 0;
}

.noscript {
  padding: 24px;
  text-align: center;
}

/* ------------------------------------------------------------ monster */

.monster--jublande {
  animation: bounce 0.9s ease-in-out infinite alternate;
}

@keyframes bounce {
  to { transform: translateY(-6px); }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation: none !important;
    transition: none !important;
  }
}

/* ------------------------------------------------------------ links and info pages */

.site-links {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px 20px;
  margin-top: 1.25rem;
}

.site-links a,
.article a {
  color: var(--blue);
  font-weight: 700;
  text-underline-offset: 3px;
}

.site-links a {
  display: inline-flex;
  align-items: center;
  min-height: 44px;
}

.page-header {
  max-width: 44rem;
  margin: 0 auto;
  padding: max(16px, env(safe-area-inset-top)) 20px 0;
}

.page-logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  min-height: 44px;
  color: var(--green);
  font-family: var(--heading);
  font-weight: 600;
  font-size: 1.5rem;
  text-decoration: none;
}

.article {
  max-width: 44rem;
  margin: 0 auto;
  padding: 16px 20px 32px;
}

.article h2 {
  margin-top: 2rem;
}

.article h3 {
  font-family: var(--heading);
  font-weight: 600;
  font-size: 1.15rem;
  margin: 0 0 0.35rem;
}

.article li {
  margin-bottom: 0.5rem;
}

.promise-quote {
  padding: 16px 18px;
  background: var(--light-green);
  border-left: 5px solid var(--green);
  border-radius: 12px;
  font-family: var(--heading);
  font-size: 1.2rem;
  font-weight: 500;
}

.facts {
  display: grid;
  gap: 12px;
}

@media (min-width: 640px) {
  .facts {
    grid-template-columns: 1fr 1fr;
  }
}

.facts section {
  padding: 16px 18px;
  background: #fff;
  border: 2px solid var(--line);
  border-radius: var(--radius);
}

.facts p {
  margin: 0;
  font-size: 0.98rem;
}

.contact {
  list-style: none;
  padding: 0;
}

.closing {
  margin-top: 2rem;
}

.page-footer {
  max-width: 44rem;
  margin: 0 auto;
  padding: 16px 20px max(32px, env(safe-area-inset-bottom));
  border-top: 2px solid var(--line);
  text-align: center;
  color: #4A5670;
  font-size: 0.95rem;
}

.page-footer .site-links {
  margin: 0 0 0.5rem;
}

/* ------------------------------------------------------------ animated logo (js/logo.js) */

.logo {
  overflow: visible;
}

.tp-body {
  animation: tp-dance 4.8s ease-in-out infinite;
  transform-origin: 60px 106px;
}

.tp-antL {
  animation: tp-antL 1.2s ease-in-out infinite;
  transform-origin: 37px 27px;
}

.tp-antR {
  animation: tp-antR 1.2s ease-in-out infinite;
  transform-origin: 83px 27px;
}

.tp-eye {
  animation: tp-blink 4s ease-in-out infinite;
  transform-origin: 60px 42px;
}

.tp-pupil {
  animation: tp-look 6s ease-in-out infinite;
}

/* A little dance: four sway steps to the beat (0.6 s each), then a jump
   with a spin, and a squashy landing. */
@keyframes tp-dance {
  0%, 100% { transform: translate(0, 0) rotate(0deg) scale(1, 1); }
  6% { transform: translate(-5px, -6px) rotate(-10deg) scale(0.98, 1.03); }
  12.5% { transform: translate(-6px, 0) rotate(-6deg) scale(1.04, 0.96); }
  19% { transform: translate(5px, -6px) rotate(10deg) scale(0.98, 1.03); }
  25% { transform: translate(6px, 0) rotate(6deg) scale(1.04, 0.96); }
  31% { transform: translate(-5px, -6px) rotate(-10deg) scale(0.98, 1.03); }
  37.5% { transform: translate(-6px, 0) rotate(-6deg) scale(1.04, 0.96); }
  44% { transform: translate(5px, -6px) rotate(10deg) scale(0.98, 1.03); }
  50% { transform: translate(6px, 0) rotate(6deg) scale(1.04, 0.96); }
  56% { transform: translate(0, 2px) rotate(0deg) scale(1.08, 0.9); }
  62% { transform: translate(0, -18px) rotate(0deg) scale(0.94, 1.08); }
  66% { transform: translate(0, -22px) rotate(0deg) scale(-1, 1.04); }
  70% { transform: translate(0, -18px) rotate(0deg) scale(1, 1.02); }
  76% { transform: translate(0, 2px) rotate(0deg) scale(1.1, 0.88); }
  82% { transform: translate(0, -4px) rotate(0deg) scale(0.98, 1.02); }
  88% { transform: translate(0, 0) rotate(0deg) scale(1.02, 0.98); }
}

@keyframes tp-antL {
  0%, 100% { transform: rotate(10deg); }
  50% { transform: rotate(-22deg); }
}

@keyframes tp-antR {
  0%, 100% { transform: rotate(22deg); }
  50% { transform: rotate(-10deg); }
}

@keyframes tp-blink {
  0%, 88%, 100% { transform: scaleY(1); }
  93% { transform: scaleY(0.08); }
}

@keyframes tp-look {
  0%, 35% { transform: translate(0, 0); }
  45%, 65% { transform: translate(-5px, 1px); }
  75%, 100% { transform: translate(0, 0); }
}
