* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

[hidden] {
  display: none !important;
}

:root {
  --ui: #0b3d6b;
  --ui2: #1d6fa5;
  --accent: #ffd447;
  --text: #f2fbff;
  --radius: 20px;
}

html,
body {
  height: 100%;
  overflow: hidden;
  overscroll-behavior: none;
}

body {
  font-family: "Nunito", "Segoe UI Rounded", "Comic Sans MS", system-ui, sans-serif;
  background: #0b3d6b;
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  touch-action: manipulation;
}

#stage {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  touch-action: none;
}

/* soft cinematic vignette over the 3D stage */
#vignette {
  position: fixed;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background: radial-gradient(115% 95% at 50% 42%, transparent 58%, rgba(2, 8, 25, 0.38) 100%);
}

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

.btn {
  font-family: inherit;
  font-size: clamp(1.05rem, 4vw, 1.25rem);
  font-weight: 800;
  color: #4a2c00;
  background: linear-gradient(180deg, #ffe27a, var(--accent));
  border: none;
  border-radius: 999px;
  padding: 15px 30px;
  cursor: pointer;
  box-shadow: 0 5px 0 rgba(0, 0, 0, 0.28), 0 10px 22px rgba(0, 0, 0, 0.3);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.2s;
  min-height: 54px;
}

.btn:active {
  transform: translateY(4px);
  box-shadow: 0 1px 0 rgba(0, 0, 0, 0.28);
}

.btn.ghost {
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  box-shadow: 0 4px 0 rgba(0, 0, 0, 0.22);
  backdrop-filter: blur(6px);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
}

.btn.big {
  width: min(86vw, 360px);
  font-size: clamp(1.15rem, 5vw, 1.4rem);
  padding: 17px 30px;
}

.btn:disabled {
  filter: grayscale(0.7) brightness(0.75);
  pointer-events: none;
}

.stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.round-btn {
  position: fixed;
  top: max(12px, env(safe-area-inset-top));
  z-index: 60;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: rgba(10, 20, 40, 0.45);
  color: #fff;
  display: grid;
  place-items: center;
  cursor: pointer;
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.round-btn svg {
  width: 24px;
  height: 24px;
}

#btn-mute {
  right: max(12px, env(safe-area-inset-right));
}

#btn-home {
  left: max(12px, env(safe-area-inset-left));
}

/* -------------------------------------------------------------- screens */

.screen {
  position: fixed;
  inset: 0;
  z-index: 40;
  display: none;
  flex-direction: column;
  align-items: center;
  justify-content: safe center;
  gap: 10px;
  padding: max(16px, env(safe-area-inset-top)) 18px max(20px, env(safe-area-inset-bottom));
  overflow-y: auto;
  overflow-x: hidden;
}

.screen.active {
  display: flex;
  animation: screenIn 0.3s ease;
}

.screen.opaque {
  background: radial-gradient(120% 90% at 50% 0%, var(--ui2), var(--ui) 75%);
}

@keyframes screenIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.stars {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(1.5px 1.5px at 12% 22%, #fff9, transparent),
    radial-gradient(2px 2px at 78% 12%, #fff7, transparent),
    radial-gradient(1.5px 1.5px at 55% 34%, #fff8, transparent),
    radial-gradient(2px 2px at 28% 72%, #fff5, transparent),
    radial-gradient(1.5px 1.5px at 88% 58%, #fff7, transparent),
    radial-gradient(2px 2px at 8% 88%, #fff4, transparent);
  animation: twinkle 4s ease-in-out infinite alternate;
}

@keyframes twinkle {
  from {
    opacity: 0.45;
  }
  to {
    opacity: 1;
  }
}

h1.logo {
  font-size: clamp(2.2rem, 9vw, 3.4rem);
  font-weight: 900;
  letter-spacing: 0.01em;
  text-shadow: 0 4px 0 rgba(0, 0, 0, 0.28);
  margin-top: 2vh;
}

.subtitle {
  opacity: 0.9;
  font-size: clamp(1rem, 4vw, 1.15rem);
  margin-bottom: 1.5vh;
}

.h2 {
  font-size: clamp(1.4rem, 6vw, 1.9rem);
  font-weight: 900;
  margin: 6vh 0 1vh;
  text-align: center;
}

.label {
  font-weight: 800;
  opacity: 0.9;
}

/* world picker */

.world-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(88vw, 380px);
  margin-bottom: 2vh;
}

.world-card {
  position: relative;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-radius: var(--radius);
  padding: 10px 6px 12px;
  text-align: center;
  cursor: pointer;
  color: #fff;
  font-family: inherit;
  font-size: clamp(0.85rem, 3.4vw, 1rem);
  font-weight: 800;
  background: rgba(0, 0, 0, 0.28);
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.3);
  transition: transform 0.15s ease, border-color 0.15s ease, background 0.2s;
}

.world-card img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  border-radius: 12px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12), 0 4px 10px rgba(0, 0, 0, 0.3);
}

.world-card .ph {
  width: 100%;
  aspect-ratio: 1;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.08);
}

.world-card.selected {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.14);
  transform: scale(1.05);
}

