:root {
  --red: #e6392f;
  --red-dark: #b32219;
  --ink: #1d1a17;
  --paper: #fffdf6;
  --cream: #fff3d6;
  --font-display: 'Baloo 2', 'Trebuchet MS', sans-serif;
  --font-hand: 'Patrick Hand', 'Comic Sans MS', cursive;
}

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

html, body {
  width: 100%; height: 100%;
  overflow: hidden;
  background: #0d0b14;
  font-family: var(--font-display);
  -webkit-user-select: none; user-select: none;
}

#app, #labels {
  position: fixed; inset: 0;
}
#app canvas { display: block; }
#labels { pointer-events: none; z-index: 5; overflow: hidden; }

.hidden { display: none !important; }
.ui { z-index: 20; }

/* ---------- film vignette + grain ---------- */
#vignette {
  position: fixed; inset: 0; z-index: 10; pointer-events: none;
  background:
    radial-gradient(ellipse at center, transparent 55%, rgba(20, 8, 4, 0.35) 100%);
}
#vignette::after {
  content: ''; position: absolute; inset: 0; opacity: 0.05; mix-blend-mode: overlay;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 200 200' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='2'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

/* ---------- intro ---------- */
#intro {
  position: fixed; inset: 0; z-index: 100;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #2a1e3f 0%, #120d1c 70%);
  transition: opacity 1.2s ease;
}
#intro.fading { opacity: 0; pointer-events: none; }
.intro-card { text-align: center; color: var(--paper); padding: 24px; animation: floatIn 0.9s ease both; }
@keyframes floatIn { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: none; } }
.intro-logo {
  font-weight: 800; font-size: clamp(42px, 8vw, 84px); letter-spacing: 2px; line-height: 0.95;
  text-shadow: 0 6px 0 rgba(0,0,0,0.35);
}
.intro-logo span { color: var(--red); display: block; font-size: 0.62em; letter-spacing: 12px; margin-left: 6px; }
.intro-sub { font-family: var(--font-hand); font-size: clamp(18px, 3vw, 26px); color: var(--cream); margin-top: 14px; }
.intro-desc { font-size: clamp(13px, 2vw, 17px); opacity: 0.75; margin-top: 12px; line-height: 1.5; }
#enterBtn {
  margin-top: 28px; padding: 14px 44px; font-family: var(--font-display); font-weight: 800; font-size: 20px;
  color: #fff; background: var(--red); border: 3px solid #fff; border-radius: 999px; cursor: pointer;
  box-shadow: 0 6px 0 var(--red-dark), 0 14px 30px rgba(0,0,0,0.5);
  transition: transform 0.12s ease, box-shadow 0.12s ease;
}
#enterBtn:hover { transform: translateY(-2px) scale(1.03); }
#enterBtn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--red-dark); }
.intro-hint { margin-top: 22px; font-size: 13px; opacity: 0.55; }

/* ---------- brand ---------- */
#brand { position: fixed; top: 18px; left: 22px; color: var(--paper); text-shadow: 0 2px 0 rgba(0,0,0,0.4); pointer-events: none; }
.brand-logo { font-weight: 800; font-size: 26px; letter-spacing: 1px; line-height: 1; }
.brand-logo span { color: var(--red); margin-left: 6px; }
.brand-tag { font-family: var(--font-hand); font-size: 13px; opacity: 0.75; margin-top: 2px; }

/* ---------- camera buttons ---------- */
#camControls { position: fixed; top: 18px; right: 22px; display: flex; gap: 8px; }
.cam-btn {
  font-family: var(--font-display); font-weight: 700; font-size: 14px; color: var(--paper);
  background: rgba(20, 15, 25, 0.72); border: 2px solid rgba(255,255,255,0.25); border-radius: 999px;
  padding: 8px 16px; cursor: pointer; backdrop-filter: blur(6px); transition: all 0.15s ease;
}
.cam-btn:hover { border-color: rgba(255,255,255,0.6); }
.cam-btn.active { background: var(--red); border-color: #fff; box-shadow: 0 3px 0 var(--red-dark); }
.cam-btn.muted { opacity: 0.5; }

/* ---------- ticker ---------- */
#ticker {
  position: fixed; bottom: 20px; left: 50%; transform: translateX(-50%);
  max-width: min(640px, 86vw);
  background: rgba(20, 15, 25, 0.78); color: var(--cream);
  border: 2px solid rgba(255, 220, 160, 0.3); border-radius: 999px;
  padding: 9px 22px; font-family: var(--font-hand); font-size: 16px; text-align: center;
  backdrop-filter: blur(6px); pointer-events: none;
  transition: opacity 0.5s ease; opacity: 0;
}
#ticker.show { opacity: 1; }

