:root {
  color-scheme: light;
  --ink: #2b1b2e;
  --ink-soft: #5b405d;
  --cream: #fff5e8;
  --peach: #ffc18b;
  --mint: #a8ffd4;
  --pink: #ff6fae;
  --sky: #b7e8ff;
  --panel: rgba(255, 255, 255, 0.82);
  --shadow: 0 18px 40px rgba(43, 27, 46, 0.18);
  --glow: 0 0 20px rgba(255, 111, 174, 0.35);
  --radius-lg: 26px;
  --radius-md: 18px;
  --radius-sm: 12px;
}

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

body {
  font-family: "Baloo 2", "Trebuchet MS", sans-serif;
  color: var(--ink);
  min-height: 100vh;
  background: radial-gradient(circle at top, #ffe2f0 0%, #fff5e8 45%, #dff9ff 100%);
  overflow-x: hidden;
}

.background-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(135deg, rgba(255, 255, 255, 0.5) 0%, rgba(255, 255, 255, 0) 60%),
    repeating-linear-gradient(0deg, rgba(255, 255, 255, 0.35) 0 2px, transparent 2px 40px),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.35) 0 2px, transparent 2px 40px);
  pointer-events: none;
  opacity: 0.45;
  z-index: -1;
}

.preview-watermark {
  position: fixed;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%) rotate(-18deg);
  font-family: "Bungee", "Trebuchet MS", sans-serif;
  font-size: clamp(1.7rem, 6vw, 4rem);
  letter-spacing: 0.08em;
  color: rgba(196, 48, 86, 0.2);
  text-shadow: 0 2px 0 rgba(255, 255, 255, 0.5);
  pointer-events: none;
  z-index: 120;
  user-select: none;
}

#app {
  max-width: 1200px;
  margin: 32px auto 48px;
  padding: 0 20px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

.title {
  font-family: "Bungee", "Trebuchet MS", sans-serif;
  font-size: clamp(1.5rem, 3vw, 2.6rem);
  letter-spacing: 1px;
  color: var(--ink);
  text-shadow: 0 6px 0 rgba(255, 111, 174, 0.25);
}

.subtitle {
  font-size: 1.1rem;
  color: var(--ink-soft);
  margin-top: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.subtitle.quote {
  font-size: 1rem;
  opacity: 0.95;
}

.nameplate {
  background: var(--pink);
  color: white;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 700;
}

.nameplate.patient {
  background: var(--sky);
  color: var(--ink);
  border: 2px solid var(--ink);
}

.toggles {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.toggle {
  border: 2px solid var(--ink);
  padding: 8px 14px;
  border-radius: 999px;
  background: var(--cream);
  font-weight: 600;
  cursor: pointer;
}

.screen {
  display: block;
}

.screen.hidden {
  display: none;
}

.hidden {
  display: none;
}

.card {
  background: var(--panel);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow);
  border: 2px solid rgba(43, 27, 46, 0.1);
}

.login-card {
  max-width: 520px;
  margin: 80px auto;
  text-align: center;
}

.badge {
  display: inline-flex;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--pink);
  color: white;
  font-weight: 700;
  margin-bottom: 12px;
}

.login-card h1 {
  font-size: 2rem;
  margin-bottom: 12px;
}

.login-card p {
  font-size: 1.1rem;
  margin-bottom: 20px;
}

.login-actions {
  display: flex;
  justify-content: center;
  gap: 14px;
  flex-wrap: wrap;
}

.password-step {
  display: grid;
  gap: 10px;
  margin-top: 16px;
}

.password-step.hidden {
  display: none;
}

.password-title {
  font-weight: 700;
  font-size: 1.1rem;
}

.password-subtitle {
  color: var(--ink-soft);
  font-size: 0.95rem;
}

.password-label {
  font-weight: 700;
}

.password-input {
  border-radius: 14px;
  border: 2px solid rgba(43, 27, 46, 0.3);
  padding: 10px 12px;
  font-size: 1rem;
  font-family: "Baloo 2", "Trebuchet MS", sans-serif;
}

.password-hint {
  font-size: 0.85rem;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.95);
  border: 1px dashed rgba(255, 111, 174, 0.35);
  padding: 6px 10px;
  border-radius: 999px;
  justify-self: center;
}

.btn {
  font-family: "Bungee", "Trebuchet MS", sans-serif;
  border: none;
  border-radius: 999px;
  padding: 12px 22px;
  font-size: 1rem;
  cursor: pointer;
  box-shadow: 0 10px 24px rgba(43, 27, 46, 0.2);
  transition: transform 0.12s ease, filter 0.12s ease;
}

.btn:active {
  transform: translateY(1px) scale(0.98);
  filter: brightness(0.98);
}

.btn.primary {
  background: var(--pink);
  color: white;
}

.btn.secondary {
  background: var(--sky);
  color: var(--ink);
}

.btn:disabled {
  cursor: not-allowed;
  opacity: 0.66;
  box-shadow: none;
}

.btn:disabled:active {
  transform: none;
  filter: none;
}

.btn.btn-locked {
  cursor: not-allowed;
  opacity: 0.72;
  box-shadow: none;
  position: relative;
}

.btn.btn-locked:active {
  transform: none;
  filter: none;
}

.btn.btn-locked[data-lock-hint]:hover::after,
.btn.btn-locked[data-lock-hint]:focus-visible::after {
  content: attr(data-lock-hint);
  position: absolute;
  left: 50%;
  top: calc(100% + 6px);
  transform: translateX(-50%);
  font-family: "Baloo 2", "Trebuchet MS", sans-serif;
  font-size: 0.74rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  color: #fff;
  background: rgba(43, 27, 46, 0.9);
  border-radius: 8px;
  padding: 5px 8px;
  z-index: 6;
}

.login-error {
  margin-top: 16px;
  color: #c43056;
  font-weight: 600;
  display: none;
}

.login-error.show {
  display: block;
}

.layout {
  display: grid;
  grid-template-columns: 1.1fr 2.4fr;
  gap: 20px;
}

.panel {
  background: var(--panel);
  border-radius: var(--radius-md);
  padding: 18px;
  box-shadow: var(--shadow);
  border: 2px solid rgba(43, 27, 46, 0.08);
}

.panel-title {
  font-family: "Bungee", "Trebuchet MS", sans-serif;
  font-size: 1rem;
  text-transform: uppercase;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.timer {
  background: var(--ink);
  color: white;
  padding: 4px 10px;
  border-radius: 999px;
}

.boss-card {
  display: grid;
  gap: 12px;
}

.boss-portrait {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  border: 5px solid var(--ink);
  background: var(--cream);
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  box-shadow: var(--glow);
}

.case-panel .boss-card {
  gap: 14px;
}

.case-name {
  font-weight: 700;
  font-size: 1rem;
}

.case-history {
  margin-top: 8px;
  display: grid;
  gap: 6px;
  padding: 10px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.7);
  border: 1px dashed rgba(43, 27, 46, 0.2);
}

.case-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--ink-soft);
  font-weight: 700;
}

.history-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 111, 174, 0.15);
  border: 1px solid rgba(255, 111, 174, 0.4);
  font-weight: 600;
  font-size: 0.9rem;
}

.vitals-list {
  display: grid;
  gap: 6px;
}

.doctor-card {
  margin-top: 16px;
  padding: 14px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 2px dashed rgba(43, 27, 46, 0.2);
}

.doctor-label {
  font-size: 0.85rem;
  text-transform: uppercase;
  font-weight: 700;
  color: var(--ink-soft);
}

