/* 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: #5c4b3b;
  --ink-deep: #8f7b62;
  --quiet: #a8987f;
  --paper: #fbf6ec;
  --paper-light: #fffdf8;
  --paper-dark: #f1e8d7;
  --gold: #ffd866;
  --red: #f08a7e;
  --green: #7fcfb4;
  --mint: #6cc9a8;
  --frame: #efe4cf;

  /* LCD 안 */
  --lcd: #f8f2e6;
  /* 선은 거의 안 보이게: 칸은 색 차이와 둥근 모서리로 나눈다 */
  --line: #e9dcc5;
  --surface: var(--paper-light);
  --danger: var(--red);
  --bevel: 0 1px 0 rgb(170 145 110 / 0.35);

  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.02) 0 0.5px, transparent 0.5px 1px),
    repeating-linear-gradient(rgb(0 0 0 / 0.02) 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-body.list-only {
  overflow: hidden;
}
.select-body.list-only > * {
  flex-shrink: 0;
}
.select-body.list-only > .room-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  /* 마지막 칸 아래 그림자가 잘리지 않게 */
  padding-bottom: 1px;
}

.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 방: 맑은 하늘 위에 캔버스, 그 위에 이름표 층. 어두운 방(클럽·영화관)은 밤하늘(.night). */
#stage {
  overflow: hidden;
  /* 이름표 층(z-index)이 메뉴 화면 위로 새지 않게 무대 안에 가둔다 */
  isolation: isolate;
  background:
    radial-gradient(18px 6px at 20% 22%, #ffffffcc 60%, transparent 62%),
    radial-gradient(12px 5px at 26% 19%, #ffffffcc 60%, transparent 62%),
    radial-gradient(22px 7px at 78% 14%, #ffffffb3 60%, transparent 62%),
    radial-gradient(14px 5px at 84% 11%, #ffffffb3 60%, transparent 62%),
    linear-gradient(#a9d8f0, #d8eff9 55%, #f1f9fc);
}
#stage.night {
  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 단추와 같은 모양) */
.music-modes {
  display: flex;
  gap: 2px;
}
.music-modes button {
  flex: 1;
  padding: 1px 0;
  border: 1px solid var(--line);
  background: var(--surface);
  box-shadow: var(--bevel);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  white-space: nowrap;
}
.music-modes button[aria-checked="true"] {
  background: var(--gold);
  box-shadow: none;
}
.music-modes button:disabled {
  box-shadow: none;
  color: var(--quiet);
  cursor: default;
}
.music-modes button[aria-checked="true"]:disabled {
  color: var(--ink);
}

/* 라디오 앞이 아니면 켜진 것만 보이고 누를 수 없다 */
.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;
}

/* 웹 버전: 브라우저 가운데에 기기 화면 하나 */
/* 웹: 휴대폰처럼 위에 붙여 세로를 꽉 채운다. 키보드가 올라오면 보이는 영역(--web-top부터 --web-h)에 맞춘다 */
html.web body {
  display: grid;
  place-items: start center;
  background: #e8f1f6;
}

html.web #root {
  display: contents;
}

html.web #device {
  position: relative;
  inset: auto;
  /* 테두리 안쪽 여백까지 324 안에 넣어야 휴대폰 너비에 꼭 맞는다 */
  box-sizing: border-box;
  width: 324px;
  height: var(--web-h, 342px);
  margin-top: var(--web-top, 0px);
  zoom: var(--ui-scale, 1);
  box-shadow: 0 6px 24px rgb(120 100 70 / 0.18);
  /* 길게 눌러 글자가 선택되거나 저장 메뉴가 뜨지 않게, 두 번 눌러 확대되지 않게 */
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
/* 입력칸과 채팅 글은 그대로 (글자를 치고, 채팅은 길게 눌러 복사) */
html.web #device :is(input, textarea, .chat-text) {
  -webkit-user-select: text;
  user-select: text;
  -webkit-touch-callout: default;
}
/* LCD는 위 막대(16)와 아래 여백(3)을 뺀 높이를 꽉 채운다 (LCD는 2배라 반으로) */
html.web #lcd {
  height: calc((var(--web-h, 342px) - 19px) / 2);
}
/* 키보드가 올라오고 내려갈 때만 높이를 부드럽게 (뚝뚝 끊기지 않게). 위치(margin-top)는 아이폰이 페이지를 미는 대로 바로 따라간다 */
html.web.kb-anim #device,
html.web.kb-anim #lcd {
  transition: height 0.22s ease-out;
}

