/* ====================================================
   PECAN STUDIO — Style A · Reading Lamp
   ==================================================== */

:root {
  --paper:    #f1e7d0;
  --paper-2:  #e6d9b8;
  --paper-3:  #d8c89c;
  --ink:      #2a1d12;
  --ink-soft: #5a4530;
  --sage:     #6d8c5e;
  --sage-dark:#4f6b44;
  --coral:    #c64f3b;
  --coral-2:  #a93b2a;
  --gold:     #d4a04b;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; min-height: 100vh; }

body {
  background:
    radial-gradient(ellipse at top, rgba(212, 160, 75, 0.10), transparent 60%),
    repeating-linear-gradient(0deg, transparent 0 23px, rgba(42,29,18,0.025) 23px 24px),
    var(--paper);
  color: var(--ink);
  font-family: 'VT323', monospace;
  font-size: 22px;
  line-height: 1.4;
  image-rendering: pixelated;
  overflow-x: hidden;
}

img, .prop-svg, .trophy-svg {
  image-rendering: pixelated;
  image-rendering: -moz-crisp-edges;
  image-rendering: crisp-edges;
}

/* ===== SCENES ===== */
.scene {
  position: fixed; inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 40px 24px;
  overflow-y: auto;
  animation: fadeIn 0.5s ease;
}
.scene.active { display: flex; }
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ===== BUTTONS ===== */
.btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  letter-spacing: 2px;
  padding: 14px 22px;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  box-shadow: 4px 4px 0 0 var(--ink);
  cursor: pointer;
  text-transform: uppercase;
  transition: transform 0.08s, background 0.15s, color 0.15s, box-shadow 0.08s;
  min-width: 200px;
  text-align: center;
}
.btn:hover { background: var(--sage); color: var(--paper); }
.btn:active {
  transform: translate(3px, 3px);
  box-shadow: 1px 1px 0 0 var(--ink);
}
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--coral); }
.btn.small { font-size: 10px; padding: 11px 16px; min-width: 0; }
.btn.tiny  { font-size: 9px;  padding: 7px 14px;  min-width: 0; box-shadow: 2px 2px 0 0 var(--ink); border-width: 2px; }
.btn.tiny:active { box-shadow: 0 0 0 0 var(--ink); }
.btn.block { width: 100%; }

/* ============================================
   SCENE 1: LANDING
   ============================================ */
.landing-inner {
  text-align: center;
  max-width: 560px;
  width: 100%;
}

/* Bird medallion */
.bird-medallion {
  position: relative;
  width: 180px;
  height: 180px;
  margin: 0 auto 24px;
  cursor: pointer;
  user-select: none;
  animation: birdBob 2.2s ease-in-out infinite;
}
@keyframes birdBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}
.bird-medallion.hop { animation: birdHop 0.6s cubic-bezier(.3,.7,.3,1.5); }
@keyframes birdHop {
  0%   { transform: translateY(0) rotate(0); }
  35%  { transform: translateY(-22px) rotate(-4deg); }
  60%  { transform: translateY(-8px)  rotate(2deg); }
  100% { transform: translateY(0)     rotate(0); }
}

.bird-frame {
  position: relative;
  width: 100%; height: 100%;
  background: var(--paper);
  border: 4px solid var(--ink);
  box-shadow:
    inset 0 0 0 3px var(--paper),
    inset 0 0 0 5px var(--ink),
    6px 6px 0 0 var(--ink);
  overflow: hidden;
  /* octagonal cut for pixel-medallion vibe */
  clip-path: polygon(
    20% 0%, 80% 0%,
    100% 20%, 100% 80%,
    80% 100%, 20% 100%,
    0% 80%, 0% 20%
  );
}
.bird-photo {
  width: 100%; height: 100%;
  object-fit: cover;
  object-position: 55% 35%;
  filter: contrast(1.05) saturate(1.1);
}
.bird-shadow {
  position: absolute;
  bottom: -14px; left: 50%;
  width: 110px; height: 8px;
  background: var(--ink);
  opacity: 0.18;
  border-radius: 50%;
  transform: translateX(-50%);
  animation: shadowPulse 2.2s ease-in-out infinite;
}
@keyframes shadowPulse {
  0%, 100% { transform: translateX(-50%) scale(1);    opacity: 0.18; }
  50%      { transform: translateX(-50%) scale(0.92); opacity: 0.12; }
}

