* { box-sizing: border-box; }
body {
  margin: 0; overflow: hidden;
  font-family: "VT323", "Courier New", monospace;
  background: #14101c; color: #f2e6d4;
  user-select: none; font-size: 20px;
}
#game-wrap, #game-wrap canvas { position: fixed; inset: 0; }
#game-wrap canvas { display: block; image-rendering: pixelated; }
#game-wrap::after {
  content: ""; position: fixed; inset: 0; pointer-events: none;
  background: radial-gradient(ellipse at center, transparent 55%, rgba(10,6,18,.55) 100%);
}

/* ---- Stardew pixel panels: dark plum + orange trim, hard shadows ---- */
#hud {
  position: fixed; top: 12px; left: 12px;
  display: flex; gap: 8px; z-index: 5;
  font-size: 22px;
}
.pill {
  background: #2e2440; color: #f2e6d4; border: 3px solid #d97b2e; border-radius: 6px;
  padding: 4px 12px; box-shadow: 4px 4px 0 rgba(0,0,0,.55);
  display: flex; align-items: center; gap: 8px;
  image-rendering: pixelated;
}
.dot { width: 12px; height: 12px; display: inline-block; border: 2px solid #000; }
.dot-green { background: #7fa653; }
.dot-blue { background: #6f8fb0; }
.vol-pill label { font-size: 20px; }
.vol-pill input[type="range"] { width: 110px; accent-color: #d97b2e; cursor: pointer; }
.vol-pill span { min-width: 28px; text-align: right; }

#toast {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  background: #2e2440; color: #f2e6d4; padding: 6px 18px; border-radius: 6px;
  opacity: 0; transition: opacity .3s; z-index: 5;
  font-size: 22px; border: 3px solid #d97b2e; max-width: 82vw; text-align: center;
  box-shadow: 4px 4px 0 rgba(0,0,0,.55);
}
#err {
  position: fixed; bottom: 64px; left: 50%; transform: translateX(-50%); z-index: 30;
  background: #5a1f28; color: #ffe3e3; border: 3px solid #ff8c8c; border-radius: 6px;
  padding: 8px 18px; max-width: 86vw; text-align: center; font-size: 21px;
  box-shadow: 4px 4px 0 rgba(0,0,0,.6);
}
#prompt {
  position: fixed; bottom: 12px; left: 50%; transform: translateX(-50%);
  background: #2e2440; color: #cfc2ad; border: 3px solid #6a5a7a; border-radius: 6px;
  padding: 4px 14px; font-size: 19px; z-index: 5; white-space: nowrap;
}

#fight {
  position: fixed; top: 12px; right: 12px; z-index: 6;
  background: #2e2440; color: #f2e6d4; border: 3px solid #d97b2e; border-radius: 6px;
  padding: 10px 16px 12px; width: 270px; box-shadow: 5px 5px 0 rgba(0,0,0,.55);
  text-align: center;
}
#fight h2 { margin: 0; font-size: 26px; font-weight: normal; color: #f0a04a; }
#fight-sub { margin: 2px 0 8px; font-size: 20px; }
.fight-hint { margin: 6px 0 0; font-size: 18px; color: #cfc2ad; }
.bars label { font-size: 18px; letter-spacing: .08em; text-transform: uppercase; }
.bar { background: #14101c; border: 3px solid #000; outline: 2px solid #d97b2e; height: 16px; overflow: hidden; margin-bottom: 8px; }
.bar div { height: 100%; width: 100%; background: #7fa653; transition: width .2s; image-rendering: pixelated; }
#ehp { background: #b0503e; }

/* taunt speech bubble */
#taunt {
  position: fixed; top: 130px; left: 50%; transform: translateX(-50%); z-index: 7;
  background: #f7f0dc; color: #3a2c22; border: 3px solid #3a2c22; border-radius: 4px;
  box-shadow: 4px 4px 0 rgba(0,0,0,.55);
  padding: 8px 16px; max-width: 520px; text-align: center; font-size: 22px; line-height: 1.2;
}
#taunt::after {
  content: ""; position: absolute; left: 50%; bottom: -14px; width: 16px; height: 16px;
  background: #f7f0dc; border-right: 3px solid #3a2c22; border-bottom: 3px solid #3a2c22;
  transform: translateX(-50%) rotate(45deg);
}
#taunt b { display: block; font-size: 26px; letter-spacing: .04em; }
#taunt span { font-size: 20px; color: #6a5544; }

/* slap paw */
#paw {
  position: fixed; right: 6vw; bottom: 8vh; width: 150px; height: 150px; z-index: 8;
  pointer-events: none;
}
#paw .paw-pad {
  position: absolute; left: 25px; bottom: 0; width: 100px; height: 85px;
  background: #2b2b31; border: 4px solid #0e0d12; border-radius: 42px;
}
#paw .toe {
  position: absolute; width: 34px; height: 44px; background: #2b2b31;
  border: 4px solid #0e0d12; border-radius: 16px;
}
#paw .t1 { left: 8px; bottom: 70px; transform: rotate(-18deg); }
#paw .t2 { left: 58px; bottom: 92px; }
#paw .t3 { left: 108px; bottom: 70px; transform: rotate(18deg); }
#paw.swipe { animation: pawswipe .3s steps(4) 1; }
@keyframes pawswipe {
  0% { transform: translate(160px,140px) rotate(28deg) scale(.6); }
  40% { transform: translate(0,0) rotate(-8deg) scale(1.15); }
  100% { transform: translate(-40px,-30px) rotate(-14deg) scale(1); }
}
#paw.hitflash .paw-pad, #paw.hitflash .toe { background: #3d3d46; }