/* 방 로딩: 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: #e8f1f6;
  color: var(--ink);
  font-size: 9px;
}
.room-loading .load-bar { width: 80px; height: 6px; border: 1px solid var(--ink); 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: var(--ink); 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;
}
/*
 * 유튜브 화면 자체는 누를 수 없게: 영상 눌러 멈추기, 제목·채널·공유·로고 링크, 다시 보기, 끝 화면 추천을 막는다.
 * 재생·멈춤·탐색은 아래 막대(영사기 앞 사람)로만 한다.
 */
.cinema-frame iframe {
  pointer-events: none;
}
/* 상영이 끝나면 내리는 막 (붉은 극장 커튼) */
.cinema-curtain {
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(90deg, #7a2430 0 6px, #8e2c39 6px 12px),
    #7a2430;
}
/* 벽 스크린: 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-bar button.cinema-cc {
  width: auto;
  padding: 0 2px;
  font-family: Galmuri7, sans-serif;
  font-size: 7px;
  color: var(--ink);
}
.cinema-bar button.cinema-cc.on {
  background: var(--gold);
}
/* 탐색 막대: 지난 부분은 금색 */
.cinema-seek {
  flex: 1;
  min-width: 20px;
  height: 3px;
  margin: 0 2px;
  padding: 0;
  border: 0;
  border-radius: 2px;
  appearance: none;
  -webkit-appearance: none;
  background: linear-gradient(to right, var(--gold) var(--seek, 0%), #5a4f73 var(--seek, 0%));
  cursor: pointer;
}
.cinema-seek:disabled {
  cursor: default;
}
.cinema-seek::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--paper-light);
  box-shadow: 0 0 0 1px var(--gold);
}
.cinema-seek:disabled::-webkit-slider-thumb {
  visibility: hidden;
}
.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배 크기로 그린다. */
/* ── 해변 서핑 ── */
/* 서핑 전광판: 위 상단바 바로 아래 LED 줄 (먹색 바탕에 금색 글자). 왼쪽은 누가 타는지, 오른쪽은 점수. 누르면 순위 */
.surf-marquee {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 4px;
  height: 10px;
  padding: 0 3px;
  border: 0;
  border-radius: 0;
  background: var(--ink);
  color: var(--quiet);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  line-height: 10px;
  white-space: nowrap;
}
#lcd .surf-marquee {
  border-radius: 0;
}
.surf-marquee.live {
  color: var(--gold);
}
.surf-marquee.on,
.surf-marquee:hover:not(:disabled) {
  background: var(--ink-deep);
  color: var(--paper-light);
}
.surf-marquee-who {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}
.surf-marquee-score {
  flex-shrink: 0;
}
/* 타는 중이면 점이 깜빡인다 (LED) */
.surf-marquee.live .surf-marquee-who::before {
  content: "";
  display: inline-block;
  width: 3px;
  height: 3px;
  margin-right: 2px;
  vertical-align: 1px;
  background: var(--red);
  animation: surf-blink 1s steps(1) infinite;
}
@keyframes surf-blink {
  50% {
    visibility: hidden;
  }
}