.doctor-name {
  font-weight: 700;
  margin-top: 6px;
}

.boss-portrait img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.08) brightness(1.08) contrast(1.03);
}

.boss-portrait .blush {
  position: absolute;
  width: 26px;
  height: 18px;
  border-radius: 999px;
  background: rgba(255, 111, 174, 0.5);
  bottom: 22px;
  right: 24px;
  filter: blur(1px);
}

.boss-status {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.status-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: rgba(255, 111, 174, 0.15);
  border: 1px solid rgba(255, 111, 174, 0.4);
  font-weight: 600;
}

.stage {
  margin: 16px 0;
  background: linear-gradient(180deg, #fff6f0 0%, #ffe6f0 55%, #ffd4e8 100%);
  border-radius: 18px;
  padding: 12px;
  position: relative;
  height: 230px;
  overflow: hidden;
}

.stage::before {
  content: "";
  position: absolute;
  inset: 20px 16px 28px;
  border-radius: 14px;
  border: 2px dashed rgba(43, 27, 46, 0.15);
}

.stage::after {
  content: "";
  position: absolute;
  left: 16px;
  right: 16px;
  top: 50%;
  height: 2px;
  background: linear-gradient(90deg, transparent 0%, rgba(255, 111, 174, 0.6) 20%, rgba(255, 193, 139, 0.7) 50%, rgba(255, 111, 174, 0.6) 80%, transparent 100%);
  opacity: 0.6;
}

.stage-label {
  position: absolute;
  top: 10px;
  left: 16px;
  padding: 4px 10px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  z-index: 2;
}

.stage-blood-kit {
  position: absolute;
  left: 50%;
  bottom: 12px;
  transform: translateX(-50%);
  display: grid;
  justify-items: center;
  gap: 6px;
  z-index: 4;
  pointer-events: none;
}

.stage-blood-kit.hidden {
  display: none;
}

.stage-blood-message {
  padding: 4px 12px;
  border-radius: 999px;
  border: 1px solid rgba(43, 27, 46, 0.2);
  background: rgba(255, 255, 255, 0.9);
  font-size: 0.76rem;
  font-weight: 700;
  color: var(--ink);
  white-space: nowrap;
}

.stage-blood-message.pop {
  animation: stage-blood-pop 0.3s ease;
}

.stage-blood-box {
  min-width: 160px;
  padding: 6px 10px 8px;
  border-radius: 12px;
  border: 2px solid rgba(43, 27, 46, 0.22);
  background: rgba(255, 255, 255, 0.9);
  display: grid;
  gap: 4px;
}

.stage-blood-box-label {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(43, 27, 46, 0.7);
}

.stage-blood-box-meter {
  height: 10px;
  border-radius: 999px;
  border: 2px solid rgba(43, 27, 46, 0.3);
  background: rgba(43, 27, 46, 0.08);
  overflow: hidden;
}

.stage-blood-fill {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #ff7ba9, #c43056);
  box-shadow: 0 0 10px rgba(196, 48, 86, 0.45);
  transition: width 0.9s ease;
}

.character {
  position: absolute;
  bottom: 10px;
  width: 120px;
  height: 170px;
  transition: transform 0.4s ease;
}

.character.patient {
  left: 10px;
}

.character.doctor {
  right: 10px;
}

.character .face {
  width: 94px;
  height: 94px;
  border-radius: 50%;
  background: var(--cream);
  border: 4px solid var(--ink);
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  overflow: hidden;
}

.character .face img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  filter: saturate(1.08) brightness(1.08) contrast(1.03);
}

.character.doctor .face img {
  object-position: 50% 30%;
}

.character .face::before,
.character .face::after {
  content: "";
  position: absolute;
  width: 18px;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 111, 174, 0.45);
  bottom: 18px;
  filter: blur(0.2px);
}

.character .face::before {
  left: 16px;
}

.character .face::after {
  right: 16px;
}

.character .body {
  width: 80px;
  height: 70px;
  background: linear-gradient(180deg, #d5ebff, #a9d3f5);
  border-radius: 24px;
  border: 3px solid var(--ink);
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  overflow: hidden;
}

.character.patient .body::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 8px;
  width: 34px;
  height: 22px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(227, 243, 255, 0.96));
  clip-path: polygon(0 0, 100% 0, 50% 100%);
  border-radius: 0 0 10px 10px;
}

.character.patient .body::after {
  content: "";
  position: absolute;
  left: 14px;
  right: 14px;
  bottom: 14px;
  height: 4px;
  border-radius: 999px;
  background: rgba(43, 27, 46, 0.18);
}

.character.doctor .body {
  background: linear-gradient(180deg, #ffffff, #eef5fb);
}

.character.doctor .body::before {
  content: "";
  position: absolute;
  left: 50%;
  top: 6px;
  width: 44px;
  height: 42px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, rgba(245, 250, 255, 0.92), rgba(230, 240, 248, 0.96));
  border-left: 2px solid rgba(43, 27, 46, 0.24);
  border-right: 2px solid rgba(43, 27, 46, 0.24);
  clip-path: polygon(0 0, 100% 0, 80% 100%, 50% 72%, 20% 100%);
}

.character.doctor .body::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 10px;
  width: 24px;
  height: 22px;
  transform: translateX(-50%);
  border: 3px solid rgba(43, 27, 46, 0.82);
  border-top: 0;
  border-radius: 0 0 14px 14px;
  background: radial-gradient(circle at 50% 96%, #8da6b8 0 4px, transparent 5px);
}

.character.doctor.walk-to {
  animation: walk-to 1.6s ease-in-out forwards;
}

.character.doctor.walk-back {
  animation: walk-back 1.6s ease-in-out forwards;
}

.blood-pop {
  position: absolute;
  top: -18px;
  right: 12px;
  background: var(--ink);
  color: white;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  white-space: nowrap;
}

.character .limb {
  width: 18px;
  height: 40px;
  background: var(--peach);
  border: 3px solid var(--ink);
  border-radius: 20px;
  position: absolute;
  bottom: 40px;
}

.character .limb.left {
  left: 6px;
  transform: rotate(-10deg);
}

.character .limb.right {
  right: 6px;
  transform: rotate(10deg);
}

.character .foot {
  width: 26px;
  height: 12px;
  background: var(--ink);
  border-radius: 12px;
  position: absolute;
  bottom: 6px;
}

.character .foot.left {
  left: 22px;
}

.character .foot.right {
  right: 22px;
}

.character.idle {
  animation: idle-bob 2.4s ease-in-out infinite;
}

.character.win {
  animation: win-hop 0.8s ease-in-out infinite;
}

.character.lose {
  animation: lose-droop 1.4s ease-in-out infinite;
}

.character.dance {
  animation: dance 0.6s ease-in-out infinite;
}

.character.patient .limb.left,
.character.patient .limb.right {
  animation: limb-sway 2.2s ease-in-out infinite;
}

.character.doctor .limb.left,
.character.doctor .limb.right {
  animation: limb-sway 1.8s ease-in-out infinite reverse;
}

.stage.blood-mode .character,
.stage.blood-mode .character .limb {
  animation: none !important;
}

.stage.blood-mode .character.doctor {
  transition: right 0.75s ease;
}

.stage.blood-mode .character.doctor::before {
  content: "";
  position: absolute;
  left: -46px;
  top: 96px;
  width: 52px;
  height: 12px;
  border-radius: 999px;
  border: 3px solid var(--ink);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.95), rgba(255, 186, 209, 0.88));
  opacity: 0;
  transform: rotate(-5deg);
  transform-origin: right center;
  transition: opacity 0.25s ease, transform 0.4s ease;
  z-index: 5;
}

