/* Pixel UI in Detox colours: ink panels, cream text, velvet red for the one thing to press. */
@font-face { font-family: 'Galmuri11'; src: url('/fonts/Galmuri11.woff2') format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: 'Galmuri11'; src: url('/fonts/Galmuri11-Bold.woff2') format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --ink: #15131d;
  --ink-2: #221f2c;
  --cream: #fbf7ee;
  --muted: #b9b2a5;
  --red: #9b111e;
  --red-hi: #c8102e;
  --ok: #4f9a4a;
  --paper: #fffdf6;
  --font: 'Galmuri11', 'Apple SD Gothic Neo', 'Malgun Gothic', 'Noto Sans KR', sans-serif;
  --safe-t: env(safe-area-inset-top, 0px);
  --safe-b: env(safe-area-inset-bottom, 0px);
  --safe-l: env(safe-area-inset-left, 0px);
  --safe-r: env(safe-area-inset-right, 0px);
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; background: #2b2a33; color: var(--cream); font-family: var(--font); overflow: hidden; }
body { -webkit-tap-highlight-color: transparent; word-break: keep-all; overflow-wrap: anywhere; }
button { font-family: inherit; }
#game { position: fixed; left: 0; top: 0; image-rendering: pixelated; image-rendering: crisp-edges; touch-action: none; cursor: pointer; display: block; }

/* buttons */
.px-btn {
  font: 700 14px/1.2 var(--font); color: var(--cream); background: var(--ink); border: 2px solid var(--cream);
  padding: 9px 14px; cursor: pointer; box-shadow: 3px 3px 0 rgba(0,0,0,.45); border-radius: 0; touch-action: manipulation;
}
.px-btn:hover:not([disabled]) { background: var(--ink-2); }
.px-btn:active:not([disabled]) { transform: translate(2px, 2px); box-shadow: 1px 1px 0 rgba(0,0,0,.45); }
.px-btn:focus-visible, .opt:focus-visible, .chip:focus-visible, .tab:focus-visible, .vote:focus-visible, .place-card:focus-visible { outline: 2px dashed var(--cream); outline-offset: 3px; }
.px-btn[disabled] { opacity: .45; cursor: not-allowed; }
.px-btn.accent { background: var(--red); color: #fff; }
.px-btn.accent:hover:not([disabled]) { background: var(--red-hi); }
.px-btn.ghost { background: transparent; box-shadow: none; border-style: dashed; }
.px-btn.sm { font-size: 13px; padding: 7px 10px; }
.px-btn.big { font-size: 16px; padding: 12px 18px; }
.px-tag { background: var(--ink); color: var(--cream); border: 2px solid var(--cream); padding: 7px 10px; font-size: 13px; box-shadow: 3px 3px 0 rgba(0,0,0,.45); }
.px-tag b { color: #fff; margin-left: 2px; }

/* HUD */
#hud { position: fixed; top: calc(var(--safe-t) + 10px); left: calc(var(--safe-l) + 10px); right: calc(var(--safe-r) + 10px); display: flex; justify-content: space-between; align-items: flex-start; gap: 8px; pointer-events: none; z-index: 5; }
#hud > * { pointer-events: auto; }
.hud-right { display: flex; gap: 6px; flex-wrap: wrap; justify-content: flex-end; }

#prompt { position: fixed; left: 50%; transform: translateX(-50%); bottom: calc(var(--safe-b) + 16px); z-index: 5; display: flex; gap: 10px; align-items: center;
  background: var(--ink); border: 2px solid var(--cream); padding: 8px 10px 8px 14px; box-shadow: 4px 4px 0 rgba(0,0,0,.45); max-width: calc(100vw - 24px); }
#prompt .prompt-text { font-size: 14px; }
#prompt:not(:has(.prompt-text)) { padding: 6px; }

#toast { position: fixed; left: 50%; top: calc(var(--safe-t) + 64px); transform: translate(-50%, -8px); opacity: 0; pointer-events: none; z-index: 40;
  background: var(--cream); color: var(--ink); border: 2px solid var(--ink); padding: 9px 14px; font-size: 14px; box-shadow: 4px 4px 0 rgba(0,0,0,.4); transition: opacity .18s, transform .18s; max-width: calc(100vw - 32px); text-align: center; }
#toast.show { opacity: 1; transform: translate(-50%, 0); }

/* loading */
#loading { position: fixed; inset: 0; background: var(--ink); display: grid; place-items: center; z-index: 50; transition: opacity .35s; }
#loading.out { opacity: 0; pointer-events: none; }
.load-box { display: grid; gap: 12px; justify-items: center; font-size: 15px; }
.bar { width: 200px; height: 14px; border: 2px solid var(--cream); padding: 2px; }
.bar i { display: block; height: 100%; width: 0; background: var(--red); transition: width .2s; }
.nojs { position: fixed; inset: 0; display: grid; place-items: center; background: var(--ink); margin: 0; padding: 24px; text-align: center; }

/* modal */
.backdrop { position: fixed; inset: 0; z-index: 20; background: rgba(12, 10, 18, .58); display: grid; place-items: center;
  padding: calc(var(--safe-t) + 16px) calc(var(--safe-r) + 16px) calc(var(--safe-b) + 16px) calc(var(--safe-l) + 16px); animation: fade .16s ease-out; }
.backdrop.out { opacity: 0; transition: opacity .15s; }
@keyframes fade { from { opacity: 0; } }
.panel { background: var(--ink); color: var(--cream); border: 3px solid var(--cream); box-shadow: 0 0 0 3px var(--ink), 8px 8px 0 3px rgba(0,0,0,.45);
  width: min(760px, 100%); max-height: min(88vh, 900px); overflow: auto; padding: 18px 20px 22px; outline: none; overscroll-behavior: contain; }
.panel h1 { font-size: 24px; margin: 6px 0 10px; line-height: 1.35; }
.panel h2 { font-size: 20px; margin: 0; line-height: 1.3; }
.panel p { margin: 0; line-height: 1.65; }

.panel-head { display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: 14px; align-items: center; padding-bottom: 14px; border-bottom: 2px dashed rgba(251,247,238,.3); }
.panel-head .thumb { width: 64px; height: 64px; object-fit: contain; image-rendering: pixelated; background: #2b2a33; border: 2px solid var(--cream); padding: 3px; }
.head-text .hints { color: var(--muted); font-size: 13px; margin-top: 4px; }
.px-btn.icon { padding: 7px 10px; font-size: 13px; }
.ask { font-size: 17px; font-weight: 700; margin: 16px 0 12px !important; }

.compose { display: grid; gap: 10px; margin-bottom: 18px; justify-items: start; }
.note-form { display: grid; gap: 8px; width: 100%; background: var(--ink-2); border: 2px solid rgba(251,247,238,.5); padding: 14px; }
.note-form label, .note-form legend { font-size: 14px; font-weight: 700; }
.note-form em { font-style: normal; color: #ff8a8a; font-weight: 400; font-size: 12px; margin-left: 4px; }
.note-form label span, .note-form legend span, .q-title span { color: var(--muted); font-weight: 400; font-size: 12px; margin-left: 4px; }
.note-form fieldset { border: 0; padding: 0; margin: 6px 0 0; }
.px-input { width: 100%; font: 16px/1.5 var(--font); color: var(--ink); background: var(--paper); border: 2px solid var(--cream); border-radius: 0; padding: 9px 10px; resize: vertical; }
.px-input:focus { outline: 2px solid var(--red-hi); outline-offset: 1px; }
.counter { justify-self: end; font-size: 12px; color: var(--muted); margin-top: -4px; }
.chips { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.chip, .opt { font: 14px/1.2 var(--font); color: var(--cream); background: transparent; border: 2px solid rgba(251,247,238,.6); padding: 8px 10px; cursor: pointer; border-radius: 0; touch-action: manipulation; }
.chip[aria-pressed='true'], .opt[aria-pressed='true'] { background: var(--cream); color: var(--ink); border-color: var(--cream); font-weight: 700; }
.form-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }

.tabs { display: flex; gap: 6px; align-items: center; margin-bottom: 12px; flex-wrap: wrap; }
.tab { font: 13px var(--font); color: var(--muted); background: transparent; border: 0; border-bottom: 2px solid transparent; padding: 6px 4px; cursor: pointer; }
.tab[aria-pressed='true'] { color: var(--cream); border-bottom-color: var(--cream); font-weight: 700; }
.tabs .count { margin-left: auto; font-size: 13px; color: var(--muted); }

.notes { display: grid; grid-template-columns: repeat(auto-fill, minmax(210px, 1fr)); gap: 14px; align-items: start; }
.empty { color: var(--muted); font-size: 14px; padding: 18px 0; grid-column: 1 / -1; }
.note { color: #2a2620; padding: 12px 12px 10px; box-shadow: 3px 4px 0 rgba(0,0,0,.4); transform: rotate(var(--rot, 0deg)); display: grid; gap: 8px; font-size: 14px; line-height: 1.55; }
.note p { line-height: 1.55; white-space: pre-wrap; }
.n-yellow { background: #ffe58a; } .n-pink { background: #ffc9d3; } .n-blue { background: #cfe5ff; } .n-green { background: #d3efc4; }
.note-title { font-weight: 700; font-size: 15px; }
.note-want { font-size: 13px; background: rgba(255,255,255,.55); padding: 6px 8px; }
.note-want span { display: block; font-size: 11px; color: #6b5e4f; margin-bottom: 2px; }
.note-chips { display: flex; flex-wrap: wrap; gap: 4px; }
.chip-s { font-size: 11px; border: 1px solid rgba(42,38,32,.45); padding: 2px 5px; }
.note-meta { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 12px; color: #5b5146; }
.note-pending { font-size: 12px; color: #7a2d2d; }
.vote { font: 700 12px var(--font); color: #2a2620; background: rgba(255,255,255,.6); border: 2px solid #2a2620; padding: 4px 7px; cursor: pointer; display: inline-flex; gap: 6px; align-items: center; white-space: nowrap; touch-action: manipulation; }
.vote.on { background: var(--red); color: #fff; border-color: var(--red); }
.vote.mine { opacity: .6; cursor: default; }

/* onboarding */
.onboard { width: min(560px, 100%); position: relative; }
.onboard .music-mini { position: absolute; top: 14px; right: 14px; }
.onboard .logo { display: block; width: 130px; height: auto; margin-bottom: 4px; }
.onboard .lead { color: #e9e3d6; font-size: 15px; }
.q { margin-top: 18px; display: grid; gap: 8px; }
.q-title { font-weight: 700; font-size: 15px; }
.opts { display: flex; flex-wrap: wrap; gap: 6px; }
.onboard .actions { display: grid; gap: 10px; margin-top: 22px; }
.need { color: var(--muted); font-size: 13px; margin-top: 10px !important; }
.fine { color: var(--muted); font-size: 12px; margin-top: 12px !important; }

/* list */
.place-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(160px, 1fr)); gap: 10px; margin-top: 16px; }
.place-card { display: grid; gap: 4px; justify-items: start; text-align: left; font-family: var(--font); color: var(--cream); background: var(--ink-2); border: 2px solid rgba(251,247,238,.55); padding: 10px; cursor: pointer; }
.place-card:hover { border-color: var(--cream); }
.place-card img { width: 100%; height: 86px; object-fit: contain; image-rendering: pixelated; background: #2b2a33; margin-bottom: 4px; }
.pc-name { font-weight: 700; font-size: 15px; display: flex; gap: 6px; align-items: center; }
.pc-hints { font-size: 12px; color: var(--muted); line-height: 1.45; }
.pc-count { font-size: 12px; color: var(--cream); margin-top: 2px; }
.stamp { font-style: normal; font-size: 11px; background: var(--ok); color: #fff; padding: 1px 5px; }
.suggest-card { border-color: var(--red-hi); }

.done { width: min(460px, 100%); display: grid; gap: 12px; }

@media (max-width: 600px) {
  .backdrop { place-items: end center; padding: calc(var(--safe-t) + 12px) 0 0; }
  .panel { width: 100%; max-height: 90vh; border-bottom: 0; box-shadow: 0 0 0 3px var(--ink); padding: 16px 16px calc(var(--safe-b) + 20px); }
  .notes { grid-template-columns: 1fr; }
  .px-btn.sm { font-size: 12px; padding: 6px 8px; }
  .px-tag { font-size: 12px; padding: 6px 8px; }
  .panel-head .thumb { width: 52px; height: 52px; }
  .place-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (prefers-reduced-motion: reduce) { * { transition: none !important; animation: none !important; } }
