:root {
  --ink: #5b3a58;
  --soft: #fff6f8;
  --card: #fff0f4;
  --pink: #f3b6c9;
  --pink2: #e48fae;
  --mint: #9fd8c4;
  --lav: #c9b7e8;
  --edge: #7a4f74;
}
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #f6dce4; font-family: "Mali", "Leelawadee UI", Tahoma, sans-serif; color: var(--ink); }
#game { position: fixed; inset: 0; }
#game canvas { image-rendering: pixelated; }
.hidden { display: none !important; }

/* ---------- HUD ---------- */
#hud { position: fixed; inset: 0; pointer-events: none; }
#profile { position: absolute; left: 12px; top: 12px; display: flex; gap: 10px; align-items: center; background: var(--soft); border: 3px solid var(--edge); border-radius: 18px; padding: 6px 14px 6px 6px; box-shadow: 0 3px 0 var(--edge); }
#profile-photo { width: 56px; height: 56px; border-radius: 50%; object-fit: cover; border: 3px solid var(--pink2); background: #fff; }
#profile-name { font-weight: 700; font-size: 18px; }
#profile-sub { font-size: 12px; opacity: .8; }
#hud-right { position: absolute; right: 12px; top: 12px; display: flex; flex-direction: column; align-items: flex-end; gap: 8px; }
#clock { text-align: right; background: var(--soft); border: 3px solid var(--edge); border-radius: 16px; padding: 6px 14px; box-shadow: 0 3px 0 var(--edge); }
#clock-time { font-size: 22px; font-weight: 700; }
#clock-date { font-size: 12px; }
#hotbar { position: absolute; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 6px; background: var(--soft); border: 3px solid var(--edge); border-radius: 14px; padding: 6px; box-shadow: 0 3px 0 var(--edge); pointer-events: auto; }
.slot { position: relative; width: 52px; height: 52px; border-radius: 10px; background: #fbe3ea; border: 2px solid #e7b9c8; display: grid; place-items: center; cursor: pointer; }
.slot img { width: 36px; height: 36px; image-rendering: pixelated; }
.slot .qty { position: absolute; right: 3px; bottom: 0; font-size: 13px; font-weight: 700; text-shadow: 0 0 3px #fff, 0 0 3px #fff; }
.slot .key { position: absolute; left: 4px; top: 1px; font-size: 10px; opacity: .55; }
.slot.sel { border-color: var(--pink2); background: #fff; box-shadow: 0 0 0 3px #f7c6d6; }
#prompt { position: absolute; left: 50%; bottom: 86px; transform: translateX(-50%); background: rgba(91, 58, 88, .88); color: #fff; padding: 6px 14px; border-radius: 12px; font-size: 15px; white-space: nowrap; }
#toasts { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); display: flex; flex-direction: column; gap: 6px; align-items: center; }
.toast { background: var(--soft); border: 2px solid var(--edge); border-radius: 12px; padding: 5px 14px; font-size: 14px; animation: pop 3.2s forwards; display: flex; gap: 6px; align-items: center; }
.toast img { width: 22px; height: 22px; image-rendering: pixelated; }
@keyframes pop { 0% { opacity: 0; transform: translateY(-8px); } 10%, 80% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#help { position: absolute; right: 12px; bottom: 14px; font-size: 11px; background: rgba(255, 246, 248, .8); border-radius: 8px; padding: 3px 8px; }

/* ---------- panels ---------- */
.panel { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); background: var(--card); border: 4px solid var(--edge); border-radius: 20px; box-shadow: 0 5px 0 var(--edge); padding: 14px; z-index: 20; max-width: 94vw; max-height: 88vh; overflow: auto; }
.panel-head { display: flex; align-items: center; gap: 10px; font-size: 18px; margin-bottom: 10px; }
.panel-head .x { margin-left: auto; }
button { font-family: inherit; color: var(--ink); background: #fff; border: 2px solid var(--edge); border-radius: 12px; padding: 6px 14px; font-size: 15px; cursor: pointer; box-shadow: 0 2px 0 var(--edge); }
button:hover { background: #ffe6ee; }
button:disabled { opacity: .45; cursor: default; }
#inv-grid { display: grid; grid-template-columns: repeat(8, 52px); gap: 6px; }
#inv-grid .slot:nth-child(-n+8) { background: #fff3c8; }
#inv-info { margin-top: 10px; font-size: 13px; min-height: 20px; }
#dialog { width: min(560px, 94vw); }
#dlg-name { font-weight: 700; }
#dlg-hearts { font-size: 14px; letter-spacing: 1px; }
#dlg-text { background: #fff; border-radius: 12px; padding: 10px 12px; min-height: 54px; font-size: 16px; line-height: 1.5; }
#dlg-actions { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.trade { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 12px; padding: 6px 10px; margin-top: 6px; font-size: 14px; }
.trade .side { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; }
.trade img { width: 24px; height: 24px; image-rendering: pixelated; }
.trade .arrow { font-size: 18px; }
.trade button { margin-left: auto; padding: 3px 10px; font-size: 13px; }
.have-ok { color: #3e8f6c; } .have-no { color: #c0567a; }

/* ---------- screens ---------- */
.screen { position: fixed; inset: 0; display: grid; place-items: center; background: radial-gradient(circle at 50% 30%, #fff3f7, #f3c9d8 70%); z-index: 30; overflow: auto; padding: 16px; }
.screen p { text-align: center; }
.spinner { width: 46px; height: 46px; border-radius: 50%; border: 6px solid #f6cfdc; border-top-color: var(--pink2); animation: spin 1s linear infinite; margin: 10px auto; }
@keyframes spin { to { transform: rotate(360deg); } }
.create-card { width: min(640px, 96vw); background: var(--card); border: 4px solid var(--edge); border-radius: 24px; box-shadow: 0 6px 0 var(--edge); padding: 18px 22px; }
.create-card h1 { margin: 0; text-align: center; font-size: 34px; }
.lead { margin: 4px 0 14px; }
#create-form label { display: block; font-size: 14px; margin-bottom: 8px; font-weight: 600; }
#create-form input, #create-form select, #create-form textarea { display: block; width: 100%; margin-top: 3px; font-family: inherit; font-size: 15px; padding: 7px 10px; border: 2px solid #e2b3c3; border-radius: 10px; background: #fff; color: var(--ink); }
.photo-row { display: flex; gap: 14px; }
.photo-row .fields { flex: 1; }
#photo-drop { width: 170px; height: 170px; border: 3px dashed var(--pink2); border-radius: 18px; display: grid; place-items: center; cursor: pointer; overflow: hidden; background: #fff; text-align: center; position: relative; flex-shrink: 0; }
#photo-drop input { display: none !important; }
#photo-preview { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; display: none; }
#photo-hint { font-size: 14px; font-weight: 400; }
.two { display: flex; gap: 10px; } .two label { flex: 1; }
#create-btn { width: 100%; margin-top: 6px; font-size: 18px; padding: 10px; background: var(--pink); }
#mode-note, .small { font-size: 12px; opacity: .8; }
@media (max-width: 560px) { .photo-row { flex-direction: column; align-items: center; } .two { flex-direction: column; gap: 0; } #inv-grid { grid-template-columns: repeat(6, 46px); } .slot { width: 46px; height: 46px; } #help { display: none; } }

/* ---------- NPC menus ---------- */
#clock-buff { font-size: 12px; margin-top: 2px; color: #8a4f9a; }
#clock-buff:empty { display: none; }
#clock-stage { font-size: 12px; margin-top: 2px; color: #b0607e; font-weight: 700; }
#dialog { width: min(640px, 96vw); display: flex; flex-direction: column; }
#dlg-text { white-space: pre-line; }
#dlg-actions button { padding: 5px 11px; font-size: 14px; }
#dlg-actions button.on { background: var(--pink); }
#dlg-actions .dot { font-size: 12px; }
#dlg-sub { overflow: auto; max-height: 46vh; display: flex; flex-direction: column; gap: 6px; }
#dlg-sub:empty { display: none; }
#dlg-sub .hint { margin: 2px 0; font-size: 13px; opacity: .85; }
#dlg-sub .row { display: flex; align-items: center; gap: 8px; background: #fff; border-radius: 12px; padding: 6px 10px; font-size: 14px; }
#dlg-sub .row .side { display: flex; gap: 4px 8px; align-items: center; flex-wrap: wrap; }
#dlg-sub .row .arrow { font-size: 18px; }
#dlg-sub .row .worth { flex-basis: 100%; font-size: 11px; color: #a08aa8; }
#dlg-sub .row button { margin-left: auto; padding: 3px 12px; font-size: 13px; flex-shrink: 0; }
#dlg-sub .row button + button { margin-left: 0; }
#dlg-sub .row.locked { opacity: .55; }
#dlg-sub .row.done { background: #eef8ee; }
#dlg-sub .stage-need { align-self: stretch; display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin: 6px 0; }
#dlg-sub .unlocks { font-size: 13px; line-height: 1.6; }
#dlg-sub .stage-need .row { background: #fff7fa; border: 1px solid #f0dbe4; }
#dlg-sub button.big { display: block; margin: 10px auto 0; padding: 6px 22px; font-size: 15px; }
.it { display: inline-flex; align-items: center; gap: 3px; white-space: nowrap; }
.it img, .tips img { width: 24px; height: 24px; image-rendering: pixelated; }
.it small { opacity: .8; }
.card { background: #fff; border-radius: 14px; padding: 10px 12px; font-size: 14px; display: flex; flex-direction: column; gap: 5px; align-items: flex-start; }
.card p { margin: 0; }
.card.done { opacity: .65; }
.card.special { background: linear-gradient(135deg, #fff7d6, #ffe6f0); border: 2px solid #f1c6d6; }
.card-title { font-weight: 700; font-size: 15px; }
.card-title small { font-weight: 400; opacity: .7; }
.card .line { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.card button { padding: 4px 14px; font-size: 14px; }
button.big { font-size: 18px; padding: 10px 20px; align-self: center; }
.pick-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 6px; }
button.pick { position: relative; display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; font-size: 12px; box-shadow: 0 2px 0 #d9a9bd; border-color: #d9a9bd; }
button.pick img { width: 32px; height: 32px; image-rendering: pixelated; }
button.pick small { opacity: .7; }
button.pick .like { position: absolute; right: 5px; top: 3px; color: #e0628c; }
button.pick.on { background: var(--pink); border-color: var(--edge); }
button.pick.locked { opacity: .45; }
button.pick.small { flex-direction: row; font-size: 13px; padding: 4px 8px; }
button.pick.small img { width: 24px; height: 24px; }
table.tips { border-collapse: collapse; background: #fff; border-radius: 12px; font-size: 13px; width: 100%; }
table.tips th, table.tips td { padding: 3px 6px; text-align: left; border-bottom: 1px solid #f6dde6; }
.dress { display: flex; gap: 12px; align-items: flex-start; }
.dress canvas { background: radial-gradient(circle, #fff, #fde3ec); border-radius: 16px; width: 180px; height: auto; image-rendering: pixelated; flex-shrink: 0; }
.dress .slots { display: flex; flex-direction: column; gap: 4px; }
.dress-left { display: flex; flex-direction: column; gap: 6px; align-items: center; flex-shrink: 0; width: 210px; align-self: flex-start; }
.dress .dress-left canvas { width: 210px; }
.wear-row.center, .slot-title.center, .hint.center { justify-content: center; text-align: center; }
.pick.small.icon { padding: 3px 5px; } .pick.small.icon img { width: 20px; height: 20px; image-rendering: pixelated; }
.dress-stage { position: relative; }
.nudge-pad { position: absolute; right: 4px; bottom: 4px; display: grid; grid-template-areas: ". u ." "l c r" ". d ."; gap: 2px; opacity: .92; }
.nudge-pad .pick { min-width: 26px; padding: 2px 4px; justify-content: center; font-size: 12px; }
.slot-title { font-weight: 700; font-size: 13px; margin-top: 4px; }
.wear-row { display: flex; flex-wrap: wrap; gap: 5px; }
.memo { position: relative; background: #fffdf4; border-left: 4px solid #f1c6d6; border-radius: 10px; padding: 8px 12px; font-size: 14px; }
.memo p { margin: 3px 0 0; white-space: pre-line; }
.memo button { position: absolute; right: 6px; top: 6px; font-size: 11px; padding: 1px 8px; box-shadow: none; }
#dlg-sub textarea, #dlg-sub input:not([type=file]) { width: 100%; font-family: inherit; font-size: 14px; padding: 6px 9px; border: 2px solid #e2b3c3; border-radius: 10px; color: var(--ink); }
#dlg-sub input[type=file] { font-family: inherit; font-size: 13px; }
.album-add input:not([type=file]) { width: 100%; }
button.pick-photos { background: #fff0f6; }
.photo-strip { display: flex; gap: 6px; flex-wrap: wrap; }
.photo-strip:empty { display: none; }
.photo-strip img { width: 52px; height: 52px; object-fit: cover; border-radius: 8px; border: 2px solid #f1c6d6; }
/* the album: polaroids pinned slightly crooked on cream paper */
.album { display: grid; grid-template-columns: repeat(auto-fill, minmax(128px, 1fr)); gap: 14px 12px; padding: 14px 10px 6px;
  background: #fffaf0 repeating-linear-gradient(0deg, transparent 0 23px, rgba(214, 170, 190, .18) 23px 24px); border-radius: 14px; }
.album > .hint { grid-column: 1 / -1; text-align: center; }
button.polaroid { position: relative; padding: 7px 7px 6px; display: flex; flex-direction: column; gap: 2px; align-items: stretch; background: #fff;
  border: 0; border-radius: 3px; box-shadow: 0 3px 8px rgba(91, 58, 88, .18); transform: rotate(var(--tilt, 0deg)); transition: transform .15s; font-size: 12px; }
button.polaroid:hover { transform: rotate(0deg) scale(1.04); z-index: 1; }
button.polaroid::before { content: ""; position: absolute; top: -7px; left: 50%; width: 38px; height: 13px; margin-left: -19px;
  background: rgba(255, 196, 214, .75); transform: rotate(-3deg); } /* washi tape */
button.polaroid img { width: 100%; aspect-ratio: 1; object-fit: cover; background: #f6eef2; border-radius: 1px; }
button.polaroid img.broken { visibility: hidden; }
button.polaroid span { min-height: 1.2em; text-align: center; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
button.polaroid small { text-align: center; font-size: 10px; opacity: .55; }
#lightbox { position: fixed; inset: 0; z-index: 40; background: rgba(60, 36, 58, .8); display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #5b3a58; padding: 20px; }
.lb-card { background: #fff; padding: 12px 12px 10px; border-radius: 4px; box-shadow: 0 8px 30px rgba(0, 0, 0, .3); display: flex; flex-direction: column; gap: 8px; max-width: 92vw; }
.lb-card img { max-width: calc(92vw - 24px); max-height: 66vh; display: block; }
.lb-card p { margin: 0; text-align: center; font-size: 15px; }
.lb-card p small { display: block; font-size: 12px; opacity: .6; }
.lb-row { display: flex; gap: 10px; }
@media (max-width: 560px) { .dress { flex-direction: column; align-items: center; } }

/* ---------- test tools ---------- */
#devtools { position: absolute; left: 12px; top: 100px; display: flex; flex-direction: column; gap: 5px; background: rgba(255, 246, 248, .92); border: 2px dashed var(--edge); border-radius: 12px; padding: 6px 8px; pointer-events: auto; }
#devtools .dev-title { font-size: 12px; font-weight: 700; }
#devtools button { font-size: 13px; padding: 3px 10px; text-align: left; }

/* ---------- decorating the house ---------- */
#decor-toggle { position: absolute; right: 14px; bottom: 96px; pointer-events: auto; font-size: 15px; }
#decor { position: absolute; left: 50%; bottom: 10px; transform: translateX(-50%); width: min(860px, 96vw); background: var(--panel, #fff6f8);
  border: 3px solid var(--edge); border-radius: 16px; padding: 10px 12px; pointer-events: auto; display: flex; flex-direction: column; gap: 8px; z-index: 20; }
.decor-top { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 14px; }
.decor-top #decor-hint { flex: 1; opacity: .85; min-width: 200px; }
.decor-btns { display: flex; gap: 6px; }
.decor-btns button { font-size: 13px; padding: 4px 10px; }
#decor-list { max-height: 150px; overflow: auto; }
#decor-list button.pick img, #dlg-sub .furn img { width: 32px; height: 32px; image-rendering: pixelated; }
.tabs { display: flex; flex-wrap: wrap; gap: 4px; }
.tabs button { font-size: 12px; padding: 3px 9px; box-shadow: none; }
.tabs button.on { background: var(--pink); }
.quest-steps { display: flex; gap: 6px; font-size: 13px; flex-wrap: wrap; }
.quest-steps span { padding: 2px 8px; border-radius: 999px; background: #f3e3ea; }
.quest-steps span.done { background: #cdeccf; }
.quest-steps span.cur { background: var(--pink); font-weight: 700; }
#decor-list .hint { grid-column: 1 / -1; margin: 4px 0; }
/* stardust */
#stardust { display: flex; gap: 6px; align-items: center; background: var(--soft); border: 3px solid var(--edge); border-radius: 14px; padding: 3px 12px 3px 8px; box-shadow: 0 3px 0 var(--edge); font-size: 17px; }
#stardust .sd-ic { font-size: 16px; }
#stardust.bump { animation: sdbump .5s; }
@keyframes sdbump { 0% { transform: scale(1); } 40% { transform: scale(1.18); background: #fff3c4; } 100% { transform: scale(1); } }
/* shipping box + shop */
#shipbox { width: min(620px, 96vw); }
#shipbox .hint { font-size: 13px; margin: 0 0 8px; }
.ship-label { font-weight: 700; margin: 10px 0 6px; display: flex; align-items: center; gap: 8px; }
#ship-mode { margin-left: auto; display: flex; gap: 4px; }
#ship-mode button, .shop-tabs button { font-size: 12px; padding: 3px 10px; }
#ship-mode button.on, .shop-tabs button.on { background: var(--pink); }
button.pick small.price { color: #8a6a1f; font-size: 11px; }
.shop-tabs { display: flex; gap: 6px; margin: 4px 0 8px; align-items: center; }
.shop-tabs .wallet { margin-left: auto; font-weight: 700; }
.shop-row { display: flex; align-items: center; gap: 8px; padding: 5px 6px; border-bottom: 1px dashed #e7c6d3; }
.shop-row img { width: 28px; height: 28px; image-rendering: pixelated; }
.shop-row .nm { flex: 1; }
.shop-row .nm small { display: block; opacity: .7; font-size: 11px; }
.shop-row .pr { font-weight: 700; color: #8a6a1f; min-width: 64px; text-align: right; }
.shop-row button { font-size: 12px; padding: 3px 10px; }

/* starter character pick on the create screen */
.starter-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 10px; }
#create-form .sp-card { display: flex; flex-direction: row; align-items: center; gap: 8px; border: 3px solid var(--edge); border-radius: 12px; padding: 6px 8px; background: #fff; cursor: pointer; }
#create-form .sp-card input { display: none; }
#create-form .sp-card:has(input:checked) { background: #ffe6ef; box-shadow: 0 3px 0 var(--edge); }
.sp-card img { width: 56px; height: 56px; image-rendering: pixelated; object-fit: contain; }
.sp-card .sp-ic { font-size: 30px; width: 56px; text-align: center; }
.sp-card b { display: block; font-size: 14px; }
.sp-card small { font-size: 11px; opacity: .75; }
/* pet picker */
#select-list { display: flex; flex-direction: column; gap: 8px; margin: 12px 0; }
.pet-card { display: flex; align-items: center; gap: 12px; border: 3px solid var(--edge); border-radius: 14px; padding: 8px 12px; background: #fff; }
.pet-card.last { background: #ffe6ef; box-shadow: 0 3px 0 var(--edge); }
.pet-card .pc-pic { width: 64px; height: 64px; display: grid; place-items: center; background: #fdf3f6; border-radius: 10px; font-size: 28px; }
.pet-card .pc-pic img { max-width: 64px; max-height: 64px; image-rendering: pixelated; }
.pet-card .pc-info { flex: 1; display: flex; flex-direction: column; }
.pet-card .pc-info b { font-size: 17px; }
.pet-card .pc-info small { font-size: 12px; opacity: .75; }
.pet-card button { min-width: 84px; }
#select-new { width: 100%; padding: 10px; font-size: 16px; }
.link-btn { background: none !important; border: none !important; box-shadow: none !important; color: #8a5a7a; padding: 2px 0 !important; font-size: 13px; text-decoration: underline; cursor: pointer; }
#create-form .sp-card.off { opacity: .45; cursor: not-allowed; }
#profile { pointer-events: auto; cursor: pointer; }
.pet-card .pc-btns { display: flex; gap: 6px; }
.pet-card .redraw { font-size: 12px; min-width: 0; }
.pet-card .del { min-width: 0; padding: 6px 9px; background: transparent; border-color: #d8b7c6; opacity: .7; }
.pet-card .del:hover { opacity: 1; background: #fde8ee; }
.ph-dialog { position: fixed; inset: 0; background: rgba(80, 40, 70, .35); display: grid; place-items: center; z-index: 100; }
.ph-box { width: min(380px, 90vw); background: var(--card); border: 4px solid var(--edge); border-radius: 18px; box-shadow: 0 5px 0 var(--edge); padding: 16px 18px; }
.ph-box p { white-space: pre-line; margin: 0 0 14px; text-align: center; line-height: 1.5; }
.ph-btns { display: flex; gap: 8px; justify-content: center; }
.ph-btns .yes { background: var(--pink); }
#species-note { display: block; font-size: 11px; font-weight: 400; opacity: .75; margin-top: 2px; }

/* ready-made pets to pick from */
#preset-box { margin: 4px 0 10px; }
#preset-box .preset-head { font-weight: bold; font-size: 14px; margin-bottom: 6px; }
#preset-box .preset-head small { font-weight: normal; opacity: .7; }
.preset-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(78px, 1fr)); gap: 6px; max-height: 260px; overflow-y: auto; padding: 2px; }
.preset-grid button { display: flex; flex-direction: column; align-items: center; gap: 2px; border: 3px solid var(--edge); border-radius: 10px; background: #fff; padding: 4px 2px; cursor: pointer; font: inherit; font-size: 11px; line-height: 1.2; }
.preset-grid button img { width: 56px; height: 56px; image-rendering: pixelated; object-fit: contain; }
.preset-grid button.on { background: #ffe6ef; box-shadow: 0 3px 0 var(--edge); }
.preset-grid button.near::after { content: "ใกล้เคียง"; font-size: 10px; color: #b0476b; }

/* home storage chest */
#dlg-sub .chest-grid { display: grid; grid-template-columns: repeat(8, 44px); gap: 4px; margin: 4px 0 10px; }
#dlg-sub .chest-slot { width: 44px; height: 44px; padding: 0; position: relative; border-radius: 8px; background: #fff7fa; }
#dlg-sub .chest-slot img { width: 32px; height: 32px; image-rendering: pixelated; }
#dlg-sub .chest-slot span { position: absolute; right: 3px; bottom: 1px; font-size: 11px; font-weight: 700; color: #5b3a58; }

/* ---------- memory card ---------- */
#memcard { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(60,36,64,0); backdrop-filter: blur(0); transition: background .8s, backdrop-filter .8s; }
#memcard.hidden { display: none; }
#memcard.mc-on { background: rgba(60,36,64,.45); backdrop-filter: blur(3px); }
.mc-flash { position: absolute; inset: 0; background: #fff; opacity: 0; pointer-events: none; }
#memcard.mc-on .mc-flash { animation: mcflash .9s ease-out; }
@keyframes mcflash { 0% { opacity: 0; } 12% { opacity: .85; } 100% { opacity: 0; } }
.mc-wrap { display: flex; flex-direction: column; align-items: center; gap: 12px; opacity: 0; }
#memcard.mc-on .mc-wrap { animation: mcfloat 1.6s cubic-bezier(.2,.8,.25,1) .5s forwards; }
@keyframes mcfloat { 0% { opacity: 0; transform: translateY(-60vh) rotate(-8deg) scale(.9); } 60% { opacity: 1; transform: translateY(12px) rotate(2deg) scale(1); } 100% { opacity: 1; transform: none; } }
.mc-img { height: min(74vh, 125vw); aspect-ratio: 4 / 5; border-radius: 18px; border: 4px solid var(--edge); box-shadow: 0 6px 0 var(--edge), 0 20px 50px rgba(40,20,40,.4); background: #fff; }
.mc-btns { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; }
.mc-keep { background: var(--pink); }
.mc-dust { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.mc-dust i { position: absolute; top: -12px; width: 6px; height: 6px; background: #fff6c8; box-shadow: 0 0 8px #fff2a8; opacity: 0; animation-name: mcdust; animation-timing-function: linear; animation-fill-mode: forwards; }
@keyframes mcdust { 0% { opacity: 0; transform: translateY(0); } 15% { opacity: 1; } 100% { opacity: 0; transform: translateY(100vh) translateX(30px); } }

/* ---------- story ---------- */
#story-btns { display: flex; gap: 6px; pointer-events: auto; }
#story-btns button { font-size: 20px; padding: 4px 9px; border-radius: 12px; border-width: 3px; }
#story-btns button.glow { animation: jglow 1.6s ease-in-out infinite; }
@keyframes jglow { 50% { background: #ffe9a8; box-shadow: 0 2px 0 var(--edge), 0 0 0 4px #ffe9a8; } }
#btn-letter:not(.hidden) { animation: jglow 1.2s ease-in-out infinite; }
#story-dlg { position: fixed; left: 50%; bottom: 18px; transform: translateX(-50%); width: min(760px, 96vw); min-height: 120px; z-index: 40; display: flex; gap: 14px; align-items: flex-start;
  background: var(--card); border: 4px solid var(--edge); border-radius: 20px; box-shadow: 0 5px 0 var(--edge); padding: 14px 18px; cursor: pointer; }
#story-dlg.hidden { display: none; }
#story-dlg.narration { background: #f4ecfb; font-style: italic; }
#sd-face { width: 84px; height: 84px; image-rendering: pixelated; background: #fff; border: 3px solid var(--pink2); border-radius: 16px; object-fit: contain; flex-shrink: 0; }
#sd-face.hidden, #sd-name.hidden { display: none; }
#sd-main { flex: 1; }
#sd-name { font-weight: 700; color: var(--pink2); font-size: 17px; margin-bottom: 2px; }
#sd-text { font-size: 18px; line-height: 1.55; white-space: pre-line; min-height: 2.6em; }
#sd-choices { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
#sd-choices button { text-align: left; }
#sd-choices.many { display: grid; grid-template-columns: 1fr 1fr; }
#sd-next { position: absolute; right: 16px; bottom: 8px; animation: bob 0.9s ease-in-out infinite; color: var(--edge); }
@keyframes bob { 50% { transform: translateY(3px); } }
#journal { width: min(520px, 94vw); }
.jq-ch { font-weight: 700; margin: 2px 0 8px; color: var(--pink2); }
.jq { background: #fff; border: 2px solid #ecc6d4; border-radius: 12px; padding: 8px 12px; margin-bottom: 8px; }
.jq.done { opacity: .6; }
.jq-t { font-weight: 700; }
.jq-who { font-size: 13px; opacity: .7; }
.jq-h { font-size: 14px; margin-top: 4px; }
.jq-more { font-size: 13px; margin-top: 4px; color: #7a5c70; }
.jq-more summary { cursor: pointer; color: var(--pink2); font-weight: 700; list-style: none; display: inline-block; }
.jq-more summary::-webkit-details-marker { display: none; }
.jq-more summary::after { content: " ▾"; }
.jq-more[open] summary::after { content: " ▴"; }
.jq-more div { margin-top: 3px; line-height: 1.5; }
.jq-sub { margin: 12px 0 6px; font-size: 13px; opacity: .7; }
#map canvas { display: block; max-width: 86vw; max-height: 72vh; border-radius: 12px; border: 3px solid var(--edge); }
#letter { position: fixed; inset: 0; z-index: 55; display: grid; place-items: center; background: rgba(60,36,64,.45); }
#letter.hidden { display: none; }
.letter-paper { width: min(520px, 92vw); max-height: 86vh; overflow: auto; background: #fffaf0; border: 4px solid #c9a27a; border-radius: 6px; box-shadow: 0 8px 0 #a07a58, 0 20px 50px rgba(40,20,40,.35);
  padding: 22px 26px; font-size: 17px; line-height: 1.7; color: #5b3a2c; background-image: repeating-linear-gradient(transparent 0 33px, #f0dcc4 33px 34px); }
#letter.open .letter-paper { animation: unfold .7s cubic-bezier(.2,.8,.3,1); }
@keyframes unfold { 0% { transform: scaleY(.05) rotate(-3deg); opacity: 0; } 100% { transform: none; opacity: 1; } }
.letter-paper p { margin: 0 0 10px; }
#letter-from { text-align: right; font-weight: 700; margin: 6px 0 12px; }
#letter-close { display: block; margin: 0 auto; }
.letter-map { width: 100%; border: 2px dashed #c9a27a; border-radius: 8px; margin: 6px 0; }
.letter-list { list-style: none; padding: 0; margin: 4px 0 10px; }
.letter-list li::before { content: "☐ "; }
.letter-list li.ok::before { content: "☑ "; color: #6aa86a; }
#cardbook { width: min(720px, 94vw); }
#cardbook-body { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
#cardbook-body .cb { border: 3px solid var(--edge); border-radius: 12px; background: #fff; aspect-ratio: 4/5; display: grid; place-items: center; overflow: hidden; cursor: pointer; padding: 0; }
#cardbook-body .cb img { width: 100%; height: 100%; object-fit: cover; }
#cardbook-body .cb.empty { background: repeating-linear-gradient(45deg, #fbe9f0 0 10px, #f6dfe9 10px 20px); color: #b48aa8; font-size: 30px; cursor: default; }

#story-hint { position: absolute; left: 50%; top: 92px; transform: translateX(-50%); background: #fff9e6; border: 3px solid var(--edge); border-radius: 14px; padding: 6px 16px; box-shadow: 0 3px 0 var(--edge); font-size: 16px; animation: hintIn .35s ease-out; }
#story-hint.hidden { display: none; }
@keyframes hintIn { from { opacity: 0; transform: translate(-50%, -6px); } to { opacity: 1; transform: translateX(-50%); } }
#bridge { position: fixed; inset: 0; z-index: 70; background: #1d1838; }
#bridge canvas { position: absolute; inset: 0; }
#bridge .br-clouds { position: absolute; left: 0; right: 0; top: 66%; height: 60px; background:
  radial-gradient(40px 22px at 10% 50%, #fff 60%, transparent 62%), radial-gradient(50px 26px at 25% 40%, #fff 60%, transparent 62%),
  radial-gradient(46px 24px at 42% 55%, #fff 60%, transparent 62%), radial-gradient(54px 26px at 58% 45%, #fff 60%, transparent 62%),
  radial-gradient(44px 22px at 74% 52%, #fff 60%, transparent 62%), radial-gradient(50px 26px at 90% 44%, #fff 60%, transparent 62%); opacity: .9; filter: drop-shadow(0 0 12px #c9b7e8); }
#bridge .br-text { position: absolute; left: 0; right: 0; top: 16%; text-align: center; color: #fff3cf; font-size: 26px; opacity: 0; }
#bridge .br-text.in { animation: brtext 4.4s ease forwards; }
#bridge .br-text { padding: 0 8%; line-height: 1.5; }
@keyframes brtext { 0% { opacity: 0; transform: translateY(8px); } 25%, 75% { opacity: 1; transform: none; } 100% { opacity: 0; } }
#bridge .br-skip { position: absolute; right: 18px; bottom: 18px; opacity: .8; }
#bridge.white { animation: brwhite .9s forwards; }
@keyframes brwhite { to { background: #fff; filter: brightness(3); opacity: 1; } }
.letter-paper.book { text-align: center; background-image: none; background: #fffdf6; border-color: #d9b8c8; box-shadow: 0 8px 0 #b48aa8; }
.book-photo { width: 180px; height: 180px; object-fit: cover; border-radius: 10px; border: 6px solid #fff; box-shadow: 0 3px 10px rgba(0,0,0,.2); transform: rotate(-2deg); margin: 6px 0 10px; }
.book-story { font-style: italic; }

#ringgame { position: fixed; inset: 0; z-index: 60; display: grid; place-items: center; background: rgba(60,36,64,.45); }
#ringgame .rg-card { width: min(380px, 92vw); background: linear-gradient(180deg, #fffaf4, #fbefe6); border: 3px solid #d8a98a; border-radius: 18px;
  box-shadow: 0 4px 0 #c08f70, 0 12px 28px rgba(80,40,40,.25); padding: 12px 14px 10px; font-family: Mali, Tahoma, sans-serif; color: #6b4632; }
#ringgame .rg-head { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
#ringgame .rg-head b { font-size: 16px; color: #7a4a30; }
#ringgame .rg-pips { display: flex; gap: 5px; }
#ringgame .rg-pips i { width: 12px; height: 12px; border-radius: 3px; background: #ead6c6; box-shadow: inset 0 -2px 0 #d8bca6; }
#ringgame .rg-pips i.on { background: #f2c95a; box-shadow: inset 0 -2px 0 #c99a2e, 0 0 6px #ffe08a; }
#ringgame .rg-stage { position: relative; margin: 10px 0 8px; border-radius: 12px; overflow: hidden; border: 3px solid #c99a6e; cursor: pointer; line-height: 0; }
#ringgame canvas { width: 100%; height: auto; image-rendering: pixelated; display: block; }
#ringgame .rg-pop { position: absolute; left: 0; right: 0; top: 14%; text-align: center; line-height: 1.2; font-weight: 700; font-size: 22px; opacity: 0; pointer-events: none; }
#ringgame .rg-pop.ok { color: #c07a12; text-shadow: 0 2px 0 #fff4c8; }
#ringgame .rg-pop.miss { color: #8d78a8; font-size: 16px; text-shadow: 0 1px 0 #fff; }
#ringgame .rg-pop.go { animation: rgPop .7s ease-out; }
@keyframes rgPop { 0% { opacity: 0; transform: translateY(8px) scale(.8); } 25% { opacity: 1; transform: none; } 100% { opacity: 0; transform: translateY(-14px); } }
#ringgame .rg-help { font-size: 12.5px; color: #9a7460; text-align: center; }
#ringgame .rg-help b { color: #7a4a30; }
#ringgame kbd { display: inline-block; padding: 0 5px; border: 1.5px solid #d8a98a; border-bottom-width: 3px; border-radius: 5px; background: #fff; font: inherit; font-size: 11.5px; color: #7a4a30; }
#ringgame.miss .rg-card { animation: shake .3s; }
@keyframes shake { 25% { transform: translateX(-6px); } 75% { transform: translateX(6px); } }

@keyframes drin { from { opacity: 0; } }
@keyframes drout { to { opacity: 0; filter: brightness(2); } }
@keyframes drift { to { transform: scale(1.06) translate(-10px, -6px); } }
@keyframes fadein { to { opacity: .95; } }
/* the credits (ผู้ใช้ 30 พ.ย.: สวยกว่านี้ + ข้อความส่งท้าย): a starry sky, the villagers with their accessories, the pet, a letter */
#credits { position: fixed; inset: 0; z-index: 75; background: #0f0b26; color: #fff3cf; overflow: hidden; animation: crin .9s ease both; }
#credits.out { animation: crout .9s ease forwards; }
@keyframes crin { from { opacity: 0; } }
@keyframes crout { to { opacity: 0; } }
#credits .cr-sky { position: absolute; inset: 0; width: 100%; height: 100%; }
#credits .cr-roll { position: absolute; left: 0; right: 0; top: 100%; display: flex; flex-direction: column; align-items: center; gap: 54px; padding: 0 20px; text-align: center; animation: roll 62s linear forwards; }
@keyframes roll { to { transform: translateY(calc(-100% - 50vh + 90px)); } }
#credits .cr-head { font-size: 34px; color: #ffe07a; text-shadow: 0 0 18px rgba(255,224,122,.45); line-height: 1.4; margin-bottom: 30px; }
#credits .cr-head small { display: block; font-size: 18px; color: #fff3cf; opacity: .8; }
#credits .cr { display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 24px; }
#credits .cr img { width: 132px; height: 132px; image-rendering: pixelated; object-fit: contain; filter: drop-shadow(0 0 14px rgba(255,230,170,.25)); animation: crbob 3s ease-in-out infinite; }
#credits .cr em { font-style: normal; font-size: 16px; opacity: .72; }
@keyframes crbob { 50% { transform: translateY(-4px); } }
#credits .cr-folk { margin-top: 10px; }
#credits .cr-sub { font-size: 20px; opacity: .85; margin-bottom: 14px; }
#credits .cr-grid { display: grid; grid-template-columns: repeat(5, 96px); gap: 14px 18px; justify-content: center; }
#credits .cr-grid div { display: flex; flex-direction: column; align-items: center; font-size: 14px; }
#credits .cr-grid img { width: 72px; height: 72px; image-rendering: pixelated; object-fit: contain; }
#credits .cr.last { position: relative; margin-top: 40px; }
#credits .cr.last img { width: 200px; height: 200px; position: relative; }
#credits .cr.last span { font-size: 34px; color: #ffe07a; text-shadow: 0 0 16px rgba(255,224,122,.5); }
#credits .cr-halo { position: absolute; top: 10px; width: 230px; height: 200px; border-radius: 50%; background: radial-gradient(rgba(255,236,170,.35), rgba(255,236,170,0) 68%); animation: crglow 4s ease-in-out infinite; }
@keyframes crglow { 50% { opacity: .55; transform: scale(1.08); } }
#credits .cr-msg { font-size: 24px; color: #ffe9b8; max-width: 640px; line-height: 1.5; }
#credits .cr-msg small { font-size: 14px; opacity: .65; }
#credits .cr-letter { margin-top: 70px; max-width: 620px; font-size: 22px; line-height: 1.75; color: #fff3cf; }
#credits .cr-letter p { margin: 0 0 34px; }
#credits .cr-letter .cr-to { font-size: 20px; opacity: .8; }
#credits .cr-letter .cr-sign { font-size: 20px; opacity: .85; margin-top: -10px; }
#credits .cr-letter .cr-last { font-size: 26px; color: #ffe07a; text-shadow: 0 0 14px rgba(255,224,122,.4); }
#credits .cr-end { font-size: 40px; margin-top: 60px; letter-spacing: 3px; color: #ffe07a; text-shadow: 0 0 22px rgba(255,224,122,.55); display: flex; flex-direction: column; gap: 8px; }
#credits .cr-end small { font-size: 16px; letter-spacing: 0; color: #fff3cf; opacity: .75; }
#credits .cr-skip { z-index: 2; }

/* the side-on cut scene at the end of chapter 5 (ending.js) */
#sidecut { position: fixed; inset: 0; z-index: 74; background: #0b0920; display: flex; align-items: center; justify-content: center; opacity: 0; transition: opacity .8s ease; }
#sidecut.in { opacity: 1; }
#sidecut.out { opacity: 0; }
#sidecut canvas { width: min(100vw, calc(100vh * 16 / 9)); height: auto; aspect-ratio: 16 / 9; image-rendering: pixelated; }
#sidecut .sc-cap { position: absolute; left: 50%; bottom: 8%; transform: translateX(-50%); width: max-content; max-width: min(86vw, 760px); box-sizing: border-box; padding: 10px 26px; border-radius: 16px; background: rgba(12,8,34,.62); box-shadow: 0 0 24px 10px rgba(12,8,34,.45); text-align: center; color: #fff6dc; font-size: 23px; font-weight: 600; line-height: 1.55; text-shadow: 0 2px 6px rgba(10,6,30,.95); opacity: 0; transition: opacity .45s ease; pointer-events: none; }
#sidecut .sc-cap:empty { display: none; }
#sidecut .sc-cap.on { opacity: 1; }
#sidecut .sc-cap.big { font-size: 28px; color: #ffe9b8; }
#sidecut .cr-skip { position: absolute; right: 18px; bottom: 18px; opacity: .8; }

#bridge .br-skips { position: absolute; right: 18px; bottom: 18px; display: flex; gap: 8px; }
#bridge .br-skips button { opacity: .85; }
#bridge .br-skip { position: static; }
.jq.missed { opacity: .45; background: #f6f0f4; }

/* ---------- achievements / collection / trophies ---------- */
#profile-title { font-size: 12px; color: #c07a2a; font-weight: 700; line-height: 1.2; }
#profile-title.hidden { display: none; }
#achbook { width: min(680px, 95vw); }
#achbook-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 10px; }
#achbook-body { max-height: 62vh; overflow: auto; }
.ab-sub { font-weight: 700; margin: 12px 0 6px; color: var(--pink2); }
.ab-sub small { color: var(--ink); opacity: .6; font-weight: 400; }
.ab-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 2px solid #ecc6d4; border-radius: 12px; padding: 6px 10px; margin-bottom: 6px; opacity: .55; }
.ab-row.ok { opacity: 1; background: #fffbea; border-color: #f0d38a; }
.ab-row > div { flex: 1; display: flex; flex-direction: column; }
.ab-row small { opacity: .75; }
.ab-ic { font-size: 20px; width: 26px; text-align: center; }
.ab-rw { font-size: 13px; white-space: nowrap; }
.coll-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(70px, 1fr)); gap: 6px; }
.coll { background: #fff; border: 2px solid #ecc6d4; border-radius: 10px; padding: 4px; text-align: center; font-size: 11px; display: flex; flex-direction: column; align-items: center; }
.coll img { width: 32px; height: 32px; image-rendering: pixelated; filter: brightness(0) opacity(.18); }
.coll.got img { filter: none; }
.coll span { line-height: 1.2; margin-top: 2px; }
.trophy-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 8px; }
.tro { background: #fff; border: 2px solid #ecc6d4; border-radius: 12px; padding: 8px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 4px; font-size: 12px; }
.tro img { height: 56px; image-rendering: pixelated; filter: brightness(0) opacity(.18); }
.tro.got { background: #fffbea; border-color: #f0d38a; }
.tro.got img { filter: none; }
.tro small { opacity: .7; }
.title-pick { display: block; width: 100%; text-align: left; margin-bottom: 6px; }
.title-pick.on { background: #ffe9a8; }
.ach-banner { position: fixed; left: 50%; top: 18px; transform: translateX(-50%); z-index: 80; display: flex; align-items: center; gap: 10px; background: #fffbea; border: 3px solid #e0b84a; border-radius: 16px; box-shadow: 0 4px 0 #c99a2e, 0 10px 30px rgba(0,0,0,.2); padding: 8px 16px; animation: abin .5s cubic-bezier(.2,.9,.3,1.3); }
.ach-banner.out { animation: about .5s forwards; }
.ach-banner div { display: flex; flex-direction: column; }
.ach-banner small { opacity: .75; }
@keyframes abin { from { transform: translate(-50%, -80px); opacity: 0; } }
@keyframes about { to { transform: translate(-50%, -80px); opacity: 0; } }

/* ---------- the sea of light: scooping minigame (sea.js) ---------- */
.sea-game { position: fixed; left: 50%; bottom: 110px; transform: translateX(-50%); z-index: 60; width: min(360px, 92vw);
  background: linear-gradient(180deg, #fffafd, #f6eefc); border: 3px solid #c9b3e6; border-radius: 18px; box-shadow: 0 4px 0 #b39ad6, 0 10px 24px rgba(80,50,120,.18); padding: 12px 14px 10px; font-family: Mali, Tahoma, sans-serif; }
.sea-game.hidden { display: none; }
.sea-head { display: flex; justify-content: space-between; align-items: center; }
.sea-title { font-weight: 700; color: #6b4f8f; font-size: 15px; }
.sea-stars { color: #f0b94a; letter-spacing: 1px; font-size: 14px; }
.sea-track { position: relative; height: 46px; margin: 10px 0 8px; border-radius: 14px; overflow: hidden;
  background: linear-gradient(180deg, #a9d4f5 0%, #8fb7ea 55%, #9c9be0 100%); box-shadow: inset 0 2px 6px rgba(40,40,110,.25); }
.sea-wave { position: absolute; inset: 0; background: repeating-linear-gradient(90deg, rgba(255,255,255,.18) 0 18px, transparent 18px 40px); animation: seaWave 3s linear infinite; }
@keyframes seaWave { to { background-position: 40px 0; } }
.sea-ring { position: absolute; top: 5px; bottom: 5px; left: 0; border: 3px solid #fff; border-radius: 50% / 40%; background: rgba(255,255,255,.14);
  box-shadow: 0 0 0 2px rgba(107,79,143,.35); transition: border-color .15s, background .15s; }
.sea-ring i { position: absolute; inset: 3px; border-radius: inherit; background: repeating-linear-gradient(45deg, rgba(255,255,255,.35) 0 2px, transparent 2px 6px), repeating-linear-gradient(-45deg, rgba(255,255,255,.35) 0 2px, transparent 2px 6px); }
.sea-ring.on { border-color: #ffe27a; background: rgba(255,236,150,.32); box-shadow: 0 0 10px #ffe27a; }
.sea-light { position: absolute; top: 15px; width: 16px; height: 16px; border-radius: 50%; background: radial-gradient(circle, #fff 0 30%, var(--c, #fffbe0) 60%, transparent 72%);
  box-shadow: 0 0 12px 4px var(--c, #fffbe0); }
.sea-prog { height: 10px; border-radius: 6px; background: #eadff5; overflow: hidden; box-shadow: inset 0 1px 2px rgba(80,50,120,.2); }
.sea-prog > div { height: 100%; width: 30%; background: linear-gradient(90deg, #ffd36e, #ff9fc2); transition: width .08s linear; }
.sea-help { font-size: 11.5px; color: #8d78a8; margin-top: 7px; line-height: 1.5; }
.sea-help b { color: #6b4f8f; }
.sea-lv { float: right; white-space: nowrap; color: #b08ac9; margin-left: 8px; }

#inv-info .inv-wear { margin-left: 6px; padding: 2px 10px; border-radius: 10px; border: 2px solid #e48fae; background: #fff0f4; color: #5b3a58; font: inherit; cursor: pointer; }
.mem-quote { margin: 10px 0; padding: 10px 14px; background: #fff6e8; border-left: 4px solid #f1c6d6; border-radius: 8px; font-size: 15px; white-space: pre-line; }
.mem-quote small { display: block; margin-top: 6px; font-size: 12px; opacity: .6; }
.pick-album { max-height: 52vh; overflow: auto; }
button.polaroid.on { outline: 3px solid #e48fae; }

/* ---------- the pet's book (book.js) ---------- */
#petbook { position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; background: rgba(60, 36, 64, .55); }
.bk-wrap { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.bk-spread { display: flex; filter: drop-shadow(0 14px 28px rgba(40, 20, 40, .35)); }
.bk-page { position: relative; width: min(400px, 44vw); height: min(580px, 76vh); overflow-y: auto; padding: 26px 28px 34px; box-sizing: border-box;
  background: #fffaf0 repeating-linear-gradient(0deg, transparent 0 27px, rgba(214, 170, 190, .16) 27px 28px); color: #5b3a58;
  display: flex; flex-direction: column; align-items: center; gap: 8px; text-align: center; animation: bkIn .25s ease-out; }
.bk-page.left { border-radius: 14px 0 0 14px; box-shadow: inset -18px 0 22px -18px rgba(120, 70, 100, .35); }
.bk-page.right { border-radius: 0 14px 14px 0; box-shadow: inset 18px 0 22px -18px rgba(120, 70, 100, .35); }
.bk-spread.one .bk-page { width: min(440px, 94vw); border-radius: 14px; box-shadow: none; }
.bk-page.blank { background: #fffaf0; }
@keyframes bkIn { from { opacity: .3; } to { opacity: 1; } }
.bk-num { position: absolute; bottom: 10px; left: 0; right: 0; font-size: 11px; opacity: .45; }
.bk-h { font-size: 12px; letter-spacing: .5px; color: #b07a9c; border-bottom: 1px dashed #e2b3c3; padding-bottom: 4px; align-self: stretch; }
.bk-page h3 { margin: 2px 0; font-size: 19px; }
.bk-text { margin: 0; text-align: left; align-self: stretch; white-space: pre-line; font-size: 15px; line-height: 28px; }
.bk-date { opacity: .5; font-size: 11px; margin-top: auto; }
.bk-tools { display: flex; gap: 6px; justify-content: center; flex-wrap: wrap; }
.bk-tools button.small, .bk-attach button.small { font-size: 12px; padding: 2px 10px; box-shadow: none; border-width: 1px; }
.bk-page:not(.write) .bk-tools { opacity: .35; transition: opacity .15s; } .bk-page:not(.write):hover .bk-tools { opacity: 1; }
.bk-page.blank { justify-content: center; }
.bk-note { margin: 0; font-size: 13px; opacity: .75; }
.bk-empty { font-size: 13px; opacity: .6; grid-column: 1 / -1; }
/* polaroids taped to the page */
.bk-pol { position: relative; background: #fff; padding: 7px 7px 9px; box-shadow: 0 3px 8px rgba(91, 58, 88, .2); transform: rotate(var(--tilt, -1.5deg)); }
.bk-pol::before { content: ""; position: absolute; top: -8px; left: 50%; width: 46px; height: 14px; margin-left: -23px; background: rgba(255, 196, 214, .75); transform: rotate(-3deg); }
.bk-pol img { display: block; width: 210px; max-width: 100%; aspect-ratio: 4 / 3; object-fit: cover; background: #f6eef2; }
.bk-pol.big img { width: 170px; aspect-ratio: 1; }
.bk-pol.small img { width: 120px; }
.bk-pol span { display: block; font-size: 11px; margin-top: 4px; }
.bk-photos { display: grid; grid-template-columns: 1fr 1fr; gap: 18px 12px; justify-items: center; padding-top: 8px; }
.bk-fact { font-size: 14px; } .bk-fact b { color: #b07a9c; font-weight: 700; margin-right: 4px; }
.bk-story { margin: 4px 0; font-size: 14px; font-style: italic; white-space: pre-line; }
.bk-keep { margin-top: 6px; padding: 6px 12px; background: #fff0f6; border-radius: 10px; font-size: 14px; }
.bk-keep small { display: block; font-size: 11px; opacity: .6; }
/* the cover: pink cloth, a paper label, the real photo */
.bk-page.cover { background: #f2b8cb repeating-linear-gradient(45deg, rgba(255, 255, 255, .08) 0 2px, transparent 2px 6px); justify-content: center; }
.bk-cover-in { background: #fffaf0; border: 3px double #d79ab4; border-radius: 10px; padding: 18px 22px; display: flex; flex-direction: column; align-items: center; gap: 6px; }
.bk-cover-in h2 { margin: 4px 0 0; font-size: 22px; }
.bk-cover-in p { margin: 0; font-size: 13px; opacity: .7; }
.bk-cover-in small { font-size: 11px; opacity: .6; }
.bk-label { font-size: 11px; letter-spacing: 1px; color: #b07a9c; }
.bk-photo img { width: 140px; height: 140px; object-fit: cover; border-radius: 50%; border: 4px solid #fff; box-shadow: 0 0 0 3px #f1c6d6; }
/* the sky-village notes at the back: small and quiet */
.bk-page.village ul { margin: 0; padding: 0; list-style: none; text-align: left; align-self: stretch; font-size: 12.5px; display: flex; flex-direction: column; gap: 6px; }
.bk-page.village li small { display: block; font-size: 10px; opacity: .5; }
/* writing a page */

.bk-chips { display: flex; flex-wrap: wrap; gap: 5px; justify-content: center; }
.bk-chips .chip { font-size: 12px; padding: 2px 9px; box-shadow: none; background: #fff0f6; border-width: 1px; border-color: #e7b5c8; }
.bk-chips .chip:hover { background: #ffe0ec; }
.bk-attach { display: flex; align-items: center; gap: 10px; }
.bk-nav { display: flex; gap: 8px; align-items: center; }
.bk-nav .bk-where { color: #fff; font-size: 13px; min-width: 60px; text-align: center; }
.mem-quote b { display: block; font-size: 13px; color: #b07a9c; margin-bottom: 4px; }
/* ---------- writing in the pet's book: ink on lined paper, not a form ---------- */
#petbook .bk-spread.guided .bk-page { width: min(560px, 94vw); height: min(640px, 82vh); border-radius: 14px; box-shadow: inset 22px 0 26px -22px rgba(120, 70, 100, .35); }
.bk-page.turn { animation: bkTurn .35s ease-out; }
@keyframes bkTurn { from { opacity: 0; transform: perspective(900px) rotateY(-12deg) translateX(14px); } to { opacity: 1; transform: none; } }
.bk-writing { display: flex; flex-direction: column; gap: 10px; align-self: stretch; flex: 1; }
.bk-w-head h3 { margin: 0; font-size: 22px; }
.bk-hint { margin: 2px 0 0; font-size: 13.5px; color: #a27d97; font-style: italic; }
.bk-title-in { border: 0 !important; border-bottom: 2px dashed #e2b3c3 !important; border-radius: 0; background: transparent !important; font: inherit; font-size: 21px; font-weight: 700; color: #5b3a58; text-align: center; padding: 10px 6px 8px; line-height: normal; height: 2.6em; overflow: visible; width: 100%; box-sizing: border-box; }
/* Thai marks above and below the letters (ั ้ ื ุ) were cut off in one-line boxes: normal line height, room around */
.bk-title-in::placeholder, .bk-when-in::placeholder { line-height: normal; }
.bk-title-in:focus, .bk-when-in:focus, .bk-ink:focus { outline: none; }
.bk-when { display: flex; align-items: baseline; gap: 6px; font-size: 13px; color: #b07a9c; align-self: center; width: min(340px, 100%); }
.bk-when-in { flex: 1; min-width: 0; border-radius: 0; line-height: normal; height: 2.2em; box-sizing: border-box; border: 0; border-bottom: 1.5px solid #ecc7d4; background: transparent; font: inherit; font-size: 13.5px; color: #5b3a58; padding: 2px 4px; }
.bk-when-read { font-size: 12px; color: #b07a9c; }
/* one ruled line per line of text: 32px each, the rule sits just under the letters (Thai needs room above and below) */
.bk-ink { flex: 1; min-height: 192px; width: 100%; box-sizing: border-box; border: 0; border-radius: 0; resize: none; padding: 1px 2px 0; margin: 0; font: inherit; font-size: 15.5px; color: #4b2f4a;
  line-height: 32px; background: transparent repeating-linear-gradient(180deg, transparent 0 30px, rgba(214, 170, 190, .6) 30px 31px, transparent 31px 32px); background-attachment: local; }
.bk-ink::placeholder { color: #c9a5bb; font-style: italic; }
.bk-ink.nudge { animation: bkNudge .5s; }
@keyframes bkNudge { 20%, 60% { transform: translateX(-4px); } 40%, 80% { transform: translateX(4px); } }
.bk-slot { display: flex; flex-direction: column; align-items: center; gap: 4px; }
.bk-slot.busy { opacity: .5; pointer-events: none; }
button.bk-pol-slot { border: 0; cursor: pointer; font: inherit; }
button.bk-pol-slot.empty { background: rgba(255, 255, 255, .55); outline: 2px dashed #e2b3c3; outline-offset: -6px; box-shadow: none; width: 150px; height: 118px; display: grid; place-items: center; color: #b07a9c; font-size: 13px; line-height: 1.5; }
.bk-photos button.bk-pol-slot.empty { width: 134px; height: 112px; }
.bk-w-btns { display: flex; justify-content: space-between; align-items: center; gap: 10px; }
button.bk-link { background: none; border: 0; box-shadow: none; color: #a27d97; text-decoration: underline; text-underline-offset: 3px; font-size: 13px; padding: 4px; }
button.bk-keep-btn { background: #ffe0ec; }
.bk-page.unwritten { justify-content: center; }
.bk-page.unwritten .bk-h { position: absolute; top: 26px; left: 28px; right: 28px; }
.bk-pol { position: relative; }
.bk-x { position: absolute; top: -8px; right: -8px; width: 22px; height: 22px; padding: 0; border-radius: 50%; font-size: 13px; line-height: 1; box-shadow: none; opacity: .65; }
.bk-x:hover { opacity: 1; }
.bk-extra { display: flex; flex-direction: column; gap: 4px; font-size: 13.5px; }
.bk-public { display: flex; align-items: center; gap: 8px; font-size: 14px; margin-top: 8px; cursor: pointer; }
.bk-public input { width: 18px; height: 18px; accent-color: #e48fae; }
.bk-page.back .bk-cover-in { gap: 8px; }
.bk-dots { display: flex; gap: 7px; }
.bk-dots i { width: 9px; height: 9px; border-radius: 50%; background: rgba(255, 255, 255, .45); }
.bk-dots i.ink { background: #f6b9cf; }
.bk-dots i.now { background: #fff; box-shadow: 0 0 0 3px rgba(255, 255, 255, .35); }
#petbook.guided .bk-nav { flex-direction: column; }
#petbook.guided .bk-nav .bk-link { color: #fff; }

.bk-page.write { background: #fffaf0; }
/* photos keep their own shape (portrait, landscape or square), just not too tall */
.bk-pol img { width: auto; height: auto; max-width: 240px; max-height: 210px; aspect-ratio: auto; }
.bk-pol.small img { max-width: 130px; max-height: 120px; }
.bk-pol.big img { width: 170px; height: 170px; aspect-ratio: 1; object-fit: cover; }
.bk-photos .bk-pol.small img { width: 120px; height: 100px; max-width: none; object-fit: cover; } /* album thumbnails: one neat size */
.bk-later-note { max-width: 300px; text-align: center; }
/* the book is done: a soft golden light washes over everything, then clears */
.bk-gold { position: fixed; inset: 0; z-index: 60; pointer-events: none; opacity: 0; transition: opacity .9s ease-out;
  background: radial-gradient(circle at 50% 45%, rgba(255, 240, 190, .95) 0%, rgba(255, 214, 140, .65) 35%, rgba(255, 196, 160, .25) 70%, rgba(255, 190, 200, 0) 100%); }
.bk-gold.on { opacity: 1; } .bk-gold.off { opacity: 0; transition: opacity 1.2s ease-in; }
.bk-gold i { position: absolute; width: 6px; height: 6px; border-radius: 50%; background: #fff7d6; box-shadow: 0 0 10px 4px rgba(255, 220, 140, .8); animation: bkSpark 1.6s ease-out both; }
@keyframes bkSpark { from { transform: translateY(14px) scale(.4); opacity: 0; } 40% { opacity: 1; } to { transform: translateY(-40px) scale(1); opacity: 0; } }
.bk-writing .bk-pol img { max-height: 150px; max-width: 200px; }
.bk-writing .bk-ink { min-height: 128px; }

/* ---------- the pet's book, round 3: a real cover, page leaves, the editor ---------- */
.bk-wrap { position: relative; }
.bk-top { position: absolute; top: -46px; right: 0; display: flex; gap: 8px; z-index: 2; }
.bk-top button { font-size: 14px; }
.bk-spread { position: relative; perspective: 2200px; }
/* the closed book: rose linen, a stitched spine, a gold frame, the photo in an oval, gilt title */
.bk-page.closed { width: min(400px, 88vw); border-radius: 6px 16px 16px 6px; padding: 0; overflow: hidden; justify-content: center;
  background: repeating-linear-gradient(45deg, rgba(255, 255, 255, .07) 0 2px, transparent 2px 5px), repeating-linear-gradient(-45deg, rgba(120, 30, 70, .08) 0 2px, transparent 2px 5px), linear-gradient(160deg, #d07c9b, #b85d80 70%, #a9547a);
  box-shadow: inset 26px 0 0 -2px rgba(120, 40, 76, .55), inset 30px 0 0 -2px rgba(255, 220, 160, .55), inset 0 0 40px rgba(110, 30, 70, .35), 4px 0 0 #f3e6d8, 7px 2px 0 #e7d4c2; }
.bk-cv { position: absolute; inset: 22px 22px 22px 46px; border: 2px solid #f0cf8a; outline: 1px solid rgba(240, 207, 138, .6); outline-offset: -8px; border-radius: 10px;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; color: #fff4dc; text-align: center; }
.bk-cv::before, .bk-cv::after { content: "✦"; position: absolute; color: #f0cf8a; font-size: 14px; }
.bk-cv::before { top: 6px; left: 10px; } .bk-cv::after { bottom: 6px; right: 10px; }
.bk-cv-top { font-size: 12px; letter-spacing: 3px; color: #f6dba2; }
.bk-cv-photo { width: 150px; height: 186px; border-radius: 50%; padding: 5px; background: linear-gradient(145deg, #fbe7b2, #d9a952 55%, #f6d991); box-shadow: 0 4px 12px rgba(90, 20, 50, .35); }
.bk-cv-photo img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; background: #fff7ef; border: 3px solid #fff7ef; box-sizing: border-box; }
.bk-cv h2 { margin: 4px 0 0; font-size: 26px; line-height: 1.35; color: #fff1cf; text-shadow: 0 1px 0 #8a3f5c, 0 -1px 0 rgba(255, 240, 200, .5), 0 0 12px rgba(255, 214, 140, .45); }
.bk-cv-orn { color: #f0cf8a; letter-spacing: 6px; font-size: 13px; }
.bk-cv small { font-size: 12px; color: #fbe3ea; opacity: .9; }
.bk-cv-back small { font-style: italic; line-height: 1.8; }
.bk-page.closed .bk-public { color: #fff4dc; } .bk-page.closed .bk-hint { color: #fbe3ea; }
.bk-page.closed .bk-keep-btn { margin-top: 4px; }
.bk-page.endpaper { justify-content: center; color: #d9a9bf; font-size: 22px; }
.bk-page.solo { border-radius: 14px; }
/* page leaves: the turning page swings round the spine, its back is the next page */
.bk-leaf { position: absolute; top: 0; width: 50%; height: 100%; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.45, .05, .25, 1); z-index: 3; }
.bk-leaf.fwd { left: 50%; transform-origin: left center; } .bk-leaf.back { left: 0; transform-origin: right center; }
.bk-leaf.fwd.go { transform: rotateY(-180deg); } .bk-leaf.back.go { transform: rotateY(180deg); }
.bk-leaf .face { position: absolute; inset: 0; width: 100% !important; height: 100% !important; backface-visibility: hidden; animation: none; }
.bk-leaf .face.rear { transform: rotateY(180deg); }
.bk-leaf .face::after { content: ""; position: absolute; inset: 0; pointer-events: none; animation: leafShade .7s ease-in-out; }
@keyframes leafShade { 0% { background: rgba(80, 40, 60, 0); } 50% { background: rgba(80, 40, 60, .18); } 100% { background: rgba(80, 40, 60, 0); } }
.bk-spread.slide-l > .bk-page { animation: bkSlideL .45s ease-out; } .bk-spread.slide-r > .bk-page { animation: bkSlideR .45s ease-out; }
@keyframes bkSlideL { from { opacity: 0; transform: perspective(900px) translateX(40px) rotateY(-14deg); } to { opacity: 1; transform: none; } }
@keyframes bkSlideR { from { opacity: 0; transform: perspective(900px) translateX(-40px) rotateY(14deg); } to { opacity: 1; transform: none; } }
.bk-page { animation: none; }
/* the editor: contents on the side, the chosen page beside it */
.bk-editor { display: flex; gap: 0; filter: none; }
.bk-toc { width: 230px; height: min(580px, 76vh); overflow-y: auto; box-sizing: border-box; padding: 18px 12px; background: #f7e3ea;
  border-radius: 14px 0 0 14px; box-shadow: inset -14px 0 18px -14px rgba(120, 70, 100, .4); display: flex; flex-direction: column; gap: 3px; }
.bk-toc-h { font-weight: 700; font-size: 16px; color: #5b3a58; text-align: center; margin-bottom: 4px; }
.bk-toc-g { font-size: 11px; letter-spacing: .5px; color: #b07a9c; margin: 10px 4px 2px; }
button.bk-toc-item { text-align: left; font-size: 13px; padding: 5px 9px; border: 0; box-shadow: none; background: transparent; border-radius: 8px; color: #5b3a58; line-height: 1.4; }
button.bk-toc-item:hover { background: rgba(255, 255, 255, .6); }
button.bk-toc-item.on { background: #fff; box-shadow: 0 1px 0 #e7b5c8; font-weight: 700; }
button.bk-toc-item.empty { color: #a88aa0; }
button.bk-toc-item.add { color: #c0587e; font-weight: 700; }
.bk-page.bk-edit-page { width: min(460px, 60vw); border-radius: 0 14px 14px 0; }
@media (max-width: 520px) {
  .bk-editor { flex-direction: column; }
  .bk-toc { width: min(440px, 94vw); height: auto; flex-direction: row; flex-wrap: nowrap; overflow-x: auto; overflow-y: hidden; padding: 8px; gap: 4px; border-radius: 14px 14px 0 0; box-shadow: none; }
  .bk-toc-h, .bk-toc-g { display: none; }
  button.bk-toc-item { white-space: nowrap; flex: none; background: rgba(255, 255, 255, .5); }
  .bk-page.bk-edit-page { width: min(440px, 94vw); height: min(520px, 62vh); border-radius: 0 0 14px 14px; }
  .bk-top { top: -42px; }
}
@media (max-width: 520px) { .bk-page.bk-edit-page { height: calc(100vh - 250px); } .bk-writing .bk-ink { min-height: 96px; } }
.bk-top .bk-x-close { width: 38px; height: 38px; padding: 0; border-radius: 50%; font-size: 16px; line-height: 1; }
.bk-toc { scrollbar-width: none; } .bk-toc::-webkit-scrollbar { display: none; }
#petbook .bk-page { scrollbar-width: thin; scrollbar-color: #e7b5c8 transparent; }

/* cinematic (story.js cineIn/cineOut): letterbox bars glide in, the scene's name in the top bar (nothing covers the game) */
.cine-bar { position: fixed; left: 0; right: 0; height: 10vh; background: #2a2038; z-index: 30; pointer-events: none; will-change: transform;
  transition: transform .8s cubic-bezier(.22,.8,.3,1); }
.cine-bar.top { top: 0; transform: translateY(-100%); } .cine-bar.bot { bottom: 0; transform: translateY(100%); }
body.cine .cine-bar { transform: none; }
#hud, #hotbar, #devtools { transition: opacity .6s ease; }
body.cine #hud, body.cine #hotbar, body.cine #devtools, body.cine #prompt, body.cine #story-hint, body.cine #decor-toggle { opacity: 0; pointer-events: none; transition: opacity .6s ease; }
#cine-cap { position: fixed; left: 0; right: 0; top: 0; height: 10vh; z-index: 31; pointer-events: none; display: flex; flex-direction: column; align-items: center; justify-content: center;
  font-family: Mali, Tahoma, sans-serif; opacity: 0; transition: opacity .9s ease; will-change: opacity; }
#cine-cap.on { opacity: 1; transition-delay: .45s; }
#cine-cap .t { font-size: clamp(15px, 3.4vh, 24px); font-weight: 700; color: #fff4e2; letter-spacing: .05em; line-height: 1.2; }
#cine-cap .t::before, #cine-cap .t::after { content: "✦"; color: #f3cf7a; font-size: .55em; vertical-align: middle; margin: 0 .6em; }
#cine-cap .s { font-size: clamp(10px, 1.8vh, 13px); color: #c9b3e6; letter-spacing: .06em; line-height: 1.3; }
#cine-cap .s:empty { display: none; }
#cine-cap .t:empty::before, #cine-cap .t:empty::after { content: none; }

/* ---------- item tiles: requests and trades (npc.js tilesHtml) ---------- */
.tiles { display: flex; flex-wrap: wrap; gap: 8px 6px; }
.tile { width: 62px; display: flex; flex-direction: column; align-items: center; gap: 2px; text-align: center; }
.tile .ic { position: relative; width: 44px; height: 44px; border-radius: 12px; background: #fff7fa; border: 2px solid #f0dbe4; display: grid; place-items: center; }
.tile .ic img { width: 32px; height: 32px; image-rendering: pixelated; }
.tile .ic b { position: absolute; right: -6px; bottom: -6px; min-width: 20px; background: var(--edge); color: #fff; font-size: 11px; line-height: 17px; border-radius: 9px; padding: 0 5px; border: 2px solid #fff; }
.tile .ic.heart { font-size: 22px; color: #e0608a; background: #fff0f4; }
.tile .nm { font-size: 11.5px; line-height: 1.25; color: var(--ink); display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.tile small { font-size: 10.5px; color: #c0567a; }
.tile.ok .ic { border-color: #a9dcc6; background: #f1fbf6; } .tile.ok small { color: #3e8f6c; }
.tile.get .ic { border-color: #f1dca0; background: #fffaea; }
/* a trade: what you give → what you get → button, the same columns on every row */
#dlg-sub .trade-row { display: grid; grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr) 80px; align-items: stretch; gap: 8px; background: #fff; border-radius: 14px; padding: 8px; border: 2px solid transparent; }
#dlg-sub .trade-row .give, #dlg-sub .trade-row .get, .req-swap .col { border-radius: 10px; padding: 8px; display: flex; flex-direction: column; justify-content: center; }
#dlg-sub .trade-row .give, .req-swap .col.ask { background: #fff4f7; }
#dlg-sub .trade-row .get, .req-swap .col.back { background: #fffbef; }
#dlg-sub .trade-row .arrow, #dlg-sub .trade-row button { align-self: center; }
#dlg-sub .trade-row.ready { border-color: #bfe5d3; }
#dlg-sub .trade-row.locked { opacity: .55; }
#dlg-sub .trade-row .arrow, .req-swap .arrow { color: #d1a9c0; font-size: 18px; text-align: center; }
#dlg-sub .trade-row .price { font-size: 10.5px; color: #a08aa8; margin-top: 4px; }
#dlg-sub .trade-row button { justify-self: stretch; padding: 6px 4px; font-size: 13px; }
/* a request: the villager's words, what they ask → what they give back, one clear button */
.card.req { align-items: stretch; gap: 10px; padding: 12px 14px; }
.req-quote { background: #fff6f8; border-left: 4px solid #f1c6d6; border-radius: 8px; padding: 8px 12px; font-size: 14.5px; line-height: 1.5; }
.req-swap { display: grid; grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr); align-items: stretch; gap: 8px; }
.req-swap .arrow { align-self: center; }
.req-swap .lbl { font-size: 12px; font-weight: 700; color: #b0607e; margin-bottom: 6px; }
.card.req button.big { align-self: center; margin: 0; padding: 7px 26px; }
.card.req .req-done { color: #3e8f6c; }
.req-swap .col { justify-content: flex-start; }
/* quest book: when a step can be done (story.js winText) and the time now */
.jq-when { display: inline-block; margin-top: 6px; font-size: 12.5px; padding: 2px 10px; border-radius: 10px; background: #f3ecfb; color: #6b4f8f; }
.jq-when.now { background: #e6f6ee; color: #2f7d5b; font-weight: 700; }
.jq-now { float: right; font-size: 12.5px; font-weight: 400; color: #a07895; }
/* the market night (ch3.js): the bar at the top with the time left and "end the festival" */
#market-bar { position: fixed; top: 10px; left: 50%; transform: translateX(-50%); z-index: 25; display: flex; align-items: center; gap: 12px;
  background: linear-gradient(180deg, #fff8ee, #ffeedd); border: 3px solid #e0a97a; border-radius: 16px; box-shadow: 0 3px 0 #c98f5f; padding: 6px 8px 6px 14px; font-family: Mali, Tahoma, sans-serif; color: #7a4a30; }
#market-bar .mb-t { font-weight: 700; }
#market-bar .mb-left { font-size: 13px; color: #a0785e; font-variant-numeric: tabular-nums; }
#market-bar button { font: inherit; font-size: 13px; padding: 4px 12px; border-radius: 10px; border: 2px solid #e0a97a; background: #fff; color: #7a4a30; cursor: pointer; }
body.cine #market-bar { opacity: 0; pointer-events: none; }
.stall-pick .pick-grid { max-height: 46vh; overflow: auto; }
.stall-pick .pick small { display: block; font-size: 10.5px; opacity: .75; }
.stall-pick .pick.on { outline: 3px solid #7fc9a4; background: #effaf4; }
#credits .cr-skip { position: absolute; right: 18px; bottom: 18px; opacity: .8; }
/* a new quest (story.js questCard) */
#quest-card { position: fixed; top: 14vh; left: 50%; transform: translateX(-50%); z-index: 70; min-width: 280px; max-width: min(460px, 90vw); text-align: center; cursor: pointer;
  background: linear-gradient(180deg, #fffaf3, #fff1f5); border: 3px solid #e9b6c8; border-radius: 18px; box-shadow: 0 4px 0 #d39bb0, 0 14px 30px rgba(90,40,70,.25);
  padding: 12px 18px 10px; font-family: Mali, Tahoma, sans-serif; color: #5b3a58; animation: qcIn .5s cubic-bezier(.2,.9,.3,1.2); }
#quest-card.out { animation: qcOut .5s ease forwards; }
#quest-card .qc-k { font-size: 12.5px; color: #c27a98; letter-spacing: .05em; }
#quest-card .qc-t { font-size: 21px; font-weight: 700; margin: 2px 0 6px; }
#quest-card .qc-h { font-size: 14px; line-height: 1.5; color: #6e5468; }
#quest-card .qc-f { font-size: 11.5px; color: #b393a8; margin-top: 6px; }
@keyframes qcIn { from { opacity: 0; transform: translate(-50%, -14px) scale(.96); } to { opacity: 1; transform: translate(-50%, 0); } }
@keyframes qcOut { to { opacity: 0; transform: translate(-50%, -10px); } }

/* ---------- แม่หมอจันทร์'s tarot table (tarot.js) ---------- */
#tarot { position: fixed; inset: 0; z-index: 70; display: flex; flex-direction: column; align-items: center; gap: 10px; padding: 16px 12px 18px;
  background: radial-gradient(ellipse at 50% 110%, #6b4f9e 0%, #3d2b63 45%, #221838 100%); color: #fff6ea; font-family: "Mali", sans-serif; animation: tr-in .3s ease; overflow: hidden; }
#tarot.out { opacity: 0; transition: opacity .25s; }
@keyframes tr-in { from { opacity: 0; } }
#tarot .tr-sky { position: absolute; inset: 0; pointer-events: none; opacity: .7;
  background-image: radial-gradient(1.5px 1.5px at 12% 18%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 30% 8%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 72% 14%, #fff4c2 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 30%, #fff 50%, transparent 51%), radial-gradient(1px 1px at 55% 24%, #fff 50%, transparent 51%), radial-gradient(1.5px 1.5px at 8% 46%, #fff4c2 50%, transparent 51%), radial-gradient(1px 1px at 94% 52%, #fff 50%, transparent 51%);
  animation: tr-tw 4s ease-in-out infinite alternate; }
@keyframes tr-tw { to { opacity: .35; } }
#tarot .tr-head { position: relative; width: min(640px, 96vw); text-align: center; z-index: 1; }
#tarot .tr-who { font-weight: 700; color: #e9d8ff; font-size: 14px; letter-spacing: .5px; }
#tarot .tr-line { margin-top: 6px; font-size: 18px; min-height: 26px; text-shadow: 0 2px 8px rgba(0,0,0,.35); }
#tarot .tr-line.in { animation: tr-up .35s ease; }
@keyframes tr-up { from { opacity: 0; transform: translateY(6px); } }
#tarot .tr-x { position: absolute; right: 0; top: -4px; background: rgba(255,255,255,.12); color: #fff; border: 0; border-radius: 50%; width: 32px; height: 32px; cursor: pointer; }
#tarot .tr-slots { display: flex; gap: 18px; justify-content: center; z-index: 1; }
#tarot .tr-slot { display: flex; flex-direction: column; align-items: center; gap: 6px; max-width: 150px; text-align: center; font-size: 13px; color: #e9d8ff; }
#tarot .tr-slot span b { color: #fff; } #tarot .tr-slot span i { color: #ffc8d6; font-style: normal; }
#tarot .tr-place { width: var(--sw, 104px); aspect-ratio: 200 / 330; border-radius: 10px; border: 2px dashed rgba(233,216,255,.45); background: rgba(255,255,255,.05); }
#tarot .tr-slots:has(.tr-slot:nth-child(1):last-child) .tr-place { --sw: 168px; }
#tarot .tc { display: block; padding: 0; border: 0; background: none; border-radius: 10px; }
#tarot .tc svg { display: block; width: 100%; height: 100%; }
#tarot .tr-place .tc { width: 100%; height: 100%; animation: tr-pop .3s ease; }
@keyframes tr-pop { from { transform: scale(.85); } }
#tarot .tr-flip { cursor: pointer; perspective: 800px; }
#tarot .tr-flip:not(.open) { animation: tr-pop .3s ease, tr-glow 1.4s ease-in-out .4s infinite alternate; border-radius: 10px; }
@keyframes tr-glow { to { box-shadow: 0 0 22px 4px rgba(255,228,160,.55); } }
#tarot .tc-in { position: relative; width: 100%; height: 100%; transform-style: preserve-3d; transition: transform .7s cubic-bezier(.3,1.3,.5,1); }
#tarot .tr-flip.open .tc-in { transform: rotateY(180deg); }
#tarot .tc-b, #tarot .tc-f { position: absolute; inset: 0; backface-visibility: hidden; -webkit-backface-visibility: hidden; }
#tarot .tc-f { transform: rotateY(180deg); }
#tarot .tc-face, #tarot .tc-face svg { width: 100%; height: 100%; }
#tarot .tc-face.rv svg { transform: rotate(180deg); }
#tarot .tr-table { position: relative; flex: 1; width: 100%; min-height: 180px; z-index: 1; }
#tarot .tr-fan { position: absolute; left: 50%; bottom: 64px; width: 0; height: 0; }
#tarot .tr-card { position: absolute; left: -43px; bottom: 0; width: 86px; aspect-ratio: 200 / 330; cursor: pointer; transform-origin: 50% 300%;
  transform: rotate(0deg) translateY(40px); transition: transform .45s cubic-bezier(.2,.9,.3,1.1) var(--d), opacity .3s; filter: drop-shadow(0 3px 4px rgba(20,8,40,.45)); }
#tarot .tr-fan.open .tr-card { transform: rotate(var(--a)); }
#tarot .tr-fan.open .tr-card:hover { transform: rotate(var(--a)) translateY(-18px); transition-delay: 0s; filter: drop-shadow(0 0 10px rgba(255,228,160,.8)); }
#tarot .tr-card.gone { opacity: 0; pointer-events: none; }
#tarot .tr-stack { position: absolute; left: -40px; bottom: 20px; width: 80px; aspect-ratio: 200 / 330; }
#tarot .tr-stack .tc { position: absolute; inset: 0; animation: tr-riffle .5s ease-in-out calc(var(--i) * 25ms) 3 alternate; }
#tarot .tr-stack .tc:nth-child(odd) { animation-name: tr-riffle2; }
@keyframes tr-riffle { 50% { transform: translateX(-46px) rotate(-8deg); } }
@keyframes tr-riffle2 { 50% { transform: translateX(46px) rotate(8deg); } }
#tarot .tr-fly { position: fixed; z-index: 5; transition: all .42s cubic-bezier(.3,.9,.4,1); pointer-events: none; }
#tarot .tr-btns { display: flex; gap: 10px; z-index: 3; transition: opacity .25s; }
#tarot .tr-btns.dim { opacity: .35; pointer-events: none; }
#tarot .tr-btns button { background: rgba(255,255,255,.14); color: #fff6ea; border: 1px solid rgba(233,216,255,.4); border-radius: 999px; padding: 8px 16px; font: inherit; cursor: pointer; }
#tarot .tr-btns button:hover { background: rgba(255,255,255,.24); }
#tarot.reading .tr-table, #tarot.reading .tr-btns { display: none; }
#tarot.reading .tr-place { --sw: 92px; }
#tarot .tr-read { z-index: 1; width: min(620px, 96vw); overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 10px; padding: 4px 4px 8px; animation: tr-up .4s ease; }
#tarot .tr-r { background: rgba(255,250,244,.96); color: #4a3b5c; border-radius: 14px; padding: 12px 14px; box-shadow: 0 4px 14px rgba(20,8,40,.3); }
#tarot .tr-r-h { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 16px; }
#tarot .tr-r-h small { color: #8a72b8; font-size: 12px; width: 100%; }
#tarot .tr-chip { font-size: 12px; background: #e7f6ee; color: #2f7a55; border-radius: 999px; padding: 2px 9px; }
#tarot .tr-chip.rv { background: #fde8ee; color: #b0476a; }
#tarot .tr-r p { margin: 6px 0 0; line-height: 1.55; font-size: 14px; }
#tarot .tr-r .tr-about { color: #7a6a8e; font-size: 13px; }
#tarot .tr-extra { background: rgba(255,236,170,.95); color: #5a4220; border-radius: 14px; padding: 10px 14px; font-size: 14px; line-height: 1.5; }
#tarot .tr-done { align-self: center; margin-top: 4px; background: #ffd877; color: #4a3b5c; border: 0; border-radius: 999px; padding: 10px 26px; font: inherit; font-weight: 700; cursor: pointer; box-shadow: 0 3px 0 #c9a24a; }
.fortune-card { display: flex; gap: 12px; align-items: flex-start; }
.fortune-card .fc-art { width: 84px; flex: none; aspect-ratio: 200 / 330; }
.fortune-card .fc-art svg { width: 100%; height: 100%; display: block; }
.fortune-card .fc-art .tc-face.rv svg { transform: rotate(180deg); }

/* ---------- 🎵 sound sliders (audio.js) ---------- */
#sound-pop { pointer-events: auto; touch-action: none; position: absolute; right: 0; top: calc(100% + 54px); z-index: 30; background: #fff8f0; border: 2px solid #6b5577; border-radius: 14px; padding: 10px 14px; display: flex; flex-direction: column; gap: 8px; box-shadow: 0 4px 0 rgba(107,85,119,.25); font-size: 14px; color: #4a3b5c; min-width: 270px; }
#sound-pop label { display: flex; align-items: center; justify-content: space-between; gap: 10px; white-space: nowrap; }
#sound-pop input[type=range] { width: 120px; accent-color: #b993da; }

/* ---------- title screen (title.js) ---------- */
#title { position: fixed; inset: 0; z-index: 31; display: grid; place-items: center; overflow: auto; background: radial-gradient(circle at 50% 30%, #fff3f7, #f3c9d8 70%); }
#title-bg { position: absolute; inset: 0; width: 100%; height: 100%; opacity: 0; transition: opacity 1.2s; image-rendering: pixelated; }
#title-bg.on { opacity: 1; }
.t-veil { position: absolute; inset: 0; background: radial-gradient(ellipse at 50% 48%, rgba(255,243,247,.38), rgba(255,243,247,.08) 45%, rgba(60,30,60,.22) 100%); pointer-events: none; }
.t-box { position: relative; width: min(400px, 92vw); display: flex; flex-direction: column; align-items: center; gap: 14px; padding: 16px; }
.t-logo { text-align: center; }
.t-logo h1 { margin: 0; font-family: Mali, Tahoma, sans-serif; font-size: 54px; line-height: 1.05; color: #fff; letter-spacing: 1px;
  text-shadow: 0 4px 0 #7a4f74, 3px 0 0 #7a4f74, -3px 0 0 #7a4f74, 0 -3px 0 #7a4f74, 3px 3px 0 #7a4f74, -3px 3px 0 #7a4f74, 3px -3px 0 #7a4f74, -3px -3px 0 #7a4f74, 0 8px 0 rgba(91,58,88,.25); }
.t-logo p { margin: 6px 0 0; font-weight: 600; color: #5b3a58; background: rgba(255,240,244,.85); border-radius: 999px; padding: 3px 14px; display: inline-block; }
.t-paw { display: block; font-size: 40px; animation: t-bob 2.4s ease-in-out infinite; }
@keyframes t-bob { 50% { transform: translateY(-6px) rotate(-6deg); } }
.t-step { width: 100%; display: flex; flex-direction: column; gap: 10px; }
.t-big { width: 100%; font-size: 21px; font-weight: 700; padding: 12px 16px; background: var(--pink); border: 4px solid var(--edge); border-radius: 18px; box-shadow: 0 5px 0 var(--edge); color: var(--ink); cursor: pointer; display: flex; flex-direction: column; align-items: center; transition: transform .08s; }
.t-big small { font-size: 13px; font-weight: 400; opacity: .8; }
.t-big:hover:not(:disabled) { transform: translateY(-2px); }
.t-big:active:not(:disabled) { transform: translateY(3px); box-shadow: 0 2px 0 var(--edge); }
.t-big:disabled { opacity: .55; cursor: not-allowed; }
.t-big.wait { opacity: .7; }
.t-alt { background: var(--card); }
#t-who-line { margin: 0; text-align: center; font-size: 14px; font-weight: 600; background: rgba(255,240,244,.9); border-radius: 12px; padding: 5px 10px; }
.t-step .link-btn { align-self: center; background: rgba(255,240,244,.85) !important; border-radius: 10px; padding: 3px 12px !important; }
#t-form { background: var(--card); border: 4px solid var(--edge); border-radius: 20px; box-shadow: 0 5px 0 var(--edge); padding: 12px 16px; display: flex; flex-direction: column; gap: 8px; }
#t-form label { font-size: 14px; font-weight: 600; display: block; }
#t-form input:not([type=checkbox]) { display: block; width: 100%; margin-top: 3px; font-family: inherit; font-size: 16px; padding: 7px 10px; border: 2px solid #e2b3c3; border-radius: 10px; background: #fff; color: var(--ink); box-sizing: border-box; }
#t-form .t-check { font-weight: 400; font-size: 13px; display: flex; gap: 6px; align-items: flex-start; }
.t-tabs { display: flex; gap: 6px; }
.t-tab { flex: 1; padding: 6px; font-size: 15px; border-radius: 12px; opacity: .6; }
.t-tab.on { opacity: 1; background: var(--pink); }
#t-err { margin: 0; min-height: 1em; color: #c0567a; font-size: 13px; text-align: center; }
#t-form .t-big { font-size: 18px; padding: 9px; }

/* ---------- new pet screen (29 พ.ย. รอบ 2) ---------- */
#title.under { z-index: 29; }
#title.under .t-box { display: none; }
#title.under ~ #create, #title.under ~ #select { background: rgba(60, 30, 60, .18); }
.cr-card { width: min(940px, 96vw); padding: 16px 22px 18px; margin: 12px 0; }
.cr-top { position: relative; text-align: center; }
.cr-top #create-back { position: absolute; left: 0; top: 2px; }
.cr-top h1 { font-size: 30px; }
.cr-top .lead { margin: 2px 0 12px; font-size: 14px; opacity: .85; }
.starter-pick { margin-bottom: 12px; }
#create-form .sp-card { padding: 8px 12px; }
#create-form .sp-card.off { opacity: .55; cursor: not-allowed; background: #f6eef1; }
.sp-card .lock { display: inline-block; font-size: 11px; font-weight: 600; background: #7a4f74; color: #fff; border-radius: 999px; padding: 1px 8px; margin-left: 4px; vertical-align: 1px; }
.cr-grid { display: grid; grid-template-columns: 230px 1fr; gap: 18px; align-items: start; }
.cr-side { position: sticky; top: 0; display: flex; flex-direction: column; gap: 12px; }
.cr-stage { background: linear-gradient(#fbe3ec, #fff6f9 70%); border: 3px solid var(--edge); border-radius: 18px; padding: 14px 10px 12px; text-align: center; display: flex; flex-direction: column; align-items: center; }
.cr-stage img { width: 136px; height: 136px; image-rendering: pixelated; object-fit: contain; animation: cr-bob 2.6s ease-in-out infinite; position: relative; z-index: 1; }
.cr-floor { width: 96px; height: 14px; border-radius: 50%; background: rgba(122, 79, 116, .18); margin-top: -18px; }
.cr-stage b { margin-top: 8px; font-size: 19px; word-break: break-word; }
.cr-stage small { font-size: 12px; opacity: .7; }
@keyframes cr-bob { 50% { transform: translateY(-4px); } }
#create-form .cr-side #photo-drop { width: 100%; height: 110px; border-width: 2px; border-radius: 14px; }
.cr-main section { background: #fff; border: 2px solid #ecc6d3; border-radius: 16px; padding: 10px 14px 6px; margin-bottom: 12px; }
.cr-main h2 { margin: 0 0 8px; font-size: 17px; display: flex; align-items: center; gap: 8px; }
.cr-no { width: 24px; height: 24px; border-radius: 50%; background: var(--pink); border: 2px solid var(--edge); display: grid; place-items: center; font-size: 13px; }
.cr-row { display: flex; align-items: center; gap: 10px; }
#create-form .cr-species { display: flex; gap: 0; margin: 0 0 10px; width: 100%; max-width: 320px; background: #f6e3ea; border: 2px solid #e2b3c3; border-radius: 14px; padding: 3px; }
#create-form .cr-species label { flex: 1; margin: 0; cursor: pointer; }
#create-form .cr-species input { position: absolute; opacity: 0; pointer-events: none; }
#create-form .cr-species span { display: block; text-align: center; padding: 7px 0; border-radius: 10px; font-weight: 700; color: #9a6b7c; transition: background .18s, color .18s, box-shadow .18s; }
#create-form .cr-species input:checked + span { background: #fff; color: #6b3d55; box-shadow: 0 2px 0 #d9a3b6; }
#create-form .cr-species input:focus-visible + span { outline: 2px solid #c77d98; }
#create-form label small { font-weight: 400; opacity: .65; }
#preset-box { margin: 0 0 6px; }
#preset-box .preset-head { margin: 0; }
.cr-main .preset-grid { grid-template-columns: repeat(auto-fill, minmax(86px, 1fr)); max-height: 330px; padding: 2px 4px 6px 2px; }
.cr-main .preset-grid button { border-width: 2px; padding: 6px 2px 5px; }
.cr-main .preset-grid button.on { border-color: var(--edge); background: #ffe1ec; box-shadow: 0 0 0 2px var(--pink2), 0 3px 0 var(--edge); }
#create-btn { font-size: 19px; padding: 12px; border-radius: 16px; }
#mode-note:empty { display: none; }
@media (max-width: 720px) {
  .cr-grid { grid-template-columns: 1fr; }
  .cr-side { position: static; flex-direction: row; }
  .cr-stage { flex: 1; } .cr-stage img { width: 96px; height: 96px; }
  #create-form .cr-side #photo-drop { width: 120px; height: auto; flex-shrink: 0; }
  .cr-top #create-back { position: static; display: block; text-align: left; }
  .starter-pick { grid-template-columns: 1fr; }
}
#create-form #photo-drop { display: grid; place-items: center; font-weight: 400; text-align: center; }
.cr-main .preset-grid button img { width: 64px; height: 64px; }

/* top middle column (29 พ.ย.): the step hint, achievement banners and toasts stack instead of overlapping */
#topmid { position: absolute; left: 50%; top: 14px; transform: translateX(-50%); display: flex; flex-direction: column; align-items: center; gap: 6px; z-index: 80; pointer-events: none; width: max-content; max-width: 92vw; }
#topmid #story-hint, #topmid #toasts { position: static; transform: none; }
#topmid #story-hint { animation: hintIn2 .35s ease-out; }
#topmid #story-hint.hidden { display: none; }
#toasts .ach-banner { position: static; transform: none; animation: abin2 .5s cubic-bezier(.2,.9,.3,1.3); }
#toasts .ach-banner.out { animation: about2 .5s forwards; }
@keyframes hintIn2 { from { opacity: 0; transform: translateY(-6px); } }
@keyframes abin2 { from { transform: translateY(-40px); opacity: 0; } }
@keyframes about2 { to { transform: translateY(-20px); opacity: 0; } }

/* a villager's speech bubble over the game (ch1.js bubble) */
.vbubble { position: fixed; left: 0; top: 0; z-index: 20; pointer-events: none; max-width: 300px; width: max-content; background: #fff6f8; color: #5b3a58;
  font: 15px/1.45 Mali, Tahoma, sans-serif; padding: 5px 10px; border-radius: 10px; box-shadow: 0 2px 0 rgba(91, 58, 88, .25); will-change: transform; }
.vbubble::after { content: ""; position: absolute; left: 50%; bottom: -6px; margin-left: -6px; border: 6px solid transparent; border-bottom: 0; border-top-color: #fff6f8; }

/* the question before the first page of the book (book.js moodCard) */
#moodcard { position: fixed; inset: 0; z-index: 90; display: grid; place-items: center; background: rgba(70, 40, 70, .42); animation: mcIn .45s ease both; }
#moodcard.out { animation: mcOut .38s ease both; }
#moodcard .mc-box { width: min(520px, 92vw); background: linear-gradient(#fffafc, #ffeef4); border: 4px solid var(--edge); border-radius: 22px; box-shadow: 0 6px 0 var(--edge), 0 18px 40px rgba(60, 30, 60, .25); padding: 22px 22px 20px; text-align: center; animation: mcPop .5s cubic-bezier(.2, 1.3, .4, 1) both; }
#moodcard .mc-pet { image-rendering: pixelated; margin: 0 auto 8px; display: block; animation: mcFloat 3s ease-in-out infinite; }
#moodcard .mc-q { font-size: 20px; font-weight: 700; color: #6b3d55; margin: 4px 0 2px; }
#moodcard .mc-sub { font-size: 14px; color: #9a7088; margin: 0 0 16px; }
#moodcard .mc-opts { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
#moodcard .mc-opts button { display: flex; align-items: center; gap: 8px; text-align: left; padding: 11px 12px; border-radius: 14px; background: #fff; border: 2px solid #e8c3d2; box-shadow: 0 3px 0 #e8c3d2; font: inherit; font-size: 15px; color: #5b3a58; cursor: pointer; transition: transform .12s, box-shadow .12s, background .12s; }
#moodcard .mc-opts button span { font-size: 20px; }
#moodcard .mc-opts button:hover { background: #fff4f8; transform: translateY(-2px); box-shadow: 0 5px 0 #e2a9bf; }
#moodcard .mc-opts button:active { transform: translateY(1px); box-shadow: 0 1px 0 #e2a9bf; }
@media (max-width: 480px) { #moodcard .mc-opts { grid-template-columns: 1fr; } }
@keyframes mcIn { from { opacity: 0; } }
@keyframes mcOut { to { opacity: 0; } }
@keyframes mcPop { from { transform: translateY(14px) scale(.96); opacity: 0; } }
@keyframes mcFloat { 50% { transform: translateY(-4px); } }

/* ---- the first writing (book.js firstWriting, 30 พ.ย.) ---- */
#petbook.guided .bk-spread.guided .bk-page { width: min(400px, 46vw); height: min(600px, 80vh); }
#petbook.guided .bk-spread.guided.one .bk-page { width: min(440px, 94vw); }
#petbook.guided .bk-page.closed { cursor: pointer; transform-origin: left center; transition: transform .6s cubic-bezier(.5, 0, .3, 1), opacity .6s; }
#petbook.guided .bk-page.closed:hover { transform: rotateY(-6deg); }
#petbook.guided .bk-page.closed.opening { transform: perspective(1400px) rotateY(-100deg); opacity: 0; }
.bk-open-hint { margin-top: 14px; font-size: 13px; line-height: 1.6; color: #fff3f8; opacity: .95; }
.bk-open-hint b { display: block; margin-top: 6px; font-size: 12px; letter-spacing: .5px; animation: bob 1.2s ease-in-out infinite; }
.bk-g-left { justify-content: flex-start; }
.bk-ribbon { align-self: flex-start; background: #f2a9c2; color: #fff; font-size: 12px; padding: 3px 12px 3px 14px; border-radius: 0 10px 10px 0; margin: -6px 0 0 -28px; box-shadow: 0 2px 0 #d98aa6; flex-shrink: 0; }
.bk-w-kick { font-size: 13px; color: #b07a9c; font-style: italic; margin-top: 6px; }
.bk-g-left .bk-w-head h3 { font-size: 23px; margin: 4px 0 10px; }
.bk-asks { list-style: none; padding: 0; margin: 0 0 14px; display: flex; flex-direction: column; gap: 7px; }
.bk-asks li { font-size: 14px; color: #6e4a66; background: #fff0f5; border-radius: 10px; padding: 6px 12px; }
.bk-asks li::before { content: "✿ "; color: #e79ab6; }
.bk-g-right .bk-writing { padding-top: 6px; }
.bk-when.stamp { align-self: flex-end; border: 1.5px dashed #e2b3c3; border-radius: 8px; padding: 2px 8px; font-size: 12px; transform: rotate(-1.5deg); background: rgba(255, 255, 255, .6); }
.bk-when.stamp input { font-size: 12px; width: 150px; }
.bk-g-foot { margin-top: auto; display: flex; flex-direction: column; align-items: center; gap: 8px; padding-top: 10px; }
.bk-dots.in i { background: #ecd3dd; }
.bk-dots.in i.ink { background: #f2a9c2; }
.bk-dots.in i.now { background: #c77d98; box-shadow: 0 0 0 3px rgba(199, 125, 152, .25); }
.bk-g-foot .bk-later { font-size: 12px; color: #a3809a; }
/* the pet murmuring at the corner of the book */
.bk-murmur { position: absolute; right: max(4vw, calc(50% - 470px)); bottom: 4vh; display: flex; flex-direction: column; align-items: flex-end; gap: 6px; z-index: 5; cursor: pointer; animation: mmIn .45s cubic-bezier(.2, 1.3, .4, 1) both; }
.bk-murmur.out { animation: mmOut .35s ease both; }
.bk-murmur img { width: 96px; image-rendering: pixelated; filter: drop-shadow(0 4px 6px rgba(60, 30, 60, .3)); display: block; }
.bk-mm-bubble { max-width: 360px; word-break: keep-all; overflow-wrap: anywhere; background: #fff; color: #5b3a58; border: 3px solid var(--edge); border-radius: 16px; padding: 10px 14px; font-size: 15px; line-height: 1.55; box-shadow: 0 4px 0 var(--edge); position: relative; }
.bk-mm-bubble::after { content: ""; position: absolute; right: 36px; bottom: -11px; border: 8px solid transparent; border-top-color: var(--edge); border-bottom: 0; }
@keyframes mmIn { from { transform: translateY(30px); opacity: 0; } }
@keyframes mmOut { to { transform: translateY(20px); opacity: 0; } }
@keyframes mmHop { 50% { transform: translateY(-10px); } }
@keyframes mmHeart { 0% { opacity: 0; transform: translateY(0) scale(.6); } 30% { opacity: 1; } 100% { opacity: 0; transform: translateY(-46px) scale(1.1); } }
/* the last page of the day */
.bk-g-end { justify-content: center; gap: 12px; }
.bk-paw { line-height: 0; animation: pawStamp .7s cubic-bezier(.2, 1.4, .4, 1) both; }
@keyframes pawStamp { 0% { transform: scale(2.4) rotate(-12deg); opacity: 0; } 60% { opacity: 1; } 100% { transform: scale(1) rotate(-8deg); } }
.bk-end-main { font-size: 19px; font-weight: 700; margin: 0; }
.bk-end-sub { font-size: 14px; line-height: 1.6; margin: 0 6px; color: #7a5c70; }
.bk-end-q { font-size: 14px; font-weight: 700; margin-top: 10px; }
.bk-share-pick { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; align-self: stretch; }
.bk-share-pick button { display: flex; flex-direction: column; gap: 4px; text-align: left; padding: 10px 12px; border-radius: 14px; background: #fff; border: 2px solid #ecd3dd; box-shadow: none; font: inherit; color: #5b3a58; cursor: pointer; }
.bk-share-pick button b { font-size: 14px; } .bk-share-pick button small { font-size: 12px; opacity: .7; }
.bk-share-pick button.on { border-color: #e07ea2; background: #fff1f6; box-shadow: 0 3px 0 #e8b3c6; }
.bk-end-note { font-size: 11.5px; opacity: .6; }
@media (max-width: 760px) { .bk-share-pick { grid-template-columns: 1fr; } .bk-murmur img { width: 72px; } .bk-mm-bubble { max-width: 240px; font-size: 14px; } }
#petbook.guided .bk-spread.guided:not(.one) .bk-page.left { border-radius: 14px 0 0 14px; box-shadow: inset -18px 0 22px -18px rgba(120, 70, 100, .35); }
#petbook.guided .bk-spread.guided:not(.one) .bk-page.right { border-radius: 0 14px 14px 0; box-shadow: inset 18px 0 22px -18px rgba(120, 70, 100, .35); }
.bk-when.stamp > span { display: none; }
#petbook.guided .bk-page { overflow-x: hidden; }
/* Thai with Mali: tall vowels and tone marks need room (ผู้ใช้ 30 พ.ย.: "ลองนึกดูนะ…" ran into the title) */
.bk-w-kick { line-height: 1.7; margin: 8px 0 2px; }
.bk-g-left .bk-w-head h3, .bk-page.write .bk-w-head h3 { line-height: 1.5; padding-top: 2px; }
.bk-asks li { line-height: 1.6; }
.bk-ribbon { line-height: 1.6; }
.bk-end-main, .bk-end-q, .bk-share-pick button b { line-height: 1.6; }
.bk-mm-bubble { line-height: 1.7; }
#moodcard .mc-q { line-height: 1.6; }
#moodcard .mc-opts button { line-height: 1.5; }
/* measured in Mali: ครั้ง's marks rise ~9px above the font's ascent at 23px bold */
.bk-g-left .bk-w-head h3, .bk-page.write .bk-w-head h3 { margin-top: 12px !important; }
.bk-w-kick { margin-bottom: 0; }
#moodcard .mc-q { margin-top: 12px; }
.bk-end-main { margin-top: 6px; }

/* the editor's contents stay on the side down to narrow windows (ผู้ใช้ 30 พ.ย.) */
@media (max-width: 760px) and (min-width: 521px) {
  .bk-toc { width: 168px; padding: 14px 8px; }
  button.bk-toc-item { font-size: 12.5px; }
  .bk-page.bk-edit-page { width: calc(94vw - 168px); }
}
/* the reading book: the closed cover opens with a tap */
#petbook .bk-page.closed.tapopen { cursor: pointer; transform-origin: left center; transition: transform .6s cubic-bezier(.5, 0, .3, 1), opacity .6s; }
#petbook .bk-page.closed.tapopen:hover { transform: rotateY(-6deg); }
#petbook .bk-page.closed.tapopen.opening { transform: perspective(1400px) rotateY(-100deg); opacity: 0; }
/* the last page: add a memory */
.bk-page.bk-add { justify-content: flex-start; }
.bk-add-kick { font-size: 13px; font-style: italic; color: #b07a9c; line-height: 1.7; margin-top: 4px; }
.bk-add .bk-writing { flex: 1; }
.bk-add-foot { font-size: 11.5px; opacity: .55; margin-top: 6px; }

/* the pet's little actions when a page is added (book.js petReact) */
.bk-mm-pet { position: relative; align-self: flex-end; margin-right: 10px; }
.bk-mm-bit { position: absolute; left: calc(50% + var(--x)); bottom: 62%; font-style: normal; font-size: 20px; line-height: 1; opacity: 0; pointer-events: none; animation: mmBit 1.7s ease-out forwards; }
.act-heart .bk-mm-bit { color: #f27aa2; }
.act-star .bk-mm-bit { color: #f5c84a; text-shadow: 0 0 6px rgba(255, 220, 120, .7); }
@keyframes mmBit { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.3); } 20% { opacity: 1; transform: translate(-50%, -8px) scale(1.2); } 35% { transform: translate(-50%, -14px) scale(1); } 100% { opacity: 0; transform: translate(-50%, -48px) scale(.9); } }
/* one page at a time: the page turns over at the left edge like the cover opening (ผู้ใช้ 30 พ.ย.) */
#petbook .bk-spread { position: relative; }
#petbook .bk-solo-leaf { position: absolute; margin: 0; z-index: 4; transform-origin: left center; transition: transform .6s cubic-bezier(.45, .05, .25, 1), opacity .6s ease-in; pointer-events: none; animation: none; box-shadow: 8px 0 18px rgba(80, 40, 70, .25); }
#petbook .bk-solo-leaf.go { transform: perspective(1400px) rotateY(-100deg); opacity: 0; }
#petbook .bk-page.bk-solo-in { transform-origin: left center; animation: bkSoloIn .6s cubic-bezier(.45, .05, .25, 1); }
@keyframes bkSoloIn { from { transform: perspective(1400px) rotateY(-100deg); opacity: 0; } to { transform: none; opacity: 1; } }
#petbook .bk-spread > .bk-page:not(.closed) { cursor: pointer; }
#petbook .bk-spread .bk-writing { cursor: auto; }

/* ================= phones (ผู้ใช้ 30 พ.ย.): touch controls + a compact HUD ================= */
html, body { overscroll-behavior: none; }
body.touch { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; -webkit-tap-highlight-color: transparent; }
body.touch input, body.touch textarea, body.touch [contenteditable] { -webkit-user-select: text; user-select: text; }
body.touch #game canvas { touch-action: none; }
body.touch #help { display: none; }
#touchpad { position: absolute; inset: 0; pointer-events: none; z-index: 15; }
/* the lower-left part of the screen: a thumb anywhere here brings the stick (touch.js) */
#tp-zone { position: absolute; left: 0; width: 46vw; top: 34vh; bottom: calc(70px + env(safe-area-inset-bottom)); pointer-events: auto; touch-action: none; }
#tp-stick { position: absolute; left: max(14px, env(safe-area-inset-left)); bottom: calc(86px + env(safe-area-inset-bottom)); width: 120px; height: 120px; border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 246, 248, .28), rgba(255, 246, 248, .5)); border: 3px solid rgba(91, 58, 88, .35); pointer-events: auto; touch-action: none; }
#tp-stick.on { background: radial-gradient(circle, rgba(255, 246, 248, .4), rgba(255, 246, 248, .65)); }
#tp-stick.float { position: fixed; }
#tp-stick .tp-knob { position: absolute; left: 50%; top: 50%; width: 52px; height: 52px; margin: -26px 0 0 -26px; border-radius: 50%; background: rgba(255, 255, 255, .92); border: 3px solid var(--edge); box-shadow: 0 2px 0 var(--edge); pointer-events: none; }
#touchpad .tp-right { position: absolute; right: max(12px, env(safe-area-inset-right)); bottom: calc(86px + env(safe-area-inset-bottom)); display: flex; align-items: flex-end; gap: 10px; pointer-events: none; }
#touchpad .tp-btn { pointer-events: auto; touch-action: none; border-radius: 50%; display: grid; place-items: center; padding: 0; background: rgba(255, 246, 248, .9); border: 3px solid var(--edge); box-shadow: 0 3px 0 var(--edge); line-height: 1; }
#touchpad .tp-btn.on { transform: translateY(2px); box-shadow: 0 1px 0 var(--edge); background: #ffe3ee; }
#tp-use { width: 74px; height: 74px; font-size: 32px; }
#tp-bag { width: 52px; height: 52px; font-size: 24px; margin-bottom: 44px; }
/* nothing to steer while someone is talking, a scene plays or a window is open: the pad steps aside */
/* (a class set by touch.js a few times a second: body:has() rules here re-styled the page on every typed letter) */
body.tp-off #touchpad, body.cine #touchpad { display: none; }
body.touch #hotbar { z-index: 16; }
body.touch #prompt { z-index: 16; pointer-events: auto; bottom: calc(76px + env(safe-area-inset-bottom)); max-width: 42vw; white-space: normal; text-align: center; font-size: 14px; line-height: 1.35; }
/* the 🧪 test buttons fold away on a phone: tap the title to open them */
body.touch #devtools > button { display: none; }
body.touch #devtools.open > button { display: block; }
body.touch #devtools .dev-title { cursor: pointer; padding: 2px 4px; }

@media (max-width: 760px), (max-height: 520px) {
  #profile { left: 8px; top: 8px; gap: 7px; padding: 4px 10px 4px 4px; border-width: 2px; border-radius: 14px; box-shadow: 0 2px 0 var(--edge); max-width: 36vw; }
  #profile-photo { width: 40px; height: 40px; border-width: 2px; }
  #profile-name { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #profile-title { font-size: 10.5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #profile-sub { display: none; }
  #hud-right { right: 8px; top: 8px; gap: 5px; max-width: 62vw; }
  #clock { padding: 3px 9px; border-width: 2px; border-radius: 12px; box-shadow: 0 2px 0 var(--edge); }
  #clock-time { font-size: 17px; }
  #clock-date, #clock-buff, #clock-stage { font-size: 10px; }
  #stardust { font-size: 14px; padding: 1px 9px 1px 6px; border-width: 2px; box-shadow: 0 2px 0 var(--edge); }
  #story-btns { gap: 4px; flex-wrap: wrap; justify-content: flex-end; }
  #story-btns button { font-size: 15px; padding: 2px 5px; border-width: 2px; border-radius: 10px; }
  #devtools { top: 64px; left: 8px; padding: 4px 6px; max-height: calc(100vh - 220px); overflow: auto; }
  #hotbar { bottom: calc(8px + env(safe-area-inset-bottom)); gap: 4px; padding: 4px; border-width: 2px; border-radius: 12px; box-shadow: 0 2px 0 var(--edge); }
  #hotbar .slot { width: min(42px, calc((100vw - 64px) / 8)); height: min(42px, calc((100vw - 64px) / 8)); border-radius: 8px; }
  #hotbar .slot img { width: 70%; height: 70%; }
  #hotbar .slot .qty { font-size: 11px; }
  #hotbar .slot .key { display: none; }
  #story-dlg { bottom: calc(8px + env(safe-area-inset-bottom)); min-height: 96px; gap: 10px; padding: 10px 12px; }
  #topmid { top: 62px; max-width: 94vw; }
}
@media (max-height: 520px) and (orientation: landscape) {
  #tp-stick, #touchpad .tp-right { bottom: calc(14px + env(safe-area-inset-bottom)); }
  #tp-stick { width: 104px; height: 104px; }
  #tp-zone { top: 22vh; bottom: 64px; width: 40vw; }
  body.touch #prompt { bottom: calc(64px + env(safe-area-inset-bottom)); }
  #story-btns { flex-wrap: nowrap; }
  #topmid { top: 10px; }
}
/* ไทย | EN */
.lang-switch { display: inline-flex; border: 2px solid var(--edge); border-radius: 999px; overflow: hidden; background: #fff; box-shadow: 0 2px 0 var(--edge); pointer-events: auto; }
.lang-switch button { border: 0; border-radius: 0; box-shadow: none; background: transparent; padding: 3px 12px; font: inherit; font-size: 13px; font-weight: 700; color: #7a4a6a; cursor: pointer; margin: 0; }
.lang-switch button.on { background: var(--pink2, #f3a6c0); color: #fff; }
#title > .lang-switch { position: absolute; top: max(12px, env(safe-area-inset-top)); right: max(12px, env(safe-area-inset-right)); z-index: 5; }
#sound-pop .lang-switch { margin-top: 6px; align-self: flex-start; }
/* a line said while walking (story.js sayAuto): no tap needed, the walk goes on under it */
#story-dlg.auto { pointer-events: none; cursor: default; }

/* ---------- Google log-in · trial · paywall (account.js, 1 ธ.ค.) ---------- */
.t-google { background: var(--card); border: 4px solid var(--edge); border-radius: 20px; box-shadow: 0 5px 0 var(--edge); padding: 12px 14px 14px; display: flex; flex-direction: column; align-items: center; gap: 10px; }
.t-google-cap { font-weight: 700; font-size: 17px; }
#t-google { min-height: 44px; width: 100%; display: flex; justify-content: center; }
#t-err:empty { display: none; }
.t-legal { margin: 0; text-align: center; font-size: 12px; }
.t-legal a { color: #8a5a7a; background: rgba(255,240,244,.85); border-radius: 8px; padding: 2px 6px; }
.g-wait { opacity: .6; padding: 10px; }
.g-err { color: #c0567a; font-size: 13px; margin: 0; }
.pet-card .pc-trial { color: #b0698f; font-weight: 600; }
.pet-card.locked .pc-pic img { filter: grayscale(.7); opacity: .7; }
.pet-card.locked .play { background: #f7d9a8; }
.paywall .pw-box { width: min(420px, 92vw); text-align: center; max-height: 92vh; overflow: auto; }
.pw-paw { font-size: 30px; }
.pw-box h2 { margin: 4px 0 2px; font-size: 20px; }
.pw-lead { margin: 0 0 8px !important; }
.pw-price { display: inline-flex; align-items: baseline; gap: 6px; background: #fff; border: 3px dashed var(--pink2); border-radius: 16px; padding: 6px 18px; margin-bottom: 6px; }
.pw-price b { font-size: 36px; color: #c0567a; }
.pw-price small { font-size: 13px; opacity: .8; }
.pw-list { text-align: left; margin: 6px 0 10px; padding-left: 22px; font-size: 14px; line-height: 1.6; }
.pw-act { display: flex; flex-direction: column; align-items: center; gap: 10px; }
.pw-terms { display: flex; gap: 8px; align-items: flex-start; text-align: left; font-size: 13px; line-height: 1.5; background: #fff; border-radius: 12px; padding: 8px 10px; cursor: pointer; }
.pw-terms input { margin-top: 3px; width: 18px; height: 18px; flex: none; }
.pw-terms a { color: #b0457a; }
.pw-pay { font-size: 19px; }
.pw-note { font-size: 14px; margin: 0 !important; }
.pw-google { min-height: 44px; display: flex; justify-content: center; width: 100%; }
.pw-err { color: #c0567a; font-size: 13px; margin: 6px 0 0 !important; min-height: 0; }
.pw-err:empty { display: none; }
.pw-later { margin-top: 6px; }