#start, #win {
  position: fixed; inset: 0; z-index: 10;
  display: flex; align-items: center; justify-content: center;
  background: rgba(12,8,20,.66); padding: 16px;
}
.card {
  max-width: 580px; background: #2e2440; border: 3px solid #d97b2e;
  border-radius: 6px; padding: 22px 28px; text-align: center;
  box-shadow: 6px 6px 0 rgba(0,0,0,.6); line-height: 1.4; color: #f2e6d4; font-size: 22px;
}
.card h1 { margin: 0 0 8px; font-size: 38px; font-weight: normal; color: #f0a04a; }
.story { background: #241d34; border: 2px solid #6a5a7a; border-radius: 4px; padding: 8px 14px; }
.controls { font-size: 20px; background: #1d1626; border: 2px solid #6a5a7a; border-radius: 4px; padding: 8px; color: #cfc2ad; }
button {
  font-family: inherit; font-size: 24px;
  background: #d97b2e; color: #1d1626; border: 3px solid #f2e6d4; border-radius: 6px;
  padding: 6px 26px; cursor: pointer; box-shadow: 4px 4px 0 rgba(0,0,0,.6);
}
button:hover { background: #f0a04a; }

/* ---- Sealed envelope + heart wax (matches reference) ---- */
#letter-wrap { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; padding: 20px; }
#letter-backdrop { position: absolute; inset: 0; background: rgba(10,6,18,.72); }
#sealed {
  position: relative; text-align: center; background: #2e2440; width: min(560px, 92vw);
  border: 3px solid #d97b2e; border-radius: 10px; padding: 40px 30px 26px;
  box-shadow: 6px 6px 0 rgba(0,0,0,.6);
  color: #f2e6d4; font-size: 24px;
}
#sealed::before {
  content: ""; position: absolute; top: -14px; left: 50%; transform: translateX(-50%) rotate(45deg);
  width: 22px; height: 22px; background: #6a5a3a; border: 3px solid #d97b2e;
}
/* ---- Sealed letter: chunky pixel art to match the UI ---- */
#sealed::before {
  content: ""; position: absolute; top: -13px; left: 50%; transform: translateX(-50%) rotate(45deg);
  width: 18px; height: 18px; background: #d97b2e; border: 3px solid #2e2440;
  box-shadow: 2px 2px 0 rgba(0,0,0,.5);
}
#sealed .env {
  width: 132px; height: 92px; margin: 0 auto 14px;
  background: #4a3a63;
  border: 4px solid #f2e6d4;
  box-shadow: 5px 5px 0 rgba(0,0,0,.55), inset 0 0 0 3px #2e2440;
  position: relative; image-rendering: pixelated;
}
/* envelope flap: two hard diagonal seams */
#sealed .env::before {
  content: ""; position: absolute; left: 4px; right: 4px; top: 4px; height: 40px;
  background:
    linear-gradient(to bottom right, transparent calc(50% - 3px), #f2e6d4 calc(50% - 3px) calc(50% + 3px), transparent calc(50% + 3px)) left top / 50% 100% no-repeat,
    linear-gradient(to bottom left, transparent calc(50% - 3px), #f2e6d4 calc(50% - 3px) calc(50% + 3px), transparent calc(50% + 3px)) right top / 50% 100% no-repeat;
}
/* Biscuit's paw mark, stamped in cream squares */
#sealed .env .pad {
  position: absolute; left: 50%; top: 54px; width: 26px; height: 22px; margin-left: -13px;
  background: #f2e6d4; box-shadow: 3px 3px 0 rgba(0,0,0,.4);
}
#sealed .env .toe {
  position: absolute; width: 11px; height: 13px;
  background: #f2e6d4; box-shadow: 2px 2px 0 rgba(0,0,0,.4);
}
#sealed .env .t1 { left: 50%; margin-left: -25px; top: 38px; }
#sealed .env .t2 { left: 50%; margin-left: -6px; top: 32px; }
#sealed .env .t3 { left: 50%; margin-left: 14px; top: 38px; }
.sealed-text { line-height: 1.4; margin: 8px 0 14px; }
.sealed-hint { font-size: 20px; opacity: .7; margin: 12px 0 0; color: #cfc2ad; }
/* pixel heart wax seal, built from hard squares */
#wax {
  position: relative; width: 104px; height: 88px; border: none; padding: 0;
  background: transparent; cursor: pointer; box-shadow: none;
  transition: transform .15s; image-rendering: pixelated;
}
#wax .px-heart {
  display: block; width: 10px; height: 10px;
  margin: 9px 0 0 7px; background: #d06a85;
  box-shadow:
    10px -10px #d06a85, 20px -10px #d06a85, 60px -10px #d06a85, 70px -10px #d06a85,
    10px 0 #d06a85, 20px 0 #a53a55, 30px 0 #a53a55, 50px 0 #a53a55, 60px 0 #a53a55, 70px 0 #d06a85, 80px 0 #d06a85,
    0 10px #a53a55, 10px 10px #a53a55, 20px 10px #a53a55, 30px 10px #a53a55, 40px 10px #a53a55, 50px 10px #a53a55, 60px 10px #a53a55, 70px 10px #a53a55, 80px 10px #a53a55,
    10px 20px #a53a55, 20px 20px #a53a55, 30px 20px #a53a55, 40px 20px #a53a55, 50px 20px #a53a55, 60px 20px #a53a55, 70px 20px #a53a55,
    20px 30px #7e2340, 30px 30px #7e2340, 40px 30px #7e2340, 50px 30px #7e2340, 60px 30px #7e2340,
    30px 40px #7e2340, 40px 40px #7e2340, 50px 40px #7e2340,
    40px 50px #7e2340;
  filter: drop-shadow(4px 4px 0 rgba(0,0,0,.45));
}
#wax span {
  position: absolute; inset: 0; display: flex; align-items: center; justify-content: center;
  font-size: 46px; color: #ffe3e8; text-shadow: 2px 2px 0 #5d1626;
  transform: translateY(-3px); pointer-events: none;
}
#wax:hover { transform: scale(1.07) rotate(-2deg); }
#wax:active { transform: scale(.93); }

