@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Playfair+Display:wght@500;600;700&display=swap');

:root {
  --cream: #fff8ef;
  --ink: #513b3d;
  --coral: #e87969;
  --coral-dark: #c85c57;
  --glass: rgba(255, 248, 239, .84);
}
* { box-sizing: border-box; }
html, body { width: 100%; height: 100%; margin: 0; overflow: hidden; background: #f5c0a5; font-family: 'DM Sans', sans-serif; color: var(--ink); }
button { font: inherit; border: 0; cursor: pointer; touch-action: manipulation; }
#game, #scene { position: fixed; inset: 0; width: 100%; height: 100%; }
#scene { display: block; outline: none; }
#top-ui { position: absolute; top: max(18px, env(safe-area-inset-top)); left: 18px; right: 18px; display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; pointer-events: none; }
.brand { font-weight: 700; font-size: 12px; letter-spacing: .18em; background: var(--glass); padding: 11px 14px; border-radius: 999px; box-shadow: 0 8px 28px #70463b18; backdrop-filter: blur(10px); }
.brand span { color: var(--coral); font-size: 16px; margin-left: 4px; }
#objective { position: relative; max-width: min(65%, 370px); text-align: right; font-size: 13px; line-height: 1.45; padding: 11px 14px; background: var(--glass); border-radius: 16px; box-shadow: 0 8px 28px #70463b18; backdrop-filter: blur(10px); }
#objective.quest-in { animation: quest-in .55s cubic-bezier(.2,.85,.3,1) both; }
@keyframes quest-in { from { opacity: 0; transform: translateX(72px); } to { opacity: 1; transform: translateX(0); } }
.hint { position: absolute; left: 50%; bottom: 122px; transform: translateX(-50%); background: rgba(70, 49, 48, .8); color: white; padding: 10px 15px; border-radius: 999px; font-size: 12px; white-space: nowrap; max-width: 90vw; text-align: center; }
.music-button { position: absolute; right: 18px; bottom: max(18px, env(safe-area-inset-bottom)); z-index: 6; display: flex; align-items: center; gap: 8px; min-height: 42px; padding: 10px 15px; border-radius: 999px; background: var(--glass); color: var(--ink); font-size: 12px; font-weight: 700; letter-spacing: .04em; box-shadow: 0 8px 28px #70463b18; backdrop-filter: blur(10px); transition: transform .15s ease, background .15s ease, color .15s ease; }
.music-button:active { transform: scale(.97); }
.music-button .music-icon { font-size: 17px; line-height: 1; color: var(--coral); }
.music-button.playing { background: rgba(200, 92, 87, .9); color: white; }
.music-button.playing .music-icon { color: white; animation: pulse 1.2s ease-in-out infinite; }
.hidden { display: none !important; }
#bottom-ui { position: absolute; bottom: max(18px, env(safe-area-inset-bottom)); left: 18px; right: 18px; display: flex; align-items: flex-end; justify-content: space-between; pointer-events: none; }
.control-note { background: var(--glass); border-radius: 12px; padding: 9px 12px; font-size: 11px; opacity: .85; }
.mobile-controls { display: none; align-items: center; gap: 12px; }
.joystick { width: 94px; height: 94px; border-radius: 50%; background: rgba(255,248,239,.36); border: 1px solid rgba(255,255,255,.65); box-shadow: inset 0 0 0 8px rgba(255,248,239,.15); position: relative; pointer-events: auto; touch-action: none; backdrop-filter: blur(5px); }
#stick { width: 40px; height: 40px; border-radius: 50%; background: rgba(255,248,239,.92); border: 1px solid #fff; position: absolute; left: 26px; top: 26px; box-shadow: 0 4px 14px #754b4130; }
.look-note { max-width: 110px; font-size: 11px; line-height: 1.4; color: white; text-shadow: 0 1px 4px #70463b; opacity: 0; }
.look-note.guide-show { animation: guide-in .55s cubic-bezier(.2,.85,.3,1) .1s both; }
.look-note.guide-hide { animation: guide-out .35s ease-in both; }
@keyframes guide-in { from { opacity: 0; transform: translateX(-52px); } to { opacity: 1; transform: translateX(0); } }
@keyframes guide-out { from { opacity: 1; transform: translateX(0); } to { opacity: 0; transform: translateX(-36px); } }
.action-bar { position: absolute; bottom: max(28px, env(safe-area-inset-bottom)); left: 50%; transform: translateX(-50%); z-index: 4; }
.primary { border-radius: 999px; padding: 13px 24px; background: linear-gradient(135deg, #f18b77, #d86a65); color: white; font-weight: 700; letter-spacing: .01em; box-shadow: 0 8px 24px #a64d4540; transition: transform .15s ease, filter .15s ease; }
.primary:active { transform: scale(.97); filter: brightness(.97); }
.overlay { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; padding: 22px; background: rgba(65, 43, 48, .32); backdrop-filter: blur(7px); }
#welcome-overlay { z-index: 8; }
.welcome-card { position: relative; width: min(100%, 470px); max-height: min(88vh, 720px); overflow: auto; text-align: center; padding: clamp(25px, 6vw, 46px); background: #fff9f0; border-radius: 24px; box-shadow: 0 25px 90px #432a2c45; border: 1px solid #fff; animation: card-in .4s ease-out both; }
.welcome-card h1 { font-family: 'Playfair Display', Georgia, serif; font-size: clamp(25px, 6vw, 36px); font-weight: 600; line-height: 1.2; margin: 12px 0 16px; }
.welcome-card > p:not(.eyebrow):not(.welcome-note) { font-family: 'Playfair Display', Georgia, serif; font-size: 16.5px; line-height: 1.8; color: #70595a; }
.welcome-card .primary { margin-top: 22px; }
.welcome-note { margin: 14px 0 0; font-size: 11.5px; color: #b98a80; }
.card-close { position: absolute; top: 12px; right: 12px; width: 34px; height: 34px; border-radius: 50%; background: #f6e3d7; color: var(--ink); font-size: 14px; line-height: 1; display: grid; place-items: center; }
.card-close:active { transform: scale(.94); }
.letter-card, .ending-card { width: min(100%, 470px); max-height: min(88vh, 720px); overflow: auto; text-align: center; padding: clamp(25px, 6vw, 46px); background: #fff9f0; border-radius: 24px 24px 22px 22px; box-shadow: 0 25px 90px #432a2c45; border: 1px solid #fff; animation: card-in .35s ease-out both; }
.letter-flower { font-size: 29px; color: #d98476; margin-bottom: 12px; }
.eyebrow { font-size: 10px; font-weight: 700; letter-spacing: .22em; color: #c57a6d; }
.letter-card h1, .ending-card h1 { font-family: 'Playfair Display', Georgia, serif; font-size: clamp(25px, 6vw, 38px); font-weight: 600; line-height: 1.2; margin: 12px 0 18px; }
.letter-card #letter-message, .ending-card > p:not(.eyebrow) { font-family: 'Playfair Display', Georgia, serif; font-size: 17px; line-height: 1.85; color: #70595a; }
.letter-sign { margin: 24px 0 28px; font-size: 13px; color: #c06c67; font-style: italic; }
.ending-card .big-heart { font-size: 54px; color: var(--coral); animation: pulse 1.2s ease-in-out infinite; }
.ending-card .primary { margin-top: 20px; }
.loading { position: absolute; inset: 0; z-index: 10; display: flex; flex-direction: column; align-items: center; justify-content: center; background: linear-gradient(160deg, #ffe4cc, #efb2a4); color: #6b4948; font-size: 14px; transition: opacity .5s ease; }
.loading.fade { opacity: 0; pointer-events: none; }
.loading-heart { font-size: 52px; color: #d86a65; animation: pulse 1.2s infinite; margin-bottom: 14px; }
.loading-sub { margin-top: 8px; font-size: 12px; opacity: .7; }
@keyframes pulse { 0%,100% { transform: scale(1); } 50% { transform: scale(1.12); } }
@keyframes card-in { from { opacity: 0; transform: translateY(14px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }
@media (max-width: 700px) {
  .mobile-controls { display: flex; }
  .control-note { display: none; }
  #top-ui { left: 12px; right: 12px; }
  .brand { font-size: 10px; padding: 10px 11px; }
  #objective { font-size: 11px; padding: 9px 10px; max-width: 65%; }
  .hint { bottom: 126px; font-size: 11px; }
  .music-button { right: 12px; }
  .action-bar { bottom: max(34px, env(safe-area-inset-bottom)); }
}