/* ---------- speech bubbles ---------- */
.bubble {
  position: relative;
  font-family: var(--font-hand); font-size: 14.5px; line-height: 1.22; color: var(--ink);
  background: var(--paper); border: 2.5px solid var(--ink); border-radius: 13px;
  padding: 7px 12px; max-width: 200px; text-align: center;
  box-shadow: 3px 4px 0 rgba(0,0,0,0.28);
  transform-origin: 50% 100%;
  animation: bubblePop 0.25s cubic-bezier(0.34, 1.56, 0.64, 1) both;
  white-space: normal; width: max-content;
}
.bubble::after {
  content: ''; position: absolute; left: 50%; bottom: -12px; transform: translateX(-50%);
  border: 7px solid transparent; border-top: 12px solid var(--ink); border-bottom: 0;
}
.bubble::before {
  content: ''; position: absolute; left: 50%; bottom: -8px; transform: translateX(-50%); z-index: 1;
  border: 5.5px solid transparent; border-top: 10px solid var(--paper); border-bottom: 0;
}
.bubble.fade { animation: bubbleOut 0.22s ease both; }
@keyframes bubblePop { from { opacity: 0; transform: scale(0.4) translateY(8px); } to { opacity: 1; transform: scale(1); } }
@keyframes bubbleOut { to { opacity: 0; transform: scale(0.6) translateY(6px); } }

