/* Coping Mechanism — warm, gentle pixel-UI. Softer palette than HR Fever Dream. */
* { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --beige-0: #f4ece0;
  --beige-1: #e6d8c6;
  --beige-2: #cdb79b;
  --ink: #43382f;
  --ink-soft: #7a6a58;
  --paper: #fbf5ec;
  --energy: #e0913f;
  --calm: #5f97ac;
  --conn: #c77b8b;
  --good: #6f9d6a;
  --danger: #c06a52;
  --px: 4px;
}

body {
  background: #d8c3a6;
  color: var(--ink);
  font-family: "Courier New", ui-monospace, monospace;
  font-weight: bold;
  display: flex; justify-content: center; align-items: flex-start;
  min-height: 100vh; padding: 26px 16px;
  overflow-x: hidden; -webkit-tap-highlight-color: transparent; -webkit-text-size-adjust: 100%;
}
.btn, .audio-btn, .cal-cell { -webkit-user-select: none; user-select: none; }

#scene { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.scene-svg { width: 100%; height: 100%; display: block; }
.bar-block.drained .bar-fill { animation: drainPulse .5s steps(2) infinite; }
.bar-block.drained .bar { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger); }
@keyframes drainPulse { 50% { opacity: 0.3; } }
#scene.scene-image { background-size: cover; background-position: center; image-rendering: pixelated; }

#game {
  position: relative; z-index: 1; width: 100%; max-width: 860px;
  display: flex; flex-direction: column; gap: 14px;
  padding: 16px; margin-top: 8px;
  background: rgba(67, 56, 47, 0.08); border-radius: 4px;
  box-shadow: 0 12px 40px rgba(67, 56, 47, 0.32);
}

.audio-ctl { position: fixed; top: 14px; right: 14px; z-index: 3; display: flex; gap: 8px; }
.audio-btn { position: relative; width: 40px; height: 40px; padding: 7px; cursor: pointer;
  background: var(--paper); color: var(--ink); border: 3px solid var(--ink); box-shadow: 3px 3px 0 var(--beige-2); }
.audio-btn svg { width: 100%; height: 100%; fill: currentColor; display: block; }
.audio-btn:hover { background: var(--beige-0); }
.audio-btn:active { transform: translate(2px, 2px); box-shadow: 1px 1px 0 var(--beige-2); }
.audio-btn .slash { position: absolute; inset: 0; display: none; pointer-events: none; }
.audio-btn.muted { color: var(--ink-soft); opacity: 0.7; }
.audio-btn.muted .slash { display: block; }
.audio-btn.muted .slash::before { content: ""; position: absolute; top: 50%; left: 4px; right: 4px; height: 3px;
  background: var(--danger); transform: rotate(-45deg); transform-origin: center; }

/* ---- HUD ---- */
.hud { background: var(--paper); border: var(--px) solid var(--ink); box-shadow: 8px 8px 0 var(--beige-2); padding: 16px 18px; }
.bars { display: grid; grid-template-columns: 1fr 1fr 1fr 1fr auto; gap: 16px; align-items: end; }
.bar-block { position: relative; }
.bar-label { display: flex; justify-content: space-between; font-size: 13px; letter-spacing: 1px; margin-bottom: 5px; }
.bar-value { font-size: 15px; }
.bar { height: 20px; background: var(--beige-1); border: 3px solid var(--ink); position: relative; overflow: hidden; }
.bar-fill { height: 100%; width: 50%; transition: width .45s cubic-bezier(.22,.61,.36,1); }
.bar-fill.energy { background: var(--energy); }
.bar-fill.calm { background: var(--calm); }
.bar-fill.conn { background: var(--conn); }
.bar-fill.mom { background: var(--energy); }
.bar-block.low .bar { animation: pulse .8s steps(2) infinite; }
@keyframes pulse { 50% { border-color: var(--danger); box-shadow: 0 0 0 2px var(--danger); } }
.delta { position: absolute; right: 0; top: -14px; font-size: 11px; opacity: 0; pointer-events: none; }
.delta.show { animation: rise 1.1s steps(6) forwards; }
@keyframes rise { 0% { opacity: 1; transform: translateY(6px);} 100% { opacity: 0; transform: translateY(-10px);} }
.delta.up { color: var(--good); } .delta.down { color: var(--danger); }

