* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2b2420; touch-action: none; user-select: none; -webkit-user-select: none;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", sans-serif; color: #3a3028; }
button, input { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; }
#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; }

#hud { position: fixed; top: max(8px, env(safe-area-inset-top)); left: 10px; right: 10px; display: flex; gap: 8px; align-items: center; pointer-events: none; z-index: 10; }
#hud > * { pointer-events: auto; }
#place, #clock { background: rgba(255, 252, 244, .92); border-radius: 999px; padding: 7px 14px; font-weight: 700; font-size: 17px; box-shadow: 0 2px 6px rgba(0, 0, 0, .18); }
#clock { font-weight: 600; font-size: 15px; }
#hud .sp { flex: 1; pointer-events: none; }
#hud button, #side button { width: 48px; height: 48px; border-radius: 50%; background: rgba(255, 252, 244, .92); font-size: 23px; box-shadow: 0 2px 6px rgba(0, 0, 0, .18); }

#hud button.pill { width: auto; padding: 0 14px; border-radius: 999px; font-size: 16px; font-weight: 700; }
#log { position: fixed; left: 12px; bottom: 170px; max-width: min(70vw, 340px); display: flex; flex-direction: column; gap: 4px; z-index: 9; pointer-events: none; }
#log div { background: rgba(40, 32, 28, .72); color: #fff; font-size: 15px; padding: 5px 10px; border-radius: 10px; width: fit-content; max-width: 100%; word-break: break-all; }
#log b { color: #ffe08a; }
#cerr { color: #c0392b; font-weight: 700; font-size: 15px; margin: -4px 0 8px; min-height: 0; }
#cerr:empty { display: none; }
#joy { position: fixed; left: 18px; bottom: max(22px, env(safe-area-inset-bottom)); width: 128px; height: 128px; border-radius: 50%; background: rgba(255, 255, 255, .28); border: 2px solid rgba(255, 255, 255, .6); z-index: 10; touch-action: none; }
#knob { position: absolute; left: 50%; top: 50%; width: 56px; height: 56px; margin: -28px; border-radius: 50%; background: rgba(255, 255, 255, .88); box-shadow: 0 2px 8px rgba(0, 0, 0, .25); }

#side { position: fixed; right: 12px; bottom: max(22px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 10px; z-index: 10; }
#emotes { position: fixed; right: 70px; bottom: max(22px, env(safe-area-inset-bottom)); width: 216px; display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; background: rgba(255, 252, 244, .96); padding: 8px; border-radius: 16px; z-index: 11; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
#emotes button { height: 46px; font-size: 26px; background: #f4ecd8; border-radius: 10px; }
#chat { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(96px, env(safe-area-inset-bottom)); width: min(92vw, 440px); display: flex; gap: 6px; background: rgba(255, 252, 244, .97); padding: 8px; border-radius: 16px; z-index: 12; box-shadow: 0 4px 14px rgba(0, 0, 0, .25); }
#chat input { flex: 1; min-width: 0; font-size: 18px; padding: 10px 12px; border: 2px solid #d9c9a8; border-radius: 10px; background: #fff; user-select: text; -webkit-user-select: text; }
#chat button { font-size: 17px; font-weight: 700; padding: 0 16px; border-radius: 10px; background: #5aa37a; color: #fff; }