/* 서핑 순위: 1~10위 한 줄씩. 1위는 금색 번호, 내 기록은 노란 칸 */
.surf-ranks ol {
  display: flex;
  flex-direction: column;
  gap: 1px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.surf-ranks li {
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 0 3px;
  border-radius: 4px;
  background: var(--paper-light);
  box-shadow: var(--bevel);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  line-height: 10px;
}
.surf-ranks li.mine {
  background: #fff6d6;
}
.surf-ranks .rank-no {
  width: 10px;
  color: var(--quiet);
  text-align: right;
}
.surf-ranks li:first-child .rank-no {
  color: var(--ink);
  background: var(--gold);
  border-radius: 2px;
  text-align: center;
}
.surf-ranks .rank-name {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* 관전 중: 화면 아래쪽에 작게 (실제 8px) */
.surf-watching {
  position: absolute;
  left: 50%;
  bottom: 8px;
  margin: 0;
  transform: translateX(-50%);
  zoom: 0.5;
  padding: 0 4px;
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper-light);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  line-height: 11px;
  pointer-events: none;
}
.surf-stage.watch {
  cursor: default;
}


/* 서핑 화면은 방 위를 덮는다 (영화관 크게 보기처럼). 캔버스는 LCD 픽셀 그대로 그리고 키운다 */
.surf-slot {
  position: absolute;
  inset: 0;
  z-index: 3;
}
.surf {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: #a9d8f0;
  /* 화면 전체가 누르기 버튼: 휴대폰에서 끌어도 화면이 움직이거나 글자가 잡히지 않게 */
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;
}
.surf-stage {
  position: absolute;
  inset: 0;
  cursor: pointer;
}
.surf-canvas {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: pixelated;
}
.surf-hud {
  position: absolute;
  top: 2px;
  left: 2px;
  right: 2px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  pointer-events: none;
}
.surf-score {
  padding: 0 3px;
  border-radius: 4px;
  background: var(--paper-light);
  box-shadow: var(--bevel);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  line-height: 10px;
}
.surf-close {
  display: grid;
  place-items: center;
  width: 12px;
  height: 11px;
  padding: 0;
  border: 0;
  background: var(--paper-light);
  box-shadow: var(--bevel);
  pointer-events: auto;
}
.surf-close:active {
  transform: translateY(1px);
  box-shadow: none;
}
/* +150 한 바퀴!: 먹선 두른 금색 글자 */
.surf-pop {
  position: absolute;
  top: 14px;
  left: 50%;
  margin: 0;
  transform: translateX(-50%);
  color: var(--gold);
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  white-space: nowrap;
  pointer-events: none;
  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);
}
/* 시작·끝 안내판: 크림 판 + 딱 떨어지는 그림자 */
.surf-card {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
  width: 136px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  padding: 4px;
  border-radius: 4px;
  background: var(--paper-light);
  box-shadow: 2px 2px 0 var(--ink-deep);
  text-align: center;
}
.surf-card h2 {
  margin: 0 0 1px;
  color: var(--ink);
  font-family: Galmuri11, sans-serif;
  font-size: 11px;
}
.surf-card p {
  margin: 0;
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
  line-height: 9px;
}
.surf-card .surf-result {
  color: var(--ink);
  font-family: Galmuri11, sans-serif;
  font-size: 11px;
  line-height: 13px;
}
.surf-actions {
  display: flex;
  justify-content: center;
  gap: 3px;
  margin-top: 3px;
}
.surf-actions button {
  padding: 2px 5px;
  white-space: nowrap;
}
.surf-actions button:not(.primary) {
  border: 0;
  background: var(--paper-dark);
  box-shadow: var(--bevel);
}

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;
}