/* Tweet bubble (appears on click) */
.tweet-stage { position: absolute; inset: 0; pointer-events: none; }
.tweet {
  position: absolute;
  top: -8px; right: -18px;
  background: var(--paper);
  color: var(--coral);
  border: 3px solid var(--ink);
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  padding: 6px 10px;
  box-shadow: 3px 3px 0 0 var(--ink);
  animation: tweetFloat 1.6s ease-out forwards;
}
.tweet::after {
  content: '';
  position: absolute;
  bottom: -8px; left: 12px;
  width: 8px; height: 8px;
  background: var(--paper);
  border-right: 3px solid var(--ink);
  border-bottom: 3px solid var(--ink);
  transform: rotate(45deg);
}
@keyframes tweetFloat {
  0%   { opacity: 0; transform: translateY(8px) scale(0.7); }
  20%  { opacity: 1; transform: translateY(0)   scale(1); }
  80%  { opacity: 1; transform: translateY(-18px); }
  100% { opacity: 0; transform: translateY(-30px); }
}

.title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(22px, 4.4vw, 38px);
  letter-spacing: 5px;
  color: var(--ink);
  margin-bottom: 12px;
}
.title .dot { color: var(--coral); }

.subtitle {
  font-size: 22px;
  color: var(--ink-soft);
  font-style: italic;
  letter-spacing: 1px;
  margin-bottom: 30px;
}

.divider {
  display: flex; align-items: center; justify-content: center;
  gap: 10px; margin-bottom: 32px;
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: var(--ink-soft);
  letter-spacing: 3px;
  animation: blink 1.6s steps(2) infinite;
}
@keyframes blink { 50% { opacity: 0.35; } }

.btn-row {
  display: flex; gap: 14px; justify-content: center; flex-wrap: wrap;
  margin-bottom: 40px;
}

.footer-credit {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  color: var(--ink-soft);
  opacity: 0.55;
  letter-spacing: 2px;
}

/* ============================================
   SCENE 2: BIRD ARRIVES WITH ENVELOPE
   ============================================ */
.scene-bird { flex-direction: column; gap: 0; }
.bird-stage {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  margin-bottom: 30px;
}
.bird-arrival {
  position: relative;
  transform: translateX(120vw);
  animation: birdFly 2.4s cubic-bezier(0.22, 0.61, 0.36, 1) 0.3s forwards;
}
@keyframes birdFly {
  0%   { transform: translateX(120vw) translateY(-30px); }
  60%  { transform: translateX(-8px)   translateY(16px); }
  80%  { transform: translateX(6px)    translateY(-6px); }
  100% { transform: translateX(0)      translateY(0); }
}
.bird-frame.large {
  width: 220px; height: 220px;
  animation: birdBobSlow 2s ease-in-out 2.7s infinite;
}
@keyframes birdBobSlow {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}

.envelope {
  position: absolute;
  bottom: -16px; right: -32px;
  width: 96px; height: 64px;
  background: var(--paper);
  border: 4px solid var(--ink);
  box-shadow: 4px 4px 0 0 var(--ink);
  opacity: 0;
  animation: envIn 0.6s ease 2.5s forwards;
}
.env-flap {
  position: absolute;
  inset: -4px -4px auto -4px;
  height: 32px;
  background:
    linear-gradient(135deg, transparent 49%, var(--paper-2) 50%) bottom right / 50% 100% no-repeat,
    linear-gradient(225deg, transparent 49%, var(--paper-2) 50%) bottom left / 50% 100% no-repeat,
    var(--paper);
  border: 4px solid var(--ink);
  border-bottom: 0;
}
.env-seal {
  position: absolute;
  top: 50%; left: 50%;
  transform: translate(-50%, -40%);
  width: 26px; height: 26px;
  background: var(--coral);
  color: var(--paper);
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid var(--ink);
  box-shadow: 2px 2px 0 0 var(--ink);
  z-index: 2;
}
@keyframes envIn {
  from { opacity: 0; transform: translateY(-12px) rotate(-8deg); }
  to   { opacity: 1; transform: translateY(0)     rotate(0); }
}