.stage.blood-mode .character.doctor::after {
  content: "";
  position: absolute;
  left: -78px;
  top: 101px;
  width: 32px;
  height: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, #9cb0bf, #d4dee5);
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.4s ease;
  z-index: 5;
}

.stage.blood-mode.blood-approach .character.doctor,
.stage.blood-mode.blood-draw .character.doctor,
.stage.blood-mode.blood-seal .character.doctor {
  right: 162px;
}

.stage.blood-mode.blood-seal .character.doctor {
  right: 122px;
}

.stage.blood-mode.blood-done .character.doctor {
  right: 48px;
}

.stage.blood-mode.blood-approach .character.doctor::before,
.stage.blood-mode.blood-approach .character.doctor::after,
.stage.blood-mode.blood-draw .character.doctor::before,
.stage.blood-mode.blood-draw .character.doctor::after,
.stage.blood-mode.blood-seal .character.doctor::before,
.stage.blood-mode.blood-seal .character.doctor::after {
  opacity: 1;
}

.stage.blood-mode.blood-draw .character.doctor::before {
  transform: rotate(-9deg) translateX(-8px);
}

.stage.blood-mode.blood-draw .character.doctor::after {
  transform: rotate(-8deg) translateX(-8px);
}

.stage.blood-mode.blood-draw .stage-blood-box,
.stage.blood-mode.blood-seal .stage-blood-box {
  box-shadow: 0 0 0 2px rgba(255, 123, 169, 0.22), 0 0 18px rgba(196, 48, 86, 0.22);
}

.reduced-motion .character,
.reduced-motion .character .limb {
  animation: none !important;
  transition: none !important;
}

.reduced-motion .blood-procedure * {
  animation: none !important;
  transition: none !important;
}

.reduced-motion .heartbeat,
.reduced-motion .heartbeat-shockwave,
.reduced-motion .beat,
.reduced-motion .level-transition-card {
  animation: none !important;
  transition: none !important;
}

@keyframes idle-bob {

  0%,
  100% {
    transform: translateY(0);
  }

  50% {
    transform: translateY(-6px);
  }
}

@keyframes win-hop {

  0%,
  100% {
    transform: translateY(0) scale(1);
  }

  50% {
    transform: translateY(-14px) scale(1.02);
  }
}

@keyframes lose-droop {

  0%,
  100% {
    transform: translateY(0) rotate(0deg);
  }

  50% {
    transform: translateY(6px) rotate(-2deg);
  }
}

@keyframes dance {
  0% {
    transform: translateY(0) rotate(-2deg) scale(1);
  }

  50% {
    transform: translateY(-8px) rotate(2deg) scale(1.03);
  }

  100% {
    transform: translateY(0) rotate(-2deg) scale(1);
  }
}

@keyframes limb-sway {

  0%,
  100% {
    transform: rotate(-8deg);
  }

  50% {
    transform: rotate(12deg);
  }
}

@keyframes walk-to {
  from {
    transform: translateX(0);
  }

  to {
    transform: translateX(-120px);
  }
}

@keyframes walk-back {
  from {
    transform: translateX(-120px);
  }

  to {
    transform: translateX(0);
  }
}

@keyframes stage-blood-pop {
  0% {
    transform: scale(0.97);
    opacity: 0.55;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

.main-panel {
  min-height: 420px;
  display: grid;
  grid-template-rows: auto auto auto auto 1fr;
}

.level-title {
  font-family: "Bungee", "Trebuchet MS", sans-serif;
  font-size: 1.4rem;
  margin-bottom: 8px;
}

.instructions {
  color: var(--ink-soft);
  margin-bottom: 16px;
}

.game-area {
  border-radius: 20px;
  border: 2px dashed rgba(43, 27, 46, 0.3);
  min-height: 260px;
  display: grid;
  place-items: center;
  padding: 20px;
  color: var(--ink-soft);
  background: rgba(255, 255, 255, 0.55);
  position: relative;
  overflow: hidden;
}

.level-transition-card {
  position: absolute;
  inset: 14px;
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 8px;
  border-radius: 16px;
  border: 2px solid rgba(43, 27, 46, 0.2);
  background:
    radial-gradient(circle at 20% 18%, rgba(255, 255, 255, 0.5), transparent 30%),
    linear-gradient(135deg, rgba(255, 240, 246, 0.92), rgba(231, 248, 255, 0.9));
  opacity: 0;
  transform: translateY(18px) scale(0.96);
  transition: opacity 0.2s ease, transform 0.28s ease;
  text-align: center;
}

.level-transition-card.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.level-transition-card.exit {
  opacity: 0;
  transform: translateY(-10px) scale(1.02);
}

.level-transition-chip {
  padding: 6px 12px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: rgba(255, 255, 255, 0.86);
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.level-transition-title {
  font-family: "Bungee", "Trebuchet MS", sans-serif;
  font-size: 1.2rem;
  color: var(--ink);
}

.level-transition-subtitle {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--ink-soft);
  max-width: 90%;
}

.level-transition-start .level-transition-chip {
  background: rgba(183, 232, 255, 0.88);
}

.level-transition-next .level-transition-chip {
  background: rgba(168, 255, 212, 0.84);
}

.level-transition-retry .level-transition-chip {
  background: rgba(255, 193, 139, 0.84);
}

.blood-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  justify-content: center;
}

.blood-procedure {
  position: relative;
  --blood-reach-shift: -88px;
  --blood-seal-shift: -58px;
  --blood-done-shift: -32px;
  height: 146px;
  border: 2px solid rgba(43, 27, 46, 0.2);
  border-radius: 18px;
  background:
    radial-gradient(circle at 18% 58%, rgba(255, 190, 210, 0.65) 0 16%, transparent 18%),
    linear-gradient(120deg, rgba(255, 255, 255, 0.88), rgba(255, 241, 247, 0.88));
  overflow: hidden;
}

.blood-track {
  position: absolute;
  left: 14px;
  right: 14px;
  top: 24px;
  bottom: 10px;
}

.blood-track::before {
  content: "";
  position: absolute;
  left: 136px;
  right: 96px;
  top: 88px;
  border-top: 2px dashed rgba(43, 27, 46, 0.25);
  z-index: 1;
}

.blood-patient-robe {
  position: absolute;
  left: 4px;
  top: 62px;
  width: 172px;
  height: 54px;
  border-radius: 26px 28px 14px 18px;
  border: 2px solid rgba(43, 27, 46, 0.3);
  background: linear-gradient(140deg, #dff3ff, #b8dfff);
  box-shadow: inset 0 -8px 0 rgba(37, 120, 174, 0.2);
  z-index: 1;
}

.blood-patient-robe::after {
  content: "";
  position: absolute;
  left: 22px;
  top: 9px;
  width: 78px;
  height: 8px;
  border-radius: 999px;
  background: rgba(43, 27, 46, 0.16);
}

.blood-patient-arm {
  position: absolute;
  left: 16px;
  top: 72px;
  width: 142px;
  height: 30px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: linear-gradient(90deg, #ffd4bf, #ffc6a8);
  box-shadow: inset 0 -4px 0 rgba(0, 0, 0, 0.09);
  z-index: 2;
}

.blood-patient-arm::before {
  content: "";
  position: absolute;
  left: 18px;
  top: -2px;
  width: 20px;
  height: 30px;
  border-radius: 6px;
  background: rgba(190, 69, 111, 0.3);
  border-left: 2px solid rgba(43, 27, 46, 0.24);
  border-right: 2px solid rgba(43, 27, 46, 0.24);
}

.blood-patient-arm::after {
  content: "";
  position: absolute;
  right: 14px;
  top: 12px;
  width: 34px;
  height: 4px;
  border-radius: 999px;
  background: rgba(196, 48, 86, 0.38);
}

.blood-doctor-coat {
  position: absolute;
  right: -4px;
  top: 42px;
  width: 122px;
  height: 84px;
  border-radius: 20px 20px 16px 20px;
  border: 2px solid rgba(43, 27, 46, 0.32);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.96), rgba(237, 245, 251, 0.95));
  box-shadow: inset -12px -14px 0 rgba(43, 27, 46, 0.06);
  z-index: 3;
}

.blood-doctor-coat::before {
  content: "";
  position: absolute;
  left: 24px;
  top: 12px;
  width: 32px;
  height: 24px;
  border-radius: 0 0 14px 14px;
  border-left: 2px solid rgba(43, 27, 46, 0.25);
  border-right: 2px solid rgba(43, 27, 46, 0.25);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.98), rgba(232, 240, 246, 0.95));
}

