@font-face { font-family: Galmuri; src: url(fonts/Galmuri11.woff2) format('woff2'); font-weight: 400; font-display: swap; }
@font-face { font-family: Galmuri; src: url(fonts/Galmuri11-Bold.woff2) format('woff2'); font-weight: 700; font-display: swap; }

:root {
  --ink: #2b2140; --paper: #f6f3ff; --line: #d8d0ee; --soft: #665c86;
  --sun: #ffd84f; --led: #ffc24a; --pink: #e2467f; --mint: #1f8a83;
  --slab: #a8d8cb; --slab-hi: #d6f1e8; --slab-lo: #6fae9f; --slab-ink: #2b2140; --wing: #8cc5b7;
  --pixel: Galmuri, 'Pretendard Variable', sans-serif;
  --text: 'Pretendard Variable', Pretendard, system-ui, sans-serif;
  --p: 2px;
}
* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; background: #57b2ee; }
body { margin: 0; min-height: 100dvh; font-family: var(--text); color: var(--ink); overflow-x: hidden; -webkit-tap-highlight-color: transparent; }
canvas { display: block; image-rendering: pixelated; }
button, select, input { font: inherit; color: inherit; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px; box-shadow: 0 0 0 6px var(--ink); }

#sky { position: fixed; inset: 0; z-index: -1; width: 100vw; height: 100lvh; }
#tower { display: flex; flex-direction: column; align-items: center; min-height: 100dvh; justify-content: flex-end; }

