/* ============================================================
   PLAYER TWO — style.css
   Neon CRT arcade. Pixel font for UI chrome, Inter for reading.
   Mobile-first; one centered "screen".
   ============================================================ */

:root {
  --bg:      #08040f;
  --bg2:     #150a28;
  --panel:   #190f30;
  --panel-2: #241644;
  --ink:     #f5eeff;
  --muted:   #a99fc8;
  --line:    rgba(255,255,255,.10);

  --pink:   #ff4d8d;
  --cyan:   #4dffe4;
  --gold:   #ffd24d;
  --purple: #b14dff;
  --green:  #4dff88;

  --accent: #ff4d8d;
  --glow:   #ff8dc0;

  --font-pixel: 'Press Start 2P', system-ui, monospace;
  --font-body:  'Inter', system-ui, -apple-system, sans-serif;
}

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

html, body { height: 100%; }

body {
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(120% 90% at 50% -10%, rgba(177,77,255,.22), transparent 60%),
    radial-gradient(120% 90% at 50% 110%, color-mix(in srgb, var(--accent) 30%, transparent), transparent 55%),
    linear-gradient(180deg, var(--bg2), var(--bg));
  background-attachment: fixed;
  overflow-x: hidden;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- CRT / ambient layers ---------- */
.crt-overlay, .scanlines, .vignette { position: fixed; inset: 0; pointer-events: none; z-index: 50; }
.scanlines {
  background: repeating-linear-gradient(180deg, rgba(0,0,0,0) 0 2px, rgba(0,0,0,.18) 2px 3px);
  mix-blend-mode: multiply; opacity: .55;
}
.crt-overlay { background: radial-gradient(120% 120% at 50% 50%, transparent 60%, rgba(120,60,200,.10)); animation: flicker 6s infinite; }
.vignette { box-shadow: inset 0 0 140px 30px rgba(0,0,0,.65); }
@keyframes flicker { 0%,100%{opacity:.6} 48%{opacity:.55} 50%{opacity:.7} 52%{opacity:.55} }

#fx-canvas { position: fixed; inset: 0; z-index: 0; pointer-events: none; }
#celebrate-canvas { position: fixed; inset: 0; z-index: 60; pointer-events: none; }

/* ---------- sound toggle ---------- */
.sound-toggle {
  position: fixed; top: 12px; right: 12px; z-index: 70;
  width: 40px; height: 40px; cursor: pointer;
  font-family: var(--font-pixel); font-size: 12px; color: var(--ink);
  background: var(--panel); border: 2px solid var(--accent);
  box-shadow: 0 0 0 2px #000, 0 0 14px var(--glow);
  display: grid; place-items: center; transition: transform .1s;
}
.sound-toggle:active { transform: scale(.92); }
.sound-toggle.muted { border-color: var(--muted); box-shadow: 0 0 0 2px #000; color: var(--muted); }

/* ---------- app screen ---------- */
.app {
  position: relative; z-index: 10;
  width: 100%; max-width: 540px; min-height: 100dvh;
  margin: 0 auto; padding: 22px 18px 40px;
  display: flex; flex-direction: column;
}
.fade-in { animation: fadeIn .4s ease both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.scene { flex: 1; display: flex; flex-direction: column; }

/* ---------- typography ---------- */
.scene-title { font-family: var(--font-pixel); font-size: clamp(13px,4.4vw,18px); line-height: 1.6; text-align: center; margin-top: 8px; text-shadow: 0 0 12px var(--glow); }
.scene-title .hl { color: var(--accent); }
.scene-sub { text-align: center; color: var(--muted); font-size: 14px; margin: 8px 0 20px; }

/* ---------- buttons ---------- */
.btn {
  font-family: var(--font-pixel); font-size: 11px; letter-spacing: .5px;
  color: #1a0c2a; cursor: pointer; border: none; user-select: none;
  padding: 14px 18px; line-height: 1.4;
  background: var(--accent);
  box-shadow: 0 5px 0 0 #000, 0 0 22px color-mix(in srgb, var(--glow) 70%, transparent);
  transition: transform .08s, box-shadow .08s, filter .1s;
  text-transform: uppercase;
}
.btn:hover { filter: brightness(1.08); }
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 0 #000, 0 0 18px var(--glow); }
.btn-primary { background: var(--accent); color: #1a0c2a; }
.btn-ghost {
  background: var(--panel-2); color: var(--ink);
  box-shadow: 0 5px 0 0 #000, inset 0 0 0 2px var(--line);
}
.btn-ghost:active { box-shadow: 0 1px 0 0 #000, inset 0 0 0 2px var(--line); }

.press-start { font-size: 15px; padding: 18px 26px; animation: pulse 1.6s ease-in-out infinite; }
@keyframes pulse { 0%,100%{ transform: scale(1) } 50%{ transform: scale(1.05) } }

.back-link {
  align-self: flex-start; background: none; border: none; cursor: pointer;
  color: var(--muted); font-family: var(--font-pixel); font-size: 9px; padding: 6px 2px;
}
.back-link:hover { color: var(--accent); }

/* =========================================================
   HOME
   ========================================================= */
.home { justify-content: center; align-items: center; text-align: center; gap: 6px; }
.home-inner { display: flex; flex-direction: column; align-items: center; gap: 18px; }
.logo-sub { font-family: var(--font-pixel); font-size: 8px; color: var(--muted); letter-spacing: 2px; }
.logo {
  font-family: var(--font-pixel); font-size: clamp(26px,8.5vw,46px); line-height: 1.15;
  color: var(--ink); text-shadow: 4px 4px 0 #000, 0 0 26px var(--glow);
}
.logo .logo-2 { color: var(--accent); }
.logo-tag { font-family: var(--font-pixel); font-size: 8px; color: var(--cyan); letter-spacing: 1px; }
.home-hearts { display: flex; align-items: center; gap: 14px; margin: 4px 0; }
.home-ava { width: 84px; height: 84px; image-rendering: pixelated; filter: drop-shadow(0 0 10px var(--glow)); }
.home-plus { font-family: var(--font-pixel); font-size: 22px; color: var(--accent); animation: beat 1.1s infinite; }
@keyframes beat { 0%,100%{ transform: scale(1) } 30%{ transform: scale(1.35) } }
.home-blurb { color: var(--muted); font-size: 14px; line-height: 1.7; max-width: 340px; }
.home-blurb b { color: var(--ink); }
.credits { margin-top: 6px; font-size: 11px; color: rgba(169,159,200,.65); display: flex; flex-direction: column; align-items: center; gap: 5px; }
.credit-handle {
  font-family: var(--font-pixel); font-size: 8px; letter-spacing: .3px;
  color: var(--accent); text-decoration: none; opacity: .8;
  transition: opacity .15s, text-shadow .15s;
}
.credit-handle:hover { opacity: 1; text-shadow: 0 0 10px var(--glow); }
.credit-fuel {
  font-size: 11px; color: var(--cyan); text-decoration: none; opacity: .85;
  border-bottom: 1px dashed color-mix(in srgb, var(--cyan) 50%, transparent);
  padding-bottom: 1px; transition: opacity .15s, text-shadow .15s;
}
.credit-fuel:hover { opacity: 1; text-shadow: 0 0 10px var(--cyan); }

/* =========================================================
   CARTRIDGE SELECT
   ========================================================= */
.cartridges { display: flex; flex-direction: column; gap: 16px; }
.cartridge { cursor: pointer; background: none; border: none; padding: 0; text-align: left; }
.cart-shell {
  position: relative; padding: 18px 18px 14px; border: 3px solid var(--c, var(--accent));
  background: linear-gradient(160deg, var(--panel), var(--bg2));
  box-shadow: 0 0 0 3px #000, 0 6px 0 3px #000, 0 0 26px color-mix(in srgb, var(--g,var(--glow)) 45%, transparent);
  transition: transform .12s, box-shadow .12s;
  overflow: hidden;
}
.cart-shell::before {
  content: ''; position: absolute; top: 0; right: 0; width: 38px; height: 100%;
  background: repeating-linear-gradient(180deg, transparent 0 8px, rgba(0,0,0,.35) 8px 12px);
  border-left: 3px solid #000;
}
.cartridge:hover .cart-shell { transform: translate(-2px,-2px); box-shadow: 0 0 0 3px #000, 0 8px 0 5px #000, 0 0 34px color-mix(in srgb, var(--g,var(--glow)) 70%, transparent); }
.cartridge:active .cart-shell { transform: translate(2px,2px); }
.cart-emoji { font-size: 38px; line-height: 1; }
.cart-label { font-family: var(--font-pixel); font-size: 15px; color: var(--c); margin-top: 10px; text-shadow: 0 0 10px color-mix(in srgb, var(--c) 60%, transparent); }
.cart-tag { color: var(--muted); font-size: 13px; margin-top: 8px; max-width: 75%; line-height: 1.5; }
.cart-foot { font-family: var(--font-pixel); font-size: 8px; color: var(--ink); margin-top: 12px; opacity: .8; }

/* =========================================================
   BUILDER
   ========================================================= */
.form { display: flex; flex-direction: column; gap: 18px; }
.field { display: flex; flex-direction: column; gap: 8px; }
.field-label { font-family: var(--font-pixel); font-size: 9px; color: var(--cyan); letter-spacing: .5px; }
.form input, .form textarea {
  font-family: var(--font-body); font-size: 16px; color: var(--ink);
  background: var(--panel); border: 2px solid var(--line);
  padding: 13px 14px; outline: none; width: 100%; resize: none;
  box-shadow: inset 0 0 0 2px #000;
  transition: border-color .15s, box-shadow .15s;
}
.form input:focus, .form textarea:focus { border-color: var(--accent); box-shadow: inset 0 0 0 2px #000, 0 0 16px color-mix(in srgb, var(--glow) 55%, transparent); }
.form input::placeholder, .form textarea::placeholder { color: rgba(169,159,200,.55); }

.gender-seg { display: flex; gap: 8px; }
.gseg {
  flex: 1; font-family: var(--font-pixel); font-size: 9px; color: var(--muted); cursor: pointer;
  background: var(--panel); border: 2px solid var(--line); box-shadow: inset 0 0 0 2px #000;
  padding: 13px 8px; transition: color .12s, background .12s, box-shadow .12s, border-color .12s;
}
.gseg:hover { color: var(--ink); }
.gseg.on { color: #1a0c2a; background: var(--accent); border-color: var(--accent); box-shadow: inset 0 0 0 2px #000, 0 0 14px var(--glow); }
.gseg.on:hover { color: #1a0c2a; }

.ava-strip {
  display: flex; gap: 10px; overflow-x: auto; padding: 6px 2px 12px;
  scroll-snap-type: x proximity; -webkit-overflow-scrolling: touch;
}
.ava-strip::-webkit-scrollbar { height: 6px; }
.ava-strip::-webkit-scrollbar-thumb { background: var(--panel-2); border-radius: 3px; }
.ava-pick {
  flex: 0 0 auto; cursor: pointer; background: var(--panel); border: 2px solid var(--line);
  padding: 4px; display: grid; place-items: center; scroll-snap-align: start;
  box-shadow: inset 0 0 0 2px #000; transition: transform .1s, border-color .1s;
}
.ava-pick canvas { image-rendering: pixelated; display: block; }
.ava-pick:hover { transform: translateY(-2px); }
.ava-pick.sel { border-color: var(--accent); box-shadow: inset 0 0 0 2px #000, 0 0 16px var(--glow); }

.advanced { background: var(--panel); border: 2px solid var(--line); box-shadow: inset 0 0 0 2px #000; padding: 4px 14px; }
.advanced summary { font-family: var(--font-pixel); font-size: 9px; color: var(--gold); cursor: pointer; padding: 12px 0; list-style: none; }
.advanced summary span { color: var(--muted); }
.advanced summary::-webkit-details-marker { display: none; }
.advanced[open] { padding-bottom: 14px; }
.advanced .field { margin-top: 6px; }

.build-actions { display: flex; gap: 12px; margin-top: 6px; }
.build-actions .btn { flex: 1; }

/* =========================================================
   SHARE
   ========================================================= */
.share { justify-content: center; }
.ticket {
  background: linear-gradient(160deg, var(--panel), var(--bg2));
  border: 3px solid var(--accent); box-shadow: 0 0 0 3px #000, 0 0 36px var(--glow);
  padding: 26px 20px; text-align: center;
  position: relative;
}
.ticket::before, .ticket::after {
  content: ''; position: absolute; width: 22px; height: 22px; border-radius: 50%;
  background: var(--bg); top: 50%; transform: translateY(-50%);
  box-shadow: inset 0 0 0 3px #000;
}
.ticket::before { left: -14px; } .ticket::after { right: -14px; }
.ticket-emoji { font-size: 42px; }
.ticket h2 { font-family: var(--font-pixel); font-size: 14px; color: var(--accent); margin-top: 12px; line-height: 1.5; text-shadow: 0 0 12px var(--glow); }
.ticket-sub { color: var(--muted); font-size: 14px; margin-top: 12px; line-height: 1.6; }
.ticket-sub b { color: var(--ink); }

.link-row { display: flex; gap: 8px; margin: 22px 0 14px; }
.link-row input {
  flex: 1; min-width: 0; font-family: var(--font-body); font-size: 13px; color: var(--cyan);
  background: var(--bg); border: 2px solid var(--line); box-shadow: inset 0 0 0 2px #000;
  padding: 12px; outline: none;
}
.link-row .btn { white-space: nowrap; }
.btn.ok { background: var(--green); }

.share-actions { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.share-actions .btn { flex: 1; min-width: 110px; font-size: 9px; padding: 12px 8px; }
.share-tip { margin-top: 18px; font-size: 12px; color: var(--muted); line-height: 1.6; }
.share-tip b { color: var(--ink); }

/* =========================================================
   GAME
   ========================================================= */
.game { gap: 0; }

/* boot */
.boot { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 20px; min-height: 70dvh; }
.boot-logo { font-family: var(--font-pixel); font-size: clamp(26px,9vw,40px); color: var(--accent); text-shadow: 3px 3px 0 #000, 0 0 28px var(--glow); animation: bootIn .6s both; }
@keyframes bootIn { from { opacity: 0; letter-spacing: 12px; } to { opacity: 1; letter-spacing: normal; } }
.boot-line { font-family: var(--font-pixel); font-size: 10px; color: var(--cyan); min-height: 14px; text-align: center; }
.boot-bar { width: 220px; max-width: 70%; height: 16px; border: 2px solid var(--accent); box-shadow: inset 0 0 0 2px #000; }
.boot-bar-fill { height: 100%; width: 0; background: var(--accent); transition: width .4s; box-shadow: 0 0 12px var(--glow); }
.boot-start { margin-top: 10px; }

/* stage */
.stage { display: flex; flex-direction: column; gap: 16px; padding: 6px 0 14px; transition: opacity .3s, filter .3s; }
.stage.dim { opacity: .25; filter: blur(2px); pointer-events: none; }

.boss-zone {
  text-align: center; padding: 16px 14px; border: 3px solid var(--accent);
  background: radial-gradient(120% 120% at 50% 0%, color-mix(in srgb, var(--accent) 16%, transparent), var(--panel));
  box-shadow: 0 0 0 3px #000, 0 0 26px color-mix(in srgb, var(--glow) 40%, transparent);
  position: relative;
}
.boss-zone.flash { animation: bossFlash .35s; }
@keyframes bossFlash { 0%,100%{ filter:none } 50%{ filter: brightness(2.2) saturate(1.5); } }
.boss-emoji { font-size: 56px; line-height: 1; filter: drop-shadow(0 0 14px var(--glow)); transition: transform .3s, opacity .5s; }
.boss-emoji.shake { animation: shake .35s; }
.boss-emoji.defeated { opacity: .25; transform: scale(.7) rotate(12deg); filter: grayscale(1); }
@keyframes shake { 0%,100%{transform:translateX(0)} 20%{transform:translateX(-8px) rotate(-4deg)} 40%{transform:translateX(8px) rotate(4deg)} 60%{transform:translateX(-6px)} 80%{transform:translateX(6px)} }
.boss-name { font-family: var(--font-pixel); font-size: 12px; color: var(--accent); margin-top: 10px; text-shadow: 0 0 10px var(--glow); }

/* bars */
.bar { position: relative; height: 18px; border: 2px solid #000; background: #1c1030; box-shadow: inset 0 0 0 2px rgba(255,255,255,.06); overflow: hidden; }
.boss-bar { margin-top: 12px; border-color: #000; }
.boss-bar .bar-fill { background: linear-gradient(90deg, var(--accent), var(--glow)); }
.bar-fill { height: 100%; width: 100%; transition: width .5s cubic-bezier(.2,.8,.2,1); box-shadow: 0 0 10px var(--glow); }
.bar-label { position: absolute; inset: 0; display: grid; place-items: center; font-family: var(--font-pixel); font-size: 8px; color: #fff; text-shadow: 1px 1px 0 #000; }

/* party */
.party-zone { display: flex; align-items: center; justify-content: center; gap: 18px; }
.fighter { display: flex; flex-direction: column; align-items: center; gap: 6px; }
.fighter .ava { image-rendering: pixelated; filter: drop-shadow(0 0 8px var(--glow)); }
.fighter .nm { font-family: var(--font-pixel); font-size: 9px; color: var(--ink); max-width: 90px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.party-plus { font-family: var(--font-pixel); font-size: 8px; color: var(--cyan); border: 2px solid var(--cyan); padding: 4px 6px; box-shadow: 0 0 10px color-mix(in srgb,var(--cyan) 40%, transparent); }

/* stats */
.stats-zone { display: flex; flex-direction: column; gap: 8px; }
.stat { display: grid; grid-template-columns: 78px 1fr; align-items: center; gap: 10px; }
.stat-label { font-family: var(--font-pixel); font-size: 8px; }
.stat-bar { height: 14px; }
.stat-bar .bar-fill { width: 0; }

/* bottom UI */
.game-ui { margin-top: auto; padding-top: 14px; }
.dialogue {
  position: relative; min-height: 92px; padding: 16px 16px 28px;
  border: 3px solid var(--accent); background: var(--panel);
  box-shadow: 0 0 0 3px #000, 0 0 22px color-mix(in srgb, var(--glow) 35%, transparent);
  cursor: pointer;
}
.dlg-text { font-family: var(--font-body); font-size: 16px; line-height: 1.6; color: var(--ink); min-height: 1.6em; }
.dlg-cont { position: absolute; right: 14px; bottom: 8px; font-family: var(--font-pixel); font-size: 8px; color: var(--accent); opacity: 0; }
.dlg-cont.show { opacity: 1; animation: bob 1s infinite; }
@keyframes bob { 0%,100%{ transform: translateY(0) } 50%{ transform: translateY(-3px) } }

.moves { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.move {
  font-family: var(--font-pixel); font-size: 10px; color: var(--ink); cursor: pointer;
  padding: 16px 10px; background: var(--panel-2); border: 2px solid var(--accent);
  box-shadow: 0 4px 0 0 #000, inset 0 0 0 2px #000; transition: transform .08s, box-shadow .08s, background .1s;
  line-height: 1.3;
}
.move:hover { background: color-mix(in srgb, var(--accent) 22%, var(--panel-2)); }
.move:active { transform: translateY(3px); box-shadow: 0 1px 0 0 #000, inset 0 0 0 2px #000; }

/* letter */
.letter {
  margin: 10px 0 16px; padding: 20px 18px; border: 3px solid var(--gold);
  background: linear-gradient(160deg, #2a1f12, var(--panel));
  box-shadow: 0 0 0 3px #000, 0 0 30px color-mix(in srgb, var(--gold) 40%, transparent);
  animation: fadeIn .5s both;
}
.letter-head { font-family: var(--font-pixel); font-size: 9px; color: var(--gold); letter-spacing: .5px; }
.letter-body { font-family: var(--font-body); font-size: 17px; line-height: 1.8; color: var(--ink); margin: 14px 0 0; min-height: 2em; font-style: italic; }
.letter-next { margin-top: 18px; width: 100%; }

/* ask */
.ask { text-align: center; padding: 8px 0; }
.ask-q { font-family: var(--font-pixel); font-size: clamp(13px,4.2vw,17px); line-height: 1.6; color: var(--accent); text-shadow: 0 0 14px var(--glow); margin-bottom: 22px; }
.ask-btns { position: relative; display: flex; align-items: center; justify-content: center; gap: 18px; min-height: 64px; }
.btn-yes { font-size: 16px; padding: 18px 30px; background: var(--green); color: #062012; box-shadow: 0 5px 0 0 #000, 0 0 26px rgba(77,255,136,.6); animation: pulse 1.3s infinite; }
.btn-no { font-size: 11px; padding: 12px 16px; background: var(--panel-2); color: var(--muted); box-shadow: 0 4px 0 0 #000, inset 0 0 0 2px var(--line); transition: transform .15s; }

/* result */
.result { position: fixed; inset: 0; z-index: 65; display: grid; place-items: center; padding: 22px; background: rgba(5,2,12,.82); backdrop-filter: blur(4px); animation: fadeIn .4s both; }
.result-card {
  width: 100%; max-width: 420px; text-align: center; padding: 28px 22px;
  border: 3px solid var(--accent); background: linear-gradient(160deg, var(--panel), var(--bg2));
  box-shadow: 0 0 0 3px #000, 0 0 50px var(--glow);
  display: flex; flex-direction: column; gap: 14px; align-items: center;
}
.result-emoji { font-size: 54px; animation: beat 1.2s infinite; }
.result-title { font-family: var(--font-pixel); font-size: 16px; color: var(--gold); text-shadow: 0 0 14px var(--gold); line-height: 1.5; }
.result-sub { color: var(--muted); font-size: 14px; }
.result-team { display: flex; align-items: center; gap: 14px; margin: 6px 0; }
.result-team .ava { image-rendering: pixelated; filter: drop-shadow(0 0 8px var(--glow)); }
.result-heart { font-size: 26px; color: var(--pink); animation: beat 1s infinite; }
.result-names { font-family: var(--font-pixel); font-size: 10px; color: var(--ink); }
.result-stats { list-style: none; width: 100%; display: flex; flex-direction: column; gap: 6px; margin: 8px 0; }
.result-stats li { display: flex; justify-content: space-between; font-family: var(--font-pixel); font-size: 9px; color: var(--muted); padding: 6px 4px; border-bottom: 1px solid var(--line); }
.result-card .btn { width: 100%; }

/* tip jar (Chai4Me) */
.tip-jar { width: 100%; margin-top: 8px; padding-top: 16px; border-top: 1px solid var(--line); display: flex; flex-direction: column; align-items: center; gap: 12px; }
.tip-text { font-size: 13px; line-height: 1.5; color: var(--muted); text-align: center; }
.tip-btn {
  display: inline-flex; align-items: center; justify-content: center;
  background: #ffffff; padding: 8px 32px; border-radius: 16px; text-decoration: none;
  border: 1px solid #e5e7eb; box-shadow: 0 4px 6px -1px rgba(0,0,0,.15), 0 2px 4px -2px rgba(0,0,0,.15);
  transition: transform .2s, box-shadow .2s;
}
.tip-btn:hover { transform: translateY(-2px); box-shadow: 0 8px 16px -4px rgba(0,0,0,.3); }
.tip-btn img { height: 32px; object-fit: contain; display: block; }

/* ---------- utility ---------- */
.hidden { display: none !important; }

/* ---------- desktop polish ---------- */
@media (min-width: 560px) {
  .app { padding: 30px 24px 50px; }
  .dlg-text { font-size: 17px; }
}

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}
