:root {
  color-scheme: dark;
  --ink: #fff7fb;
  --muted: #d8c7cf;
  --panel: rgba(24, 24, 28, 0.78);
  --panel-strong: rgba(18, 18, 23, 0.92);
  --pink: #ff8fbd;
  --rose: #ff5f8f;
  --mint: #8ee6c8;
  --gold: #ffd36e;
  --blue: #8fc7ff;
  --danger: #ff6961;
  --line: rgba(255, 255, 255, 0.16);
  --glass: rgba(255, 255, 255, 0.08);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  width: 100%;
  min-height: 100%;
  margin: 0;
  overflow: hidden;
  background:
    radial-gradient(circle at 12% 18%, rgba(255, 143, 189, 0.24), transparent 28%),
    radial-gradient(circle at 86% 10%, rgba(142, 230, 200, 0.18), transparent 30%),
    linear-gradient(135deg, #14131a 0%, #1d2430 48%, #251821 100%);
  color: var(--ink);
}

button {
  border: 0;
  font: inherit;
  color: inherit;
}

.game-shell {
  position: relative;
  width: 100vw;
  height: 100vh;
  height: 100svh;
  min-height: 540px;
  isolation: isolate;
}

.game-shell.shake {
  animation: shake 0.34s ease;
}

#scene {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: -1;
}

.scanlines {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    linear-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1px),
    radial-gradient(circle at 50% 38%, transparent 0 44%, rgba(0, 0, 0, 0.32) 88%);
  background-size: 100% 4px, 100% 100%;
  mix-blend-mode: screen;
  opacity: 0.42;
}

.alarm {
  position: absolute;
  top: 96px;
  left: 50%;
  z-index: 3;
  transform: translateX(-50%);
  width: min(780px, calc(100vw - 28px));
  padding: 9px 12px;
  border: 1px solid rgba(255, 105, 97, 0.58);
  border-radius: 8px;
  background: rgba(75, 14, 24, 0.72);
  color: #ffd4d1;
  text-align: center;
  font-size: 12px;
  font-weight: 950;
  letter-spacing: 0.18em;
  box-shadow: 0 0 34px rgba(255, 95, 143, 0.24);
  animation: alarmPulse 1s ease-in-out infinite;
  backdrop-filter: blur(12px);
}

.hud {
  position: absolute;
  top: 18px;
  left: 50%;
  width: min(1120px, calc(100vw - 28px));
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 14px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(120deg, rgba(15, 18, 22, 0.78), rgba(48, 31, 43, 0.68));
  box-shadow: 0 20px 80px rgba(0, 0, 0, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.12);
  backdrop-filter: blur(18px);
  z-index: 2;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  flex: 0 0 auto;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--rose), var(--gold));
  color: #241018;
  font-weight: 900;
  box-shadow: 0 0 24px rgba(255, 95, 143, 0.38), inset 0 -10px 22px rgba(0, 0, 0, 0.14);
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(18px, 2.4vw, 28px);
  line-height: 1.05;
}

.brand p {
  margin-top: 4px;
  color: var(--muted);
  font-size: 13px;
}

.stats {
  display: flex;
  gap: 8px;
}

.stat {
  min-width: 82px;
  padding: 9px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--glass);
  text-align: right;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.08);
}

.stat span {
  display: block;
  color: var(--muted);
  font-size: 12px;
}

.stat strong {
  display: block;
  margin-top: 2px;
  font-size: 22px;
  color: var(--gold);
}

.story-panel,
.challenge-panel,
.ending-panel {
  position: absolute;
  left: 50%;
  bottom: 26px;
  width: min(760px, calc(100vw - 28px));
  transform: translateX(-50%);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 24px 90px rgba(0, 0, 0, 0.36), 0 0 0 1px rgba(255, 143, 189, 0.05);
  backdrop-filter: blur(20px);
  z-index: 2;
  overflow: hidden;
}

.story-panel::before,
.challenge-panel::before,
.ending-panel::before {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--pink), var(--mint), transparent);
  opacity: 0.9;
}

.story-panel {
  padding: 18px;
}