/* ══ 동물의 숲 느낌 (덮어쓰기): 짙은 테두리 대신 크림 바탕·둥근 칸·부드러운 그림자 ══ */
#device {
  background: var(--frame);
  border-radius: 14px;
  padding: 0 3px 3px;
}
#title {
  color: var(--ink-deep);
}
#controls .pixel-icon rect {
  fill: var(--ink-deep);
}
#controls button {
  border-radius: 6px;
}
#controls button:hover {
  background: var(--paper-dark);
}
#lcd {
  border-radius: 6px;
}
#lcd::after {
  display: none;
}
/* 모든 칸·버튼·입력은 둥글게 (LCD는 2배로 보이므로 4px = 화면에서 8px) */
#lcd button,
#lcd input,
#lcd select,
#lcd textarea,
.dialog {
  border-radius: 4px;
}
#lcd button:focus-visible:not(.primary) {
  background: var(--paper-dark);
  color: var(--ink);
}
#lcd button:focus-visible .pixel-icon rect {
  fill: var(--ink);
}
#lcd button:focus-visible,
#lcd input:focus,
#lcd select:focus {
  outline: 1px solid var(--mint);
}
button.primary {
  border: 0;
  border-radius: 999px;
  background: var(--mint);
  color: #fff;
  box-shadow: 0 1px 0 #4fa98a;
}
button.primary:disabled {
  background: var(--paper-dark);
  color: var(--quiet);
}
button.primary.danger {
  background: var(--red);
  color: #fff;
  box-shadow: 0 1px 0 #c9645a;
}
input {
  border-color: var(--line);
  background: #fff;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--paper-dark);
  border-radius: 3px;
}
/* 위 상단바·전광판: 짙은 막대 대신 크림 */
.app-bar,
.marquee {
  background: var(--frame);
  color: var(--ink);
}
.app-bar {
  border-bottom: 0;
}
.bar-title {
  color: var(--ink);
}
.bar-button .pixel-icon rect {
  fill: var(--ink-deep);
}
button.bar-button:hover {
  background: var(--paper-dark);
}
#lcd .marquee:focus-visible {
  background: var(--paper-dark);
  color: var(--ink);
}
.toast {
  border-radius: 4px;
  background: var(--ink);
  color: var(--paper-light);
}
/* 목록 칸: 선 없이 흰 칸 + 아래쪽 그림자 */
.room-list {
  gap: 2px;
}
.room-card {
  border: 0;
  padding: 2px 4px;
  box-shadow: var(--bevel);
}
.room-card:hover:not(:disabled) {
  background: #fff6d6;
}

/* 채팅 말풍선: 말한 사람 머리 위. 흰 둥근 칸 + 아래 꼬리 (실제 8px 글자) */
.say3d {
  position: absolute;
  left: 0;
  top: 0;
  pointer-events: none;
  font-family: Galmuri7, sans-serif;
  font-size: 8px;
}
.say3d span {
  position: relative;
  display: block;
  zoom: 0.5;
  max-width: 120px;
  width: max-content;
  padding: 2px 5px;
  border-radius: 6px;
  background: #fffdf8;
  color: var(--ink);
  line-height: 1.3;
  white-space: pre-wrap;
  word-break: break-all;
  box-shadow: 0 1px 0 rgb(120 100 70 / 0.35);
}
.say3d span::after {
  content: "";
  position: absolute;
  left: 50%;
  bottom: -3px;
  margin-left: -3px;
  border: 3px solid transparent;
  border-bottom: 0;
  border-top-color: #fffdf8;
}

/* 채팅 입력 막대: 방 아래쪽(탭바 바로 위)에 떠 있다 (방은 그대로 보인다) */
.chat-bar {
  position: absolute;
  bottom: 3px;
  left: 3px;
  right: 3px;
  /* 방(#stage)보다 위, 설정 화면(.settings, 4)보다 아래 */
  z-index: 3;
  display: flex;
  gap: 2px;
  padding: 2px;
  border-radius: 6px;
  background: rgb(255 253 248 / 0.92);
  box-shadow: var(--bevel);
}
.chat-bar input {
  flex: 1;
  min-width: 0;
  height: 13px;
}
.chat-bar button {
  flex: none;
  padding: 0 6px;
  font-size: 8px;
}

/* 대화 상자(서버 암호 등)는 화면 너비를 넘지 않는다. 입력 칸은 상자 너비에 맞춘다 */
.dialog {
  box-sizing: border-box;
  max-width: 100%;
  min-width: 0;
}
.dialog input {
  width: 100%;
  min-width: 0;
}

/* 강퇴 투표 막대: 방 위쪽 (채팅 입력 막대가 열리면 그 아래) */
.kick-bar {
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 3px;
  padding: 2px 3px;
  border-radius: 6px;
  background: #fff3c4;
  box-shadow: var(--bevel);
  font-size: 8px;
}

