/* Galmuri 픽셀 폰트 (SIL OFL 1.1, © Lee Minseo). 쓰는 것만 woff2로 넣는다. */
@font-face {
  font-family: Galmuri9;
  src: url("./Galmuri9-B9HMP827.woff2") format("woff2");
}

@font-face {
  font-family: Galmuri11;
  font-weight: 400;
  src: url("./Galmuri11-DfQIlyDK.woff2") format("woff2");
}

@font-face {
  font-family: Galmuri11;
  font-weight: 600 700;
  src: url("./Galmuri11-Bold-QdFGsJ3v.woff2") format("woff2");
}

@font-face {
  font-family: Galmuri14;
  src: url("./Galmuri14-BIHuh8Vm.woff2") format("woff2");
}

/* 방 안 이름표·말풍선 (Pixi) */
@font-face {
  font-family: Galmuri7;
  src: url("./Galmuri7-DZrunm1m.woff2") format("woff2");
}
/* 옆자리 화면 스타일. 손바닥만 한 기기(껍데기) 안에 160×160 픽셀 LCD.
   LCD 안은 진짜 160px 좌표로 짜고 zoom: 2로 키운다. 규칙은 docs/GAME_STYLE.md */
:root {
  /* 팔레트 (GAME_STYLE.md 3장) */
  --ink: #2b2620;
  --ink-deep: #3e3228;
  --quiet: #7a7064;
  --paper: #f4efe6;
  --paper-light: #fbf7ef;
  --paper-dark: #d9cfbf;
  --gold: #e0b45c;
  --red: #c0584a;
  --green: #6b9a74;

  /* LCD 안 */
  --lcd: #e9e4d4;
  --line: var(--ink-deep);
  --surface: var(--paper-light);
  --danger: var(--red);
  --bevel: inset -1px -1px 0 rgb(0 0 0 / 0.25), inset 1px 1px 0 rgb(255 255 255 / 0.6);

  font-family: Galmuri9, Galmuri11, sans-serif;
  font-size: 10px;
  -webkit-font-smoothing: none;
  color: var(--ink);
}

html,
body {
  margin: 0;
  height: 100%;
  background: transparent;
  overflow: hidden;
}

button,
input,
select {
  font: inherit;
  color: inherit;
  margin: 0;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
}

h1,
h2,
p {
  margin: 0;
}

/* ── 창 = 화면 하나. 짙은 테두리 + 위쪽 막대(잡고 옮기기) ── */
#device {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  padding: 0 2px 2px;
  background: var(--ink-deep);
  user-select: none;
}

#titlebar {
  display: flex;
  align-items: center;
  height: 16px;
  padding: 0 2px 0 4px;
  -webkit-app-region: drag;
}

#title {
  flex: 1;
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  letter-spacing: 0.2em;
  color: var(--paper-dark);
}

#controls {
  display: flex;
  gap: 2px;
  -webkit-app-region: no-drag;
}

#controls button {
  display: grid;
  place-items: center;
  width: 12px;
  height: 12px;
  padding: 0;
  border: 0;
  background: none;
}

#controls button:hover {
  background: var(--ink);
}

#controls .pixel-icon rect {
  fill: var(--paper-dark);
}

/* LCD: 160×160 픽셀. 은은한 픽셀 격자로 화면 느낌을 낸다 */
#lcd {
  position: relative;
  zoom: 2;
  width: 160px;
  height: 160px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--lcd);
}

#lcd::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
  background:
    repeating-linear-gradient(90deg, rgb(0 0 0 / 0.04) 0 0.5px, transparent 0.5px 1px),
    repeating-linear-gradient(rgb(0 0 0 / 0.04) 0 0.5px, transparent 0.5px 1px);
}

/* ── LCD 안 공통 ── */
.pixel-icon {
  display: block;
  flex-shrink: 0;
}

.screen {
  flex: 1;
  position: relative;
  min-height: 0;
}

h1 {
  font-family: Galmuri11, sans-serif;
  font-size: 12px;
  font-weight: 700;
}

h2 {
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  color: var(--quiet);
}

.quiet {
  color: var(--quiet);
}

.form-error:empty {
  display: none;
}

.form-error {
  color: var(--danger);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
}

