:root {
  color-scheme: dark;
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-synthesis: none;
  --ink: #f4f5f5;
  --muted: rgba(232, 237, 239, 0.68);
  --line: rgba(255, 255, 255, 0.18);
  --glass: rgba(17, 24, 32, 0.74);
  --cyan: #88d9e6;
  --coral: #ff9d91;
  --shadow: rgba(6, 10, 15, 0.52);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  height: 100%;
  margin: 0;
  overflow: hidden;
  background: #111820;
}

body {
  min-width: 280px;
  overscroll-behavior: none;
}

button {
  font: inherit;
}

.game-shell {
  width: 100%;
  min-height: 100dvh;
  min-height: 100svh;
  overflow: hidden;
  background: #111820;
}

.room-stage {
  position: relative;
  width: 100%;
  height: 100dvh;
  min-height: 100svh;
  overflow: hidden;
  background-color: #252c39;
  touch-action: none;
  user-select: none;
}

.room-background {
  position: absolute;
  z-index: 0;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center 58%;
  pointer-events: none;
}

.stage-wash {
  position: absolute;
  inset: 0;
  z-index: 1;
  background: rgba(7, 12, 18, 0.16);
  pointer-events: none;
}

.room-floor {
  position: absolute;
  z-index: 1;
  left: 50%;
  bottom: -8vh;
  width: min(62vw, 54rem);
  height: 22vh;
  min-height: 8rem;
  transform: translateX(-50%) perspective(26rem) rotateX(58deg);
  transform-origin: center bottom;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(24, 31, 41, 0.2);
  box-shadow: 0 0 3rem rgba(9, 12, 20, 0.22);
  pointer-events: none;
}

.hud {
  position: absolute;
  z-index: 5;
  top: max(1rem, env(safe-area-inset-top));
  right: max(1rem, env(safe-area-inset-right));
  left: max(1rem, env(safe-area-inset-left));
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  pointer-events: none;
}

.room-tag,
.stats-cluster,
.status-dock {
  border: 1px solid var(--line);
  background: var(--glass);
  box-shadow: 0 0.75rem 2rem var(--shadow);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.room-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-height: 2.7rem;
  padding: 0 0.9rem;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.16em;
  white-space: nowrap;
}

.room-light {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--coral);
  box-shadow: 0 0 0.7rem rgba(255, 157, 145, 0.78);
}

.stats-cluster {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  min-height: 3.8rem;
  padding: 0.35rem 0.4rem 0.35rem 0.85rem;
}

.tap-readout {
  display: grid;
  justify-items: end;
  line-height: 1;
}

.tap-label {
  color: var(--cyan);
  font-size: 0.62rem;
  font-weight: 800;
  letter-spacing: 0.2em;
}

.tap-readout strong {
  margin-top: 0.3rem;
  color: var(--ink);
  font-size: clamp(1.35rem, 3vw, 2rem);
  font-weight: 800;
  letter-spacing: 0;
  font-variant-numeric: tabular-nums;
}

.reset-button {
  display: grid;
  width: 2.8rem;
  height: 2.8rem;
  place-items: center;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 50%;
  color: rgba(244, 245, 245, 0.78);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
  pointer-events: auto;
  transition: color 160ms ease, background 160ms ease, transform 160ms ease;
}

.reset-button span {
  display: block;
  font-size: 1.35rem;
  line-height: 1;
}

.reset-button:hover,
.reset-button:focus-visible {
  color: #fff;
  background: rgba(255, 255, 255, 0.16);
  outline: none;
}

.reset-button:active {
  transform: scale(0.92);
}

.character-button {
  position: absolute;
  z-index: 2;
  bottom: clamp(4rem, 10vh, 7rem);
  left: 50%;
  display: block;
  width: min(42vw, 30rem);
  height: min(78svh, 48rem);
  min-width: 18rem;
  min-height: 30rem;
  padding: 0;
  transform: translateX(-50%);
  border: 0;
  color: inherit;
  background: transparent;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

.character-button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 0.45rem;
}

