:root {
  color-scheme: light;
  --paper: #f5f1e7;
  --ink: #322e26;
  --muted: #635f54;
  --line: #d3ccbc;
  --leaf: #4a5843;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
  color: var(--ink);
  background: var(--paper);
  -webkit-font-smoothing: antialiased;
}
* { box-sizing: border-box; }
body { margin: 0; }
button { font: inherit; color: inherit; cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:focus-visible { outline: 3px solid #a45931; outline-offset: 3px; }
button:disabled { opacity: .55; cursor: default; }
.pixel { width: 16px; height: 16px; fill: currentColor; shape-rendering: crispEdges; flex: none; }
.actions .pixel { width: 32px; height: 32px; }
.glint { fill: #946239; }
.actions [aria-pressed="true"] .glint { fill: #f4c686; }
.dpad [data-direction="left"] .pixel { transform: rotate(-90deg); }
.dpad [data-direction="right"] .pixel { transform: rotate(90deg); }
.dpad [data-direction="down"] .pixel { transform: rotate(180deg); }
.room { max-width: 1480px; margin: auto; padding: 0 clamp(16px, 4vw, 64px) 22px; }
.masthead, .controls, .room-tools, .input-tools, .actions, .presence, .invite, .filter {
  display: flex; align-items: center;
}
.masthead { justify-content: space-between; min-height: 84px; gap: 12px; }
h1 { margin: 0; font: 750 clamp(25px, 2.6vw, 38px)/1.15 "Nanum Myeongjo", "AppleMyungjo", "Batang", serif; letter-spacing: -.075em; }
.room-tools { gap: clamp(12px, 2vw, 28px); }
.presence { gap: 7px; font: 600 13px/1 system-ui, sans-serif; color: var(--muted); font-variant-numeric: tabular-nums; }
.invite { gap: 7px; min-height: 42px; padding: 0 16px; border: 0; border-radius: 6px; color: #fffdf6; background: var(--leaf); font-weight: 650; font-size: 14px; }
.invite:hover { background: #384633; }
.stage { position: relative; isolation: isolate; overflow: hidden; border-radius: 8px; background: #e8e0d0; height: clamp(340px, calc(100svh - 185px), 860px); }
#scene { display: block; width: 100%; height: 100%; image-rendering: pixelated; }
.filter { position: absolute; top: 15px; right: 15px; gap: 7px; min-height: 40px; padding: 0 12px; border: 1px solid #c7c0ad; border-radius: 5px; background: #f9f5e9; color: #645e51; font-size: 12px; font-weight: 650; }
.filter[aria-pressed="true"] { border-color: var(--leaf); color: var(--leaf); }
.filter[aria-pressed="false"] svg { opacity: .4; }
.controls { min-height: 95px; justify-content: space-between; gap: 20px; }
.identity { display: block; font-size: 16px; font-weight: 750; letter-spacing: -.045em; }
#status { margin: 5px 0 0; font-size: 13px; line-height: 1.4; color: var(--muted); overflow-wrap: anywhere; }
.input-tools { gap: 22px; }
.keyboard-tip { font-size: 12px; color: var(--muted); }
.keyboard-tip span { color: #8a8475; }
.actions { gap: 6px; }
.actions button, .dpad button { display: flex; align-items: center; justify-content: center; background: transparent; border: 1px solid var(--line); border-radius: 6px; }
.actions button { min-height: 44px; gap: 7px; padding: 0 15px; font-size: 14px; font-weight: 650; white-space: nowrap; }
.actions button:enabled[aria-pressed="false"]:hover, .dpad button:active { background: #ebe7da; }
.actions button[aria-pressed="true"] { color: #fffaf0; border-color: var(--leaf); background: var(--leaf); }
.dpad { display: none; }
@media (pointer: coarse), (max-width: 650px) {
  .keyboard-tip { display: none; }
  .dpad { display: grid; grid-template-columns: repeat(3, 44px); grid-template-rows: repeat(2, 44px); gap: 2px; }
  .dpad button { font: 20px/1 system-ui, sans-serif; user-select: none; -webkit-user-select: none; touch-action: none; }
  .dpad [data-direction="up"] { grid-column: 2; }
  .dpad [data-direction="left"] { grid-column: 1; grid-row: 2; }
  .dpad [data-direction="down"] { grid-column: 2; grid-row: 2; }
  .dpad [data-direction="right"] { grid-column: 3; grid-row: 2; }
}
@media (max-width: 700px) {
  .room { padding: 0 12px max(12px, env(safe-area-inset-bottom)); }
  .masthead { min-height: 66px; }
  .room-tools { gap: 10px; }
  .invite { min-height: 40px; padding: 0 10px; }
  .stage { height: clamp(300px, calc(100svh - 247px), 700px); }
  .filter { top: 9px; right: 9px; }
  .controls { display: grid; gap: 10px; padding: 12px 0 0; }
  .room-state { display: flex; align-items: baseline; gap: 9px; flex-wrap: wrap; }
  .identity { font-size: 14px; }
  #status { margin: 0; font-size: 12px; }
  .input-tools { justify-content: space-between; gap: 6px; }
  .actions { gap: 4px; }
  .actions .pixel { width: 24px; height: 24px; }
  .actions button { min-width: 47px; min-height: 54px; padding: 6px 7px; flex-direction: column; gap: 3px; font-size: 12px; }
}
@media (pointer: coarse) and (min-width: 701px) {
  .controls { min-height: 105px; }
  .stage { height: clamp(220px, calc(100svh - 205px), 850px); }
}
.scene-error { position: absolute; inset: 45% 1rem auto; text-align: center; color: var(--ink); }
