@font-face {
  font-family: "Gowun Batang";
  src: url("./assets/fonts/GowunBatang-Regular.woff2") format("woff2");
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: "Gowun Batang";
  src: url("./assets/fonts/GowunBatang-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}
@font-face {
  font-family: "Gaegu";
  src: url("./assets/fonts/Gaegu-Bold.woff2") format("woff2");
  font-weight: 700;
  font-display: swap;
}

:root {
  color-scheme: dark;
  --paper: #fff0d7;
  --quiet: #d7c8a9;
  --ground: #30312b;
  --edge: #746a56;
  --active: #784d39;
  font-family: "Apple SD Gothic Neo", "Malgun Gothic", system-ui, sans-serif;
}
* { box-sizing: border-box; }
body { margin: 0; background: var(--ground); color: var(--paper); }
main { max-width: 1440px; margin: 0 auto; padding: 24px clamp(14px, 3vw, 40px) 28px; }
header { display: flex; align-items: end; justify-content: space-between; gap: 12px; margin-bottom: 18px; }
.felt-workshop {
  font-family: "Gowun Batang", "Nanum Myeongjo", "Apple SD Gothic Neo", serif;
  --book-font: "Gaegu", "Gowun Batang", "Nanum Myeongjo", serif;
}
.felt-workshop > header h1 {
  font: 700 clamp(1.8rem, 4vw, 2.5rem) / 1.1 var(--book-font);
  letter-spacing: normal;
}
.home { color: var(--quiet); font-size: .88rem; text-underline-offset: 4px; }
h1 { margin: 7px 0 0; font: 650 clamp(1.25rem, 3vw, 1.9rem) / 1.2 "Nanum Myeongjo", "Iowan Old Style", Georgia, serif; letter-spacing: -.035em; }
button {
  min-height: 44px;
  font: inherit;
  color: var(--paper);
  background: #444238;
  border: 1px solid var(--edge);
  border-radius: 8px;
  padding: 8px 14px;
  cursor: pointer;
}
button:focus-visible, a:focus-visible { outline: 2px solid #ffe6af; outline-offset: 3px; }
button:hover:not(:disabled) { background: #585042; }
button:disabled { color: #b9ad96; opacity: .66; cursor: default; }
figure {
  margin: 0;
  position: relative;
  aspect-ratio: 1672 / 941;
  overflow: hidden;
  border-radius: 8px;
  outline: 1px solid #b8a68655;
  background: #858479;
}
#table { width: 100%; height: 100%; display: block; user-select: none; }
.controls { display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 14px; padding-top: 16px; }
.brew-clock { color: #eed2a8; font-size: .9rem; margin-bottom: 6px; font-variant-numeric: tabular-nums; }
.brew-clock output { color: #fff3dd; font-weight: 700; margin-left: 5px; }
.brew-clock output, .measure output { font-family: system-ui, sans-serif; }
.brew-status p { font-size: 1rem; margin: 0 0 7px; }
.measure { display: flex; align-items: center; gap: 10px; color: var(--quiet); font-size: .875rem; font-variant-numeric: tabular-nums; }
progress { width: 86px; height: 8px; accent-color: #d39963; }
.tools { display: flex; flex-wrap: wrap; gap: 8px; }
.tools button { display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.tools [data-step]:not(:disabled) { background: var(--active); border-color: #b88667; }
.tools [data-step]:not(:disabled):hover { background: #905d44; }
.tools [data-step="filter"], #kettle.is-grabbable, #spare-filter.is-grabbable, #grounds-bowl.is-grabbable { touch-action: none; }
#kettle.is-grabbable, #spare-filter.is-grabbable, #grounds-bowl.is-grabbable { cursor: grab; }
.tools img { width: 24px; height: 24px; object-fit: contain; }
#reset { font-size: .875rem; }
#wet-grounds { filter: brightness(.68) saturate(1.12); }
@media (max-width: 700px) {
  main { padding-top: 17px; }
  figure { aspect-ratio: 1220 / 941; }
  .controls { gap: 13px; }
  .tools { width: 100%; }
  .tools [data-step] { padding-inline: 9px; flex: 1; white-space: nowrap; font-size: .875rem; }
  .tools img { width: 19px; height: 19px; }
}
@media (min-width: 701px) and (min-height: 590px) {
  header, .workbench {
    max-width: min(100%, calc((100svh - 178px) * 1.777));
    margin-inline: auto;
  }
}
.fabric-picker {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 8px 18px;
  margin: 0 0 12px;
}
.fabric-picker label {
  display: flex;
  align-items: center;
  gap: 7px;
  color: var(--quiet);
  font-size: .875rem;
  white-space: nowrap;
}
.fabric-picker select {
  appearance: none;
  min-height: 35px;
  padding: 4px 26px 4px 10px;
  color: var(--paper);
  background: #444238 url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 14 14'%3E%3Cpath d='m3 5 4 4 4-4' fill='none' stroke='%23d7c8a9' stroke-width='1.5'/%3E%3C/svg%3E") no-repeat right 6px center;
  border: 1px solid var(--edge);
  border-radius: 6px;
  font: inherit;
}
.fabric-picker select:focus-visible { outline: 2px solid #ffe6af; outline-offset: 3px; }
.screen-reader-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
@media (min-width: 701px) and (min-height: 590px) {
  .felt-workshop header, .felt-workshop .workbench {
    max-width: min(100%, calc((100svh - 225px) * 1.777));
  }
}
@media (max-width: 700px) {
  .fabric-picker { gap: 6px; }
  .fabric-picker label { flex: 1 1 auto; flex-direction: column; align-items: stretch; gap: 4px; }
  .fabric-picker select { min-height: 44px; width: 100%; }
  .felt-cup { transform: translate(160px, 68px); }
}
#serve[hidden], .tools [data-step][hidden] { display: none; }
#serve:not(:disabled) { background: var(--active); border-color: #b88667; }
#serving-cup.is-grabbable { cursor: grab; touch-action: none; }
#beaker.is-grabbable { cursor: grab; touch-action: none; }

.guest-picker { display: flex; align-items: center; flex-wrap: wrap; gap: 6px; width: 100%; padding: 0; margin: 0 0 5px; border: 0; }
.guest-picker legend { float: left; margin: 0 12px 0 0; padding: 7px 0; color: var(--quiet); font-size: .875rem; }
.fabric-picker .guest-picker label { display: inline-flex; cursor: pointer; }
.guest-picker input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.guest-picker label span { display: inline-flex; align-items: center; min-height: 35px; padding: 5px 10px; border: 1px solid var(--edge); border-radius: 6px; background: #444238; color: var(--quiet); }
.guest-picker input:checked + span { background: #765440; border-color: #c49a72; color: #fff0d7; }
.guest-picker input:focus-visible + span { outline: 2px solid #ffe6af; outline-offset: 3px; }
@media (max-width: 700px) {
  .guest-picker legend { float: none; width: 100%; padding: 0 0 5px; }
  .fabric-picker .guest-picker label { flex: 0 1 auto; }
  .guest-picker label span { min-height: 44px; }
}

.recipe-bar { display:flex; align-items:center; flex-wrap:wrap; gap:10px 14px; margin:0 0 13px; color:var(--quiet); font-size:.875rem; }
.recipe-sign { display: inline-flex; align-items: center; flex-wrap: wrap; gap: 5px 10px; padding: 6px 12px 6px 6px; border: 1px dashed #ba8c66; border-radius: 9px; background: #604a3c; color: #fff0d7; }
.recipe-sign[hidden] { display: none; }
.recipe-stage { flex: none; padding: 4px 9px; border-radius: 5px; background: #e7c89c; color: #51372b; font-size: .85rem; font-weight: 700; }
#recipe-summary { font-size: 1rem; }
.recipe-bar button { min-height:38px; background:#694b39; border-color:#ac8262; padding:6px 13px; }
#recipe-book { width:min(480px, calc(100vw - 32px)); max-height:calc(100dvh - 32px); overflow:auto; border:1px solid #ae8d6e; border-radius:14px; padding:0; color:#42372c; background:#eee0c9; box-shadow:0 20px 70px #17150f99; }
#recipe-book::backdrop { background:#171812b8; }
#recipe-form { padding:24px; }
.recipe-heading { display:flex; justify-content:space-between; align-items:start; margin-bottom:20px; }
.recipe-heading h2 { margin:2px 0 0; font:700 2rem/1.05 var(--book-font); }
.recipe-kicker { margin:0; font-size:.8rem; color:#806b57; }
#recipe-close { min-height:38px; min-width:38px; padding:0; font-size:1.5rem; line-height:1; color:#554336; background:transparent; border-color:#bba58e; }
.recipe-types { display:grid; gap:8px; padding:0; margin:0 0 19px; border:0; }
.recipe-types legend { margin-bottom:8px; font-size:.9rem; font-weight:700; }
.recipe-types label { position:relative; cursor:pointer; }
.recipe-types input { position:absolute; opacity:0; }
.recipe-types label span { display:flex; flex-direction:column; gap:3px; padding:11px 13px; background:#f7eddd; border:1px solid #d4c4ae; border-radius:8px; }
.recipe-types input:checked + span { background:#f3dfc4; border-color:#9d6b49; box-shadow:inset 3px 0 #9d6b49; }
.recipe-types input:focus-visible + span { outline:2px solid #76543b; outline-offset:2px; }
.recipe-types small { color:#796b5c; font-size:1rem; }
.recipe-amounts { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.recipe-amounts p { margin:0; padding:9px 12px; border-radius:6px; background:#fffaf1; font-size:.9rem; }
#recipe-ratio { color:#796b5c; font-size:.875rem; margin:11px 0 18px; font-variant-numeric:tabular-nums; }
.recipe-apply { width:100%; background:#77523c; border-color:#77523c; font-weight:700; }

.recipe-servings { display:flex; align-items:center; justify-content:space-between; gap:12px; margin-bottom:15px; font-size:.9rem; font-weight:700; }
.recipe-servings select { min-height:42px; min-width:110px; padding:7px 10px; color:#42372c; background:#fffaf1; border:1px solid #bba58e; border-radius:6px; font:inherit; }
.recipe-servings select:focus-visible { outline:2px solid #76543b; outline-offset:2px; }

[data-cup].is-grabbable { cursor:grab; touch-action:none; }
#handoff-button[hidden], #handoff-choice[hidden] { display: none; }
#handoff-choice { display: inline-flex; align-items: center; gap: 8px; color: var(--quiet); font-size: .875rem; }
#handoff-recipient { min-height: 44px; padding: 6px 8px; border: 1px solid var(--edge); border-radius: 8px; color: var(--paper); background: #444238; font: inherit; }
#handoff-button:not(:disabled) { background:var(--active); border-color:#b88667; }
.cup-drop-zone { fill: #fcddad; fill-opacity: .28; stroke: #fff0cb; stroke-width: 4; stroke-dasharray: 10 8; }
.cup-drop-zone.is-ready { fill-opacity: .58; stroke: #fff9e8; stroke-width: 6; stroke-dasharray: none; }
#room-copy { min-inline-size: 5rem; }

.admin-screen { max-width: 540px; padding-block: 44px; }
.admin-screen h1 { margin: 0 0 12px; }
.admin-screen p { color: var(--quiet); line-height: 1.5; }
#admin-form { display: grid; gap: 14px; margin-top: 24px; }
.admin-field { display: grid; gap: 6px; }
#admin-form input, #admin-form select { min-height: 46px; padding: 8px 10px; border: 1px solid var(--edge); border-radius: 8px; color: var(--paper); background: #444238; font: inherit; }
#admin-form button:not(:disabled) { background: var(--active); border-color: #b88667; }
#admin-message:empty { display: none; }

.room-panel { max-width: min(100%, calc((100svh - 225px) * 1.777)); margin: 0 auto 14px; }
.room-actions, #room-share { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.room-panel [hidden], #room-share[hidden] { display: none; }
.room-panel button { min-height: 44px; padding: 6px 12px; }
body[data-lobby] .felt-workshop { display: grid; align-content: center; min-height: 100svh; max-width: 870px; padding-block: 36px; }
body[data-lobby] .felt-workshop header { max-width: none; margin: 0 0 22px; }
body[data-lobby] h1 { font-size: clamp(2rem, 5vw, 3rem); }
body[data-lobby] .room-panel { width: 100%; max-width: none; margin: 0; }
body[data-lobby] .workbench { display: none; }
.opening-roles { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
#opening-roles .opening-role-card {
  display: grid; align-content: center; gap: 10px; min-height: 184px; padding: clamp(20px, 3vw, 32px);
  border-color: #a87b5f; border-radius: 13px; background: #6d4a38; text-align: left;
}
#opening-roles #opening-drink { border-color: #82947d; background: #465849; }
#opening-roles #opening-brew:hover:not(:disabled) { background: #815942; }
#opening-roles #opening-drink:hover:not(:disabled) { background: #536954; }
.opening-role-card strong { font-size: clamp(1.5rem, 4vw, 2.1rem); }
.opening-role-card span { font-size: 1rem; font-weight: 400; line-height: 1.55; word-break: keep-all; }
.opening-detail h2 { margin: 20px 0 8px; font-size: clamp(1.4rem, 4vw, 1.8rem); }
.opening-detail p { margin: 8px 0 16px; color: var(--quiet); line-height: 1.5; }
#opening-message:empty { display: none; }
#opening-action:not(:disabled) { background: var(--active); border-color: #b88667; }
@media (max-width: 600px) {
  .opening-roles { grid-template-columns: 1fr; gap: 12px; }
  #opening-roles .opening-role-card { min-height: 140px; }
}
:is(#opening-space, #opening-character) { width: min(540px, calc(100vw - 28px)); max-height: calc(100dvh - 28px); padding: 16px; border: 1px solid var(--edge); border-radius: 12px; color: var(--paper); background: var(--panel, #35362e); }
:is(#opening-space, #opening-character)::backdrop { background: #171812b8; }
.opening-space-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin-bottom: 12px; }
.opening-space-heading h2 { margin: 0; font-size: 1.25rem; }
:is(#opening-space-close, #opening-character-close) { width: 44px; font-size: 1.25rem; }
#opening-space-options { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.opening-space-option { display: grid; gap: 8px; padding: 6px 6px 8px; }
.opening-space-option img { display: block; width: 100%; aspect-ratio: 1672 / 941; object-fit: cover; border-radius: 4px; }
body[data-quiet-table] #room-message, body[data-quiet-table] .recipe-bar,
body[data-quiet-table] .fabric-picker, body[data-quiet-table] .controls { display: none; }
body[data-quiet-table] #table { pointer-events: none; }
#room-role { font-weight: 650; }
#room-role:not(:empty) { margin-inline-end: auto; }
#room-message { margin: 7px 0; font-size: 1rem; color: var(--quiet); }
#room-message:empty { display: none; }
#room-share input { min-width: 0; flex: 1; color: var(--paper); background: #444238; border: 1px solid var(--edge); border-radius: 6px; padding: 7px; font: inherit; }
body[data-room-role] .guest-picker, body[data-room-role] .fabric-picker,
body[data-room-role] #reset,
body[data-room-role="guest"] #recipe-open, body[data-room-role="guest"] #status, body[data-room-role="guest"] .tools,
body[data-room-role="joining"] .workbench,
body[data-resting] #recipe-open,
body[data-resting] .controls { display: none; }
#brew-list-summary { margin: 10px 0 0; font-weight: 700; }
#room-steam path { opacity: .52; animation: room-steam 5s ease-in-out infinite; }
#room-steam path + path { animation-delay: -2s; }
@keyframes room-steam { 0%, 100% { opacity: .2; } 50% { opacity: .72; } }
@media (prefers-reduced-motion: reduce) { #room-steam path { animation: none; } }
@media (max-width: 700px) { .room-panel { max-width: 100%; } }

#recipe-hint {
  position: absolute; right: 3%; bottom: calc(3% + 48px);
  max-width: 94%; margin: 0; pointer-events: none;
}
#recipe-hint:not(:empty) {
  padding: 8px 12px; border: 1px solid #c29170; border-radius: 8px;
  background: #fff0d7; color: #463127; font-size: 1rem; font-weight: 650;
}
#recipe-open {
  position:absolute; right:3%; bottom:3%; min-height:54px;
  padding:7px 12px 7px 15px; border:1px dashed #d3a37f; border-left:5px solid #c29170;
  border-radius:4px 7px 7px 4px; background:#694633; color:#fff1da;
  box-shadow:2px 3px 0 #382920, 4px 6px 10px #28191466;
  font:700 1.4rem/1 var(--book-font);
  transform: perspective(240px) rotateX(45deg); transform-origin: center bottom;
}
.guest-order:not([hidden]) { margin:0 0 14px; }
.guest-order h2 { margin:0 0 8px; font-size:1rem; }
#guest-menu { display:flex; gap:8px; flex-wrap:wrap; }
#guest-menu button { display:grid; text-align:left; }
#guest-menu button[aria-pressed="true"] { border-color:#e8bb85; background:#704e3a; }
#guest-menu small { color:var(--quiet); }
#guest-order-status { color:var(--quiet); margin:8px 0 0; }
#round-actions:not([hidden]) { display:flex; flex-wrap:wrap; align-items:center; gap:12px; margin-top:12px; }
#round-actions p { margin:0; }
#brew-list-add { width:100%; margin-bottom:10px; background:#503e32; }
#brew-list:not([hidden]) { border-block:1px solid #bba58e; padding:12px 0; margin:4px 0 12px; }
#brew-list h3 { margin:0 0 8px; font-size:.95rem; }
#brew-list-items { display:grid; gap:6px; margin:0; padding-left:22px; }
#brew-list-items li > div { display:flex; flex-wrap:wrap; align-items:center; justify-content:space-between; gap:4px 8px; }
#brew-list-items small { display:block; color:#796b5c; }
#brew-list-items button { min-height:32px; padding:4px 8px; color:#42372c; background:#f7eddd; border-color:#bba58e; }
#upcoming-brews { margin:12px 0 0; color:var(--quiet); }
#recipe-feedback:empty { display:none; }

body[data-room-role="host"][data-order-room] .fabric-picker { display:flex; }
#room-space-picker[hidden] { display:none; }

#fabric-hint { margin: 10px 0 0; color: #e4ceb1; font-size: 1rem; }
#scene [aria-haspopup="dialog"]:focus-visible { outline: 2px dashed #ffe6af; outline-offset: 3px; }
#scene [aria-haspopup="dialog"]:not(.is-grabbable) { cursor: pointer; }
#fabric-palette {
  position: fixed; z-index: 10; display: grid; grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 5px; width: min(252px, calc(100vw - 16px)); padding: 7px;
  border: 1px dashed #ac8666; border-radius: 12px; box-sizing: border-box;
  background: #f2e3c9; color: #42372c; box-shadow: 0 6px 20px #16130f88;
}
#fabric-palette[hidden] { display: none; }
#fabric-palette::after {
  position: absolute; left: var(--fabric-pointer, 50%); top: 100%;
  width: 0; height: 0; content: ''; transform: translateX(-50%);
  border-left: 8px solid transparent; border-right: 8px solid transparent; border-top: 8px solid #f2e3c9;
}
#fabric-palette[data-below="true"]::after { top: auto; bottom: 100%; transform: translateX(-50%) rotate(180deg); }
#fabric-palette button {
  position: relative; min-width: 0; height: 64px; padding: 5px; border: 1px solid transparent;
  background: transparent; color: inherit;
}
#fabric-palette button:hover { background: #dec8ac; }
#fabric-palette button:focus-visible { outline: 2px solid #76543b; outline-offset: 0; }
#fabric-palette button[aria-pressed="true"] { border-color: #876248; background: #e8d2b5; }
#fabric-palette button[aria-pressed="true"]::after { position: absolute; top: 1px; right: 3px; content: '✓'; }
#fabric-palette img { display: block; width: 100%; height: 100%; object-fit: contain; pointer-events: none; }

#cafe-nickname { margin: 0; color: var(--paper); font-size: .9rem; }
#opening-character-options { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
#opening-character-options button { align-content: end; min-width: 0; }
#opening-character-options img { aspect-ratio: 4 / 5; object-fit: contain; object-position: center bottom; }

#message-options { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 10px; }
#message-options[hidden] { display: none; }
#message-options button { min-height: 44px; padding: 6px 11px; font-size: .9rem; }
#message-options .message-emoji { min-width: 44px; padding: 6px; font-size: 1.3rem; }
#message-options [data-tone-message], .skin-tone-picker { -webkit-user-select: none; user-select: none; -webkit-touch-callout: none; }

#table-message {
  position: absolute; top: 4%; left: 50%; transform: translateX(-50%);
  width: min(88%, 280px); display: flex; flex-direction: column; gap: 5px;
  max-height: 62%; overflow: hidden; pointer-events: none;
}
#table-message[hidden] { display: none; }
.table-message-bubble {
  flex: none; padding: 7px 12px; border: 1px dashed #b18764;
  border-radius: 12px; background: #fff0d7; color: #463127;
  text-align: center; box-shadow: 0 3px 12px #2d201744;
  transition: opacity .5s ease, transform .5s ease;
}
.table-message-bubble.is-leaving { opacity: 0; transform: translateY(-18px); }
.table-message-bubble strong { display: block; font-size: .85rem; }
.table-message-bubble span { display: block; font-size: 1rem; }
@media (prefers-reduced-motion: reduce) {
  .table-message-bubble { transition: none; }
}

.person-name {
  font: 700 27px "Gowun Batang", serif;
  fill: #513a2e; stroke: #fff0d7; stroke-width: 14px;
  stroke-linejoin: round; paint-order: stroke fill;
}


.scene-layout { position: relative; }
.view-preview {
  position: absolute; z-index: 3; top: 10px; right: 10px;
  display: grid; place-items: center; width: 44px; height: 44px;
  min-height: 44px; padding: 0; border: 1px solid #d9bd97;
  border-radius: 50%; background: #604a3c; color: #fff0d7;
  box-shadow: 0 3px 12px #26170a88;
}
.view-preview[hidden] { display: none; }
.view-icon { display: block; width: 26px; height: 26px; }
#view-preview-image {
  position: absolute; top: calc(100% + 8px); right: 0;
  display: block; width: min(clamp(150px, 22vw, 290px), calc(100vw - 48px)); aspect-ratio: 1672 / 941;
  pointer-events: none; padding: 3px; border: 2px solid #f2dbb8;
  border-radius: 8px; background: #604a3c; box-shadow: 0 3px 12px #26170a88;
}
#view-preview-image[hidden] { display: none; }
#view-preview-image svg { display: block; width: 100%; height: 100%; border-radius: 3px; }
@media (hover: none) {
  .view-preview { width: 44px; height: 44px; }
}

.ambient-rain-streaks {
  opacity: .42; stroke-dasharray: 8 55; animation: ambient-rain 2.4s linear infinite;
}
[data-space="autumn"] .ambient-light { fill: #6d3026; opacity: .42; }
[data-space="autumn"] .ambient-light > path { stroke: #6d3026; }
.ambient-light { transform-origin: -55px 35px; animation: ambient-light 8s ease-in-out infinite alternate; }
.shadow-leaf { transform-box: fill-box; transform-origin: center bottom; animation: shadow-leaf 5s ease-in-out infinite alternate; }
.shadow-leaf-two { animation-duration: 6.7s; animation-delay: -2s; }
.shadow-leaf-three { animation-duration: 5.8s; animation-delay: -3s; }
@keyframes ambient-rain { to { stroke-dashoffset: -63; } }
@keyframes ambient-light {
  0% { transform: rotate(-3deg); }
  55% { transform: rotate(2deg); }
  100% { transform: rotate(4deg); }
}
@keyframes shadow-leaf {
  from { transform: rotate(-4deg); }
  to { transform: rotate(5deg); }
}
@media (prefers-reduced-motion: reduce) {
  .ambient-rain-streaks, .ambient-light { animation: none; opacity: 0; }
  .shadow-leaf { animation: none; }
}

.room-icon-action svg { display: block; width: 21px; height: 21px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; }
.room-panel .room-icon-action:not([hidden]) { flex: 0 0 44px; width: 44px; min-width: 44px; height: 44px; padding: 0; display: inline-grid; place-items: center; }
.room-icon-action .room-action-label { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (max-width: 700px) {
  .room-actions:has(#room-role:not(:empty)) { flex-wrap: nowrap; }
  #room-role { min-width: 0; overflow-wrap: anywhere; }
  #message-options { flex-wrap: nowrap; overflow-x: auto; overscroll-behavior-inline: contain; -webkit-overflow-scrolling: touch; padding-bottom: 5px; }
  #message-options button { flex: 0 0 auto; white-space: nowrap; }
}

.opening-tables { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(100%, 235px), 1fr)); gap: 14px; }
.opening-tables[hidden] { display: none; }
.room-panel .opening-table-card { display: block; overflow: hidden; padding: 0; border-radius: 12px; text-align: left; background: #514637; }
.opening-table-card:hover { border-color: #dbbc91; }
.opening-table-scene { display: block; position: relative; aspect-ratio: 1672 / 941; overflow: hidden; }
.opening-table-background { display: block; width: 100%; height: 100%; object-fit: cover; }
.opening-table-character { position: absolute; bottom: 10%; left: 50%; width: 31%; height: 68%; object-fit: contain; object-position: bottom; transform: translateX(-50%); }
.opening-table-info { display: grid; gap: 4px; padding: 12px 14px 14px; }
.opening-table-info strong { font-size: 1.15rem; }
.opening-table-info span { font-size: .92rem; color: #e0d2b9; }
.opening-table-info .opening-table-status { color: #f0c99e; }
 .skin-tone-picker { position: fixed; z-index: 1000; width: max-content; max-width: calc(100vw - 16px); border: 1px solid #a78e72; border-radius: 12px; padding: 10px; color: var(--paper); background: #444238; box-shadow: 0 5px 16px #0006; }
.skin-tone-picker[hidden] { display: none; }
.skin-tone-choices { display: flex; gap: 3px; }
.skin-tone-choices button { min-width: 40px; min-height: 44px; padding: 4px; font-size: 1.3rem; }
.skin-tone-choices button[aria-pressed="true"] { border-color: #f0cf9f; background: #78624b; }
.skin-tone-picker label { display: flex; align-items: center; gap: 5px; margin-top: 7px; font-size: .9rem; }
.skin-tone-picker input { width: 18px; height: 18px; }

body[data-lobby]:has(#opening-roles:not([hidden])) { background: #ead1ac; color: #543b2c; }
body[data-lobby]:has(#opening-roles:not([hidden])) .felt-workshop { max-width: 760px; padding-block: 20px 36px; }
body[data-lobby]:has(#opening-roles:not([hidden])) .felt-workshop header { text-align: center; margin: 0 0 12px; }
body[data-lobby]:has(#opening-roles:not([hidden])) h1 { display: inline-block; padding: 8px 34px; border: 2px dashed #bd8b6d; border-radius: 50px; background: #f5e7ca; box-shadow: 0 3px 0 #ad805c; font-size: clamp(1.8rem, 5vw, 2.5rem); }
body[data-lobby]:has(#opening-roles:not([hidden])) #cafe-nickname { color: #735744; }
.opening-window { grid-column: 1 / -1; overflow: hidden; border-radius: 16px; box-shadow: 0 5px 15px #60432a3b; }
.opening-window img { display: block; width: 100%; aspect-ratio: 4 / 3; object-fit: cover; }
#opening-roles .opening-role-card { position: relative; min-height: 108px; padding: 18px 25px; border: 2px dashed #e6c7a4; border-radius: 16px; box-shadow: 0 4px 0 #79513c; background: #718158; color: #fff0d9; }
#opening-roles #opening-drink { border-color: #e8c5ab; background: #ad6b6c; }
#opening-roles #opening-brew:hover:not(:disabled) { background: #819269; }
#opening-roles #opening-drink:hover:not(:disabled) { background: #bd7a7a; }
.opening-role-card strong { font-size: clamp(1.4rem, 3vw, 1.8rem); }
.opening-role-card span { font-size: .95rem; }
@media (max-width: 600px) {
  body[data-lobby]:has(#opening-roles:not([hidden])) .felt-workshop { padding-block: 12px 24px; }
  #opening-roles .opening-role-card { min-height: 88px; padding: 13px 20px; gap: 3px; }
  .opening-window img { aspect-ratio: 4 / 3; }
}

/* A muted felt wall carries the entrance palette into the role screens. */
body[data-lobby] {
  background: #b8bba6;
  color: #493b2d;
  --quiet: #665746;
  --paper: #fff2df;
  --edge: #b48a6c;
}
body[data-lobby]:has(#opening-roles:not([hidden])) { background: #b8bba6; color: #493b2d; }
body[data-lobby] .felt-workshop header { text-align: center; margin-bottom: 18px; }
body[data-lobby] .felt-workshop header h1 {
  display: inline-block; padding: 8px 34px; border: 2px dashed #bd8b6d;
  border-radius: 50px; background: #f5e7ca; color: #543b2c;
  box-shadow: 0 3px 0 #ad805c; font-size: clamp(1.8rem, 5vw, 2.5rem);
}
body[data-lobby] #cafe-nickname { color: #4e493a; }
body[data-lobby] .opening-detail {
  padding: clamp(18px, 4vw, 30px); border: 2px dashed #bb997a;
  border-radius: 18px; background: #f5e7ce; box-shadow: 0 4px 0 #9c8f75;
}
body[data-lobby] .opening-detail h2 { color: #503e30; }
body[data-lobby] .opening-detail p { color: #665746; }
body[data-lobby] .opening-detail button:not(.opening-table-card),
body[data-lobby] :is(#opening-space, #opening-character) button {
  border: 2px dashed #e6c7a4; border-radius: 12px; background: #718158;
  color: #fff0d9; box-shadow: 0 3px 0 #69714f;
}
body[data-lobby] .opening-detail button:hover:not(:disabled),
body[data-lobby] :is(#opening-space, #opening-character) button:hover:not(:disabled) { background: #819269; }
body[data-lobby] #opening-role-back { background: #ad6b6c; box-shadow: 0 3px 0 #8d5658; }
body[data-lobby] :is(#opening-space, #opening-character) {
  color: #503e30; background: #f5e7ce; border: 2px dashed #bb997a;
  box-shadow: 0 5px 0 #9c8f75;
}
body[data-lobby] .room-panel .opening-table-card { border: 2px dashed #bb997a; background: #718158; box-shadow: 0 3px 0 #69714f; }
body[data-lobby] .opening-table-info span { color: #fff0d9; }
body[data-lobby] button:focus-visible { outline-color: #704132; }

#previous-cups .is-grabbable { cursor: grab; touch-action: none; }

.sip-hint { fill: #fff3dc; font: 700 22px 'Gowun Batang', serif; paint-order: stroke; stroke: #664633; stroke-width: 7px; stroke-linejoin: round; pointer-events: none; }

#recipe-order-badge:not([hidden]) {
  position: absolute; top: -11px; right: -10px; display: grid; place-items: center;
  min-width: 24px; height: 24px; padding: 0 5px; border: 2px solid #ffe9c7;
  border-radius: 50%; background: #b65b4b; color: #fff7e8;
  font: 700 .8rem/1 system-ui, sans-serif; box-shadow: 0 2px 4px #38292066;
}
body[data-resting][data-room-role="host"] #recipe-open:has(#recipe-order-badge:not([hidden])) { display: block; }

#chat-history { position: absolute; top: 3%; left: 3%; z-index: 3; }
#chat-history[hidden], #chat-history-list[hidden] { display: none; }
#chat-history-toggle { display: grid; place-items: center; width: 36px; height: 36px; min-height: 36px; padding: 0; border: 1px dashed #d1aa85; border-radius: 50%; background: #694633e8; color: #fff1da; font-size: 1.1rem; }
#chat-history-list { width: min(260px, 75vw); max-height: min(45vh, 310px); overflow-y: auto; margin-top: 6px; padding: 9px 12px; border: 1px dashed #b18764; border-radius: 12px; background: #fff0d7f2; color: #463127; box-shadow: 0 3px 12px #2d201744; }
#chat-history-list div { display: flex; flex-wrap: wrap; gap: 4px 8px; padding: 4px 0; overflow-wrap: anywhere; }
#chat-history-list strong { font-size: .85rem; }
#chat-history-list span { font-size: .95rem; }

.sip-notice { animation: sip-notice-rise 1.8s ease-out forwards; }
@keyframes sip-notice-rise { 0% { opacity: 0; transform: translateY(4px); } 20% { opacity: 1; } 75% { opacity: 1; } 100% { opacity: 0; transform: translateY(-24px); } }
@media (prefers-reduced-motion: reduce) { .sip-notice { animation: none; } }

.sip-touch-hint { position: fixed; z-index: 1000; transform: translateX(-50%); padding: 5px 10px; border: 1px dashed #d7ad87; border-radius: 12px; background: #694633; color: #fff3dc; font: 700 15px 'Gowun Batang', serif; pointer-events: none; white-space: nowrap; }
.sip-touch-hint[hidden] { display: none; }

#opening-character-options.animal-draw { display: block; }
#opening-character-options .animal-card { display: grid; place-items: center; align-content: center; gap: 8px; min-height: 170px; padding: 12px; text-align: center; }
.animal-card-art { display: grid; place-items: center; width: min(76%, 92px); aspect-ratio: 3 / 4; border: 2px dashed #e8c49c; border-radius: 12px; background: #96654d; color: #f9dbad; font-size: 2.3rem; box-shadow: inset 0 0 0 5px #96654d, inset 0 0 0 6px #d8ad82; }
.animal-draw-panel { display: grid; justify-items: center; gap: 10px; text-align: center; }
#opening-character-options .animal-draw-image { width: min(220px, 55vw); height: min(240px, 35dvh); object-fit: contain; animation: animal-reveal .38s ease-out both; }
.animal-draw-panel p { margin: 0; font-size: 1.1rem; }
.animal-draw-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
.animal-draw-actions button { min-height: 44px; padding: 8px 12px; }
@keyframes animal-reveal { from { opacity: 0; transform: perspective(600px) rotateY(80deg) scale(.95); } to { opacity: 1; transform: perspective(600px) rotateY(0) scale(1); } }
@media (prefers-reduced-motion: reduce) { #opening-character-options .animal-draw-image { animation: none; } }

.animal-card-waiting { width: min(155px, 40vw); height: min(205px, 30dvh); margin: 18px 0; animation: animal-card-sway 1.8s ease-in-out both; }
@keyframes animal-card-sway { 0%, 100% { transform: rotate(0); } 30% { transform: rotate(-4deg); } 65% { transform: rotate(4deg); } }
@media (prefers-reduced-motion: reduce) { .animal-card-waiting { animation: none; } }

#souvenir-dialog { width: min(620px, calc(100vw - 24px)); max-height: calc(100dvh - 24px); padding: 16px; border: 2px dashed #bb997a; border-radius: 16px; background: #f5e7ce; color: #503e30; }
#souvenir-dialog::backdrop { background: #171812b8; }
#souvenir-dialog h2 { margin: 0; }
#souvenir-dialog button, #souvenir-save { display: inline-block; min-height: 44px; padding: 9px 14px; border: 2px dashed #e6c7a4; border-radius: 12px; background: #718158; color: #fff0d9; text-decoration: none; font: inherit; }
#souvenir-preview { display: block; width: min(100%, 500px); height: auto; margin: 10px auto; }
#souvenir-preview[hidden], #souvenir-save[hidden], #souvenir-share[hidden] { display: none; }
.souvenir-actions { text-align: center; }

.room-panel #souvenir-open { position: relative; overflow: visible; }
.souvenir-badge { position: absolute; top: -7px; right: -7px; min-width: 20px; height: 20px; padding: 0 4px; border-radius: 20px; background: #b75b50; color: white; font: 700 12px/20px sans-serif; text-align: center; }
.souvenir-badge[hidden], .skin-tone-picker label[hidden] { display: none; }
.skin-tone-choices { max-width: min(300px, calc(100vw - 40px)); flex-wrap: wrap; }

#recipe-title:not([hidden]), #recipe-target:not([hidden]) { display: block; }
#recipe-open:has(#recipe-target:not([hidden])) { width: 112px; padding: 5px; border: 3px solid #694633; }
#recipe-target:not([hidden]) { white-space: pre-line; padding: 9px 4px; color: #543a2b; text-align: center; font: 700 .82rem/1.25 system-ui, sans-serif; background: linear-gradient(95deg, #ecdec2, #faf0da 20%, #f3e5c9 100%); border-radius: 3px; }
#recipe-open:disabled:has(#recipe-target:not([hidden])) { opacity: 1; }
#guest-brew-target:not([hidden]) { position: absolute; right: 3%; bottom: 3%; width: 112px; min-height: 54px; padding: 9px 4px; border: 3px solid #694633; border-radius: 5px; background: linear-gradient(95deg, #ecdec2, #faf0da 20%, #f3e5c9 100%); color: #543a2b; text-align: center; font: 700 .82rem/1.25 system-ui, sans-serif; white-space: pre-line; transform: perspective(240px) rotateX(45deg); transform-origin: center bottom; }
@media (max-width: 700px) {
  #recipe-open { font-size: 1.1rem; padding-inline: 9px; }
  #recipe-open:has(#recipe-target:not([hidden])), #guest-brew-target:not([hidden]) { width: 84px; }
  #recipe-target:not([hidden]), #guest-brew-target:not([hidden]) { font-size: .7rem; padding-block: 7px; }
}

.pour-touch-area { display: none; }
@media (pointer: coarse) {
  #scene:has(#kettle.is-grabbable), #scene:has(#beaker.is-grabbable),
  #scene:has(#spare-filter.is-grabbable), #scene:has(#grounds-bowl.is-grabbable) { touch-action: none; }
  #kettle.is-grabbable .pour-touch-area, #beaker.is-grabbable .pour-touch-area { display: inline; fill: transparent; pointer-events: all; touch-action: none; }
  #kettle.is-grabbable *, #beaker.is-grabbable *, #grounds-bowl.is-grabbable * { touch-action: none; }
}