.dialogue-panel {
  position: relative;
  background: var(--paper);
  color: var(--ink);
  border: 3px solid var(--ink);
  padding: 22px 26px;
  max-width: 580px;
  width: 100%;
  box-shadow: 6px 6px 0 0 var(--ink);
}
.dialogue-panel.delayed {
  opacity: 0;
  animation: fadeIn 0.5s ease 3.0s forwards;
}
.dialogue-panel::before {
  content: '';
  position: absolute;
  top: -14px; left: 32px;
  width: 0; height: 0;
  border-left: 12px solid transparent;
  border-right: 12px solid transparent;
  border-bottom: 14px solid var(--ink);
}
.dialogue-panel::after {
  content: '';
  position: absolute;
  top: -8px; left: 38px;
  width: 0; height: 0;
  border-left: 6px solid transparent;
  border-right: 6px solid transparent;
  border-bottom: 8px solid var(--paper);
}
.typewriter {
  font-family: 'VT323', monospace;
  font-size: 24px;
  line-height: 1.4;
  min-height: 70px;
}
.typewriter .cursor {
  display: inline-block;
  width: 9px; height: 22px;
  background: var(--ink);
  margin-left: 2px;
  vertical-align: middle;
  animation: caret 0.7s steps(2) infinite;
}
@keyframes caret { 50% { opacity: 0; } }

.advance-btn { margin-top: 16px; transition: opacity 0.4s; }
.advance-btn.hidden { opacity: 0; pointer-events: none; }

/* ============================================
   SCENE 3-5: QUIZ
   ============================================ */
.quiz-card {
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 0 var(--ink);
  padding: 28px 32px 30px;
  max-width: 580px;
  width: 100%;
}
.quiz-num {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  color: var(--coral);
  letter-spacing: 3px;
  margin-bottom: 16px;
}
.prop {
  height: 130px;
  position: relative;
  background:
    repeating-linear-gradient(45deg, rgba(42,29,18,0.04) 0 6px, transparent 6px 12px),
    var(--paper-2);
  border: 2px solid var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 20px;
  overflow: hidden;
}
.prop-svg { width: 110px; height: 90px; }

/* Crab bubbles */
.bubble {
  position: absolute;
  background: rgba(42, 29, 18, 0.18);
  border-radius: 50%;
  animation: bubble 3s ease-in-out infinite;
}
.bubble-1 { width: 6px; height: 6px; left: 30%; bottom: 16px; animation-delay: 0s; }
.bubble-2 { width: 4px; height: 4px; left: 60%; bottom: 24px; animation-delay: 0.8s; }
.bubble-3 { width: 5px; height: 5px; left: 75%; bottom: 12px; animation-delay: 1.4s; }
@keyframes bubble {
  0%   { transform: translateY(0);    opacity: 0; }
  20%  { opacity: 1; }
  100% { transform: translateY(-90px); opacity: 0; }
}

/* Poker cards */
.poker-stage { gap: 6px; }
.pcard {
  width: 46px; height: 66px;
  background: var(--paper);
  color: var(--ink);
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  border: 3px solid var(--ink);
  display: flex; flex-direction: column; align-items: flex-start; justify-content: space-between;
  padding: 4px 5px;
  box-shadow: 3px 3px 0 0 var(--ink);
}
.pcard .suit { font-size: 14px; align-self: flex-end; color: var(--ink); }
.pcard .suit.red { color: var(--coral); }
.card-A { transform: rotate(-6deg); animation: cardBob 4s ease-in-out 0.0s infinite; }
.card-K { transform: rotate(-2deg); animation: cardBob 4s ease-in-out 0.2s infinite; }
.card-Q { transform: rotate( 3deg); animation: cardBob 4s ease-in-out 0.4s infinite; }
.card-J { transform: rotate( 7deg); animation: cardBob 4s ease-in-out 0.6s infinite; }
@keyframes cardBob {
  0%, 100% { translate: 0 0; }
  50%      { translate: 0 -5px; }
}

/* Auction */
.auction-stage { gap: 14px; }
.gavel { animation: hammer 1.6s ease-in-out infinite; transform-origin: bottom left; }
@keyframes hammer {
  0%, 60%, 100% { transform: rotate(0); }
  70% { transform: rotate(-25deg); }
  80% { transform: rotate(0); }
}

.q-text {
  font-family: 'Press Start 2P', monospace;
  font-size: 13px;
  line-height: 1.7;
  color: var(--ink);
  margin-bottom: 18px;
}
.q-text .zh { color: var(--coral); }

.opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.opt {
  text-align: left;
  font-family: 'VT323', monospace;
  font-size: 20px;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: 11px 14px;
  cursor: pointer;
  display: flex; align-items: center; gap: 10px;
  transition: background 0.12s, transform 0.08s;
}
.opt:hover { background: var(--paper-2); transform: translate(-1px, -1px); }
.opt .k {
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  background: var(--ink);
  color: var(--paper);
  padding: 4px 6px;
}
.opt:disabled { cursor: not-allowed; opacity: 0.45; }
.opt.correct {
  background: var(--sage);
  color: var(--paper);
  animation: pulseGood 0.6s ease;
}
.opt.correct .k { background: var(--paper); color: var(--ink); }
.opt.wrong {
  background: var(--coral);
  color: var(--paper);
  animation: shake 0.45s ease;
}
.opt.wrong .k { background: var(--paper); color: var(--ink); }
.opt.correct:disabled, .opt.wrong:disabled { opacity: 1; }
@keyframes pulseGood {
  0%   { box-shadow: 0 0 0 0 rgba(109, 140, 94, 0.6); }
  100% { box-shadow: 0 0 0 14px rgba(109, 140, 94, 0); }
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

.feedback {
  margin-top: 16px;
  min-height: 22px;
  text-align: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  letter-spacing: 2px;
}
.feedback.good { color: var(--sage-dark); }
.feedback.bad  { color: var(--coral-2); }

/* ============================================
   SCENE 6: CONGRATS
   ============================================ */
.scene-congrats { flex-direction: column; }
.congrats-inner {
  text-align: center;
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 0 var(--ink);
  padding: 36px 36px 32px;
  max-width: 480px;
  width: 100%;
}
.trophy-svg {
  width: 96px; height: 96px;
  display: block;
  margin: 0 auto 18px;
  animation: trophyBob 2s ease-in-out infinite;
}
@keyframes trophyBob {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-6px); }
}
.congrats-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(16px, 3.4vw, 24px);
  color: var(--ink);
  letter-spacing: 4px;
  margin-bottom: 12px;
}
.congrats-sub {
  font-size: 22px;
  color: var(--ink-soft);
  margin-bottom: 28px;
  font-style: italic;
}

/* ============================================
   SCENE 7: LETTER
   ============================================ */