.kick-bar p {
  flex: 1;
  min-width: 0;
  margin: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  line-height: 1.2;
}
/* 둘째 줄: 찬성 수와 남은 초 */
.kick-count {
  display: block;
  font-family: Galmuri7, sans-serif;
  color: var(--quiet);
}
.kick-actions {
  display: flex;
  gap: 2px;
}
.kick-actions button {
  padding: 0 4px;
  font-size: 8px;
}
.people .kick-button {
  margin-left: auto;
  padding: 0 4px;
  font-size: 8px;
  color: var(--danger);
}

/*
 * 영화관 미니 창 (356×220): 위 200은 영상, 아래 20은 미니 플레이어 막대.
 * 영상 플레이어는 옮기면 다시 받아서, 숨겨 둔 큰 화면을 그대로 보이게 하고 영상만 남기도록 나머지를 감춘다.
 * LCD(160 기준)를 1.25배로 키워 높이 200에 맞춘다.
 */
html.mini-cinema #device {
  position: fixed;
  left: 0;
  top: 0;
  width: 356px;
  height: 200px;
  padding: 0;
  border-radius: 0;
  visibility: visible;
  background: #1a1626;
}
html.mini-cinema #titlebar,
html.mini-cinema .app-bar,
html.mini-cinema .tab-bar,
html.mini-cinema #stage,
html.mini-cinema .chat-bar,
html.mini-cinema .kick-bar,
html.mini-cinema .menu-panel,
html.mini-cinema .cinema-bar {
  display: none !important;
}
html.mini-cinema #lcd {
  zoom: 1.25;
  width: 284.8px;
  height: 160px;
  border-radius: 0;
}
html.mini-cinema .room-body {
  flex: 1;
}
html.mini-cinema .cinema-slot {
  z-index: 3;
  pointer-events: auto;
}
html.mini-cinema .mini-player {
  top: auto;
  height: 20px;
  border-width: 0;
  padding: 0 3px;
  gap: 3px;
}
html.mini-cinema .mini-player .mini-room-icon,
html.mini-cinema .mini-player .mini-room,
html.mini-cinema .mini-player .mini-dot {
  display: none;
}

/* 채팅 입력 막대 왼쪽: 대화 내역 버튼 */
.chat-bar .chat-history-toggle {
  display: grid;
  place-items: center;
  width: 14px;
  padding: 0;
  background: none;
  border: 0;
}
.chat-bar .chat-history-toggle.on {
  background: var(--gold);
}

/* 대화 내역 (카톡처럼): 방 위부터 아래 입력 막대 바로 위까지 덮는다 */
.chat-history {
  position: absolute;
  top: 3px;
  left: 3px;
  right: 3px;
  bottom: 22px;
  z-index: 3;
  margin: 0;
  padding: 4px;
  list-style: none;
  overflow-y: auto;
  border-radius: 6px;
  background: #e8f1f6;
  box-shadow: var(--bevel);
  display: flex;
  flex-direction: column;
  gap: 3px;
  font-size: 8px;
}
.chat-history .chat-system {
  align-self: center;
  padding: 0 4px;
  border-radius: 4px;
  background: rgb(0 0 0 / 0.08);
  color: var(--quiet);
  font-family: Galmuri7, sans-serif;
}
.chat-row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  max-width: 85%;
}
.chat-row.mine {
  align-self: flex-end;
  align-items: flex-end;
}
.chat-name {
  margin: 0 0 1px 2px;
  font-family: Galmuri7, sans-serif;
  color: var(--ink-deep);
}
.chat-say {
  display: flex;
  align-items: flex-end;
  gap: 2px;
}
.chat-row.mine .chat-say {
  flex-direction: row-reverse;
}
.chat-bubble {
  padding: 2px 4px;
  border-radius: 5px;
  background: #fffdf8;
  color: var(--ink);
  white-space: pre-wrap;
  word-break: break-all;
  line-height: 1.3;
}
.chat-row.mine .chat-bubble {
  background: var(--gold);
}
.chat-say time {
  flex: none;
  font-family: Galmuri7, sans-serif;
  font-size: 7px;
  color: var(--quiet);
}
/* 카톡처럼 대화가 적으면 입력 막대 쪽(아래)부터 쌓인다 */
.chat-history > :first-child {
  margin-top: auto;
}