.face { width: 46px; height: 46px; line-height: 0; align-self: center; }
.face .pxicon { width: 100%; height: 100%; }
.pxicon { display: block; image-rendering: pixelated; }
.portrait .pxicon { width: 108px; height: 108px; }

/* ---- Recovery Ladder ---- */
.ladder { margin-top: 16px; display: flex; align-items: center; gap: 12px; }
.ladder-track { display: grid; grid-template-columns: repeat(5, 1fr); gap: 6px; flex: 1; }
.ladder-pip {
  height: 34px; border: 3px solid var(--ink); background: var(--beige-1);
  display: flex; align-items: center; justify-content: center; font-size: 18px;
  filter: grayscale(0.5) opacity(0.55); transition: all .3s;
}
.ladder-pip.reached { filter: none; background: var(--beige-0); }
.ladder-pip.current {
  filter: none; background: var(--good); transform: translateY(-3px) scale(1.12);
  box-shadow: 0 4px 0 var(--ink); z-index: 2;
}
.ladder-pip.rockbottom.current { background: var(--danger); }
.ladder-pip.bump { animation: bump .5s ease-out; }
@keyframes bump { 40% { transform: translateY(-9px) scale(1.28); } 100% { } }
.ladder-label { min-width: 128px; text-align: right; font-size: 14px; letter-spacing: 1px; text-transform: uppercase; color: var(--ink-soft); }
.goal-label { font-size: 12px; letter-spacing: 1px; color: var(--energy); white-space: nowrap; }

.calendar { position: relative; display: grid; grid-template-columns: repeat(12, 1fr); gap: 5px; margin-top: 16px; }
.cal-cell { height: 26px; border: 3px solid var(--ink); background: var(--beige-1); font-size: 11px; font-weight: bold;
  text-align: center; line-height: 20px; color: var(--ink-soft); overflow: visible; position: relative; transition: background .2s, transform .2s; }
.cal-cell.done { background: var(--calm); color: var(--paper); }
.cal-cell.now { background: var(--energy); color: var(--paper); transform: translateY(-2px) scale(1.06); box-shadow: 0 3px 0 var(--ink); z-index: 2; }

/* ---- Stage / card ---- */
.stage { min-height: 420px; display: flex; }
.screen { flex: 1; background: var(--paper); border: var(--px) solid var(--ink); box-shadow: 8px 8px 0 var(--beige-2);
  padding: 34px; display: flex; flex-direction: column; align-items: center; text-align: center; justify-content: center; gap: 18px; }
.screen.card { will-change: transform, opacity; }
.screen.card.enter { animation: dealIn .3s cubic-bezier(.22,.61,.36,1) both; }
.screen.card.exit { animation: dealOut .2s cubic-bezier(.55,.06,.68,.19) both; }
@keyframes dealIn { 0% { transform: translateX(70px); opacity: 0; } 100% { transform: translateX(0); opacity: 1; } }
@keyframes dealOut { 0% { transform: translateX(0); opacity: 1; } 100% { transform: translateX(-70px); opacity: 0; } }
.hidden { display: none !important; }

.start h1 { font-size: 40px; letter-spacing: 3px; }
.subtitle { letter-spacing: 3px; font-size: 13px; color: var(--ink-soft); }
.pitch { font-size: 17px; max-width: 540px; line-height: 1.55; }
.fineprint { font-size: 12px; color: var(--ink-soft); font-weight: normal; max-width: 520px; line-height: 1.5; }

.portrait { width: 128px; height: 128px; border: var(--px) solid var(--ink); background: var(--beige-1);
  display: flex; align-items: center; justify-content: center; box-shadow: 5px 5px 0 var(--beige-2); }
.character { font-size: 14px; letter-spacing: 2px; text-transform: uppercase; color: var(--ink-soft); }
.description { font-size: 22px; line-height: 1.55; min-height: 96px; max-width: 560px; }
.description::after { content: "▌"; animation: blink 1s steps(1) infinite; }
.description.done::after { content: ""; }
@keyframes blink { 50% { opacity: 0; } }