/* ------------------------------------------------------------------ HUD */

#hud {
  position: fixed;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: max(12px, env(safe-area-inset-top)) 12px max(16px, env(safe-area-inset-bottom));
}

.status-pill {
  max-width: min(calc(100vw - 132px), 560px);
  min-height: 46px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-weight: 800;
  font-size: clamp(0.95rem, 3.9vw, 1.15rem);
  background: rgba(10, 20, 40, 0.55);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(8px);
  border-radius: 999px;
  padding: 8px 22px;
  margin-top: 2px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
}

.chips {
  display: flex;
  gap: 6px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: 94vw;
}

.chip {
  width: 46px;
  height: 46px;
  border-radius: 14px;
  background: rgba(10, 20, 40, 0.5);
  border: 1.5px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  display: grid;
  place-items: center;
  overflow: hidden;
  transition: opacity 0.3s, filter 0.3s;
}

.chip img {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.chip.done {
  filter: grayscale(1) brightness(0.6);
  opacity: 0.55;
}

.hud-actions {
  margin-top: auto;
  display: flex;
  gap: 12px;
  pointer-events: none;
}

.hud-actions .btn {
  pointer-events: auto;
}

/* landscape: actions to the right so they never cover the board */
@media (min-aspect-ratio: 13/10) {
  #hud {
    flex-direction: row;
    align-items: flex-start;
    justify-content: space-between;
  }
  .status-pill {
    max-width: 40vw;
    margin-left: 60px;
  }
  .chips {
    position: fixed;
    left: 50%;
    transform: translateX(-50%);
    bottom: max(10px, env(safe-area-inset-bottom));
    margin: 0;
  }
  .hud-actions {
    margin: 0;
    flex-direction: column;
    align-self: flex-end;
    position: fixed;
    right: max(12px, env(safe-area-inset-right));
    bottom: max(12px, env(safe-area-inset-bottom));
  }
}

/* --------------------------------------------------------- pass / win */

.pass-card,
.win-card {
  background: rgba(10, 20, 40, 0.55);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(10px);
  border-radius: 26px;
  padding: 34px 26px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  max-width: min(92vw, 420px);
  box-shadow: 0 18px 44px rgba(0, 0, 0, 0.45);
}

#screen-win {
  background: rgba(5, 10, 25, 0.35);
  z-index: 45;
}

.pass-title,
.win-title {
  font-size: clamp(1.5rem, 6.5vw, 2.1rem);
  font-weight: 900;
  text-align: center;
}

.win-title {
  animation: winPulse 1.2s ease-in-out infinite;
}

@keyframes winPulse {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

.pass-sub {
  opacity: 0.9;
  text-align: center;
  font-size: clamp(0.95rem, 4vw, 1.1rem);
  max-width: 34ch;
  line-height: 1.5;
}

/* ----------------------------------------------------------- online */

.hint {
  opacity: 0.8;
  font-size: 0.95rem;
  text-align: center;
  line-height: 1.5;
  max-width: 40ch;
}

.qr-box {
  background: #fff;
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.4);
}

.qr-box svg {
  display: block;
  width: min(56vw, 40vh, 250px);
  height: min(56vw, 40vh, 250px);
}

.game-code {
  font-size: clamp(2rem, 10vw, 2.8rem);
  font-weight: 900;
  letter-spacing: 0.35em;
  text-indent: 0.35em;
  background: rgba(0, 0, 0, 0.3);
  border-radius: var(--radius);
  padding: 8px 20px;
}

.code-input {
  font-family: inherit;
  font-size: clamp(1.8rem, 9vw, 2.4rem);
  font-weight: 900;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  text-align: center;
  text-transform: uppercase;
  width: min(80vw, 300px);
  padding: 12px;
  border-radius: var(--radius);
  border: 3px solid rgba(255, 255, 255, 0.35);
  background: rgba(0, 0, 0, 0.3);
  color: var(--text);
  outline: none;
}