.blood-stethoscope {
  position: absolute;
  right: 58px;
  top: 50px;
  width: 38px;
  height: 46px;
  border: 3px solid rgba(43, 27, 46, 0.72);
  border-top: 0;
  border-radius: 0 0 20px 20px;
  z-index: 4;
}

.blood-stethoscope::before {
  content: "";
  position: absolute;
  left: -5px;
  top: -6px;
  width: 10px;
  height: 12px;
  border-radius: 50%;
  background: #8aa0af;
  border: 2px solid rgba(43, 27, 46, 0.72);
}

.blood-stethoscope::after {
  content: "";
  position: absolute;
  right: -5px;
  top: -6px;
  width: 10px;
  height: 12px;
  border-radius: 50%;
  background: #8aa0af;
  border: 2px solid rgba(43, 27, 46, 0.72);
}

.blood-doctor-hand {
  position: absolute;
  right: 14px;
  top: 56px;
  width: 90px;
  height: 58px;
  border-radius: 20px 20px 16px 16px;
  border: 2px solid var(--ink);
  background: linear-gradient(130deg, #ffe4d3, #ffc9b0);
  transform: rotate(-5deg);
  box-shadow: inset -8px -10px 0 rgba(0, 0, 0, 0.08);
  z-index: 6;
}

.blood-doctor-hand::before {
  content: "";
  position: absolute;
  left: 10px;
  bottom: -7px;
  width: 66px;
  height: 18px;
  border-radius: 10px;
  border: 2px solid var(--ink);
  background: linear-gradient(90deg, #ffd6c0, #ffccb2);
}

.blood-syringe {
  position: absolute;
  right: 62px;
  top: 74px;
  width: 126px;
  height: 24px;
  transform: translateX(0) rotate(-4deg);
  transform-origin: right center;
  transition: transform 0.7s ease;
  z-index: 5;
}

.blood-needle {
  position: absolute;
  left: -28px;
  top: 10px;
  width: 30px;
  height: 4px;
  border-radius: 4px;
  background: linear-gradient(90deg, #9cb0bf, #d4dee5);
}

.blood-barrel {
  position: absolute;
  left: 0;
  top: 3px;
  width: 82px;
  height: 18px;
  border-radius: 8px;
  border: 2px solid var(--ink);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.95), rgba(255, 186, 209, 0.86));
}

.blood-plunger {
  position: absolute;
  right: 0;
  top: 0;
  width: 38px;
  height: 24px;
  border-radius: 6px;
  border: 2px solid var(--ink);
  background: linear-gradient(90deg, #a7b8c3, #ced8df);
  transition: transform 0.7s ease;
}

.blood-tube {
  position: absolute;
  left: 160px;
  top: 88px;
  width: 118px;
  height: 10px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: rgba(255, 255, 255, 0.46);
  overflow: hidden;
  z-index: 4;
}

.blood-tube::after {
  content: "";
  position: absolute;
  inset: 1px auto 1px 1px;
  width: 0;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(196, 48, 86, 0.85), rgba(255, 135, 172, 0.96));
  transition: width 1.1s ease;
}

.blood-vial {
  position: absolute;
  left: 284px;
  top: 70px;
  width: 34px;
  height: 44px;
  border-radius: 8px 8px 10px 10px;
  border: 2px solid var(--ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.92), rgba(255, 206, 221, 0.9));
  overflow: hidden;
  z-index: 3;
}

.blood-vial::before {
  content: "";
  position: absolute;
  left: 0;
  right: 0;
  top: -2px;
  height: 8px;
  background: #b2c2cb;
  border-bottom: 2px solid var(--ink);
}

.blood-vial::after {
  content: "";
  position: absolute;
  left: 2px;
  right: 2px;
  bottom: 2px;
  height: 0;
  border-radius: 4px;
  background: linear-gradient(180deg, rgba(255, 122, 162, 0.95), rgba(196, 48, 86, 0.95));
  transition: height 1.1s ease;
}

.blood-dialogue {
  position: absolute;
  left: 50%;
  top: 8px;
  transform: translateX(-50%);
  width: min(88%, 320px);
  padding: 5px 10px;
  border-radius: 999px;
  border: 1px solid rgba(43, 27, 46, 0.2);
  background: rgba(255, 255, 255, 0.88);
  text-align: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--ink);
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.8);
  z-index: 7;
}

.blood-dialogue:empty {
  display: none;
}

.blood-dialogue.pop {
  animation: blood-dialogue-pop 0.35s ease;
}

.blood-procedure.prep .blood-doctor-hand {
  animation: blood-hand-ready 0.9s ease-in-out infinite alternate;
}

.blood-procedure.reach .blood-syringe {
  transform: translateX(var(--blood-reach-shift)) rotate(-3deg);
}

.blood-procedure.draw .blood-plunger {
  transform: translateX(-14px);
}

.blood-procedure.draw .blood-tube::after {
  width: 96%;
}

.blood-procedure.draw .blood-vial::after {
  height: 18px;
}

.blood-procedure.seal .blood-syringe {
  transform: translateX(var(--blood-seal-shift)) rotate(-2deg);
}

.blood-procedure.seal .blood-vial::after {
  height: 26px;
}

.blood-procedure.done .blood-syringe {
  transform: translateX(var(--blood-done-shift)) rotate(-1deg);
}

.blood-procedure.done .blood-vial::after {
  height: 30px;
}

.blood-status {
  font-weight: 700;
  text-align: center;
  color: var(--ink);
}

.blood-report {
  background: #1b1a1f;
  color: #f4f2f6;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  padding: 14px;
  display: grid;
  gap: 8px;
  text-align: left;
}

.blood-report.hidden {
  display: none;
}

.report-grid {
  display: grid;
  grid-template-columns: 1.4fr 0.8fr 0.8fr 0.4fr;
  gap: 6px 10px;
  text-align: left;
  font-size: 0.85rem;
}