/* ---- Open pixel letter, Stardew-like ---- */
#letter {
  position: relative; max-width: 640px; width: 100%; max-height: 90vh; overflow: auto;
  background: #ffd3dc;
  border: 4px solid #c9506e;
  box-shadow: 0 0 0 4px #ffd3dc, 0 0 0 8px #8e2f45, 0 18px 60px rgba(0,0,0,.6);
  border-radius: 2px;
  image-rendering: pixelated;
}
#letter .hearts-row {
  color: #ef7d99; background: #ffc2cf; text-align: center;
  letter-spacing: 4px; font-size: 20px; padding: 8px 6px;
  border-bottom: 3px solid #c9506e;
  text-shadow: 1px 1px 0 #a03a54; white-space: nowrap; overflow: hidden;
}
#letter .hearts-row:last-of-type { border-bottom: none; border-top: 3px solid #c9506e; }
.letter-body {
  position: relative; padding: 24px 32px 16px;
  font-size: 24px; line-height: 1.32; color: #7a3f21;
  text-shadow: 1px 1px 0 rgba(255,255,255,.55);
}
.letter-body h2 { font-size: 27px; margin: 0 0 12px; font-weight: normal; }
.letter-body p { margin: 0 0 12px; }
.big-heart { position: absolute; left: 50%; top: 46%; width: 78%; transform: translate(-50%,-50%); opacity: .55; pointer-events: none; }
.sign { margin-top: 16px; color: #5d2f18; }
#letter #close-letter { display: block; margin: 6px auto 16px; }
.hidden { display: none !important; }
@media (max-width: 600px) { .letter-body { padding: 20px 18px; font-size: 21px; } body { font-size: 18px; } }