/* 키보드로 고른 칸은 반전 */
#lcd button:focus-visible,
#lcd input:focus,
#lcd select:focus {
  outline: 1px solid var(--ink);
  outline-offset: 0;
}

#lcd button:focus-visible:not(.primary) {
  background: var(--ink);
  color: var(--lcd);
}

#lcd button:focus-visible .pixel-icon rect {
  fill: var(--lcd);
}

button.primary {
  padding: 2px 6px;
  border: 1px solid var(--line);
  background: var(--gold);
  color: var(--ink);
  font-weight: 700;
  box-shadow: var(--bevel);
}

button.primary:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: none;
}

button.primary:disabled {
  background: var(--paper-dark);
  color: var(--quiet);
  box-shadow: none;
}

button.primary.danger {
  background: var(--red);
  color: var(--paper-light);
}

button.link {
  padding: 0;
  border: 0;
  background: none;
  color: var(--quiet);
  text-decoration: underline;
}

input {
  box-sizing: border-box;
  height: 14px;
  padding: 0 2px;
  border: 1px solid var(--line);
  background: var(--surface);
}

input::placeholder {
  color: var(--quiet);
}

/* 픽셀 스크롤바 */
::-webkit-scrollbar {
  width: 3px;
}

::-webkit-scrollbar-track {
  background: var(--paper-dark);
}

::-webkit-scrollbar-thumb {
  background: var(--ink-deep);
}

/* ── 시작 화면 ── */
.start-card {
  display: flex;
  flex-direction: column;
  gap: 4px;
  height: 100%;
  box-sizing: border-box;
  padding: 4px;
}

.start-body {
  flex: 1;
  display: flex;
  gap: 4px;
  min-height: 0;
}

.avatar-stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-end;
  gap: 2px;
  width: 52px;
  flex-shrink: 0;
  padding: 2px 0;
  border: 1px solid var(--line);
  background:
    linear-gradient(#cbb994 0 0) top / 100% 30% no-repeat,
    repeating-linear-gradient(#e8dcc8 0 5px, #ddcfb7 5px 6px);
}

.avatar-name {
  max-width: 48px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
}

.start-fields {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.field {
  display: flex;
  align-items: center;
  gap: 2px;
}

.field > span:first-child {
  width: 16px;
  flex-shrink: 0;
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  color: var(--quiet);
}

.field input {
  flex: 1;
  min-width: 0;
}

.swatches {
  display: flex;
  flex-wrap: wrap;
  gap: 1px;
}

.swatch {
  width: 8px;
  height: 8px;
  padding: 0;
  border: 1px solid var(--line);
}

.swatch[aria-checked="true"] {
  outline: 1px solid var(--ink);
  outline-offset: 1px;
}

.start .primary {
  margin-top: auto;
}

.credit {
  color: var(--quiet);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  text-align: right;
}

/* ── 방 선택 ── */
.select {
  display: flex;
  flex-direction: column;
}

/* 서버·방 고르기: 위 상단바 아래 내용 */
.select-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 3px;
  overflow-y: auto;
}

.room-card strong {
  display: inline-flex;
  align-items: center;
  gap: 2px;
}

.select-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.me {
  display: flex;
  align-items: center;
  gap: 2px;
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
}

.me svg {
  background: var(--paper-dark);
}

.select-head h1 {
  order: -1;
  white-space: nowrap;
}

.me > span {
  max-width: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.room-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}

.room-card {
  width: 100%;
  padding: 1px 3px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
}

.room-card-body {
  display: flex;
  justify-content: space-between;
}

.room-card:disabled {
  opacity: 0.5;
}

.room-card:hover:not(:disabled) strong::before,
.room-card:focus strong::before {
  content: "▶";
}

/* ── 방 ── */
.room {
  display: flex;
  flex-direction: column;
}

.icon-row {
  display: flex;
  justify-content: space-around;
  flex-shrink: 0;
  height: 12px;
  background: var(--paper-dark);
  border-block: 1px solid var(--line);
}

.icon-row:first-child {
  border-top: 0;
}

.icon-row:last-child {
  border-bottom: 0;
}

.icon-row button {
  position: relative;
  display: grid;
  place-items: center;
  width: 20px;
  padding: 0;
  border: 0;
  background: none;
}

.icon-row button:disabled {
  opacity: 0.35;
}

.icon-row button[aria-pressed="true"] {
  background: var(--gold);
}

.badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 5px;
  padding: 0 1px;
  background: var(--danger);
  color: var(--paper-light);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  line-height: 7px;
}