.report-grid>div {
  padding: 6px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.report-grid>div:nth-last-child(-n+4) {
  border-bottom: none;
}

.report-head {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: rgba(255, 255, 255, 0.7);
}

.report-flag {
  font-weight: 700;
  color: #ffb1c7;
}

.report-title {
  font-family: "Bungee", "Trebuchet MS", sans-serif;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.report-meta {
  font-size: 0.8rem;
  color: rgba(255, 255, 255, 0.65);
}

.report-row {
  font-weight: 600;
}

.mini-grid {
  display: grid;
  gap: 12px;
  width: 100%;
}

@keyframes blood-dialogue-pop {
  0% {
    transform: translateX(-50%) scale(0.98);
    opacity: 0.4;
  }
  100% {
    transform: translateX(-50%) scale(1);
    opacity: 1;
  }
}

@keyframes blood-hand-ready {
  from {
    transform: rotate(-5deg) translateY(0);
  }
  to {
    transform: rotate(-8deg) translateY(-4px);
  }
}

.triage-card {
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
  border: 2px dashed rgba(43, 27, 46, 0.2);
}

.triage-text {
  font-weight: 700;
  margin-bottom: 12px;
}

.triage-options {
  display: grid;
  gap: 10px;
}

.rx-card {
  padding: 16px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.75);
  border: 2px dashed rgba(43, 27, 46, 0.2);
  display: grid;
  gap: 10px;
}

.rx-title {
  font-family: "Bungee", "Trebuchet MS", sans-serif;
  font-size: 1rem;
}

.rx-item {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-weight: 600;
}

.rx-item.avoid {
  color: #c43056;
}

.rx-note {
  font-size: 0.9rem;
  color: var(--ink-soft);
  margin-top: 6px;
}

.tap-wrap {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  justify-content: center;
}

.pill {
  padding: 12px 18px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--cream);
  font-weight: 700;
  cursor: pointer;
}


.pill.correct {
  background: var(--mint);
}

/* --- Mobile Responsiveness --- */

/* Critical for game mechanics on touch devices */
.iv-drip,
.bandage,
.defib-slider,
.defib-area {
  touch-action: none;
}

@media (max-width: 768px) {
  #app {
    margin: 10px auto 30px;
    padding: 0 16px;
  }

  /* Stack the layout vertically */
  .layout {
    grid-template-columns: 1fr;
    gap: 16px;
  }

  /* Make panels more compact */
  .panel {
    padding: 16px;
  }

  .case-panel {
    order: 1;
  }

  .main-panel {
    order: 2;
  }

  /* Adjust Topbar */
  .topbar {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .toggles {
    width: 100%;
    justify-content: space-between;
  }

  .toggle {
    flex: 1;
    text-align: center;
    font-size: 0.9rem;
    padding: 8px 10px;
  }

  /* Adjust Typography */
  .title {
    font-size: 1.8rem;
    line-height: 1.2;
  }

  .subtitle {
    font-size: 0.95rem;
  }

  /* Compact Case File (Boss Card) */
  .boss-card {
    grid-template-columns: auto 1fr;
    align-items: center;
    gap: 12px;
  }

  .boss-portrait {
    width: 80px;
    height: 80px;
    border-width: 3px;
  }

  .case-panel .doctor-card {
    margin-top: 10px;
    padding: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  /* Hide detailed history initially or simplify on mobile to save space if needed */
  .case-history {
    font-size: 0.85rem;
    padding: 8px;
  }

  .history-pill {
    padding: 4px 10px;
    font-size: 0.8rem;
  }

  /* Game Area Adjustments */
  .stage {
    height: 150px;
    padding: 8px;
    max-width: 100%;
    overflow: hidden;
  }

  .stage-blood-kit {
    bottom: 8px;
    gap: 4px;
  }

  .stage-blood-message {
    font-size: 0.68rem;
    padding: 3px 9px;
  }

  .stage-blood-box {
    min-width: 126px;
    padding: 5px 8px 6px;
  }

  .stage-blood-box-label {
    font-size: 0.6rem;
  }

  .character {
    transform-origin: 50% 100%;
    transform: scale(0.75);
    bottom: 5px;
  }

  /* Force side-by-side positioning */
  .character.patient {
    left: 20px;
    bottom: 5px;
  }

  .character.doctor {
    right: 20px;
    bottom: 5px;
  }

  .stage.blood-mode.blood-approach .character.doctor,
  .stage.blood-mode.blood-draw .character.doctor {
    right: 110px;
  }

  .stage.blood-mode.blood-seal .character.doctor {
    right: 86px;
  }

  .stage.blood-mode.blood-done .character.doctor {
    right: 34px;
  }

  /* Login Screen */
  .login-card {
    margin: 40px auto;
    padding: 20px;
  }

  .login-card h1 {
    font-size: 1.6rem;
  }

  .btn {
    padding: 12px 20px;
    min-height: 46px;
    margin-bottom: 0;
  }

  .login-actions {
    flex-direction: column;
    width: 100%;
  }

  .login-actions .btn,
  .password-step .btn,
  .blood-actions .btn,
  .final-actions .btn,
  .modal-actions .btn {
    width: 100%;
  }

  /* Mini Grids in Games */
  .report-grid {
    font-size: 0.75rem;
    gap: 6px 4px;
  }

  .level-transition-card {
    inset: 10px;
    gap: 6px;
    padding: 0 8px;
  }

  .level-transition-title {
    font-size: 1rem;
  }

  .level-transition-subtitle {
    font-size: 0.8rem;
  }

  .blood-procedure {
    --blood-reach-shift: -66px;
    --blood-seal-shift: -44px;
    --blood-done-shift: -24px;
    height: 132px;
  }

  .blood-track::before {
    left: 116px;
    right: 82px;
    top: 80px;
  }

  .blood-patient-arm {
    width: 116px;
    left: 10px;
    top: 64px;
    height: 28px;
  }

  .blood-patient-robe {
    left: 4px;
    top: 56px;
    width: 138px;
    height: 46px;
  }

  .blood-patient-robe::after {
    left: 18px;
    width: 62px;
  }

  .blood-patient-arm::before {
    width: 16px;
    height: 28px;
    left: 14px;
  }

  .blood-patient-arm::after {
    width: 28px;
    top: 11px;
  }

  .blood-doctor-hand {
    width: 72px;
    height: 48px;
    right: 10px;
    top: 52px;
  }

  .blood-doctor-coat {
    right: -2px;
    top: 42px;
    width: 94px;
    height: 68px;
  }

  .blood-stethoscope {
    right: 46px;
    top: 48px;
    width: 28px;
    height: 34px;
    border-width: 2px;
  }

  .blood-stethoscope::before,
  .blood-stethoscope::after {
    width: 8px;
    height: 10px;
    top: -5px;
    border-width: 2px;
  }

  .blood-syringe {
    width: 102px;
    right: 42px;
    top: 66px;
  }

  .blood-barrel {
    width: 66px;
  }

  .blood-tube {
    left: 118px;
    width: 84px;
    top: 80px;
    height: 9px;
  }

  .blood-vial {
    left: 208px;
    width: 28px;
    top: 62px;
    height: 38px;
  }

  .blood-dialogue {
    top: 6px;
    width: min(90%, 260px);
    font-size: 0.74rem;
    padding: 4px 8px;
  }

  .heartbeat {
    height: 108px;
    padding: 14px 10px;
  }

  .heartbeat-beats {
    gap: 6px;
  }

  .beat {
    width: 16px;
    height: 16px;
  }

  .iv-track {
    /* Ensure track fits on screen */
    height: 220px;
  }

  .bandage-area {
    transform: scale(0.88);
    transform-origin: top center;
    margin-bottom: -18px;
  }

  /* Final Screen Buttons */
  .final-buttons {
    display: flex;
    flex-direction: column;
    gap: 12px;
    align-items: center;
    position: relative;
    height: 220px;
    /* Give room for running button */
  }

  .final-no {
    position: absolute;
    /* Keep absolute for the running mechanic */
  }

  /* Toast & Achievements */
  .bottom-bar {
    flex-direction: column-reverse;
    /* Important info top */
    gap: 16px;
    text-align: center;
  }

  .combo {
    justify-content: center;
    display: flex;
    gap: 16px;
  }

}

@media (max-width: 380px) {

  /* Extra small screens */
  .title {
    font-size: 1.5rem;
  }

  .character {
    transform: scale(0.75);
  }

  .stage {
    height: 170px;
  }
}

.pill.wrong {
  background: #ffd1df;
}

.heartbeat {
  position: relative;
  width: 100%;
  height: 120px;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.7);
  border: 2px dashed rgba(43, 27, 46, 0.2);
  padding: 18px 16px;
}