.code-input:focus {
  border-color: var(--accent);
}

.error-msg {
  color: #ffb0b0;
  font-weight: 700;
  min-height: 1.4em;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 5px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* ---------------------------------------------------------- Weltreise */

#journey-stops {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(92vw, 440px);
  margin-bottom: 1.5vh;
}

.journey-stop {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(0, 0, 0, 0.24);
  border: 1.5px solid rgba(255, 255, 255, 0.14);
  border-radius: 14px;
  padding: 9px 14px;
  font-weight: 800;
  font-size: 0.92rem;
}

.journey-stop.current {
  border-color: var(--accent);
  background: rgba(255, 255, 255, 0.12);
  transform: scale(1.02);
}

.journey-stop.locked {
  opacity: 0.45;
}

.journey-emoji {
  font-size: 1.2rem;
}

.journey-label {
  flex: 1;
}

.journey-world {
  opacity: 0.7;
  font-size: 0.8rem;
}

/* ------------------------------------------------------- chase overlay */

#chase-move {
  position: fixed;
  inset: 0;
  z-index: 64;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: max(14px, env(safe-area-inset-bottom));
  background: rgba(5, 10, 25, 0.45);
}

.chase-move-card {
  background: rgba(10, 20, 40, 0.9);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 24px;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  backdrop-filter: blur(8px);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.5);
}

.chase-move-title {
  font-weight: 900;
  font-size: 1.1rem;
}

.chase-move-sub {
  font-size: 0.9rem;
  opacity: 0.85;
}

.arrow-pad {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
}

.arrow-mid {
  display: flex;
  gap: 6px;
}

.arrow-btn {
  width: 58px;
  height: 58px;
  font-size: 1.5rem;
  border: none;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.14);
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  color: var(--text);
  cursor: pointer;
}

.arrow-btn:active {
  background: rgba(255, 255, 255, 0.28);
}

/* --------------------------------------------------------- extras row */

.extras-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  width: min(88vw, 380px);
}

.extra-card {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: 16px;
  border: 2px solid rgba(255, 255, 255, 0.22);
  background: rgba(0, 0, 0, 0.28);
  color: var(--text);
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(0.88rem, 3.6vw, 1rem);
  cursor: pointer;
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.28);
  transition: transform 0.12s ease, background 0.15s;
}

.extra-card:active {
  transform: scale(0.96);
  background: rgba(255, 255, 255, 0.12);
}

.xemoji {
  font-size: 1.35rem;
}

.extras-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 12px;
}

.extras-row .btn {
  font-size: 0.95rem;
  padding: 10px 18px;
  min-height: 44px;
}

/* ------------------------------------------------------- extra rules */

.rules-row {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: center;
  max-width: min(92vw, 420px);
  margin-bottom: 1.5vh;
}

.rule-chip {
  cursor: pointer;
}

.rule-chip input {
  position: absolute;
  opacity: 0;
  pointer-events: none;
}

.rule-chip span {
  display: inline-block;
  font-size: 0.85rem;
  font-weight: 800;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.28);
  border: 2px solid rgba(255, 255, 255, 0.22);
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}

.rule-chip input:checked + span {
  background: rgba(255, 255, 255, 0.18);
  border-color: var(--accent);
  transform: scale(1.04);
}

/* ----------------------------------------------------- sticker album */

.album-total {
  font-weight: 900;
  font-size: clamp(1.05rem, 4.5vw, 1.3rem);
}

#album-worlds {
  display: flex;
  flex-direction: column;
  gap: 14px;
  width: min(94vw, 520px);
  margin-bottom: 1vh;
}

.album-section {
  background: rgba(0, 0, 0, 0.24);
  border: 1.5px solid rgba(255, 255, 255, 0.16);
  border-radius: var(--radius);
  padding: 10px 12px 12px;
}

.album-world-name {
  font-weight: 900;
  margin-bottom: 8px;
}

.album-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.album-slot {
  position: relative;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 14px;
  padding: 6px 2px 4px;
  text-align: center;
}

.album-slot img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: contain;
  filter: drop-shadow(0 3px 4px rgba(0, 0, 0, 0.35));
}

.album-slot.locked img {
  filter: grayscale(1) brightness(0.18);
  opacity: 0.85;
}