.room-body {
  flex: 1;
  position: relative;
  min-height: 0;
}

#stage {
  position: absolute;
  inset: 0;
}

/* 3D 방: 밤하늘 위에 캔버스, 그 위에 이름표 층 */
#stage {
  overflow: hidden;
  /* 이름표 층(z-index)이 메뉴 화면 위로 새지 않게 무대 안에 가둔다 */
  isolation: isolate;
  background:
    radial-gradient(1px 1px at 12% 18%, #fbf7ef 50%, transparent 51%),
    radial-gradient(1px 1px at 78% 12%, #fbf7ef 50%, transparent 51%),
    radial-gradient(1px 1px at 88% 64%, #fbf7ef99 50%, transparent 51%),
    radial-gradient(1px 1px at 22% 80%, #fbf7ef99 50%, transparent 51%),
    radial-gradient(1px 1px at 52% 6%, #fbf7ef 50%, transparent 51%),
    radial-gradient(1px 1px at 6% 52%, #fbf7ef77 50%, transparent 51%),
    radial-gradient(ellipse at 50% 60%, #2d2540, #1a1626 70%);
}

.room-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}

.room-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

/*
 * 이름표: 상자 없이 글자만, 1px 먹선을 두른 글자로 어디서나 읽힌다. 내 이름은 금색.
 * LCD 2배를 반으로 되돌려(zoom 0.5) 실제 8px로 작게 띄운다. 위치를 잡는 .tag3d는 그대로 두고 안쪽만 줄인다.
 */
.tag3d {
  position: absolute;
  left: 0;
  top: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1px;
  white-space: nowrap;
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
}

.tag3d.dropped {
  opacity: 0.5;
}

.plate3d,
.bubble3d {
  zoom: 0.5;
}

.plate3d {
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--paper);
  text-shadow:
    1px 0 var(--ink), -1px 0 var(--ink), 0 1px var(--ink), 0 -1px var(--ink),
    1px 1px var(--ink), -1px 1px var(--ink), 1px -1px var(--ink), -1px -1px var(--ink);
}

.tag3d.me .plate3d {
  color: var(--gold);
}

.dot3d {
  width: 4px;
  height: 4px;
  outline: 1px solid var(--ink);
}

.plate3d svg {
  filter: drop-shadow(1px 0 var(--ink)) drop-shadow(-1px 0 var(--ink)) drop-shadow(0 1px var(--ink)) drop-shadow(0 -1px var(--ink));
}

.bubble3d {
  max-width: 140px;
  padding: 1px 3px;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--ink);
  border: 1px solid var(--ink);
  background: var(--paper-light);
}

/* 마우스를 올린 자리·라디오: 금색 테두리(바깥·안쪽 ink 선) + 위에 이름표. 누가 앉은 자리는 흐린 색. */
.hover3d {
  position: absolute;
  left: 0;
  top: 0;
  box-sizing: border-box;
  border: 1px solid var(--gold);
  outline: 1px solid var(--ink);
  box-shadow: inset 0 0 0 1px var(--ink);
  z-index: 100000;
}
.hover3d.taken { border-color: var(--quiet); }
.hover3d-name {
  position: absolute;
  left: 50%;
  bottom: 100%;
  margin-bottom: 1px;
  transform: translateX(-50%);
  white-space: nowrap;
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
}
.hover3d-name span {
  color: var(--gold);
}
.hover3d.taken .hover3d-name span {
  color: var(--paper-dark);
}

.emote3d {
  position: absolute;
  left: 0;
  top: 0;
}

.avatar-img {
  display: block;
  image-rendering: auto;
}

.picker {
  justify-content: space-between;
}

.picker button {
  padding: 0 3px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--bevel);
}

.hint,
.toast {
  position: absolute;
  left: 50%;
  z-index: 1;
  transform: translateX(-50%);
  padding: 0 3px;
  border: 1px solid var(--line);
  white-space: nowrap;
  pointer-events: none;
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
}

.hint {
  top: 3px;
  padding: 0;
  border: 0;
  background: none;
}
/* 방 위에 뜨는 글(안내·자리 이름표·머리 위 이름표)은 상자 없이 먹선 두른 작은 글자(실제 8px) */
.hint span,
.hover3d-name span {
  display: block;
  zoom: 0.5;
  text-shadow:
    1px 0 var(--ink), -1px 0 var(--ink), 0 1px var(--ink), 0 -1px var(--ink),
    1px 1px var(--ink), -1px 1px var(--ink), 1px -1px var(--ink), -1px -1px var(--ink);
}
.hint span {
  color: var(--paper-light);
}

.toast {
  bottom: 2px;
  max-width: 150px;
  white-space: normal;
  background: var(--ink);
  color: var(--lcd);
}

/* 전광판: LED 글자가 한 칸씩(steps) 흘러간다 */
.marquee {
  flex-shrink: 0;
  height: 10px;
  padding: 0;
  overflow: hidden;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--ink);
  color: var(--gold);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  line-height: 10px;
  text-align: left;
  white-space: nowrap;
}

.marquee span {
  display: inline-block;
  padding-left: 100%;
  animation: marquee 12s steps(240) infinite;
}

.marquee.on,
#lcd .marquee:focus-visible {
  background: var(--ink-deep);
  color: var(--paper-light);
}