.character-shadow {
  position: absolute;
  right: 7%;
  bottom: 1.2%;
  left: 7%;
  height: 4%;
  border-radius: 50%;
  background: rgba(8, 11, 17, 0.42);
  filter: blur(0.85rem);
  pointer-events: none;
}

.character-sprite-frame {
  position: absolute;
  inset: 0;
  display: block;
  overflow: visible;
  filter: drop-shadow(0 1rem 0.9rem rgba(10, 12, 19, 0.4));
  transition: transform 160ms cubic-bezier(0.2, 0.8, 0.25, 1);
}

.character-button.is-pressed .character-sprite-frame {
  transform: translateY(0.35rem) scale(0.985);
}

.character-sprite {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  object-position: center bottom;
  pointer-events: none;
  transition: opacity 120ms ease;
}

.character-idle {
  opacity: 1;
}

.character-voice {
  opacity: 0;
}

.character-button.is-voice .character-idle {
  opacity: 0;
}

.character-button.is-voice .character-voice {
  opacity: 1;
}

.tap-burst {
  position: absolute;
  top: 23%;
  left: 50%;
  width: 1rem;
  height: 1rem;
  border: 2px solid rgba(255, 157, 145, 0.85);
  border-radius: 50%;
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.35);
}

.tap-burst.is-visible {
  animation: tap-burst 460ms ease-out both;
}

.status-dock {
  position: absolute;
  z-index: 5;
  right: max(1rem, env(safe-area-inset-right));
  bottom: max(1rem, env(safe-area-inset-bottom));
  left: max(1rem, env(safe-area-inset-left));
  display: inline-flex;
  align-items: center;
  gap: 0.7rem;
  width: fit-content;
  min-height: 2.55rem;
  padding: 0 0.85rem;
  color: var(--muted);
  font-size: 0.62rem;
  font-weight: 750;
  letter-spacing: 0.14em;
}

.status-value {
  color: var(--cyan);
  font-size: 0.62rem;
  font-variant-numeric: tabular-nums;
}

.status-pulse {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--cyan);
  box-shadow: 0 0 0.65rem rgba(136, 217, 230, 0.78);
}

.status-dock.is-active .status-value {
  color: var(--coral);
}

.status-dock.is-active .status-pulse {
  background: var(--coral);
  box-shadow: 0 0 0.8rem rgba(255, 157, 145, 0.85);
  animation: pulse 720ms ease-in-out infinite alternate;
}

@keyframes tap-burst {
  0% {
    opacity: 0.9;
    transform: translate(-50%, -50%) scale(0.35);
  }
  100% {
    opacity: 0;
    transform: translate(-50%, -50%) scale(4.2);
  }
}

@keyframes pulse {
  from {
    transform: scale(0.8);
  }
  to {
    transform: scale(1.25);
  }
}

@media (max-width: 680px) {
  .room-stage {
    background-position: center 57%;
  }

  .room-tag {
    min-height: 2.45rem;
    padding: 0 0.75rem;
    font-size: 0.58rem;
  }

  .stats-cluster {
    min-height: 3.35rem;
    padding-left: 0.7rem;
  }

  .tap-label {
    font-size: 0.56rem;
  }

  .tap-readout strong {
    font-size: 1.35rem;
  }

  .reset-button {
    width: 2.45rem;
    height: 2.45rem;
  }

  .character-button {
    bottom: 7rem;
    width: min(96vw, 27rem);
    height: min(70svh, 37rem);
    min-width: 16rem;
    min-height: 25rem;
  }

  .character-shadow {
    bottom: 1%;
  }

  .status-dock {
    right: auto;
    min-height: 2.35rem;
    font-size: 0.55rem;
  }

  .status-value {
    font-size: 0.55rem;
  }
}

@media (max-height: 620px) and (orientation: landscape) {
  .character-button {
    bottom: 1rem;
    width: min(32vw, 20rem);
    height: 88svh;
    min-width: 15rem;
    min-height: 22rem;
  }

  .status-dock {
    bottom: max(0.65rem, env(safe-area-inset-bottom));
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 1ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 1ms !important;
  }
}