.speaker,
.eyebrow {
  display: inline-flex;
  align-items: center;
  min-height: 24px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(142, 230, 200, 0.14);
  color: var(--mint);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.speaker::before {
  content: "●";
  margin-right: 7px;
  color: var(--danger);
  text-shadow: 0 0 16px var(--danger);
  animation: blink 0.9s steps(2, end) infinite;
}

#storyText {
  margin-top: 12px;
  color: #fff3f8;
  font-size: clamp(18px, 2.2vw, 23px);
  line-height: 1.45;
}

.actions,
.choices {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  margin-top: 16px;
}

.primary,
.choice,
.ghost {
  min-height: 48px;
  border-radius: 8px;
  padding: 12px 14px;
  cursor: pointer;
  font-weight: 800;
  position: relative;
  overflow: hidden;
  transition: transform 140ms ease, border-color 140ms ease, background 140ms ease, box-shadow 140ms ease;
}

.primary {
  background: linear-gradient(135deg, var(--rose), #ffb86d);
  color: #241018;
  box-shadow: 0 12px 28px rgba(255, 95, 143, 0.24);
}

.ghost,
.choice {
  border: 1px solid rgba(255, 255, 255, 0.14);
  background: rgba(255, 255, 255, 0.08);
}

.primary:hover,
.choice:hover,
.ghost:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 36px rgba(0, 0, 0, 0.22);
}

.choice.correct {
  border-color: rgba(142, 230, 200, 0.65);
  background: rgba(142, 230, 200, 0.18);
  box-shadow: 0 0 28px rgba(142, 230, 200, 0.18);
}

.choice.wrong {
  border-color: rgba(255, 105, 97, 0.72);
  background: rgba(255, 105, 97, 0.18);
  box-shadow: 0 0 28px rgba(255, 105, 97, 0.2);
}

.challenge-panel {
  padding: 18px;
  background:
    linear-gradient(135deg, rgba(255, 143, 189, 0.1), transparent 42%),
    var(--panel-strong);
}

.guard-card {
  display: flex;
  align-items: center;
  gap: 14px;
}

.dog-badge {
  position: relative;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  flex: 0 0 auto;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 30%, #b77c5a, #362a22 70%);
  color: #fff0d7;
  font-weight: 900;
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.22), 0 0 22px rgba(255, 211, 110, 0.16);
}

.dog-badge::before,
.dog-badge::after {
  content: "";
  position: absolute;
  top: -7px;
  width: 18px;
  height: 24px;
  border-radius: 60% 60% 30% 30%;
  background: #6b4635;
}

.dog-badge::before {
  left: 4px;
  transform: rotate(-30deg);
}

.dog-badge::after {
  right: 4px;
  transform: rotate(30deg);
}

.guard-card h2 {
  margin-top: 6px;
  font-size: clamp(22px, 3vw, 34px);
}

.question {
  margin-top: 14px;
  color: #fff4f9;
  font-size: clamp(18px, 2.1vw, 22px);
  line-height: 1.42;
}

.feedback {
  min-height: 26px;
  margin-top: 12px;
  color: var(--gold);
  font-weight: 800;
  text-shadow: 0 0 18px rgba(255, 211, 110, 0.22);
}

.ending-panel {
  top: 50%;
  bottom: auto;
  max-width: 690px;
  padding: 22px;
  text-align: center;
  transform: translate(-50%, -42%);
  background:
    radial-gradient(circle at 50% 18%, rgba(255, 143, 189, 0.22), transparent 38%),
    rgba(18, 18, 23, 0.88);
}

.ending-panel h2 {
  font-size: clamp(30px, 5vw, 54px);
}

.ending-panel p {
  margin: 12px auto 0;
  max-width: 560px;
  color: var(--muted);
  font-size: 18px;
  line-height: 1.5;
}

.ending-art {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 18px;
  height: 118px;
  margin: 12px 0 18px;
}

.bin-avatar,
.nhu-avatar {
  display: grid;
  place-items: center;
  width: 86px;
  height: 86px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--blue), var(--mint));
  color: #10202b;
  font-weight: 900;
  box-shadow: 0 18px 38px rgba(0, 0, 0, 0.26);
  animation: bob 1.6s ease-in-out infinite;
}