@keyframes marquee {
  to {
    transform: translateX(-100%);
  }
}

/* 메뉴를 열면 방 대신 그 화면 */
.menu-panel {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  background: var(--lcd);
}

.menu-list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 3px;
  overflow-y: auto;
}

.menu-list > button {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 1px 3px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
}

.menu-list > button[aria-checked="true"]::after {
  content: "◀";
  margin-left: auto;
}

.dot {
  width: 5px;
  height: 5px;
  flex-shrink: 0;
}

.emotes {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 2px;
}

.emotes button {
  display: grid;
  place-items: center;
  height: 24px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--surface);
}

/* 음악 */
.music {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.music .mute {
  display: flex;
  align-items: center;
  gap: 3px;
  align-self: flex-start;
  padding: 1px 3px;
  border: 1px solid var(--line);
  background: var(--surface);
}

.music select {
  appearance: none;
  padding: 1px 10px 1px 2px;
  border: 1px solid var(--line);
  background: var(--surface)
    url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='5' height='3' shape-rendering='crispEdges'%3E%3Cpath d='M0 0h5v1H0zM1 1h3v1H1zM2 2h1v1H2z' fill='%232b2620'/%3E%3C/svg%3E")
    right 2px center / 5px 3px no-repeat;
}

.music .track {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.music input[type="range"] {
  appearance: none;
  height: 4px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--paper-dark);
}

.music input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 4px;
  height: 8px;
  border: 1px solid var(--line);
  background: var(--gold);
}

/* 채팅 */
.chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.chat-log {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 2px;
  margin: 0;
  padding: 2px 3px;
  overflow-y: auto;
  list-style: none;
}

.chat-empty,
.chat-system {
  color: var(--quiet);
  text-align: center;
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
}

.chat-empty {
  margin: auto 0;
}

.chat-line {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.chat-line.mine {
  align-items: flex-end;
}

.chat-meta {
  display: flex;
  gap: 2px;
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
}

.chat-meta time {
  color: var(--quiet);
}

.chat-text {
  max-width: 100%;
  padding: 0 2px;
  border: 1px solid var(--line);
  background: var(--surface);
  word-break: break-word;
  user-select: text;
}

.chat-line.mine .chat-text {
  background: var(--gold);
}

.chat-input {
  padding: 2px;
  border-top: 1px solid var(--line);
}

.chat-input input {
  width: 100%;
}

/* 사람 목록 */
.people {
  display: flex;
  flex-direction: column;
  min-height: 0;
}

.people header {
  display: flex;
  padding: 2px 3px;
  border-bottom: 1px solid var(--line);
}

.people header strong {
  display: flex;
  align-items: center;
  gap: 3px;
}

.people ul {
  margin: 0;
  padding: 1px;
  overflow-y: auto;
  list-style: none;
}

.people li {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 1px;
}

.people li.dropped {
  opacity: 0.5;
}

.people li svg:first-child {
  background: var(--paper-dark);
}

.person {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.person-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.person-tags {
  display: flex;
  align-items: center;
  gap: 2px;
  color: var(--quiet);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 1px;
}

.people button {
  padding: 0 2px;
  border: 1px solid var(--line);
  background: var(--surface);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  white-space: nowrap;
}

.people button.danger {
  color: var(--danger);
}

/* 연결 안내 · 대화 상자 */
#overlay {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px;
  background: color-mix(in srgb, var(--lcd) 90%, transparent);
  text-align: center;
}

.dialog {
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 4px;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: 2px 2px 0 var(--ink-deep);
}

.dialog-actions {
  display: flex;
  justify-content: center;
  gap: 3px;
}

.dialog-actions button:not(.primary) {
  padding: 2px 6px;
  border: 1px solid var(--line);
  background: var(--surface);
}

/* ASMR */
.asmr {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin-top: 4px;
  padding-top: 3px;
  border-top: 1px dashed var(--line);
}

.asmr-buttons {
  display: flex;
  gap: 2px;
}

.asmr-buttons button {
  flex: 1;
  padding: 1px 0;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--bevel);
}

