:root {
  color-scheme: light;
  --red: #d9091d;
  --deep-red: #7a0613;
  --coral: #ff6048;
  --cream: #fff7d1;
  --sky: #55d8e3;
  --ink: #31070d;
  --shadow: 0 18px 40px rgba(122, 6, 19, 0.2);
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
}

body {
  overflow: hidden;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: #d9091d;
  color: var(--ink);
}

button {
  font: inherit;
}

.app-shell {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  padding: 0;
}

.game-phone {
  width: min(100%, 430px);
  height: 100dvh;
  min-height: 600px;
  display: grid;
  grid-template-rows: minmax(0, 1fr) auto;
  gap: 0;
  position: relative;
  background: #14080b;
}

.topbar {
  position: absolute;
  z-index: 5;
  top: max(12px, env(safe-area-inset-top));
  left: 14px;
  right: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  pointer-events: none;
}

.controls {
  z-index: 6;
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
  padding: 10px 10px max(10px, env(safe-area-inset-bottom));
  background: linear-gradient(180deg, rgba(20, 8, 11, 0), rgba(20, 8, 11, 0.9) 28%, #14080b);
}

.eyebrow {
  margin: 0 0 2px;
  color: #fff176;
  font-size: 0.73rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

h1 {
  margin: 0;
  color: #fff;
  font-size: 1.6rem;
  line-height: 1;
  text-shadow: 0 3px 10px rgba(49, 7, 13, 0.45);
}

.icon-button,
.tap-button,
.overlay button {
  border: 0;
  cursor: pointer;
  box-shadow: var(--shadow);
  -webkit-tap-highlight-color: transparent;
}

.icon-button {
  width: 44px;
  height: 44px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-size: 1.25rem;
  font-weight: 900;
  pointer-events: auto;
}

.camera-panel {
  position: absolute;
  z-index: 6;
  top: calc(max(12px, env(safe-area-inset-top)) + 58px);
  right: 14px;
  display: block;
  padding: 0;
  border: 0;
  background: transparent;
  box-shadow: none;
}

.camera-preview {
  display: none;
}

#cameraVideo {
  position: absolute;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  display: block;
  object-fit: cover;
  transform: scaleX(-1);
}

.camera-preview img {
  position: absolute;
  inset: -6% -34% auto -34%;
  width: 168%;
  height: auto;
  pointer-events: none;
}

.camera-copy {
  display: none;
}

.camera-copy p {
  margin: 0 0 6px;
  color: #fff;
  font-size: 0.8rem;
  font-weight: 850;
  line-height: 1.18;
}

.mouth-meter {
  width: 100%;
  height: 10px;
  overflow: hidden;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
}

.mouth-meter span {
  width: 0%;
  height: 100%;
  display: block;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff6048, #fff176);
  transition: width 80ms linear;
}

#cameraButton {
  min-width: 74px;
  height: 44px;
  border: 0;
  border-radius: 8px;
  background: #fff176;
  color: #7a0613;
  font-size: 0.86rem;
  font-weight: 950;
  box-shadow: 0 8px 18px rgba(122, 6, 19, 0.12);
}

.canvas-wrap {
  grid-row: 1;
  position: relative;
  overflow: hidden;
  border: 0;
  border-radius: 0;
  background: #141012;
  touch-action: none;
}

#gameCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

.overlay {
  position: absolute;
  inset: 0;
  display: grid;
  align-content: center;
  justify-items: center;
  padding: 28px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(49, 7, 13, 0.52), rgba(49, 7, 13, 0.36)),
    radial-gradient(circle at 50% 42%, rgba(255, 247, 209, 0.62), rgba(255, 247, 209, 0.18) 42%, transparent 70%);
  color: #fff;
}

.overlay::before {
  content: "";
  position: absolute;
  left: 30px;
  right: 30px;
  top: 27%;
  bottom: 24%;
  border: 2px solid rgba(255, 247, 209, 0.36);
  border-radius: 8px;
  background: rgba(49, 7, 13, 0.72);
  box-shadow: 0 24px 50px rgba(49, 7, 13, 0.32);
}

.overlay > * {
  position: relative;
  z-index: 1;
}

.overlay.hidden {
  display: none;
}

.overlay img {
  width: min(48%, 180px);
  height: auto;
  filter: drop-shadow(0 12px 0 rgba(122, 6, 19, 0.12));
  animation: floaty 1.25s ease-in-out infinite alternate;
}

.overlay h2 {
  margin: 18px 0 8px;
  color: #fff;
  font-size: clamp(2rem, 9vw, 3.1rem);
  line-height: 0.95;
  text-shadow: 0 4px 0 rgba(49, 7, 13, 0.52);
}

.overlay p {
  max-width: 280px;
  margin: 0 0 22px;
  color: #fff;
  font-size: 1rem;
  font-weight: 750;
  line-height: 1.35;
}

.overlay button,
.tap-button {
  min-height: 52px;
  border-radius: 8px;
  background: var(--red);
  color: #fff;
  font-weight: 950;
}

.overlay button {
  min-width: 144px;
  padding: 0 24px;
  font-size: 1.05rem;
}

.tap-button {
  width: 100%;
  padding: 0 6px;
  font-size: 0.74rem;
  line-height: 1.08;
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.25);
}

.tongue-button {
  background: #ff8d1a;
}

.close-button {
  background: #65101a;
}

.kiss-button {
  background: #ff4fa0;
}

.icon-button:active,
.tap-button:active,
.overlay button:active {
  transform: translateY(1px);
}

@keyframes floaty {
  from {
    transform: translateY(0) rotate(-4deg);
  }
  to {
    transform: translateY(-10px) rotate(4deg);
  }
}

@media (min-width: 760px) {
  .game-phone {
    height: min(92dvh, 880px);
  }
}

@media (max-height: 700px) {
  .game-phone {
    min-height: 0;
  }

  .camera-panel {
    top: calc(max(8px, env(safe-area-inset-top)) + 48px);
  }
}