.heartbeat.pulse {
  animation: heartbeat-shell-pulse 0.26s ease-out;
}

.heartbeat-beats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  height: 100%;
  gap: 8px;
}

.beat {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  border: 2px solid var(--ink);
  background: var(--cream);
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}

.beat.active {
  background: var(--pink);
  transform: scale(1.2);
  box-shadow: var(--glow);
}

.beat.incoming {
  animation: beat-incoming 0.2s ease-out;
  background: rgba(255, 111, 174, 0.35);
}

.beat.hit {
  background: var(--mint);
}

.beat.perfect {
  background: linear-gradient(160deg, #ffc18b, #ff6fae);
  transform: scale(1.26);
}

.beat.late {
  background: #ffd1df;
}

.heartbeat-shockwave {
  position: absolute;
  width: 34px;
  height: 34px;
  left: calc(50% - 17px);
  top: calc(50% - 17px);
  border-radius: 50%;
  border: 2px solid rgba(255, 111, 174, 0.5);
  opacity: 0;
  pointer-events: none;
}

.heartbeat-shockwave.fire {
  animation: heartbeat-wave-fire 0.34s ease-out;
}

.pulse-marker {
  position: absolute;
  bottom: 16px;
  left: 50%;
  width: 8px;
  height: 60px;
  transform: translateX(-50%);
  background: linear-gradient(180deg, transparent 0%, var(--pink) 50%, transparent 100%);
  opacity: 0.6;
}

@keyframes heartbeat-shell-pulse {
  0% {
    transform: scale(1);
  }
  55% {
    transform: scale(1.018);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes heartbeat-wave-fire {
  0% {
    transform: scale(0.6);
    opacity: 0.7;
  }
  100% {
    transform: scale(2.2);
    opacity: 0;
  }
}

@keyframes beat-incoming {
  0% {
    transform: scale(1);
  }
  100% {
    transform: scale(1.16);
  }
}

.iv-setup {
  display: grid;
  justify-items: center;
  gap: 6px;
  margin-bottom: 4px;
}

.iv-bag {
  width: 72px;
  height: 92px;
  border-radius: 14px;
  border: 3px solid var(--ink);
  background: linear-gradient(180deg, rgba(183, 232, 255, 0.88), rgba(255, 255, 255, 0.84));
  position: relative;
  box-shadow: var(--shadow);
}

.iv-bag::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 50%;
  transform: translateX(-50%);
  width: 24px;
  height: 10px;
  border: 2px solid var(--ink);
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.9);
}

.iv-bag-label {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 0.8rem;
  font-weight: 800;
  color: var(--ink);
}

.iv-hose {
  width: 4px;
  height: 28px;
  border-radius: 999px;
  background: rgba(67, 98, 118, 0.45);
}

.iv-track {
  width: 70px;
  height: 250px;
  margin: 0 auto;
  border-radius: 30px;
  border: 3px solid var(--ink);
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(240, 249, 255, 0.9));
  position: relative;
  overflow: hidden;
  touch-action: none;
}

.iv-instructions {
  text-align: center;
  font-weight: 600;
  color: var(--ink);
}

.iv-progress {
  height: 14px;
  width: 100%;
  border-radius: 999px;
  background: rgba(43, 27, 46, 0.12);
  overflow: hidden;
}

.iv-progress span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--mint), var(--pink));
}

.iv-zone {
  position: absolute;
  left: 10px;
  right: 10px;
  border-radius: 999px;
  background: rgba(168, 255, 212, 0.55);
  border: 2px solid rgba(43, 27, 46, 0.35);
  display: grid;
  place-items: center;
}

.iv-zone span {
  font-size: 0.58rem;
  letter-spacing: 0.04em;
  font-weight: 800;
  color: rgba(43, 27, 46, 0.65);
}

.iv-drip {
  position: absolute;
  left: 50%;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: linear-gradient(180deg, #ff94bf, #ff5a9a);
  border: 2px solid rgba(43, 27, 46, 0.55);
  transform: translateX(-50%);
  box-shadow: var(--glow);
  touch-action: none;
}

.bandage-area {
  position: relative;
  width: 320px;
  height: 280px;
  margin: 0 auto;
  touch-action: none;
}

.heart {
  position: absolute;
  top: 24px;
  left: 50%;
  width: 170px;
  height: 150px;
  background: var(--pink);
  transform: translateX(-50%) rotate(-45deg);
  border-radius: 18px 18px 6px 6px;
  box-shadow: var(--glow);
  z-index: 1;
}

.heart::before,
.heart::after {
  content: "";
  position: absolute;
  width: 170px;
  height: 150px;
  border-radius: 50%;
  background: var(--pink);
}

.heart::before {
  top: -76px;
  left: 0;
}

.heart::after {
  top: 0;
  left: 85px;
}

.bandage-target {
  position: absolute;
  width: 56px;
  height: 18px;
  border-radius: 999px;
  border: 2px dashed rgba(43, 27, 46, 0.42);
  background: rgba(255, 255, 255, 0.35);
  z-index: 2;
}

.bandage-target.filled {
  border-style: solid;
  background: rgba(255, 193, 139, 0.7);
}

.bandage {
  position: absolute;
  width: 70px;
  height: 22px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--cream);
  display: grid;
  place-items: center;
  font-weight: 700;
  cursor: grab;
  z-index: 3;
  touch-action: none;
}

.bandage.placed {
  cursor: default;
  background: var(--peach);
}

.defib-area {
  height: 140px;
  border-radius: 18px;
  border: 2px dashed rgba(43, 27, 46, 0.25);
  background: rgba(255, 255, 255, 0.7);
  display: grid;
  place-items: center;
  font-weight: 700;
  text-align: center;
  padding: 10px;
}

.defib-slider {
  width: 100%;
  accent-color: var(--pink);
}

.charge-bar {
  height: 14px;
  width: 100%;
  border-radius: 999px;
  background: rgba(43, 27, 46, 0.12);
  overflow: hidden;
}

.charge-bar span {
  display: block;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--sky), var(--pink));
}

.roulette {
  width: 200px;
  height: 200px;
  border-radius: 50%;
  border: 6px solid var(--ink);
  background: conic-gradient(var(--pink) 0deg 72deg, var(--peach) 72deg 144deg, var(--mint) 144deg 216deg, var(--sky) 216deg 288deg, #ffe2f0 288deg 360deg);
  position: relative;
  margin: 0 auto;
}

.roulette::after {
  content: \"LOVE OVERDOSE\";
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-weight: 700;
  color: var(--ink);
}

.stitch-line {
  width: 100%;
  height: 120px;
  border: 2px dashed var(--ink-soft);
  border-radius: 18px;
  display: grid;
  place-items: center;
  gap: 10px;
}

.stitch-button {
  border-radius: 12px;
  border: 2px solid var(--ink);
  padding: 10px 18px;
  background: var(--cream);
  cursor: pointer;
  font-weight: 700;
}

.bingo-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  width: 100%;
}