.asmr-buttons button[aria-pressed="true"] {
  background: var(--gold);
  box-shadow: none;
}

/* 라디오 앞이 아니면 켜진 것만 보이고 누를 수 없다 */
.asmr-buttons button:disabled {
  box-shadow: none;
  color: var(--quiet);
  cursor: default;
}

.asmr input[type="range"] {
  appearance: none;
  height: 4px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--paper-dark);
}

.asmr input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 4px;
  height: 8px;
  border: 1px solid var(--line);
  background: var(--gold);
}

/* 아래 아이콘 줄: 나가기만 오른쪽 끝에 떼어 두고 빨간 바탕 */
.icon-gap {
  flex: 1;
}

.icon-row button.exit {
  border-left: 1px solid var(--line);
  background: color-mix(in srgb, var(--red) 25%, transparent);
}

/* 메뉴 화면 맨 위 "◀ 방으로" */
.back-to-room {
  flex-shrink: 0;
  padding: 1px 3px;
  border: 0;
  border-bottom: 1px solid var(--line);
  background: var(--paper-dark);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  text-align: left;
}

.back-to-room:hover {
  background: var(--gold);
}

/* 음악 메뉴: 지금 곡 + 곡 목록 (라디오 앞에서만) */
.now-playing {
  display: flex;
  align-items: center;
  gap: 3px;
  min-width: 0;
}

.track-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
}

.track-list button {
  padding: 1px 3px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}

.track-list button[aria-checked="true"] {
  background: var(--gold);
}

.track-list button[aria-checked="true"]::before {
  content: "▶ ";
}

.hint-line {
  color: var(--quiet);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
}

/* 웹 버전: 브라우저 가운데에 기기 화면 하나 */
html.web body {
  display: grid;
  place-items: center;
  background: #1a1626;
}

html.web #root {
  display: contents;
}

html.web #device {
  position: relative;
  inset: auto;
  width: 324px;
  height: 342px;
  zoom: var(--ui-scale, 1);
  box-shadow: 0 0 0 1px var(--ink);
}

