* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: #78c4d6;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", "Noto Sans KR", system-ui, sans-serif;
  color: #4a4036;
  -webkit-user-select: none; user-select: none;
}
#c { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; cursor: pointer; }

.panel {
  background: rgba(255, 250, 240, .9);
  -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  border-radius: 16px;
  box-shadow: 0 4px 18px rgba(40, 60, 80, .16);
}
button {
  font: inherit; color: inherit; border: 0; background: transparent;
  border-radius: 11px; padding: 8px 11px; cursor: pointer; white-space: nowrap;
}
button:hover { background: rgba(120, 100, 70, .12); }
button.on { background: #ffd98a; }
button.primary { background: #f2a65a; color: #fff; }

#hud-left { position: fixed; left: 14px; top: 14px; padding: 10px 14px; }
#vname {
  font: inherit; font-size: 19px; font-weight: 700; color: inherit;
  border: 0; background: transparent; width: 220px; padding: 2px 4px; border-radius: 6px;
  -webkit-user-select: text; user-select: text;
}
#vname:focus { outline: 2px solid #f2c078; background: #fff; }
#clock { font-size: 13px; padding: 2px 4px; color: #7b6d5c; }

#hud-right { position: fixed; right: 14px; top: 14px; display: flex; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.group { display: flex; padding: 5px; gap: 2px; }
#btn-diary { position: relative; }
#badge { position: absolute; right: 3px; top: 3px; width: 9px; height: 9px; border-radius: 50%; background: #e8685c; }

#toolbar {
  position: fixed; left: 50%; bottom: 16px; transform: translateX(-50%);
  display: flex; gap: 2px; padding: 6px; max-width: calc(100vw - 16px); overflow-x: auto;
}
#toolbar[hidden], #visit[hidden], #rec[hidden] { display: none; }
#toolbar button { display: flex; flex-direction: column; align-items: center; gap: 2px; font-size: 11px; min-width: 50px; padding: 6px 5px; flex: none; }
#toolbar i { font-style: normal; font-size: 22px; line-height: 1.1; }

#diary {
  position: fixed; right: 14px; top: 74px; bottom: 100px; width: 320px; max-width: calc(100vw - 28px);
  display: flex; flex-direction: column; overflow: hidden;
}
#diary[hidden], #card[hidden], .modal[hidden] { display: none; }
#diary header { display: flex; justify-content: space-between; align-items: center; padding: 10px 10px 8px 16px; }
#diary-list { overflow-y: auto; padding: 0 14px 14px; font-size: 14px; line-height: 1.55; -webkit-user-select: text; user-select: text; }
#diary-list h4 { margin: 12px 0 6px; font-size: 12px; color: #a08c72; font-weight: 600; }
#diary-list p { margin: 0 0 8px; padding: 8px 10px; background: #fff; border-radius: 10px; }
#diary-list p b { display: block; font-size: 12px; color: #c0793a; }
#diary-list .empty { color: #a08c72; background: transparent; padding: 20px 4px; }

#card { position: fixed; left: 14px; bottom: 16px; width: 250px; padding: 12px 14px; font-size: 13px; line-height: 1.5; }
#card h3 { margin: 0 0 4px; font-size: 16px; }
#card .q { margin-top: 6px; color: #7b6d5c; font-style: italic; }
#card .x { position: absolute; right: 6px; top: 6px; padding: 4px 8px; }

#toasts { position: fixed; left: 50%; bottom: 104px; transform: translateX(-50%); display: flex; flex-direction: column-reverse; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  background: rgba(60, 50, 44, .86); color: #fff; padding: 8px 14px; border-radius: 999px; font-size: 13px;
  animation: pop .3s ease-out; transition: opacity .5s; max-width: 90vw; text-align: center;
}
.toast.out { opacity: 0; }
@keyframes pop { from { transform: translateY(8px); opacity: 0; } }