.bubble.shout {
  background: #ffe23e; border-color: var(--ink); font-weight: 700; font-size: 18px;
  border-radius: 6px; transform: rotate(-2deg);
  box-shadow: 4px 5px 0 rgba(0,0,0,0.3);
  animation: shoutPop 0.35s cubic-bezier(0.34, 1.8, 0.64, 1) both;
}
.bubble.shout::before { border-top-color: #ffe23e; }
@keyframes shoutPop { from { opacity: 0; transform: scale(0.2) rotate(-14deg); } to { opacity: 1; transform: scale(1) rotate(-2deg); } }

.bubble.note {
  background: var(--cream); text-align: left; font-size: 13.5px; border-radius: 8px;
  box-shadow: 3px 4px 0 rgba(0,0,0,0.28), inset 0 0 0 1px rgba(160, 120, 40, 0.2);
}
.bubble.note::before { border-top-color: var(--cream); }
.bubble.note .note-title { font-family: var(--font-display); font-weight: 700; font-size: 12px; color: var(--red-dark); letter-spacing: 0.5px; margin-bottom: 4px; }
.bubble.note .note-line { opacity: 0; animation: noteLine 0.3s ease both; }
.bubble.note .note-line b { color: #6b4a12; }
@keyframes noteLine { from { opacity: 0; transform: translateX(-6px); } to { opacity: 1; transform: none; } }

/* name tag shown on hover/click */
.nametag {
  font-family: var(--font-display); font-weight: 700; font-size: 12px; color: #fff;
  background: rgba(20, 15, 25, 0.85); border: 1.5px solid rgba(255,255,255,0.4);
  padding: 3px 10px; border-radius: 999px; white-space: nowrap;
  animation: bubblePop 0.2s ease both;
}
.nametag .role { font-weight: 500; opacity: 0.75; font-size: 11px; }
.nametag.boss { background: var(--red); border-color: #fff; }

/* ---------- phone ---------- */
#phone {
  position: fixed; right: 20px; bottom: 20px; width: 292px;
  background: #14121c; border: 3px solid #2e2a3d; border-radius: 26px;
  box-shadow: 0 18px 44px rgba(0,0,0,0.55), inset 0 0 0 2px rgba(255,255,255,0.05);
  overflow: hidden; transition: height 0.35s cubic-bezier(0.4, 1.3, 0.5, 1);
  height: 400px; display: flex; flex-direction: column;
}
#phone.collapsed { height: 58px; }
#phoneHead { position: relative; padding: 12px 16px 10px; cursor: pointer; background: linear-gradient(180deg, #201c2e, #191624); flex: 0 0 auto; }
.ph-notch { position: absolute; top: 5px; left: 50%; transform: translateX(-50%); width: 64px; height: 5px; border-radius: 3px; background: #000; }
.ph-title { display: flex; align-items: center; gap: 8px; color: #fff; font-weight: 700; font-size: 14px; margin-top: 6px; }
.ph-avatar {
  width: 24px; height: 24px; border-radius: 50%; background: var(--red); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; font-size: 13px; font-weight: 800;
}
.ph-badge {
  margin-left: auto; margin-right: 16px; background: var(--red); color: #fff; font-size: 11px; font-weight: 800;
  min-width: 20px; height: 20px; border-radius: 10px; display: inline-flex; align-items: center; justify-content: center;
  padding: 0 6px; transition: transform 0.2s ease;
}
.ph-badge.bump { transform: scale(1.35); }
.ph-caret { position: absolute; right: 14px; bottom: 10px; color: #8a84a0; font-size: 14px; transition: transform 0.3s ease; }
#phone.collapsed .ph-caret { transform: rotate(180deg); }
#phoneBody { flex: 1; overflow-y: auto; padding: 10px 12px; display: flex; flex-direction: column; gap: 8px; scrollbar-width: thin; }
.ph-msg {
  background: #211d30; border-radius: 14px 14px 14px 4px; padding: 8px 12px;
  animation: msgIn 0.35s cubic-bezier(0.34, 1.4, 0.64, 1) both;
}
@keyframes msgIn { from { opacity: 0; transform: translateY(14px) scale(0.92); } to { opacity: 1; transform: none; } }
.ph-from { font-size: 11px; font-weight: 800; color: #ffb46b; letter-spacing: 0.3px; }
.ph-text { font-size: 13px; color: #efeaf6; margin-top: 2px; line-height: 1.35; font-family: var(--font-hand); font-size: 14.5px; }
.ph-time { font-size: 10px; color: #6f6987; text-align: right; margin-top: 2px; }

/* ---------- char card ---------- */
#charCard {
  position: fixed; left: 50%; bottom: 26px; transform: translateX(-50%);
  background: rgba(20, 15, 25, 0.85); border: 2px solid var(--red); border-radius: 16px;
  color: #fff; padding: 12px 26px; text-align: center; backdrop-filter: blur(8px);
  animation: bubblePop 0.25s ease both; pointer-events: none;
}
#ccName { font-weight: 800; font-size: 19px; }
#ccRole { font-family: var(--font-hand); font-size: 15px; color: var(--cream); }
.cc-hint { font-size: 11px; opacity: 0.5; margin-top: 4px; }

/* ---------- epic flash ---------- */
#flash {
  position: fixed; inset: 0; z-index: 15; pointer-events: none; opacity: 0;
  background: radial-gradient(ellipse at center, rgba(255, 220, 90, 0.55), rgba(255, 120, 40, 0.15) 60%, transparent 80%);
}
#flash.go { animation: flashGo 1.1s ease-out both; }
@keyframes flashGo { 0% { opacity: 0; } 18% { opacity: 1; } 100% { opacity: 0; } }

@media (max-width: 640px) {
  #phone { width: 240px; height: 330px; right: 12px; bottom: 12px; }
  #brand { top: 12px; left: 14px; }
  .brand-logo { font-size: 20px; }
  #camControls { top: 12px; right: 12px; }
  .cam-btn { font-size: 12px; padding: 6px 11px; }
  .bubble { font-size: 13.5px; max-width: 170px; }
}