#actions { position: fixed; left: 50%; transform: translateX(-50%); bottom: max(30px, env(safe-area-inset-bottom)); display: flex; flex-direction: column; gap: 8px; align-items: center; z-index: 10; width: max-content; max-width: calc(100vw - 230px); }
#action, #action2 { font-size: 19px; font-weight: 700; padding: 14px 22px; border-radius: 999px; background: #fffaf0; border: 3px solid #e2a04a; box-shadow: 0 4px 10px rgba(0, 0, 0, .25); white-space: nowrap; }
#action2 { border-color: #8a9aa8; font-size: 16px; padding: 9px 18px; }
@media (max-width: 520px) { #actions { bottom: 170px; max-width: 92vw; } #chat { bottom: 240px; } }

#say { position: fixed; left: 50%; transform: translateX(-50%); top: 72px; max-width: 90vw; background: rgba(40, 32, 28, .9); color: #fff; font-size: 19px; font-weight: 600; padding: 12px 20px; border-radius: 14px; z-index: 40; text-align: center; line-height: 1.4; }

#cut { position: fixed; inset: 0; width: 100%; height: 100%; opacity: 0; pointer-events: none; transition: opacity .6s; z-index: 30; }
#cut.on { opacity: 1; pointer-events: auto; }
#cutcap { position: fixed; left: 50%; transform: translateX(-50%); top: max(14px, env(safe-area-inset-top)); max-width: 92vw; text-align: center; font-size: 21px; font-weight: 700; color: #fff; background: rgba(40, 32, 28, .78); border-radius: 999px; opacity: 0; transition: opacity .6s; z-index: 31; pointer-events: none; padding: 10px 22px; }
#cutcap:empty { display: none; }
#cutcap.on { opacity: 1; }

#modal { position: fixed; inset: 0; background: rgba(30, 24, 20, .45); display: flex; align-items: center; justify-content: center; z-index: 20; padding: 16px; }
#modal .box { background: #fffaf0; border-radius: 20px; padding: 20px; width: min(94vw, 440px); max-height: 88vh; overflow: auto; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); text-align: center; }
#modal h2 { margin: 0 0 10px; font-size: 22px; }
#modal .txt { margin: 0 0 14px; font-size: 18px; line-height: 1.6; white-space: pre-line; word-break: keep-all; }
#modal .sub { margin: -4px 0 14px; font-size: 15px; color: #8a7a66; }
#modal .sub:empty, #modal .txt:empty { display: none; }
#modal .opts { display: flex; flex-direction: column; gap: 8px; }
#modal .opts.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); }
#modal .opts button { display: flex; align-items: center; justify-content: center; gap: 8px; font-size: 18px; font-weight: 700; padding: 13px 10px; border-radius: 14px; background: #f4e7c8; min-height: 52px; }
#modal .opts.grid button { flex-direction: column; gap: 4px; padding: 10px 6px; font-size: 16px; }
#modal .opts button:active { background: #e9d5a6; }
#modal .opts .em { font-size: 34px; line-height: 1; }
#modal .opts canvas { width: 56px; height: 56px; }
#modal .close { margin-top: 12px; font-size: 17px; padding: 11px 26px; border-radius: 999px; background: #e6ded0; font-weight: 600; }
#mcanvas { width: 260px; height: 280px; border-radius: 14px; margin: 0 auto 10px; display: block; }
/* 펼친 책 */
#modal.book .box { background: linear-gradient(90deg, #fbf5e6 0, #fbf5e6 48%, #e9dfc6 50%, #fbf5e6 52%, #fbf5e6 100%); border: 8px solid #8a5a34; border-radius: 12px; padding: 26px 22px 18px; }
#modal.book h2 { font-size: 15px; color: #a08a66; letter-spacing: 2px; }
#modal.book .txt { font-size: 21px; line-height: 1.75; font-family: "AppleMyungjo", "Nanum Myeongjo", "Batang", serif; font-weight: 600; margin: 18px 0; }
#modal.book .opts button { background: transparent; border: 2px solid #c9b48a; font-size: 16px; min-height: 44px; padding: 8px; }

#minput { width: 100%; font-size: 19px; padding: 11px 12px; border: 2px solid #d9c9a8; border-radius: 10px; background: #fff; margin: 0 0 12px; user-select: text; -webkit-user-select: text; }
/* 사진첩·방명록 큰 창 */
#panel { position: fixed; inset: 0; background: rgba(30, 24, 20, .5); z-index: 25; display: flex; align-items: center; justify-content: center; padding: 10px; }
#panel .pbox { background: #fffaf0; border-radius: 20px; width: min(100%, 640px); height: min(100%, 860px); display: flex; flex-direction: column; overflow: hidden; box-shadow: 0 10px 30px rgba(0, 0, 0, .35); }
#panel .phead { display: flex; align-items: center; gap: 8px; padding: 14px 16px; border-bottom: 2px solid #eadfc8; }
#panel .phead h2 { flex: 1; margin: 0; font-size: 21px; }
#panel button { font-size: 17px; font-weight: 700; padding: 10px 16px; border-radius: 12px; background: #f1e7d0; }
#panel button.go { background: #5aa37a; color: #fff; }
#panel button.del { background: #f6d9d4; color: #a8322a; }
#panel .pbody { flex: 1; overflow-y: auto; padding: 14px; touch-action: pan-y; -webkit-overflow-scrolling: touch; }
#panel .pfoot { padding: 12px 14px; border-top: 2px solid #eadfc8; display: flex; gap: 8px; }
#panel .pfoot:empty { display: none; }
#panel .pfoot input { flex: 1; min-width: 0; font-size: 18px; padding: 10px 12px; border: 2px solid #d9c9a8; border-radius: 10px; background: #fff; user-select: text; -webkit-user-select: text; }
#panel .empty { text-align: center; color: #8a7a66; font-size: 18px; padding: 40px 10px; line-height: 1.6; }
.grid3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(140px, 1fr)); gap: 10px; }
.grid3 .ph { position: relative; aspect-ratio: 1; border-radius: 12px; overflow: hidden; background: #e9dfc8; padding: 0 !important; border: 4px solid #fff; box-shadow: 0 2px 6px rgba(0, 0, 0, .18); }
.grid3 .ph img { width: 100%; height: 100%; object-fit: cover; display: block; }
.grid3 .ph span { position: absolute; left: 0; right: 0; bottom: 0; background: linear-gradient(transparent, rgba(0, 0, 0, .6)); color: #fff; font-size: 14px; padding: 14px 6px 5px; text-align: left; }
.big img { width: 100%; max-height: 56vh; object-fit: contain; border-radius: 12px; background: #2b2420; display: block; }
.big .cap { font-size: 20px; font-weight: 700; margin: 10px 0 2px; }
.big .meta { color: #8a7a66; font-size: 15px; margin-bottom: 10px; }
.big .row { display: flex; gap: 8px; margin: 10px 0; flex-wrap: wrap; }
.line { background: #f6eedb; border-radius: 12px; padding: 9px 12px; margin: 6px 0; font-size: 17px; line-height: 1.45; display: flex; gap: 8px; align-items: flex-start; }
.line b { color: #7a5230; white-space: nowrap; }
.line .tx { flex: 1; word-break: break-all; }
.line small { color: #a09078; white-space: nowrap; font-size: 13px; padding-top: 3px; }
.line button { padding: 2px 9px !important; font-size: 14px !important; background: #f6d9d4 !important; color: #a8322a; }
#fade { position: fixed; inset: 0; background: #1c1612; opacity: 0; pointer-events: none; transition: opacity .25s; z-index: 50; }
#fade.on { opacity: 1; }

#create { position: fixed; inset: 0; background: linear-gradient(#9fd6f2, #d9f0d2 60%, #f1e0b0); z-index: 60; overflow: auto; display: flex; justify-content: center; align-items: flex-start; padding: 16px; touch-action: pan-y; }
#create .card { background: #fffaf0; border-radius: 22px; padding: 18px 18px 22px; width: min(96vw, 460px); box-shadow: 0 10px 30px rgba(0, 0, 0, .2); text-align: center; margin: auto; }
#create h1 { margin: 2px 0 6px; font-size: 26px; }
#pv { width: 200px; height: 180px; }
#create .name { display: block; font-size: 18px; font-weight: 700; margin: 6px 0 12px; }
#create .name input { font-size: 20px; padding: 9px 12px; border: 2px solid #d9c9a8; border-radius: 10px; width: 190px; margin-left: 8px; background: #fff; user-select: text; -webkit-user-select: text; }
#rows .row { display: flex; align-items: center; gap: 10px; margin: 8px 0; text-align: left; }
#rows .lbl { width: 62px; font-size: 16px; font-weight: 700; flex: none; }
#rows .ch { display: flex; flex-wrap: wrap; gap: 6px; }
#rows .ch button { min-width: 44px; height: 42px; padding: 0 12px; border-radius: 10px; background: #f1e7d0; font-size: 16px; font-weight: 600; border: 3px solid transparent; }
#rows .ch button.sw { width: 42px; min-width: 42px; padding: 0; border-radius: 50%; border: 3px solid #fff; box-shadow: 0 0 0 1px #d9c9a8; }
#rows .ch button.sel { border-color: #e2804a; }
#rows .ch button.sw.sel { box-shadow: 0 0 0 3px #e2804a; }
#enter { margin-top: 14px; width: 100%; font-size: 21px; font-weight: 800; padding: 15px; border-radius: 14px; background: #5aa37a; color: #fff; }