.modal { position: fixed; z-index: 5; inset: 0; background: rgba(30, 40, 60, .5); display: flex; align-items: center; justify-content: center; padding: 16px; }
.sheet { padding: 14px; max-width: min(900px, 100%); }
#pc { width: 100%; height: auto; display: block; border-radius: 8px; box-shadow: 0 2px 10px rgba(0, 0, 0, .18); }
.row { display: flex; gap: 6px; justify-content: flex-end; flex-wrap: wrap; margin-top: 10px; }

#vid { width: 100%; max-height: 70vh; display: block; border-radius: 8px; background: #000; }
.sheet.small { width: 380px; padding: 18px 20px; }
.sheet.small h3 { margin: 0 0 6px; }
.warn { margin: 0 0 14px; font-size: 13px; color: #a0624a; }
.opt { display: flex; flex-wrap: wrap; gap: 6px 14px; align-items: center; margin-bottom: 12px; font-size: 14px; }
.opt b { width: 100%; font-size: 12px; color: #a08c72; }
.opt label { cursor: pointer; }
#visit { position: fixed; left: 50%; top: 14px; transform: translateX(-50%); padding: 6px 8px 6px 14px; display: flex; gap: 6px; align-items: center; font-size: 13px; max-width: calc(100vw - 28px); flex-wrap: wrap; justify-content: center; z-index: 2; }
#rec { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); background: rgba(60, 50, 44, .9); color: #fff; padding: 12px 20px; border-radius: 999px; font-size: 14px; z-index: 6; }
#rec::before { content: '●'; color: #ff6b5e; margin-right: 8px; }

@media (max-width: 640px) {
  /* 세로로 든 휴대전화: 이름과 시계를 한 줄에, 버튼들을 그 아래 한 줄에 아이콘만으로 놓는다 */
  #hud-left { left: 8px; right: 8px; top: 8px; padding: 6px 10px; display: flex; align-items: baseline; gap: 6px; }
  #vname { flex: 1 1 0; min-width: 0; width: auto; font-size: 15px; }
  #clock { flex: none; font-size: 11px; white-space: nowrap; }
  #hud-right { right: 8px; top: 50px; gap: 6px; flex-wrap: nowrap; }
  .group { padding: 3px; }
  .group button { padding: 6px 9px; }
  .lbl { display: none; }
  #diary { top: 98px; }
  #toolbar button { min-width: 44px; padding: 6px 3px; }
  #visit { top: 98px; }
  #card { bottom: 104px; }
}

/* 가로로 돌린 휴대전화: 도구 모음을 오른쪽 세로 격자로 옮겨서 위아래 공간을 확보한다 */
@media (orientation: landscape) and (max-height: 520px) {
  #hud-left { left: 8px; right: auto; top: 6px; padding: 5px 10px; display: flex; align-items: baseline; gap: 6px; max-width: calc(100vw - 316px); }
  #vname { flex: 0 1 120px; min-width: 60px; width: 120px; font-size: 15px; }
  #clock { flex: 0 1 auto; min-width: 0; font-size: 11px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  #hud-right { right: 8px; top: 6px; gap: 6px; flex-wrap: nowrap; }
  .lbl { display: none; }
  .group { padding: 3px; }
  .group button { padding: 5px 8px; font-size: 13px; }
  #toolbar {
    left: auto; right: 8px; top: 54px; bottom: auto; transform: none;
    display: grid; grid-template-columns: 1fr 1fr; gap: 2px; padding: 4px;
    max-height: calc(100vh - 62px); overflow-y: auto; overflow-x: hidden;
  }
  #toolbar button { min-width: 40px; padding: 5px 4px; font-size: 0; gap: 0; }
  #toolbar i { font-size: 21px; }
  #diary { top: 54px; bottom: 8px; right: 106px; }
  #card { left: 8px; bottom: 8px; }
  #toasts { bottom: 12px; }
  #visit { top: 54px; }
}