.nhu-avatar {
  background: linear-gradient(135deg, #ffadd0, #ffe08f);
}

.hug-heart {
  width: 58px;
  height: 58px;
  background: var(--rose);
  transform: rotate(45deg);
  animation: pulse 0.9s ease-in-out infinite;
}

.hug-heart::before,
.hug-heart::after {
  content: "";
  position: absolute;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background: inherit;
}

.hug-heart::before {
  left: -29px;
}

.hug-heart::after {
  top: -29px;
}

.hidden {
  display: none;
}

@keyframes alarmPulse {
  0%, 100% { opacity: 0.72; }
  50% { opacity: 1; }
}

@keyframes blink {
  50% { opacity: 0.24; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  18% { transform: translateX(-10px); }
  36% { transform: translateX(8px); }
  54% { transform: translateX(-6px); }
  72% { transform: translateX(4px); }
}

@keyframes bob {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-7px); }
}

@keyframes pulse {
  0%, 100% { transform: rotate(45deg) scale(0.92); }
  50% { transform: rotate(45deg) scale(1.08); }
}

@media (max-width: 720px) {
  .game-shell {
    min-height: 540px;
  }

  .hud {
    align-items: stretch;
    flex-direction: column;
    top: 10px;
    gap: 10px;
    padding: 10px;
  }

  .alarm {
    top: 134px;
    letter-spacing: 0.08em;
  }

  .stats {
    width: 100%;
  }

  .stat {
    flex: 1;
    text-align: left;
  }

  .actions,
  .choices {
    grid-template-columns: 1fr;
  }

  .brand p {
    display: none;
  }

  .mark {
    width: 38px;
    height: 38px;
  }

  .stat {
    padding: 7px 10px;
  }

  .stat strong {
    font-size: 18px;
  }

  .story-panel,
  .challenge-panel,
  .ending-panel {
    bottom: 12px;
    width: min(560px, calc(100vw - 20px));
    padding: 14px;
  }

  .question,
  #storyText {
    font-size: 17px;
  }

  .primary,
  .choice,
  .ghost {
    min-height: 43px;
    padding: 10px 12px;
  }

  .ending-panel {
    transform: translate(-50%, -36%);
  }

  .ending-art {
    height: 88px;
    margin: 6px 0 12px;
  }

  .bin-avatar,
  .nhu-avatar {
    width: 66px;
    height: 66px;
  }

  .hug-heart,
  .hug-heart::before,
  .hug-heart::after {
    width: 42px;
    height: 42px;
  }

  .hug-heart::before {
    left: -21px;
  }

  .hug-heart::after {
    top: -21px;
  }
}

@media (max-height: 620px) {
  .hud {
    top: 8px;
  }

  .story-panel,
  .challenge-panel {
    bottom: 10px;
  }

  .alarm {
    display: none;
  }

  .guard-card h2 {
    font-size: 22px;
  }

  .choices {
    gap: 7px;
    margin-top: 10px;
  }

  .feedback {
    margin-top: 8px;
  }
}

.game-shell.cinematic {
  cursor: none;
}

.hud.hidden {
  display: none;
}

.game-shell.cinematic .scanlines {
  opacity: 0.28;
}

.game-shell.playing .hud {
  top: 10px;
  width: min(560px, calc(100vw - 20px));
  padding: 8px 10px;
  gap: 10px;
  align-items: center;
  flex-direction: row;
  min-height: 0;
}

.game-shell.playing .brand {
  gap: 8px;
}

.game-shell.playing .brand p {
  display: none;
}

.game-shell.playing .mark {
  width: 34px;
  height: 34px;
}

.game-shell.playing h1 {
  max-width: 170px;
  overflow: hidden;
  text-overflow: ellipsis;
  font-size: 15px;
  white-space: nowrap;
}

.game-shell.playing .stats {
  margin-left: auto;
  width: auto;
  flex: 0 0 auto;
}

.game-shell.playing .stat {
  flex: 0 0 auto;
  min-width: 68px;
  padding: 6px 8px;
  text-align: left;
}

.game-shell.playing .stat strong {
  font-size: 17px;
}
