:root {
  --bg: #07070b;
  --phone-bg: #0d0d14;
  --panel: #111119;
  --ink: #e8e6ef;
  --muted: #8a8aa0;
  --hot: #ff2a1a;
  --hot2: #ff7a2a;
  --cool: #36b6ff;
  --cool2: #6ee7ff;
  --bubble-her: #1c1c28;
  --bubble-me: #2a2342;
  --frame: 9 / 16;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }

html, body {
  margin: 0;
  height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: ui-monospace, "SF Mono", Menlo, Consolas, monospace;
  overscroll-behavior: none;
}

/* ---- STAGE: centers the 9:16 phone on desktop ---- */
.stage {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  background:
    radial-gradient(120% 90% at 50% 0%, #16121f 0%, #07070b 60%) fixed;
  padding: 0;
}

.phone {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: 100vw;
  background: var(--phone-bg);
  display: grid;
  grid-template-rows: auto 1fr auto;
  overflow: hidden;
}

/* desktop: fixed 9:16 column in the middle */
@media (min-width: 560px) {
  .phone {
    width: auto;
    height: min(96vh, 900px);
    aspect-ratio: var(--frame);
    border: 1px solid #23232f;
    border-radius: 22px;
    box-shadow: 0 0 0 6px #0b0b12, 0 30px 80px rgba(0,0,0,.6);
  }
}

/* ===== PROFILE ===== */
.profile {
  padding: 0 0 12px;
  background:
    linear-gradient(180deg, var(--panel), #0c0c13);
  border-bottom: 1px solid #1d1d29;
  transition: background .5s ease, box-shadow .5s ease;
}

.portrait-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 46vh;
  margin: 0 0 10px;
  overflow: hidden;
  border-bottom: 2px solid #2a2a3a;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
  transition: box-shadow .4s ease, transform .12s ease;
}

.portrait {
  width: 100%;
  height: 100%;
  object-fit: cover;
  image-rendering: pixelated;
  display: block;
  transition: filter .4s ease;
}

.scanlines {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: repeating-linear-gradient(
    180deg, rgba(0,0,0,0) 0px, rgba(0,0,0,0) 2px,
    rgba(0,0,0,.18) 3px, rgba(0,0,0,.18) 4px);
  mix-blend-mode: multiply;
}

/* shake when she gets angrier */
.portrait-wrap.hit { animation: shake .32s linear; }
@keyframes shake {
  0%,100% { transform: translate(0,0) }
  20% { transform: translate(-3px,2px) rotate(-1deg) }
  40% { transform: translate(3px,-2px) rotate(1deg) }
  60% { transform: translate(-2px,1px) }
  80% { transform: translate(2px,-1px) }
}

.nameRow {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  margin-bottom: 10px;
  padding: 0 14px;
}

.name {
  font-family: "Press Start 2P", ui-monospace, monospace;
  font-size: 11px;
  letter-spacing: .5px;
  color: var(--ink);
}

.status {
  font-family: "Press Start 2P", monospace;
  font-size: 9px;
  padding: 4px 7px;
  border-radius: 4px;
  background: #2a1010;
  color: var(--hot2);
  border: 1px solid #4a1a12;
  transition: all .4s ease;
}

/* ===== ANGRY METER ===== */
.meter { width: 100%; max-width: 260px; margin: 0 auto; }

.meter-label {
  display: flex;
  justify-content: space-between;
  font-size: 8px;
  letter-spacing: 1px;
  color: var(--muted);
  margin-bottom: 4px;
  font-family: "Press Start 2P", monospace;
}
#meterLeft { color: var(--cool); }
#meterRight { color: var(--hot); }

.meter-track {
  position: relative;
  height: 16px;
  background: #060609;
  border: 2px solid #23232f;
  border-radius: 3px;
  overflow: hidden;
}

.meter-fill {
  position: absolute;
  top: 0; bottom: 0; left: 0;
  width: 12%;
  background: linear-gradient(90deg, #ffae00, var(--hot2) 60%, var(--hot));
  transition: width .5s cubic-bezier(.2,.8,.2,1), background .5s ease, left .5s ease, right .5s ease;
}
/* ZEN: fill flows from the RIGHT toward the LEFT, blue */
.meter-track.zen .meter-fill {
  left: auto; right: 0;
  background: linear-gradient(90deg, var(--cool), var(--cool2));
}

.meter-ticks {
  position: absolute; inset: 0;
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  pointer-events: none;
}
.meter-ticks span { border-right: 1px solid rgba(255,255,255,.08); }
.meter-ticks span:last-child { border-right: 0; }

/* ===== CHAT ===== */
.chat {
  padding: 14px 12px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 9px;
  scroll-behavior: smooth;
}
.chat::-webkit-scrollbar { width: 0; }

.msg {
  max-width: 80%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.35;
  word-wrap: break-word;
  animation: pop .18s ease;
}
@keyframes pop { from { opacity:0; transform: translateY(6px) scale(.98) } to { opacity:1; transform:none } }

.msg.her {
  align-self: flex-start;
  background: var(--bubble-her);
  border: 1px solid #26263400;
  border-bottom-left-radius: 4px;
  color: #f3ecec;
}
.msg.me {
  align-self: flex-end;
  background: var(--bubble-me);
  border-bottom-right-radius: 4px;
  color: #ece8ff;
}
.msg.typing { color: var(--muted); font-style: italic; }

/* her bubble heat tint via data attr on chat */
.chat[data-lvl="5"] .msg.her,
.chat[data-lvl="6"] .msg.her,
.chat[data-lvl="7"] .msg.her {
  background: #2a1212;
  color: #ffdedd;
}

/* ===== COMPOSER ===== */
.composer {
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: #0b0b12;
  border-top: 1px solid #1d1d29;
}
.input {
  flex: 1;
  background: #15151f;
  border: 1px solid #26263a;
  border-radius: 20px;
  color: var(--ink);
  padding: 11px 14px;
  font-size: 15px;
  outline: none;
  font-family: inherit;
}
.input:focus { border-color: #3a3a55; }
.send {
  width: 44px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--hot2), var(--hot));
  color: #fff;
  font-size: 15px;
  cursor: pointer;
  transition: transform .1s ease, filter .3s ease;
}
.send:active { transform: scale(.92); }
.composer.zen .send { background: linear-gradient(180deg, var(--cool2), var(--cool)); }

/* ===== VICTORY ===== */
.victory {
  position: fixed; inset: 0;
  display: grid; place-items: center;
  background: radial-gradient(circle at 50% 40%, rgba(54,182,255,.25), rgba(0,0,0,.9));
  backdrop-filter: blur(4px);
  z-index: 50;
  animation: fade .5s ease;
}
@keyframes fade { from { opacity:0 } to { opacity:1 } }
.victory[hidden] { display: none; }
.victory-card { text-align: center; }
.victory-title {
  font-family: "Press Start 2P", monospace;
  font-size: 40px;
  color: var(--cool2);
  text-shadow: 0 0 24px var(--cool);
  margin-bottom: 12px;
  letter-spacing: 4px;
}
.victory-sub { color: #cfeaff; margin-bottom: 24px; font-size: 14px; }
.victory-btn {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  padding: 12px 16px;
  background: transparent;
  color: var(--cool2);
  border: 2px solid var(--cool);
  border-radius: 6px;
  cursor: pointer;
}
.victory-btn:active { transform: scale(.95); }

/* ===== HIDDEN CHAOS MODE: the page collapses ===== */
.phone.quaking { animation: quake .07s linear infinite; }
@keyframes quake {
  0%{transform:translate(0,0) rotate(0)}
  20%{transform:translate(-7px,4px) rotate(-.7deg)}
  40%{transform:translate(7px,-5px) rotate(.7deg)}
  60%{transform:translate(-6px,-3px) rotate(-.5deg)}
  80%{transform:translate(6px,3px) rotate(.5deg)}
  100%{transform:translate(0,0)}
}
/* let pieces fall past the phone frame, down the whole page */
.phone.chaos-open { overflow: visible; }

.chaos-screen {
  position: fixed; inset: 0;
  z-index: 70;
  display: grid; place-items: center;
  background: #050000;
  overflow: hidden;
  animation: quake .08s linear infinite;
}
.chaos-screen[hidden] { display: none; }
.chaos-screen::before {       /* red/cyan torn static */
  content: "";
  position: absolute; inset: -20%;
  background:
    repeating-linear-gradient(0deg, rgba(255,0,0,.06) 0 2px, transparent 2px 4px),
    repeating-linear-gradient(90deg, rgba(0,255,255,.05) 0 3px, transparent 3px 7px);
  mix-blend-mode: screen;
  animation: tear .2s steps(2) infinite;
}
@keyframes tear { to { transform: translate(6px, -4px); } }

.chaos-glitch {
  position: relative;
  font-family: "Press Start 2P", monospace;
  font-size: clamp(40px, 14vw, 92px);
  color: #fff;
  letter-spacing: 4px;
  text-shadow: 0 0 18px #ff0030;
}
.chaos-glitch::before, .chaos-glitch::after {
  content: attr(data-text);
  position: absolute; left: 0; top: 0;
}
.chaos-glitch::before { color: #ff0040; animation: glitchA .18s infinite steps(2); }
.chaos-glitch::after  { color: #00f0ff; animation: glitchB .21s infinite steps(2); }
@keyframes glitchA { 0%{transform:translate(0,0)} 50%{transform:translate(-4px,2px)} 100%{transform:translate(3px,-2px)} }
@keyframes glitchB { 0%{transform:translate(0,0)} 50%{transform:translate(4px,-2px)} 100%{transform:translate(-3px,2px)} }

.chaos-sub {
  position: relative; z-index: 2;
  margin: 18px 0 26px;
  font-family: "Press Start 2P", monospace;
  font-size: 12px;
  color: #ff7a7a;
  text-shadow: 0 0 10px #ff0030;
  animation: infTitle .1s infinite;
}
.chaos-btn {
  position: relative; z-index: 2;
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  padding: 12px 16px;
  background: rgba(40,0,0,.5);
  color: #ff9a9a;
  border: 2px solid #ff2a2a;
  border-radius: 6px;
  cursor: pointer;
  text-shadow: 0 0 8px #ff0030;
}
.chaos-btn:active { transform: scale(.95); }

/* ===== INFERNO END: the whole screen burns ===== */
.inferno-screen {
  position: fixed; inset: 0;
  z-index: 60;
  display: grid; place-items: center;
  overflow: hidden;
  background: radial-gradient(circle at 50% 130%, #ff7a00 0%, #c00 38%, #2a0000 75%, #000 100%);
  animation: infShake .11s linear infinite;
}
.inferno-screen[hidden] { display: none; }

.inferno-fire {
  position: absolute; inset: 0;
  transform-origin: bottom;
  background:
    radial-gradient(55% 42% at 18% 100%, rgba(255,180,20,.95), transparent 70%),
    radial-gradient(50% 55% at 50% 100%, rgba(255,90,0,.98), transparent 72%),
    radial-gradient(55% 46% at 82% 100%, rgba(255,140,0,.95), transparent 70%),
    radial-gradient(38% 62% at 34% 100%, rgba(255,60,0,.92), transparent 70%),
    radial-gradient(38% 64% at 66% 100%, rgba(255,210,60,.9), transparent 70%),
    radial-gradient(30% 70% at 50% 100%, rgba(255,240,160,.85), transparent 60%);
  filter: blur(2px) contrast(1.45);
  animation: infRise .8s ease-out both, infFlicker .16s infinite alternate .8s;
}
@keyframes infRise { from { transform: scaleY(0); opacity:.25 } to { transform: scaleY(1); opacity:1 } }
@keyframes infFlicker {
  from { opacity:.8;  filter: blur(2px) brightness(1) }
  to   { opacity:1;   filter: blur(3px) brightness(1.28) }
}

.inferno-smoke {
  position: absolute; inset: 0;
  background: radial-gradient(120% 70% at 50% -10%, rgba(0,0,0,.85), transparent 60%);
  pointer-events: none;
}

@keyframes infShake {
  0%{transform:translate(0,0)} 25%{transform:translate(-4px,2px)}
  50%{transform:translate(4px,-3px)} 75%{transform:translate(-3px,-1px)}
  100%{transform:translate(3px,2px)}
}

.inferno-card { position: relative; z-index: 2; text-align: center; }
.inferno-title {
  font-family: "Press Start 2P", monospace;
  font-size: clamp(26px, 8vw, 46px);
  line-height: 1.45;
  color: #fff8e6;
  letter-spacing: 2px;
  text-shadow: 0 0 10px #ffdd00, 0 0 26px #ff6a00, 0 0 50px #ff2a00, 0 3px 0 #7a0000;
  animation: infTitle .09s infinite;
  margin-bottom: 26px;
}
@keyframes infTitle {
  0%,100% { opacity:1;  transform: scale(1) translateY(0) }
  50%     { opacity:.88; transform: scale(1.03) translateY(-1px) }
}
.inferno-btn {
  font-family: "Press Start 2P", monospace;
  font-size: 10px;
  padding: 12px 16px;
  background: rgba(0,0,0,.35);
  color: #ffd9a0;
  border: 2px solid #ffae3a;
  border-radius: 6px;
  cursor: pointer;
  text-shadow: 0 0 8px #ff6a00;
}
.inferno-btn:active { transform: scale(.95); }

/* red rage flash on the whole phone at high levels */
.phone.rage { animation: rageflash .5s ease; }
@keyframes rageflash {
  0% { box-shadow: inset 0 0 0 0 rgba(255,0,0,0) }
  30% { box-shadow: inset 0 0 80px 0 rgba(255,30,0,.35) }
  100% { box-shadow: inset 0 0 0 0 rgba(255,0,0,0) }
}