.album-slot-name {
  font-size: 0.62rem;
  font-weight: 800;
  opacity: 0.9;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.album-slot.locked .album-slot-name {
  opacity: 0.45;
}

.album-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--accent);
  color: #4a2c00;
  font-size: 0.68rem;
  font-weight: 900;
  border-radius: 999px;
  padding: 2px 7px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.35);
}

/* sticker reward on the win screen */

#win-sticker {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  background: rgba(255, 255, 255, 0.08);
  border: 1.5px dashed rgba(255, 255, 255, 0.35);
  border-radius: 18px;
  padding: 10px 18px;
}

#win-sticker img {
  width: 74px;
  height: 74px;
  object-fit: contain;
  animation: stickerPop 0.5s cubic-bezier(0.2, 1.6, 0.4, 1);
}

@keyframes stickerPop {
  from {
    transform: scale(0) rotate(-16deg);
  }
  to {
    transform: scale(1) rotate(0);
  }
}

.sticker-label {
  font-weight: 800;
  font-size: 0.95rem;
}

.sticker-unlock {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--accent);
}

.style-hint {
  font-size: 0.85rem;
  font-weight: 700;
  opacity: 0.85;
  margin-bottom: 8px;
}

/* -------------------------------------------------------- style panel */

#customizer {
  position: fixed;
  inset: 0;
  z-index: 65;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: max(14px, env(safe-area-inset-top)) 14px max(14px, env(safe-area-inset-bottom));
  background: rgba(5, 10, 25, 0.6);
  backdrop-filter: blur(4px);
}

.cust-card {
  width: min(94vw, 420px);
  max-height: 100%;
  overflow-y: auto;
  background: rgba(10, 20, 40, 0.92);
  border: 1.5px solid rgba(255, 255, 255, 0.22);
  border-radius: 26px;
  padding: 16px 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, 0.55);
  animation: screenIn 0.25s ease;
}

.cust-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.cust-title {
  text-align: center;
}

.cust-name {
  font-weight: 900;
  font-size: 1.15rem;
}

.cust-count {
  font-size: 0.78rem;
  opacity: 0.7;
  font-weight: 700;
}

#cust-canvas {
  width: min(64vw, 250px, 32vh);
  height: min(64vw, 250px, 32vh);
  display: block;
}

.pager-btn {
  width: 46px;
  height: 46px;
  flex: none;
  font-size: 1.5rem;
  font-weight: 900;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.12);
  color: var(--text);
  cursor: pointer;
}

.pager-btn:active {
  background: rgba(255, 255, 255, 0.26);
}

.cust-hat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  width: 100%;
}

.cust-hat-name {
  font-weight: 800;
  font-size: 0.95rem;
  text-align: center;
  flex: 1;
}

.tint-dot.locked {
  opacity: 0.35;
  filter: grayscale(0.4);
}

.btn.small {
  padding: 8px 18px;
  min-height: 40px;
  font-size: 0.95rem;
}

.tint-dots {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.tint-dot {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  padding: 0;
  flex: none;
}

.tint-dot.none {
  background: repeating-conic-gradient(#dfe8f0 0 25%, #97a6b4 0 50%);
  background-size: 9px 9px;
}

.tint-dot.selected {
  border-color: #fff;
  box-shadow: 0 0 0 2.5px var(--accent);
}

.hat-btn {
  font-family: inherit;
  font-weight: 800;
  font-size: 0.82rem;
  border-radius: 999px;
  padding: 9px 12px;
  background: rgba(255, 255, 255, 0.14);
  color: var(--text);
  cursor: pointer;
  border: 1.5px solid rgba(255, 255, 255, 0.25);
  flex: none;
  min-width: 104px;
}

/* landscape: keep the customizer card fully on screen */
@media (min-aspect-ratio: 13/10) {
  .cust-card {
    max-height: calc(100vh - 20px);
  }
  #cust-canvas {
    width: min(30vh, 200px);
    height: min(30vh, 200px);
  }
}

/* ------------------------------------------------------------- toast */

#toast {
  position: fixed;
  left: 50%;
  bottom: max(86px, env(safe-area-inset-bottom));
  transform: translateX(-50%) translateY(300%);
  background: rgba(10, 20, 40, 0.85);
  border: 1.5px solid rgba(255, 255, 255, 0.2);
  color: #fff;
  font-weight: 800;
  padding: 12px 22px;
  border-radius: 999px;
  z-index: 70;
  transition: transform 0.3s cubic-bezier(0.2, 1.4, 0.4, 1);
  max-width: 86vw;
  text-align: center;
  pointer-events: none;
}

#toast.show {
  transform: translateX(-50%) translateY(0);
}