/* 옥상 간판 */
.roof { position: relative; width: 100%; display: flex; justify-content: center; padding-top: max(14px, env(safe-area-inset-top)); }
.roof canvas { position: absolute; bottom: 0; left: 50%; transform: translateX(-50%); }
.sign { position: relative; margin-bottom: calc(var(--p) * 17); background: var(--ink); padding: calc(var(--p) * 4); box-shadow: 0 0 0 var(--p) #8790b5, 0 0 0 calc(var(--p) * 2) var(--ink); }
.sign::before { content: ''; position: absolute; inset: calc(var(--p) * 1.5); border: calc(var(--p) * 1) dotted var(--sun); opacity: .9; animation: bulbs 1.4s steps(2) infinite; }
@keyframes bulbs { 50% { border-color: #ff8a5c; } }
.sign h1 { margin: 0; padding: 8px 18px 9px; font: 700 36px/1.15 var(--pixel); letter-spacing: 1px; color: var(--sun); text-shadow: 0 0 14px rgba(255, 190, 70, .55), 3px 3px 0 #6b3a52; white-space: nowrap; }

/* 전광판 */
.board { width: var(--bw); display: flex; align-items: center; gap: 16px; min-height: 36px; padding: 5px 14px; background: #1a1430; border: solid var(--ink); border-width: var(--p) var(--p) 0; color: var(--led); font: 400 12px/1.5 var(--pixel); position: relative; }
.board::after { content: ''; position: absolute; inset: 0; pointer-events: none; background: radial-gradient(circle, transparent 1px, rgba(0, 0, 0, .28) 1.4px) 0 0 / 3px 3px; }
.board-count { color: #7df0c0; white-space: nowrap; }
.board-feed { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: center; }
.board-feed.new { animation: led .5s steps(6); }
@keyframes led { from { clip-path: inset(0 100% 0 0); } to { clip-path: inset(0); } }
.board-clock { white-space: nowrap; color: #ff9d7a; }

/* 방 */
.rooms { width: var(--bw); display: grid; grid-template-columns: repeat(var(--cols), 1fr); border-left: var(--p) solid var(--ink); border-right: var(--p) solid var(--ink); background: var(--ink); }
.room { appearance: none; border: 0; padding: 0; margin: 0; background: none; text-align: left; cursor: pointer; position: relative; display: block; }
.room:not(.edge) { border-right: var(--p) solid var(--ink); }
.room:focus-visible { z-index: 2; outline-offset: -3px; box-shadow: none; }
.plate { display: flex; align-items: center; gap: 8px; min-height: 34px; padding: 4px 10px; background: var(--slab); border-top: var(--p) solid var(--ink); border-bottom: var(--p) solid var(--ink); box-shadow: inset 0 var(--p) var(--slab-hi), inset 0 calc(var(--p) * -1) var(--slab-lo); color: var(--slab-ink); font: 400 12px/1.4 var(--pixel); }
.plate b { font-weight: 700; white-space: nowrap; }
.plate .say { margin-left: auto; text-align: right; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.lamp { flex: none; display: inline-block; width: 8px; height: 8px; background: #7d7896; box-shadow: 0 0 0 2px var(--ink); }
.room[data-mood=work] .lamp, .key.on .lamp { background: #4be08a; }
.room[data-mood=wait] .lamp { background: #ff4f5e; animation: blink .6s steps(2) infinite; }
.room[data-mood=rest] .lamp { background: var(--sun); }
.room[data-mood=wait] .plate { background: #ffd84f; color: var(--ink); box-shadow: inset 0 var(--p) #fff0b0, inset 0 calc(var(--p) * -1) #d9a520; }
@keyframes blink { 50% { opacity: .15; } }
@media (hover: hover) { .room:hover .plate b { text-decoration: underline; text-underline-offset: 3px; } }

.street { width: 100%; position: relative; overflow: hidden; }
.street canvas { margin: 0 auto; }

/* 아래 조작판 */
.dock { position: fixed; z-index: 5; left: 50%; bottom: max(12px, env(safe-area-inset-bottom)); transform: translateX(-50%); display: flex; flex-direction: column; gap: 8px; max-width: calc(100vw - 20px); padding: 8px; background: var(--ink); box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--ink); transition: opacity .3s, translate .3s; }
.keys { display: flex; gap: 6px; justify-content: center; }
.key { border: 0; min-height: 40px; padding: 0 14px; background: #e9e3ff; color: var(--ink); font: 700 12px/1 var(--pixel); white-space: nowrap; cursor: pointer; box-shadow: inset 0 -4px #a99bd6, inset 0 2px #fff; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.key:active { box-shadow: inset 0 3px #a99bd6; padding-top: 4px; }
.key.on, .key.strong { background: var(--sun); box-shadow: inset 0 -4px #d99b1f, inset 0 2px #fff3bd; }
@media (hover: hover) { .key:hover { background: #fff; } .key.on:hover, .key.strong:hover { background: #ffe684; } }
.replay { width: min(560px, calc(100vw - 36px)); color: #fff; }
.replay-row { display: flex; align-items: center; gap: 8px; }
.replay select { flex: 1; min-width: 0; min-height: 40px; padding: 0 8px; border: 0; background: #40335e; color: #fff; font: 400 12px/1 var(--pixel); }
.replay .key { min-width: 48px; padding-inline: 8px; }
.replay-time { font: 700 24px/1 var(--pixel); color: var(--sun); min-width: 74px; text-align: center; font-variant-numeric: tabular-nums; }
.track { position: relative; height: 40px; margin-top: 8px; }
.track canvas { position: absolute; inset: 6px 0; width: 100%; height: 28px; background: #1a1430; }
.track input { position: absolute; inset: 0; width: 100%; height: 100%; margin: 0; appearance: none; background: none; cursor: pointer; }
.track input::-webkit-slider-thumb { appearance: none; width: 12px; height: 36px; background: var(--sun); border: 2px solid var(--ink); box-shadow: 0 0 0 2px #fff; }
.track input::-moz-range-thumb { width: 8px; height: 32px; border-radius: 0; background: var(--sun); border: 2px solid var(--ink); box-shadow: 0 0 0 2px #fff; }

/* 직원 카드 */
dialog { border: 0; padding: 0; color: var(--ink); }
dialog::backdrop { background: rgba(26, 18, 52, .5); }
.panel { position: fixed; inset: 0 0 0 auto; width: min(430px, 100vw); height: 100dvh; max-height: none; max-width: none; margin: 0; background: var(--paper); border-left: 4px solid var(--ink); }
.panel[open] { animation: slide .22s steps(6); }
@keyframes slide { from { transform: translateX(60px); opacity: 0; } }
.panel-in { height: 100%; display: flex; flex-direction: column; }
.p-hero { flex: none; display: flex; align-items: center; gap: 16px; padding: 18px 18px 16px; background: var(--wall, #a9b6e6); border-bottom: 4px solid var(--ink); position: relative; }
.p-pet { flex: none; border: 0; padding: 0; cursor: pointer; background: rgba(255, 255, 255, .55); box-shadow: 0 0 0 4px var(--ink); }
.p-pet canvas { width: 115px; height: 125px; }
.p-id { min-width: 0; padding-right: 30px; }
.p-id h2 { margin: 0 0 4px; font: 700 24px/1.2 var(--pixel); word-break: keep-all; }
.p-id p { margin: 0; font-size: 14px; line-height: 1.5; }
.p-now { margin-top: 10px !important; display: inline-block; padding: 5px 10px; background: var(--ink); color: #fff; font: 400 12px/1.4 var(--pixel) !important; }
.p-x { position: absolute; top: 10px; right: 10px; width: 40px; height: 40px; border: 0; background: none; font-size: 18px; cursor: pointer; }
.p-body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 20px 18px calc(32px + env(safe-area-inset-bottom)); }
.p-body h3 { margin: 26px 0 10px; font: 700 12px/1.4 var(--pixel); }
.p-body h3:first-child { margin-top: 0; }
.p-body p { margin: 0; font-size: 14px; line-height: 1.65; }
.p-sum { font-size: 17px !important; line-height: 1.6 !important; word-break: keep-all; }
.p-sum b { font-weight: 700; }
.acts { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; }
.acts li { display: grid; grid-template-columns: 26px 92px 1fr 34px; align-items: center; gap: 8px; font-size: 14px; }
.acts canvas { width: 22px; height: 16px; }
.acts .bar { height: 14px; background: #e4dcf7; position: relative; }
.acts .bar i { position: absolute; inset: 0 auto 0 0; background: var(--accent); box-shadow: inset 0 -3px rgba(43, 33, 64, .22), inset 0 2px rgba(255, 255, 255, .35); }
.acts .n { text-align: right; font-variant-numeric: tabular-nums; font-weight: 600; }
.days { display: grid; grid-template-columns: repeat(14, 1fr); gap: 4px; align-items: end; height: 92px; }
.days div { position: relative; height: 100%; display: flex; align-items: flex-end; border-bottom: 2px solid var(--line); }
.days i { width: 100%; background: #bdb2de; min-height: 0; }
.days .now i { background: var(--accent); }
.days-label { display: flex; justify-content: space-between; margin-top: 6px !important; font-size: 12px !important; color: var(--soft); }
.log { list-style: none; margin: 0; padding: 0; }
.log li { display: grid; grid-template-columns: 26px 1fr auto; gap: 8px; align-items: center; padding: 8px 0; border-bottom: 1px solid var(--line); font-size: 14px; }
.log canvas { width: 22px; height: 16px; }
.log .d { display: block; color: var(--soft); font-size: 13px; overflow-wrap: anywhere; }
.log time { color: var(--soft); font-size: 13px; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tok { display: grid; grid-template-columns: auto 1fr 1fr; gap: 6px 14px; font-size: 14px; font-variant-numeric: tabular-nums; }
.tok span { text-align: right; } .tok .h { color: var(--soft); font-size: 13px; }
.titles { margin: 0; padding-left: 18px; font-size: 14px; line-height: 1.7; }
.hint { color: var(--soft); margin-top: 18px !important; }
.hint button { border: 0; background: none; padding: 0; text-decoration: underline; text-underline-offset: 3px; cursor: pointer; color: var(--ink); font-weight: 600; }

.login { width: min(360px, calc(100vw - 32px)); background: var(--paper); box-shadow: 0 0 0 4px var(--ink), 0 0 0 8px var(--sun), 0 0 0 12px var(--ink); margin: auto; }
.login form { padding: 24px; display: grid; gap: 10px; }
.login h2 { margin: 0; font: 700 24px/1.2 var(--pixel); }
.login p { margin: 0; font-size: 14px; line-height: 1.6; color: var(--soft); word-break: keep-all; }
.login label { font-size: 14px; font-weight: 600; margin-top: 6px; }
.login input { height: 46px; padding: 0 12px; border: 3px solid var(--ink); background: #fff; font-size: 16px; border-radius: 0; }
.l-err { color: #b8203a !important; min-height: 1.4em; }
.l-row { display: flex; gap: 8px; justify-content: flex-end; }

/* TV 화면 */
body.tv { overflow: hidden; cursor: none; }
body.tv.awake { cursor: auto; }
body.tv .dock { opacity: 0; translate: 0 20px; pointer-events: none; }
body.tv.awake .dock, body.tv .dock:focus-within { opacity: 1; translate: 0 0; pointer-events: auto; }
body.tv #tower { height: 100dvh; min-height: 0; justify-content: center; }
body.tv .roof { padding-top: 6px; }
body.tv .street { position: absolute; bottom: 0; z-index: -1; }
body.replaying .board { color: #9fd8f0; }

@media (max-width: 639px) {
  .sign h1 { font-size: 24px; padding: 8px 12px; }
  .board { flex-wrap: wrap; gap: 0 12px; padding: 7px 12px; }
  .board-count { flex: 1; }
  .board-feed { order: 3; flex: 1 0 100%; text-align: left; }
  .key { padding: 0 11px; min-height: 44px; }
  .panel { inset: auto 0 0; width: 100vw; height: 86dvh; border-left: 0; border-top: 4px solid var(--ink); }
  .panel[open] { animation-name: rise; }
  .p-hero { padding: 14px; gap: 14px; }
  .p-pet canvas { width: 92px; height: 100px; }
  .street { padding-bottom: 0; }
}
@keyframes rise { from { transform: translateY(80px); opacity: 0; } }
@media (prefers-reduced-motion: reduce) { *, *::before { animation: none !important; transition: none !important; } }

body.big .plate { min-height: 46px; font-size: 24px; padding-inline: 14px; }
body.big .lamp { width: 14px; height: 14px; }
body.big .board { font-size: 24px; min-height: 48px; }
body.big .sign h1 { padding: 4px 18px 5px; }