.bingo-cell {
  background: var(--cream);
  border: 2px solid var(--ink);
  border-radius: 12px;
  min-height: 70px;
  display: grid;
  place-items: center;
  text-align: center;
  padding: 6px;
  cursor: pointer;
  font-weight: 700;
}

.bingo-cell.revealed {
  background: var(--mint);
}

.cpr-button {
  font-family: \"Bungee\", \"Trebuchet MS\", sans-serif;
  font-size: 1rem;
  padding: 18px 30px;
  border-radius: 999px;
  border: none;
  background: var(--pink);
  color: white;
  cursor: pointer;
  box-shadow: var(--shadow);
}

.checkbox-group {
  display: grid;
  gap: 12px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 600;
}

.sign-button {
  margin-top: 12px;
  padding: 12px 24px;
  border-radius: 999px;
  background: var(--ink);
  color: white;
  border: none;
  cursor: pointer;
  font-weight: 700;
}

.final-screen {
  display: grid;
  gap: 16px;
  text-align: center;
  width: 100%;
}

.final-screen h2 {
  font-family: "Bungee", "Trebuchet MS", sans-serif;
  font-size: 1.5rem;
  color: var(--ink);
}

.final-buttons {
  display: flex;
  gap: 16px;
  justify-content: center;
  align-items: flex-start;
  flex-wrap: wrap;
  position: relative;
  min-height: 220px;
  padding-top: 6px;
}

.final-yes {
  background: var(--pink);
  color: white;
  border: none;
  padding: 12px 28px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
  transform-origin: center;
}

.final-no {
  position: absolute;
  background: var(--sky);
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: 10px 20px;
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
  user-select: none;
  touch-action: none;
  will-change: left, top, transform;
}

.final-no.evasive {
  transform: rotate(-2deg);
}

.final-message {
  font-weight: 700;
  color: var(--ink);
}

.final-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
  flex-wrap: wrap;
  margin-top: 6px;
}

.final-actions.hidden {
  display: none;
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 16px;
  background: var(--pink);
  opacity: 0.9;
  border-radius: 3px;
  animation: confetti-fall 2.6s ease-in-out forwards;
}

@keyframes confetti-fall {
  0% {
    transform: translateY(-20px) rotate(0deg);
    opacity: 0;
  }

  10% {
    opacity: 1;
  }

  100% {
    transform: translateY(520px) rotate(320deg);
    opacity: 0;
  }
}

.meters .meter {
  display: grid;
  gap: 6px;
  margin-bottom: 16px;
}

.meter-bar {
  height: 14px;
  background: rgba(43, 27, 46, 0.12);
  border-radius: 999px;
  overflow: hidden;
}

.meter-bar span {
  display: block;
  height: 100%;
  width: 50%;
  background: linear-gradient(90deg, var(--pink), var(--peach));
}

.meter-value {
  font-weight: 700;
}

.bottom-bar {
  margin-top: 18px;
  display: flex;
  flex-wrap: wrap;
  justify-content: space-between;
  gap: 16px;
}

.achievements {
  background: var(--panel);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  border: 2px solid rgba(43, 27, 46, 0.08);
  flex: 1 1 300px;
}

.combo {
  display: flex;
  gap: 16px;
  background: var(--panel);
  border-radius: var(--radius-md);
  padding: 14px 18px;
  box-shadow: var(--shadow);
  border: 2px solid rgba(43, 27, 46, 0.08);
  flex-wrap: wrap;
}

.toast {
  position: fixed;
  bottom: 30px;
  right: 30px;
  background: var(--ink);
  color: white;
  padding: 12px 18px;
  border-radius: 999px;
  box-shadow: var(--shadow);
}

.toast.hidden {
  display: none;
}

.confetti {
  position: fixed;
  inset: 0;
  pointer-events: none;
}

.confetti.hidden {
  display: none;
}

@media (max-width: 1024px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .character {
    position: relative;
    margin: 0 auto;
  }

  .stage {
    height: auto;
  }
}

@media (max-width: 640px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .login-card {
    margin: 40px auto;
  }
}

/* Mobile-first gameplay HUD and touch ergonomics */
@media (max-width: 768px) {
  .bottom-bar {
    position: static;
    margin-top: 14px;
    gap: 10px;
    padding: 0;
    border: 0;
    background: transparent;
    box-shadow: none;
  }

  .achievements {
    flex: 1 1 100%;
    padding: 10px 12px;
    border-radius: 14px;
    background: rgba(255, 255, 255, 0.75);
    box-shadow: none;
  }

  .achievements .badge {
    margin-bottom: 6px;
    padding: 4px 10px;
    font-size: 0.72rem;
  }

  #achievement-list {
    font-size: 0.85rem;
    line-height: 1.25;
    max-height: 2.8em;
    overflow: auto;
  }

  .combo {
    width: 100%;
    padding: 0;
    gap: 8px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    background: transparent;
    border: 0;
    box-shadow: none;
  }

  .combo > div {
    padding: 8px 6px;
    border-radius: 12px;
    text-align: center;
    font-size: 0.8rem;
    font-weight: 700;
    background: rgba(255, 255, 255, 0.78);
    border: 1px solid rgba(43, 27, 46, 0.14);
  }

  .game-area {
    min-height: 280px;
    padding: 14px 12px;
  }

  #game-screen button,
  #game-screen .pill {
    min-height: 48px;
  }

  #game-screen .beat {
    width: 22px;
    height: 22px;
  }

  .final-buttons {
    min-height: 250px;
  }

  .toast {
    left: 12px;
    right: 12px;
    bottom: calc(12px + env(safe-area-inset-bottom));
    text-align: center;
    border-radius: 14px;
  }
}

@media (max-width: 420px) {
  .bottom-bar {
    margin-top: 12px;
  }

  .combo {
    gap: 6px;
  }

  .combo > div {
    font-size: 0.74rem;
    padding: 7px 4px;
  }

  .achievements {
    padding: 8px 10px;
  }
}

/* Reduced-motion: disable most transitions/animations */
.reduced-motion * {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
  scroll-behavior: auto !important;
}

/* Theme presets (swap CSS variables) */
body.theme-pink {
  --pink: #ff6fae;
  --sky: #b7e8ff;
  --mint: #a8ffd4;
  --peach: #ffc18b;
}

body.theme-sky {
  --pink: #4aa3ff;
  --sky: #b7e8ff;
  --mint: #a8ffd4;
  --peach: #ffd38a;
  --glow: 0 0 20px rgba(74, 163, 255, 0.28);
}

body.theme-mint {
  --pink: #15c98b;
  --sky: #b7e8ff;
  --mint: #a8ffd4;
  --peach: #ffc18b;
  --glow: 0 0 20px rgba(21, 201, 139, 0.28);
}

body.theme-midnight {
  color-scheme: light;
  --ink: #1f1533;
  --ink-soft: #3d2c63;
  --cream: #fff5e8;
  --pink: #8b5cf6;
  --sky: #60a5fa;
  --mint: #34d399;
  --peach: #fbbf24;
  --panel: rgba(255, 255, 255, 0.84);
  --shadow: 0 18px 40px rgba(31, 21, 51, 0.18);
  --glow: 0 0 20px rgba(139, 92, 246, 0.28);
}