.choices { display: flex; gap: 18px; flex-wrap: wrap; justify-content: center; }
.btn { font-family: inherit; font-weight: bold; font-size: 16px; background: var(--paper); color: var(--ink);
  border: var(--px) solid var(--ink); box-shadow: 5px 5px 0 var(--beige-2); padding: 15px 24px; cursor: pointer; letter-spacing: 1px; text-transform: uppercase; }
.btn:hover { background: var(--beige-0); }
.btn:active { transform: translate(3px, 3px); box-shadow: 2px 2px 0 var(--beige-2); }
.btn.primary { background: var(--ink); color: var(--paper); }
.btn.primary:hover { background: var(--ink-soft); }
.btn.choice { min-width: 190px; }
.btn:disabled { opacity: .4; cursor: default; }

.gameover h2 { font-size: 32px; letter-spacing: 2px; }
.gameover p { font-size: 18px; line-height: 1.6; max-width: 560px; }
.score { color: var(--ink-soft); font-size: 15px !important; }
.share-card { width: 100%; max-width: 480px; border: var(--px) solid var(--ink); box-shadow: 5px 5px 0 var(--beige-2); image-rendering: auto; }
.over-buttons { display: flex; gap: 14px; flex-wrap: wrap; justify-content: center; }

.foot { text-align: center; font-size: 12px; color: var(--paper); font-weight: normal; text-shadow: 0 1px 3px rgba(0,0,0,0.7); }

/* ---- Tablet ---- */
@media (max-width: 820px) { body { padding: 16px 10px; } #game { max-width: 100%; } }

/* ---- Phone ---- */
@media (max-width: 600px) {
  body { padding: 50px 6px 10px; align-items: stretch; }
  #game { padding: 8px; gap: 10px; box-shadow: 0 8px 24px rgba(67,56,47,0.32); }
  .hud { padding: 12px 12px; box-shadow: 5px 5px 0 var(--beige-2); }
  .bars { grid-template-columns: 1fr 1fr 1fr 1fr; gap: 8px; }
  .face { display: none; }
  .bar-label { font-size: 9px; letter-spacing: 0; }
  .bar-value { font-size: 12px; }
  .bar { height: 16px; border-width: 2px; }
  .ladder { margin-top: 12px; gap: 8px; flex-direction: column; align-items: stretch; }
  .ladder-label { text-align: center; min-width: 0; }
  .goal-label { text-align: center; }
  .ladder-pip { height: 30px; font-size: 15px; }
  .calendar { gap: 3px; margin-top: 12px; }
  .cal-cell { height: 22px; font-size: 9px; line-height: 16px; border-width: 2px; }
  .stage { min-height: 0; }
  .screen { padding: 22px 16px; box-shadow: 5px 5px 0 var(--beige-2); gap: 14px; }
  .start h1 { font-size: 27px; letter-spacing: 2px; }
  .subtitle { font-size: 11px; letter-spacing: 2px; }
  .pitch { font-size: 15px; }
  .portrait { width: 92px; height: 92px; }
  .portrait .pxicon { width: 78px; height: 78px; }
  .description { font-size: 18px; min-height: 72px; }
  .choices { flex-direction: column; width: 100%; gap: 12px; }
  .btn.choice { min-width: 0; width: 100%; }
  .btn { font-size: 15px; padding: 14px 18px; box-shadow: 4px 4px 0 var(--beige-2); }
  .gameover h2 { font-size: 26px; }
  .gameover p { font-size: 16px; }
  .share-card { max-width: 100%; }
  .over-buttons { flex-direction: column; width: 100%; }
  .over-buttons .btn { width: 100%; }
  .audio-ctl { top: 8px; right: 8px; gap: 6px; }
  .audio-btn { width: 34px; height: 34px; padding: 6px; }
}
@media (max-width: 380px) {
  .bar-label { font-size: 8px; } .bar-value { font-size: 11px; }
  .cal-cell { font-size: 8px; } .ladder-pip { font-size: 13px; height: 26px; }
  .start h1 { font-size: 23px; } .description { font-size: 16px; }
}