.scene-letter { flex-direction: column; padding: 30px 24px; }
.letter-paper {
  background:
    repeating-linear-gradient(0deg, transparent 0 22px, rgba(42,29,18,0.06) 22px 23px),
    linear-gradient(135deg, #fbf2d8 0%, #ecd9a8 100%);
  color: var(--ink);
  width: min(560px, 95vw);
  padding: 40px 44px 36px;
  border: 3px solid var(--ink);
  box-shadow:
    0 0 0 3px var(--paper-3),
    0 0 0 6px var(--ink),
    10px 14px 0 0 rgba(42,29,18,0.4);
  position: relative;
  font-family: 'Special Elite', 'VT323', monospace;
  font-size: 18px;
  line-height: 1.7;
  transform-origin: top center;
  animation: letterIn 0.9s cubic-bezier(0.22, 0.61, 0.36, 1) forwards;
}
@keyframes letterIn {
  0%   { opacity: 0; transform: scaleY(0.4) rotateX(70deg); }
  60%  { opacity: 1; }
  100% { opacity: 1; transform: scaleY(1) rotateX(0); }
}
.letter-stamp {
  position: absolute;
  top: -12px; right: -12px;
  background: var(--coral);
  color: var(--paper);
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  padding: 10px 8px;
  border: 3px solid var(--ink);
  text-align: center;
  line-height: 1.4;
  transform: rotate(8deg);
  box-shadow: 3px 3px 0 0 var(--ink);
}
.letter-content p {
  margin-bottom: 14px;
  opacity: 0;
  animation: lineIn 0.4s ease forwards;
}
.letter-content p:nth-child(1) { animation-delay: 0.9s; }
.letter-content p:nth-child(2) { animation-delay: 1.3s; }
.letter-content p:nth-child(3) { animation-delay: 1.7s; }
.letter-content p:nth-child(4) { animation-delay: 2.1s; }
.letter-content p:nth-child(5) { animation-delay: 2.5s; }
.letter-content p:nth-child(6) { animation-delay: 2.9s; }
.letter-content p:nth-child(7) { animation-delay: 3.3s; }
.salut { font-weight: bold; font-size: 22px; }
.sign  { font-size: 20px; margin-top: 18px; }
@keyframes lineIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.letter-cta {
  margin-top: 28px;
  opacity: 0;
  animation: fadeIn 0.6s ease 3.9s forwards;
}

/* ============================================
   SCENE 8: ACCOUNT FORM + MODAL
   ============================================ */
.form-card {
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 0 var(--ink);
  padding: 30px 30px 28px;
  width: min(420px, 100%);
}
.form-header {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  letter-spacing: 3px;
  color: var(--coral);
  text-align: center;
  margin-bottom: 14px;
}
.form-intro {
  text-align: center;
  font-size: 18px;
  color: var(--ink-soft);
  margin-bottom: 22px;
  font-style: italic;
}
.pixel-form { display: flex; flex-direction: column; gap: 14px; }

.role-picker {
  border: none;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.role-picker legend {
  grid-column: 1 / -1;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--ink);
  margin-bottom: 6px;
}
.role-opt {
  position: relative;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Press Start 2P', monospace;
  font-size: 12px;
  letter-spacing: 2px;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: 12px 10px;
  cursor: pointer;
  user-select: none;
  box-shadow: 3px 3px 0 0 var(--ink);
  transition: background 0.12s, transform 0.06s;
}
.role-opt input { position: absolute; opacity: 0; pointer-events: none; }
.role-opt:hover { background: var(--paper-2); }
.role-opt:has(input:checked) {
  background: var(--ink);
  color: var(--paper);
  box-shadow: 1px 1px 0 0 var(--ink);
  transform: translate(2px, 2px);
}
.pixel-label {
  display: flex; flex-direction: column; gap: 6px;
  font-family: 'Press Start 2P', monospace;
  font-size: 10px;
  letter-spacing: 2px;
  color: var(--ink);
}
.pixel-label input {
  font-family: 'VT323', monospace;
  font-size: 20px;
  background: var(--paper);
  color: var(--ink);
  border: 2px solid var(--ink);
  padding: 10px 12px;
  outline: none;
}
.pixel-label input:focus {
  border-color: var(--coral);
  box-shadow: 0 0 0 2px rgba(198, 79, 59, 0.25);
}
.form-error {
  color: var(--coral-2);
  font-size: 18px;
  text-align: center;
  min-height: 24px;
}
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(42, 29, 18, 0.55);
  display: flex; align-items: center; justify-content: center;
  z-index: 9500;
  padding: 24px;
}
.modal-backdrop[hidden] { display: none; }
.modal-card { animation: fadeIn 0.3s ease; }
#loginCancel { margin-top: 6px; align-self: center; }

/* ============================================
   SCENE 9: FINAL
   ============================================ */
.final-inner {
  text-align: center;
  max-width: 540px;
  width: 100%;
}
.final-title {
  font-family: 'Press Start 2P', monospace;
  font-size: clamp(16px, 3.2vw, 22px);
  letter-spacing: 3px;
  color: var(--ink);
  margin-bottom: 24px;
}
#finalName { color: var(--coral); }
.final-card {
  background: var(--paper);
  border: 3px solid var(--ink);
  box-shadow: 6px 6px 0 0 var(--ink);
  padding: 26px 26px;
  margin-bottom: 30px;
  font-size: 20px;
}
.final-card p:first-child { margin-bottom: 8px; }
.final-card .excited { color: var(--coral); font-style: italic; }
.final-foot {
  font-family: 'Press Start 2P', monospace;
  font-size: 11px;
  color: var(--ink);
  letter-spacing: 3px;
  margin-bottom: 6px;
}
.final-foot.small { font-size: 9px; color: var(--ink-soft); margin-bottom: 28px; }
#resetBtn { opacity: 0.55; }

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 560px) {
  body { font-size: 18px; }
  .title { letter-spacing: 4px; }
  .opts { grid-template-columns: 1fr; }
  .pcard { width: 38px; height: 56px; font-size: 10px; }
  .bird-medallion { width: 150px; height: 150px; }
  .bird-frame.large { width: 180px; height: 180px; }
  .btn { font-size: 10px; padding: 12px 18px; min-width: 180px; }
  .letter-paper { padding: 30px 24px; font-size: 16px; }
}