body.theme-sunset {
  --pink: #ff5a7a;
  --sky: #ffd1a6;
  --mint: #a8ffd4;
  --peach: #ffb37e;
  --glow: 0 0 20px rgba(255, 90, 122, 0.28);
}

/* Modal (certificate) */
.modal.hidden {
  display: none;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
}

.modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(43, 27, 46, 0.55);
  backdrop-filter: blur(6px);
}

.modal-panel {
  position: relative;
  width: min(920px, 100%);
  max-height: min(92vh, 980px);
  overflow: auto;
  background: var(--panel);
  border-radius: var(--radius-lg);
  border: 2px solid rgba(43, 27, 46, 0.12);
  box-shadow: var(--shadow);
  padding: 18px;
}

.modal-close {
  position: sticky;
  top: 10px;
  margin-left: auto;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  border: 2px solid var(--ink);
  background: var(--cream);
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.modal-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
  flex-wrap: wrap;
  margin-top: 14px;
}

.modal-footnote {
  margin-top: 8px;
  color: var(--ink-soft);
  font-size: 0.9rem;
}

/* Certificate layout (single-page memory-first) */
.certificate-paper {
  width: min(794px, 100%);
  margin: 8px auto 0;
  background: radial-gradient(circle at top, #ffe2f0 0%, #fff5e8 45%, #dff9ff 100%);
  border-radius: 22px;
  border: 2px solid rgba(43, 27, 46, 0.12);
  padding: 18px;
}

.certificate-paper.export-static,
.certificate-paper.preview-static {
  width: 794px !important;
  max-width: none !important;
  margin: 0 !important;
}

.certificate-paper.certificate-locked-preview {
  position: relative;
  overflow: hidden;
}

.certificate-paper.certificate-locked-preview > .certificate-hero,
.certificate-paper.certificate-locked-preview > .certificate-memory-strip,
.certificate-paper.certificate-locked-preview > .certificate-grid {
  filter: blur(1.8px);
}

.certificate-hero {
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid rgba(43, 27, 46, 0.1);
  border-radius: 18px;
  padding: 14px;
}

.certificate-head {
  display: flex;
  justify-content: space-between;
  gap: 14px;
  align-items: flex-start;
}

.certificate-title {
  font-family: "Bungee", "Trebuchet MS", sans-serif;
  font-size: clamp(1.05rem, 1.9vw, 1.35rem);
  letter-spacing: 0.35px;
}

.certificate-meta {
  color: var(--ink-soft);
  font-size: 0.9rem;
  margin-top: 6px;
}

.certificate-hero-row {
  margin-top: 10px;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 12px;
  align-items: center;
}

.certificate-avatars {
  display: flex;
  gap: 10px;
  align-items: center;
}

.certificate-avatar {
  width: 68px;
  height: 68px;
  border-radius: 50%;
  border: 4px solid var(--ink);
  overflow: hidden;
  background: var(--cream);
  box-shadow: var(--glow);
}

.certificate-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.certificate-story {
  border: 1px dashed rgba(255, 111, 174, 0.35);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.75);
  padding: 10px 12px;
  line-height: 1.35;
  font-weight: 700;
}

.certificate-approval-stamp {
  width: 132px;
  height: 132px;
  border-radius: 50%;
  border: 5px solid #ba1028;
  background: radial-gradient(circle at 50% 50%, rgba(255, 240, 242, 0.9) 0%, rgba(255, 207, 213, 0.82) 100%);
  box-shadow: inset 0 0 0 3px rgba(186, 16, 40, 0.18), 0 10px 18px rgba(186, 16, 40, 0.2);
  display: grid;
  place-items: center;
  transform: rotate(-8deg);
  position: relative;
}

.certificate-approval-stamp::before {
  content: "";
  position: absolute;
  inset: 10px;
  border-radius: 50%;
  border: 2px dashed rgba(186, 16, 40, 0.7);
}

.certificate-approval-inner {
  position: relative;
  display: grid;
  text-align: center;
  line-height: 1.1;
  color: #93061a;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  z-index: 1;
}

.certificate-approval-inner span {
  font-size: 0.73rem;
  font-weight: 800;
}

.certificate-approval-inner strong {
  font-family: "Bungee", "Trebuchet MS", sans-serif;
  font-size: 1rem;
}

.certificate-memory-strip {
  margin-top: 10px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 10px;
}

.certificate-memory-card {
  background: rgba(255, 255, 255, 0.88);
  border: 1px solid rgba(43, 27, 46, 0.14);
  border-radius: 14px;
  padding: 10px 11px;
}

.certificate-memory-label {
  color: var(--ink-soft);
  font-size: 0.77rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 800;
}

.certificate-memory-value {
  margin-top: 4px;
  font-weight: 700;
  line-height: 1.3;
  font-size: 0.9rem;
}

.certificate-grid {
  margin-top: 10px;
  display: grid;
  gap: 10px;
}

.certificate-grid-compact {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.certificate-section {
  background: rgba(255, 255, 255, 0.86);
  border: 1px dashed rgba(43, 27, 46, 0.18);
  border-radius: 16px;
  padding: 11px 12px;
}

.certificate-section h3 {
  font-family: "Bungee", "Trebuchet MS", sans-serif;
  font-size: 0.89rem;
  letter-spacing: 0.04em;
  margin-bottom: 8px;
}

.certificate-kv {
  display: grid;
  grid-template-columns: minmax(98px, auto) 1fr;
  gap: 6px 10px;
  font-weight: 600;
  font-size: 0.9rem;
}

.certificate-kv .muted {
  color: var(--ink-soft);
  font-weight: 700;
}

.certificate-vitals .history-pill {
  font-size: 0.82rem;
  padding: 4px 9px;
}

.certificate-procedure-list {
  display: grid;
  gap: 7px;
}

.certificate-procedure-item {
  border: 1px solid rgba(43, 27, 46, 0.1);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.65);
  padding: 7px 9px;
}

.certificate-procedure-title {
  font-weight: 800;
  font-size: 0.84rem;
}

.certificate-procedure-text {
  font-size: 0.84rem;
  color: var(--ink-soft);
}

.certificate-note {
  margin-top: 8px;
  padding: 9px 10px;
  border-radius: 12px;
  background: rgba(255, 111, 174, 0.12);
  border: 1px solid rgba(255, 111, 174, 0.22);
  font-weight: 800;
  font-size: 0.89rem;
}

.certificate-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 14px;
  border: 1px solid rgba(43, 27, 46, 0.12);
}

.certificate-table th,
.certificate-table td {
  text-align: left;
  padding: 8px 10px;
  font-size: 0.92rem;
  border-bottom: 1px solid rgba(43, 27, 46, 0.1);
  vertical-align: top;
}

.certificate-table th {
  background: rgba(255, 111, 174, 0.14);
  font-weight: 800;
}

@media (max-width: 860px) {
  .certificate-paper:not(.preview-static):not(.export-static) .certificate-head {
    flex-wrap: wrap;
  }

  .certificate-paper:not(.preview-static):not(.export-static) .certificate-hero-row {
    grid-template-columns: 1fr;
  }

  .certificate-paper:not(.preview-static):not(.export-static) .certificate-memory-strip,
  .certificate-paper:not(.preview-static):not(.export-static) .certificate-grid-compact {
    grid-template-columns: 1fr;
  }

  .certificate-paper:not(.preview-static):not(.export-static) .certificate-approval-stamp {
    width: 112px;
    height: 112px;
  }
}