/* 방 로딩: 3D 모델을 받는 동안 문구가 바뀌며 보인다 */
.room-loading {
  position: absolute;
  inset: 0;
  /* 이름표(깊이 순서로 z-index를 매긴다)보다 위 */
  z-index: 10000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: #1a1626;
  color: #f4efe6;
  font-size: 9px;
}
.room-loading .load-bar { width: 80px; height: 6px; border: 1px solid #f4efe6; overflow: hidden; }
.room-loading .load-bar span { display: block; width: 40%; height: 100%; background: #e0b45c; animation: room-load-slide 1.2s steps(12) infinite; }
.room-loading p { margin: 0; color: #f4efe6; opacity: 1; animation: room-load-in 0.25s steps(3); }
@keyframes room-load-slide { from { transform: translateX(-100%); } to { transform: translateX(250%); } }
@keyframes room-load-in { from { opacity: 0; transform: translateY(3px); } }

/* 미니 플레이어: 창 전체가 작은 막대 하나 (220×44). 큰 화면은 숨기되 지우지 않는다 (방 연결·3D·음악 유지). */
html.mini body { background: transparent; }
html.mini #device {
  position: fixed;
  left: -10000px;
  visibility: hidden;
}
.mini-player {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  box-sizing: border-box;
  background: #2d2540;
  border: 2px solid #2b2620;
  box-shadow: inset 0 0 0 1px #3e3228;
  color: #f4efe6;
  font-family: Galmuri9, Galmuri11, sans-serif;
  /* 막대를 잡고 옮길 수 있게 (버튼은 제외) */
  -webkit-app-region: drag;
  user-select: none;
}
/* 방 아이콘 (카페면 커피잔). 막대를 옮길 때는 여기를 잡는다. */
.mini-room-icon {
  position: relative;
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  box-sizing: border-box;
  border: 2px solid #e0b45c;
  background: #3a3052;
  cursor: grab;
}
.mini-room-icon .badge { top: -2px; right: -2px; }
/* 글자 쪽은 끌기 영역에서 뺀다: 끌기 영역에서는 휠·클릭이 오지 않는다. */
.mini-text { flex: 1; min-width: 0; line-height: 1.2; -webkit-app-region: no-drag; cursor: default; }
.mini-title { display: block; overflow: hidden; white-space: nowrap; font-size: 10px; color: #e0b45c; }
.mini-scroll { display: inline-block; padding-left: 100%; animation: mini-scroll 12s linear infinite; }
.mini-room { display: block; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-family: Galmuri7, sans-serif; font-size: 8px; color: #d9cfbf; }
.mini-room b { font-weight: normal; }
.mini-player button {
  -webkit-app-region: no-drag;
  flex: none;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 1px solid #2b2620;
  background: #f4efe6;
  cursor: pointer;
}
.mini-player button:active { background: #d9cfbf; }
.mini-player button:disabled { cursor: default; opacity: 0.5; }
/* 채팅 알림: 글자 자리에 닉네임과 내용. 누르면 큰 창의 채팅으로. */
.mini-player .mini-chat {
  display: block;
  /* 버튼 공통(flex: none; 20px)을 덮어 글자 자리를 채운다. 안 그러면 긴 채팅이 막대 밖으로 버튼을 밀어낸다 */
  flex: 1;
  min-width: 0;
  overflow: hidden;
  width: auto;
  height: 30px;
  padding: 1px 3px;
  text-align: left;
  font: inherit;
  color: inherit;
  background: #3a3052;
  border: 1px solid #e0b45c;
  animation: mini-blink 0.6s steps(1) 3;
}
.mini-player .mini-chat:active { background: #2d2540; }
.mini-chat .pixel-icon { vertical-align: -1px; }
.mini-chat .pixel-icon rect[fill="#fbf7ef"] { fill: #e0b45c; }
@keyframes mini-blink { 50% { border-color: #2d2540; } }
.mini-dot { width: 8px; height: 8px; border: 1px solid #2b2620; background: #a39a8c; }
/* 불투명도: 키가 커지는 막대 4칸. 누른 칸까지 불이 들어오고 곧바로 그 밝기가 된다. */
.mini-gauge { flex: none; display: flex; align-items: flex-end; height: 20px; -webkit-app-region: no-drag; }
.mini-player .mini-gauge button {
  width: 5px;
  height: 20px;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  border: 0;
  background: transparent;
}
.mini-gauge span { display: block; width: 3px; background: #7a7064; }
.mini-gauge button:nth-child(1) span { height: 5px; }
.mini-gauge button:nth-child(2) span { height: 9px; }
.mini-gauge button:nth-child(3) span { height: 13px; }
.mini-gauge button:nth-child(4) span { height: 17px; }
.mini-gauge button.on span { background: #e0b45c; }
.mini-gauge button:hover span { background: #f4efe6; }
@keyframes mini-scroll { to { transform: translateX(-100%); } }

/* ── 영화관 ── */
/* 영화관 겹 순서: 밤하늘(.room-body) → 벽 스크린 플레이어(.cinema-slot) → 3D 방(#stage, 스크린 칸이 뚫려 있음) → 메뉴.
   크게 보기(.full)면 플레이어가 방 위로 올라와 덮는다. */
.room-body.cinema-room {
  background: radial-gradient(ellipse at 50% 60%, #2d2540, #1a1626 70%);
}
.cinema-room #stage {
  z-index: 1;
  background: none;
}
.cinema-slot {
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.cinema-slot.full {
  z-index: 3;
  pointer-events: auto;
}

.cinema {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  background: #1a1626;
  color: var(--paper-light);
}
.cinema-player {
  position: relative;
  flex: 1;
  min-height: 0;
  background: #000;
}
.cinema-frame,
.cinema-frame iframe {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  border: 0;
}
/* 벽 스크린: 178×100 상자를 스크린 귀퉁이에 맞춰 기울인다 (transform은 CinemaScreen이 넣는다) */
.cinema.wall {
  background: none;
}
.cinema.wall .cinema-player {
  position: absolute;
  left: 0;
  top: 0;
  flex: none;
  width: 178px;
  height: 100px;
  transform-origin: 0 0;
}
/* LCD 안은 zoom: 2라서 유튜브가 160px짜리 작은 플레이어로 안다. 반으로 되돌려 실제 크기(320×220쯤)로 보게 한다. */
.cinema.lcd .cinema-frame {
  zoom: 0.5;
}
/* 안내는 얼굴·자막을 가리지 않게 화면 아래쪽에 */
.cinema-note {
  position: absolute;
  left: 50%;
  bottom: 6px;
  z-index: 1;
  margin: 0;
  transform: translateX(-50%);
  max-width: 90%;
  padding: 2px 4px;
  border: 1px solid var(--ink-deep);
  background: #2d2540;
  color: var(--paper-light);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  text-align: center;
}
button.cinema-note.primary {
  background: var(--gold);
  color: var(--ink);
}

/* 조작 줄: 밤색 바탕에 픽셀 버튼 */
.cinema-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 2px;
  height: 11px;
  padding: 0 2px;
  border-top: 1px solid var(--ink-deep);
  background: #2d2540;
}
.cinema-bar button {
  display: grid;
  place-items: center;
  width: 10px;
  height: 9px;
  padding: 0;
  border: 0;
  background: var(--paper-dark);
  box-shadow: var(--bevel);
}
.cinema-bar button:hover:not(:disabled) {
  background: var(--paper-light);
}
.cinema-bar button:active:not(:disabled) {
  transform: translateY(1px);
  box-shadow: none;
}
.cinema-bar button:disabled {
  opacity: 0.4;
}
.cinema-bar button:last-child {
  margin-left: auto;
}
.cinema-time {
  margin-left: 2px;
  color: var(--gold);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  white-space: nowrap;
}

/* 영사기 메뉴 */
.cinema-menu .now-video {
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.video-form {
  display: flex;
  gap: 2px;
}
.video-form input {
  flex: 1;
  min-width: 0;
}
.cinema-menu .danger-line {
  align-self: flex-start;
  padding: 1px 3px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--danger);
}
.cinema-menu input[type="range"] {
  appearance: none;
  height: 4px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--paper-dark);
}
.cinema-menu input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 4px;
  height: 8px;
  border: 1px solid var(--line);
  background: var(--gold);
}
.cinema-away {
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: #1a1626;
  color: var(--paper-light);
}
.cinema-away p {
  margin: 0;
}

/* 큰 창(팝업): 창 전체가 스크린. LCD가 아니므로 글자·버튼을 2배 크기로 그린다. */
html.cinema-window,
html.cinema-window body,
html.cinema-window #root {
  height: 100%;
  background: #1a1626;
}
.cinema-popup {
  display: flex;
  flex-direction: column;
  height: 100%;
}
.cinema-popup-title {
  flex-shrink: 0;
  display: flex;
  gap: 12px;
  height: 22px;
  padding: 0 8px;
  border-bottom: 2px solid var(--ink-deep);
  background: var(--ink);
  color: var(--gold);
  font-family: Galmuri11, sans-serif;
  font-size: 11px;
  line-height: 22px;
  white-space: nowrap;
}
.cinema-popup-name {
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--paper-light);
}
.cinema-popup .cinema {
  flex: 1;
  min-height: 0;
}
.cinema.popup .cinema-bar {
  height: 28px;
  gap: 4px;
  padding: 0 6px;
  border-top-width: 2px;
}
.cinema.popup .cinema-bar button {
  width: 24px;
  height: 22px;
}
.cinema.popup .cinema-time,
.cinema.popup .cinema-note {
  font-family: Galmuri11, sans-serif;
  font-size: 11px;
}
.cinema.popup .cinema-note {
  padding: 6px 10px;
  border-width: 2px;
}
.cinema-popup-lost {
  margin: auto;
  padding: 0 16px;
  color: var(--paper-light);
  font-family: Galmuri11, sans-serif;
  font-size: 11px;
  text-align: center;
}

.cinema-bar[hidden] {
  display: none;
}

/* ── 스마트폰처럼: 위 상단바(뒤로 · 전광판 · 설정), 아래 탭바(아이콘 + 작은 이름) ── */
.app-bar {
  flex-shrink: 0;
  display: flex;
  align-items: stretch;
  height: 12px;
  background: var(--ink);
  border-bottom: 1px solid var(--line);
}
.app-bar .marquee {
  flex: 1;
  min-width: 0;
  height: 12px;
  line-height: 12px;
  border-bottom: 0;
}
.bar-button {
  flex-shrink: 0;
  display: grid;
  place-items: center;
  width: 14px;
  padding: 0;
  border: 0;
  background: none;
}
button.bar-button:hover {
  background: var(--ink-deep);
}
.bar-button .pixel-icon rect {
  fill: var(--paper-dark);
}
.bar-title {
  flex: 1;
  margin: 0;
  color: var(--paper-light);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  line-height: 12px;
  text-align: center;
}

.tab-bar {
  flex-shrink: 0;
  display: flex;
  height: 17px;
  background: var(--paper-dark);
  border-top: 1px solid var(--line);
}
.tab-bar button {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 0;
  border: 0;
  background: none;
}
.tab-bar button + button {
  border-left: 1px solid color-mix(in srgb, var(--line) 25%, transparent);
}
.tab-bar button:hover:not(:disabled) {
  background: var(--paper);
}
.tab-bar button[aria-pressed="true"],
.tab-bar button[aria-pressed="true"]:hover {
  background: var(--gold);
}
.tab-bar button:disabled {
  opacity: 0.35;
}
/* 탭 이름: LCD 2배를 반으로 되돌려 실제 8px */
.tab-label {
  zoom: 0.5;
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  line-height: 8px;
  white-space: nowrap;
}
.tab-bar .badge {
  top: 1px;
  right: calc(50% - 9px);
}

/* 나: 상태 두 줄 + 한 줄 메시지 */
.status-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 2px;
}
.status-grid button {
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 1px 2px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
}
.status-grid button[aria-checked="true"] {
  background: var(--gold);
}
.message-form {
  display: flex;
  gap: 2px;
}
.message-form input {
  flex: 1;
  min-width: 0;
}

/* 설정: 방·방 고르기 위를 덮는다 (확인 창 #overlay는 그 위) */
.settings {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: flex;
  flex-direction: column;
  background: var(--lcd);
}
.settings-list {
  flex: 1;
  min-height: 0;
}
.setting-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  padding: 1px 3px;
  border: 1px solid var(--line);
  background: var(--surface);
  text-align: left;
}
button.setting-row:hover {
  background: var(--paper);
}
.setting-row .switch {
  flex-shrink: 0;
  padding: 0 2px;
  border: 1px solid var(--line);
  background: var(--paper-dark);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
}
.setting-row[aria-checked="true"] .switch,
.setting-row button.switch[aria-checked="true"] {
  background: var(--gold);
}
.setting-row button.switch {
  line-height: 10px;
  color: inherit;
}
.setting-row input[type="range"] {
  flex: 1;
  min-width: 0;
}
.setting-row input[type="range"] {
  appearance: none;
  width: 60px;
  height: 4px;
  padding: 0;
  border: 1px solid var(--line);
  background: var(--paper-dark);
}
.setting-row input[type="range"]::-webkit-slider-thumb {
  appearance: none;
  width: 4px;
  height: 8px;
  border: 1px solid var(--line);
  background: var(--gold);
}
.settings .version {
  margin-top: auto;
}
.menu-list > button.setting-row::after {
  content: none;
}
/* 설정은 한 화면에 들어가게 줄 간격을 좁히고, 아래 정보 줄은 실제 8px로 */
.settings-list {
  gap: 1px;
  padding: 2px 3px;
}
.settings-list h2 {
  margin: 1px 0 0;
  line-height: 9px;
}
.settings-list .setting-row {
  line-height: 10px;
}
.settings-list .hint-line {
  zoom: 0.5;
  text-align: center;
}
.setting-pair {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
}
.setting-pair .setting-row {
  min-width: 0;
  justify-content: center;
  white-space: nowrap;
}
