@font-face {
  font-family: "Luckiest Guy";
  src: url("../assets/luckiest-guy.woff") format("woff");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --bg: #ffe340;
  --ink: #141414;
  --bar: #141414;
  --bar-text: #ffe340;
  --muted: rgba(20, 20, 20, 0.55);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  height: 100dvh;
  background: var(--bg);
  color: var(--ink);
  font-family: "Luckiest Guy", "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  letter-spacing: 0.02em;
  overflow: hidden;
  touch-action: manipulation;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
  cursor: pointer;
}

body {
  min-height: 100dvh;
  min-height: 100svh;
}

#app {
  height: 100%;
  height: 100dvh;
  min-height: 100dvh;
  padding: calc(10px + var(--safe-top)) 16px calc(88px + var(--safe-bottom));
  display: flex;
  flex-direction: column;
  align-items: center;
}

.top {
  text-align: center;
  width: 100%;
  flex: 0 0 auto;
}

.top h1 {
  font-size: clamp(28px, 8vw, 72px);
  font-weight: 400;
  line-height: 0.95;
  letter-spacing: 0.04em;
  text-shadow: 3px 3px 0 #fff, 6px 6px 0 rgba(0,0,0,0.08);
  margin-top: 4px;
}

.count {
  font-size: clamp(56px, 18vw, 160px);
  line-height: 0.9;
  letter-spacing: 0.02em;
  margin-top: 4px;
  font-variant-numeric: tabular-nums;
  text-shadow: 4px 4px 0 #fff;
}

.stage {
  flex: 1 1 auto;
  min-height: 0;
  width: min(100%, 520px);
  max-height: calc(100dvh - 200px - var(--safe-top) - var(--safe-bottom));
  position: relative;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  touch-action: none;
  margin-top: 4px;
}

.face, .flip {
  width: auto;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  object-position: bottom center;
  pointer-events: none;
  -webkit-user-drag: none;
  user-select: none;
}

.face {
  display: block;
}

.flip {
  display: none;
  position: absolute;
  inset: 0;
  margin: auto;
  background: var(--bg);
  object-fit: contain;
}

.stage.is-flipping .face { visibility: hidden; }
.stage.is-flipping .flip { display: block; }

.stage.is-down .face {
  transform: scale(0.985) translateY(4px);
}

.hint {
  margin-top: 8px;
  font-family: system-ui, sans-serif;
  font-weight: 700;
  font-size: 13px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--muted);
  pointer-events: none;
}

.hint.is-hidden { opacity: 0; transition: opacity 0.4s ease; }

.world {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  background: var(--bar);
  color: var(--bar-text);
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 20px calc(14px + var(--safe-bottom));
  z-index: 5;
  box-shadow: 0 -8px 0 rgba(0,0,0,0.08);
}

.world-label {
  font-size: clamp(16px, 4vw, 26px);
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.world-count {
  font-size: clamp(22px, 6vw, 40px);
  letter-spacing: 0.02em;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.world[data-state="offline"] .world-label,
.world[data-state="offline"] .world-count {
  font-family: system-ui, sans-serif;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: none;
}

.world[data-state="offline"] .world-count { display: none; }
.world[data-state="offline"] .world-label { font-size: 15px; letter-spacing: 0.02em; }

.world.is-pulse .world-count {
  animation: popnum 0.18s ease-out;
}

@keyframes popnum {
  0% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

@media (min-width: 900px) {
  #app { padding-top: calc(12px + var(--safe-top)); }
  .stage { width: min(100%, 620px); max-height: calc(100dvh - 190px - var(--safe-top) - var(--safe-bottom)); }
}
