.sketch {
  --studio-ink:#f7edd6;
  --studio-accent:#f1b7ac;
  --studio-rule:#bca57e55;
  --studio-tray:#243333;
  --studio-metal:#d6b986;
  width:min(1080px,calc(100% - 40px));
}
:root[data-theme="light"] .sketch {
  --studio-ink:#302c23;
  --studio-accent:#803f42;
  --studio-rule:#80664252;
  --studio-tray:#ebe9db;
  --studio-metal:#765831;
}
.sketch .sketch-sign {
  --sign-title:#fff2d6;
  position:relative;
  display:flex;
  align-items:end;
  gap:16px;
  min-height:184px;
  padding:24px;
  margin:0;
  border-radius:8px;
  background:linear-gradient(90deg,#112322ea,#162729ad 32%,#18232510 70%),
    #243434 url('/hall-online.webp') 55% 55% / cover no-repeat;
}
.sketch-sign::after {
  content:""; position:absolute; inset:5px; border:1px solid #efd8a764;
  border-radius:4px; pointer-events:none;
}
.sketch-sign .game-art {
  width:72px; aspect-ratio:1; border-radius:8px; border:1px solid #e4c3919c;
}
.sketch .mini-heading.sketch-sign h1 {
  color:var(--sign-title); font:700 44px/1.04 var(--woodays-type,Georgia,serif);
  text-wrap:balance; margin:0;
}
.sketch-title { min-width:0; align-self:end; }
.sketch .sketch-title #sketch-phase { color:var(--studio-accent); font-size:15px; font-weight:650; line-height:1.35; }
.sketch-title #sketch-phase:empty { margin:0; }

/* Leave the painted sign at the door; the room needs that space for drawing. */
.sketch:has(#sketch-room:not([hidden])) .sketch-sign {
  --sign-title:var(--studio-ink);
  min-height:0; align-items:center; gap:12px; padding:0 0 14px; background:none;
}
.sketch:has(#sketch-room:not([hidden])) .sketch-sign::after { content:none; }
.sketch:has(#sketch-room:not([hidden])) .sketch-sign .game-art { width:46px; }
.sketch:has(#sketch-room:not([hidden])) .sketch-title { align-self:center; }
.sketch:has(#sketch-room:not([hidden])) .sketch-sign h1 { font-size:30px; }

.sketch-lobby {
  display:grid; grid-template-columns:minmax(0,1.15fr) minmax(0,.85fr);
  column-gap:48px; padding:26px 24px 20px; align-items:start;
}
.sketch-lobby:has(#sketch-entry[hidden]) { display:none; }
.sketch .sketch-lobby #sketch-entry {
  display:grid; grid-template-columns:minmax(0,1fr); gap:16px;
  align-content:start; padding:0; margin:0; background:transparent;
}
.sketch-entry .room-modes {
  display:grid; grid-template-columns:repeat(2,minmax(0,1fr)); gap:3px;
  padding:4px; border:1px solid var(--studio-rule); border-radius:8px; background:var(--studio-tray);
}
.sketch-entry .room-modes button {
  min-height:44px; margin:0; border:1px solid transparent; color:var(--muted); background:transparent;
}
.sketch-entry .room-modes [aria-pressed="true"] {
  color:var(--studio-ink); background:var(--panel); border-color:var(--studio-rule); font-weight:700;
}
.sketch-field { display:grid; gap:6px; min-width:0; }
.sketch-field label, #sketch-answer label { font-weight:650; color:var(--studio-ink); }
.sketch .input-tools { display:flex; align-items:stretch; gap:6px; }
.sketch :is(.sketch-field,#sketch-answer,#sketch-chat-form) input {
  min-width:0; width:100%; color:inherit; background:var(--input); padding:8px 11px; min-height:44px;
}
.sketch input::placeholder { color:var(--muted); opacity:1; }
.sketch #paste-invite { flex:none; width:44px; }
.sketch-entry > .primary { min-height:44px; justify-self:start; padding-inline:24px; }
.sketch-shelf { min-width:0; align-self:stretch; border-inline-start:1px solid var(--studio-rule); padding-inline-start:32px; display:grid; align-content:center; }
.sketch-supplies { width:min(68%,230px); height:auto; justify-self:center; }
.sketch-shelf:has(#sketch-history:not([hidden])) { align-content:start; }
.sketch-shelf:has(#sketch-history:not([hidden])) .sketch-supplies { display:none; }
#sketch-history h2, .sketch-players h2 { margin:0; color:var(--studio-ink); font-size:22px; line-height:1.2; }
#sketch-history ul, .sketch-players ul { list-style:none; padding:0; margin:5px 0 0; }
#sketch-history li { min-width:0; border-bottom:1px solid var(--studio-rule); padding-block:4px; }
#sketch-history a { display:block; flex:1; min-width:0; padding:10px 0; color:var(--gold); overflow-wrap:anywhere; }
#sketch-history a:hover { text-decoration:underline; text-underline-offset:3px; }
#sketch-history button { flex:none; min-height:44px; }
#sketch-error { color:var(--gold); overflow-wrap:anywhere; margin:0; }
#sketch-error:not(:empty) { padding-block:10px; }

.sketch-roombar {
  display:flex; flex-wrap:wrap; align-items:center; gap:6px 10px; padding:8px 0;
  border-block:1px solid var(--studio-rule); margin-bottom:18px;
}
.sketch-room-id { min-width:0; max-width:100%; display:flex; flex-wrap:wrap; align-items:baseline; gap:6px; }
.sketch-room-id > span, #connection { color:var(--muted); font-size:13px; }
#sketch-code { font-variant-numeric:tabular-nums; color:var(--studio-ink); overflow-wrap:anywhere; }
.sketch-roombar #connection { margin-inline-end:auto; min-width:0; overflow-wrap:anywhere; }
.sketch-roombar button { display:inline-flex; align-items:center; justify-content:center; gap:7px; min-height:44px; }
.sketch-roombar button svg { display:block; width:16px; height:16px; fill:none; stroke:currentColor; stroke-width:1.65; stroke-linejoin:round; stroke-linecap:round; }
.sketch-roombar #sketch-leave { background:transparent; }
.sketch .mini-layout { grid-template-columns:minmax(0,1fr) minmax(220px,250px); gap:24px; }
.sketch-play, .sketch-players { min-width:0; }
.sketch-players { border-inline-start:1px solid var(--studio-rule); padding-inline-start:18px; }
.sketch-players li { display:flex; justify-content:space-between; align-items:center; gap:8px; min-height:38px; border-bottom:1px solid var(--line); padding-block:6px; overflow-wrap:anywhere; }
.sketch-players li > span { min-width:0; }
.sketch-players li small { flex:none; max-width:45%; color:var(--muted); text-align:end; }
#sketch-board-heading { display:flex; justify-content:space-between; align-items:center; gap:12px; min-height:30px; margin-bottom:8px; }
#sketch-board-heading h2 { color:var(--studio-ink); font-size:22px; line-height:1.2; overflow-wrap:anywhere; }
#sketch-timer { flex:none; min-width:5ch; text-align:center; font-variant-numeric:tabular-nums; white-space:nowrap; color:var(--studio-metal); }
#sketch-timer:empty { display:none; }
.sketch :is(select,summary,[role="log"],#sketch-phase):focus-visible { outline:2px solid var(--gold); outline-offset:3px; }
#sketch-tools,#sketch-options,#sketch-answer,#sketch-host-tools { display:flex; flex-wrap:wrap; gap:8px; align-items:center; }
#sketch-tools {
  padding:10px; margin-bottom:10px; border:1px solid var(--studio-rule);
  border-radius:6px; background:var(--studio-tray);
}
#sketch-tools label { display:flex; align-items:center; gap:7px; }
#sketch-tools :is(button,select), #sketch-answer button, #sketch-host-tools button { min-height:44px; }
#sketch-tools select { font:inherit; background:var(--input); color:inherit; border:1px solid var(--line); padding-inline:8px; border-radius:6px; }
#ink { display:flex; flex-wrap:wrap; flex-basis:100%; gap:4px; }
#ink button {
  display:grid; place-items:center; width:44px; height:44px; padding:0;
  background:transparent; border:2px solid transparent; touch-action:manipulation;
}
#ink span { width:27px; height:27px; border-radius:50%; border:1px solid #8b806e; pointer-events:none; }
#ink [aria-pressed="true"] { border-color:var(--studio-metal); background:var(--panel); }
#stroke-eraser[aria-pressed="true"] { background:var(--gold); color:var(--panel); }
#sketch-tools:has(#stroke-eraser[aria-pressed="true"]) #ink [aria-pressed="true"] { border-color:transparent; background:transparent; }
.sketch-play:has(#stroke-eraser[aria-pressed="true"]) #sketch-canvas:not([aria-disabled="true"]) { cursor:cell; }

/* The easel owns the frame. The canvas box itself is exactly the drawable area. */
.sketch-easel { padding:6px; background:#856347 url('/timber.webp') center / 540px auto; border-radius:6px; }
.sketch-easel:has(#sketch-canvas[hidden]) { display:none; }
.sketch canvas { display:block; width:100%; height:auto; aspect-ratio:3 / 2; background:#fff1d5; }
#sketch-canvas { padding:0; border:0; touch-action:none; cursor:crosshair; }
#sketch-canvas[aria-disabled="true"] { cursor:default; }
#sketch-answer, #sketch-options:not(:empty), #sketch-host-tools:not(:empty) { margin-top:12px; }
#sketch-answer label { flex-basis:100%; }
#sketch-answer input { flex:1 1 160px; max-width:100%; }
#sketch-host-tools button { flex:1 1 100%; text-align:start; }
#sketch-chat { margin-top:20px; border-top:1px solid var(--studio-rule); padding-top:12px; }
#sketch-log { max-width:100%; scrollbar-color:var(--muted) var(--panel); scrollbar-gutter:stable; overscroll-behavior-y:contain; }
#sketch-log p { margin:0; padding:7px 2px; border-bottom:1px solid var(--line); font-size:14px; line-height:1.5; overflow-wrap:anywhere; }
#sketch-log:empty::after { content:"No messages yet."; color:var(--muted); font-size:13px; }
#sketch-log .chat-message-menu { max-width:100%; margin-inline-start:4px; }
#sketch-log summary { display:inline-grid; place-items:center; min-width:36px; min-height:36px; vertical-align:middle; }
#sketch-log .chat-message-menu button { max-width:100%; min-height:44px; white-space:normal; }
#sketch-chat-form { display:grid; grid-template-columns:minmax(0,1fr) auto; margin-top:10px; gap:8px; }
#sketch-chat-form button { min-height:44px; }
#sketch-gallery { display:grid; grid-template-columns:repeat(auto-fit,minmax(min(100%,235px),1fr)); gap:16px; }

@media (hover:hover) {
  .sketch-entry .room-modes button:not([aria-pressed="true"]):hover, #ink button:not(:disabled):hover { background:var(--hover); }
}
@media (max-width:820px) {
  .sketch .mini-layout { grid-template-columns:minmax(0,1fr); gap:20px; }
  .sketch-players { border-inline-start:0; padding-inline-start:0; padding-top:14px; border-top:1px solid var(--studio-rule); }
  #sketch-host-tools button { flex:1 1 150px; text-align:center; }
}
@media (max-width:640px) {
  .sketch { width:calc(100% - 24px); margin-top:14px; }
  .sketch .sketch-sign { min-height:142px; padding:16px; gap:10px; background-position:center,63% 55%; }
  .sketch-sign .game-art { width:52px; }
  .sketch .mini-heading.sketch-sign h1 { font-size:32px; }
  .sketch:has(#sketch-room:not([hidden])) .sketch-sign h1 { font-size:26px; }
  .sketch-lobby { grid-template-columns:minmax(0,1fr); gap:20px; padding:18px 2px; }
  .sketch-supplies,.sketch-shelf:has(#sketch-history[hidden]) { display:none; }
  .sketch-shelf { border:0; border-top:1px solid var(--studio-rule); padding:14px 0 0; }
  .sketch-entry > .primary { justify-self:stretch; }
  .sketch :is(input,select) { font-size:16px; }
  #sketch-tools { padding:6px; }
}
@media (max-width:480px) {
  .sketch-roombar { display:grid; grid-template-columns:minmax(0,1fr) auto; }
  .sketch-roombar #connection { text-align:end; margin:0; }
  .sketch-roombar button { justify-self:start; }
  .sketch-roombar #sketch-leave { justify-self:end; grid-column:2; }
}
@media (pointer:coarse) {
  #sketch-log summary { min-width:44px; min-height:44px; }
}
@media (forced-colors:active) {
  .sketch .mini-heading.sketch-sign h1 { color:CanvasText; }
  #ink span { forced-color-adjust:none; }
  #ink [aria-pressed="true"], .sketch-entry .room-modes [aria-pressed="true"] { outline:2px solid Highlight; outline-offset:-3px; }
}
