/* Shared UI for the pixel-art gift games (Stardew-ish wooden panels).
   Fonts: Silkscreen for labels/numbers, VT323 for dialog & long text. */
:root {
  --ink: #3d2633; --paper: #fbe9c0; --paper2: #f1d59a; --wood: #9a5f3a; --wood2: #6b3d26; --accent: #e04f5f; --accent2: #8e2a37;
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #241820; color: var(--ink); font-family: 'VT323', monospace; font-size: 22px; }
canvas.game { display: block; touch-action: none; image-rendering: pixelated; }
.vignette { position: fixed; inset: 0; pointer-events: none; background: radial-gradient(ellipse at center, transparent 58%, rgba(30,15,25,.38)); z-index: 1; }

.panel {
  background: var(--paper); border: 4px solid var(--wood2); border-radius: 6px;
  box-shadow: inset 0 0 0 3px var(--paper2), inset 0 0 0 6px var(--wood), 0 6px 0 rgba(0,0,0,.35);
}
.label, h1, h2, h3, .who, .hud-chip, button { font-family: 'Silkscreen', monospace; font-weight: 400; }

/* ---------- HUD ---------- */
.hud { position: fixed; top: 10px; left: 10px; right: 10px; display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; pointer-events: none; z-index: 3; }
.hud-chip { padding: 8px 14px; font-size: 13px; display: inline-flex; align-items: center; gap: 8px; }
.hud-col { display: grid; gap: 8px; justify-items: start; }
.hud-col.right { justify-items: end; }
.quest { padding: 10px 14px; font-size: 20px; line-height: 1.15; max-width: min(340px, 60vw); }
.quest .label { font-size: 12px; color: var(--wood2); margin-bottom: 4px; display: block; }
.quest .done { text-decoration: line-through; opacity: .55; }
.icon-btn { pointer-events: auto; cursor: pointer; width: 42px; height: 42px; padding: 0; font-size: 14px; color: var(--wood2); }

/* ---------- dialog ---------- */
.dialog {
  position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); width: min(660px, calc(100% - 20px));
  padding: 14px 18px 22px; display: none; z-index: 6; cursor: pointer; gap: 14px; align-items: flex-start;
}
.dialog.open { display: flex; animation: dlg-in .18s steps(3); }
@keyframes dlg-in { from { transform: translate(-50%, 20px); opacity: 0; } }
.portrait { flex: none; width: 88px; height: 88px; background: #c8e6a0; border: 4px solid var(--wood2); border-radius: 4px; image-rendering: pixelated; }
.dialog .who { color: var(--accent); font-size: 14px; margin-bottom: 4px; }
.dialog .text { font-size: 25px; line-height: 1.1; min-height: 56px; }
.dialog .more { position: absolute; right: 16px; bottom: 6px; font-size: 18px; color: var(--wood2); animation: nudge .5s steps(2) infinite alternate; }
@keyframes nudge { to { transform: translateY(3px); } }
.choices { display: grid; gap: 8px; margin-top: 10px; }
.choices button { text-align: left; font-size: 14px; padding: 9px 12px; background: #fff7e2; color: var(--ink); border: 3px solid var(--wood); border-radius: 6px; cursor: pointer; }
.choices button:hover, .choices button:focus { background: #ffe9a8; border-color: var(--wood2); outline: none; }

/* ---------- touch controls ---------- */
.pad { position: fixed; bottom: 14px; left: 0; right: 0; display: flex; justify-content: space-between; align-items: flex-end; padding: 0 14px; pointer-events: none; z-index: 4; }
body.talking .pad { display: none; }
.dpad { display: grid; grid-template-columns: repeat(3, 56px); grid-template-rows: repeat(3, 56px); }
.dpad.h { grid-template-columns: repeat(2, 66px); grid-template-rows: 66px; gap: 10px; }
.pad button {
  pointer-events: auto; font-size: 16px; color: var(--wood2); touch-action: none; user-select: none;
  background: var(--paper); border: 3px solid var(--wood2); border-radius: 8px; box-shadow: 0 4px 0 var(--wood2);
}
.pad button:active, .pad button.on { transform: translateY(3px); box-shadow: 0 1px 0 var(--wood2); }
.dpad [data-k=up] { grid-area: 1 / 2; } .dpad [data-k=left] { grid-area: 2 / 1; } .dpad [data-k=right] { grid-area: 2 / 3; } .dpad [data-k=down] { grid-area: 3 / 2; }
.dpad.h [data-k=left], .dpad.h [data-k=right] { grid-area: auto; }
.actions { display: flex; gap: 10px; align-items: flex-end; }
.actions button { width: 74px; height: 74px; border-radius: 50%; font-size: 12px; }
@media (hover: hover) and (pointer: fine) { .pad { display: none; } }

/* ---------- overlays ---------- */
.overlay { position: fixed; inset: 0; display: none; align-items: center; justify-content: center; padding: 16px; background: rgba(36,20,30,.6); z-index: 8; }
.overlay.open { display: flex; }
.card { width: 100%; max-width: 460px; max-height: 90vh; overflow: auto; padding: 24px 22px; text-align: center; animation: pop .3s steps(4); }
@keyframes pop { from { transform: scale(.6); } }
.card h1 { margin: 6px 0 10px; font-size: 22px; color: var(--wood2); line-height: 1.3; }
.card h2 { margin: 4px 0 10px; font-size: 18px; color: var(--wood2); }
.card .kicker { font-family: 'Silkscreen', monospace; color: var(--accent); font-size: 12px; letter-spacing: 1px; }
.card p, .card .letter { font-size: 23px; line-height: 1.2; margin: 10px 0 16px; white-space: pre-line; }
.card .letter { text-align: left; }
.card img.photo { width: 100%; aspect-ratio: 4 / 3; object-fit: cover; border: 4px solid var(--wood2); border-radius: 4px; display: block; margin: 8px 0; }
.card canvas { image-rendering: pixelated; }
.card .keys { font-size: 19px; opacity: .7; }
.card .credit { font-family: 'Silkscreen', monospace; font-size: 10px; opacity: .5; margin-top: 12px; }
.btn {
  font-size: 15px; border: 3px solid var(--accent2); border-radius: 6px; padding: 11px 22px; cursor: pointer;
  background: var(--accent); color: #fff; box-shadow: 0 4px 0 var(--accent2);
}
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 var(--accent2); }
.btn:disabled { opacity: .6; cursor: wait; }
.btn.alt { background: var(--paper); color: var(--wood2); border-color: var(--wood2); box-shadow: 0 4px 0 var(--wood2); }

/* ---------- hotbar (Stardew-style toolbar) ---------- */
.hotbar { position: fixed; left: 50%; bottom: 14px; transform: translateX(-50%); display: flex; gap: 6px; padding: 8px; z-index: 3; }
body.talking .hotbar { display: none; }
.slot { position: relative; width: 56px; height: 56px; background: #f6dca4; border: 3px solid var(--wood); border-radius: 4px; display: grid; place-items: center; cursor: pointer; }
.slot.sel { border-color: var(--accent); box-shadow: 0 0 0 3px #ffd34d; }
.slot canvas { width: 42px; height: 42px; image-rendering: pixelated; }
.slot .n { position: absolute; right: 3px; bottom: 0; font-family: 'Silkscreen', monospace; font-size: 11px; color: var(--ink); text-shadow: 1px 1px 0 #fff; }
@media (hover: none) and (pointer: coarse) { .hotbar { bottom: auto; top: 64px; } }

.toast { position: fixed; left: 50%; top: 70px; transform: translateX(-50%) translateY(-30px); opacity: 0; z-index: 7; padding: 8px 16px; font-family: 'Silkscreen', monospace; font-size: 13px; transition: .25s steps(4); pointer-events: none; }
.toast.show { opacity: 1; transform: translateX(-50%); }
.fade { position: fixed; inset: 0; background: #000; opacity: 0; pointer-events: none; z-index: 7; transition: opacity .6s; }
.fade.on { opacity: 1; }
