/* ToastChat - a Nintendo DS running ToastChat, drawn in CSS.
   Screen size is set from JS (--screen-w/--screen-h) so both screens stay a
   true 4:3 and Excalidraw always gets a real pixel box to live in.

   Two axes of theming, deliberately independent:
     data-shell="silver|onyx|cobalt|crimson|candy|turquoise"  the plastic
     data-theme="light|dark" (absent = follow the OS)         the screens */

:root {
  --screen-h: 300px;
  --screen-h2: 300px; /* bottom screen; only differs on phones */
  --screen-w: 400px;
  --side: 92px;
  --bezel: 12px;

  /* ---- the desk the console sits on ---- */
  --desk-1: #3c4250;
  --desk-2: #23262e;
  --desk-3: #16181d;

  /* ---- console plastic (overridden per data-shell) ---- */
  --plastic: #dfe1e6;
  --plastic-hi: #f4f5f7;
  --plastic-lo: #b6bac4;
  --plastic-edge: #8b8f9a;
  --brand-ink: #7d818c;
  --btn-hi: #6f737d;
  --btn-lo: #4c505a;
  --btn-edge: #3a3d45;
  --btn-ink: #f0f1f4;
  --bezel-color: #23252b;

  /* ---- the on-screen UI: pale steel-blue chrome over a white page ---- */
  --pc-page: #ffffff;
  --pc-rule: rgba(148, 163, 184, .10);
  --pc-chrome: #c3cfe0;
  --pc-chrome-hi: #e2e9f3;
  --pc-line: #94a3b8;
  --pc-ink: #2b3340;
  --pc-ink-soft: #64748b;
  --pc-ink-faint: #94a3b8;
  --pc-sys: #f0f4fa;
  --pc-sys-ink: #5b6b82;
  --pc-panel: #eef3fa;
  --pc-panel-2: #dde5f1;
  --pc-card: #ffffff;
  --pc-card-2: #dbe4f0;
  --pc-card-hover: #cfe0f7;
  --pc-divider: #c2ccdb;
  --pc-me-bg: #f7fbff;
  --pc-accent: #2f6fd0;
  --pc-accent-hi: #6fb0f5;
  --pc-heading: #33405a;
  --pc-emboss: #ffffff;
  /* Sent drawings are always exported light-on-transparent, so dark mode flips
     them the same way Excalidraw flips its own canvas. */
  --img-filter: none;
  /* light the display casts onto the plastic around it */
  --screen-glow: rgba(226, 238, 255, .55);
  --gloss: rgba(255, 255, 255, .07);

  color-scheme: light;
}

/* ---- dark values, defined once and mapped twice (OS pref + explicit) ---- */
:root {
  --d-desk-1: #23262f;
  --d-desk-2: #14161b;
  --d-desk-3: #0c0d11;
  --d-pc-page: #14181f;
  --d-pc-rule: rgba(148, 163, 184, .07);
  --d-pc-chrome: #202734;
  --d-pc-chrome-hi: #2a3341;
  --d-pc-line: #3a4454;
  --d-pc-ink: #dde5f0;
  --d-pc-ink-soft: #93a1b5;
  --d-pc-ink-faint: #6b7889;
  --d-pc-sys: #1b212b;
  --d-pc-sys-ink: #8b98ab;
  --d-pc-panel: #1b212b;
  --d-pc-panel-2: #151a22;
  --d-pc-card: #232b38;
  --d-pc-card-2: #1b222d;
  --d-pc-card-hover: #2c3644;
  --d-pc-divider: #2e3846;
  --d-pc-me-bg: #1a212c;
  --d-pc-accent: #4b8ae0;
  --d-pc-heading: #cfdbea;
  --d-pc-emboss: rgba(255, 255, 255, .06);
  --d-img-filter: invert(93%) hue-rotate(180deg);
  --d-screen-glow: rgba(90, 140, 210, .30);
  --d-gloss: rgba(255, 255, 255, .05);
}

@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    color-scheme: dark;
    --screen-glow: var(--d-screen-glow); --gloss: var(--d-gloss);
    --desk-1: var(--d-desk-1); --desk-2: var(--d-desk-2); --desk-3: var(--d-desk-3);
    --pc-page: var(--d-pc-page); --pc-rule: var(--d-pc-rule);
    --pc-chrome: var(--d-pc-chrome); --pc-chrome-hi: var(--d-pc-chrome-hi);
    --pc-line: var(--d-pc-line); --pc-ink: var(--d-pc-ink);
    --pc-ink-soft: var(--d-pc-ink-soft); --pc-ink-faint: var(--d-pc-ink-faint);
    --pc-sys: var(--d-pc-sys); --pc-sys-ink: var(--d-pc-sys-ink);
    --pc-panel: var(--d-pc-panel); --pc-panel-2: var(--d-pc-panel-2);
    --pc-card: var(--d-pc-card); --pc-card-2: var(--d-pc-card-2);
    --pc-card-hover: var(--d-pc-card-hover); --pc-divider: var(--d-pc-divider);
    --pc-me-bg: var(--d-pc-me-bg); --pc-accent: var(--d-pc-accent);
    --pc-heading: var(--d-pc-heading); --pc-emboss: var(--d-pc-emboss);
    --img-filter: var(--d-img-filter);
  }
}

:root[data-theme="dark"] {
  color-scheme: dark;
    --screen-glow: var(--d-screen-glow); --gloss: var(--d-gloss);
  --desk-1: var(--d-desk-1); --desk-2: var(--d-desk-2); --desk-3: var(--d-desk-3);
  --pc-page: var(--d-pc-page); --pc-rule: var(--d-pc-rule);
  --pc-chrome: var(--d-pc-chrome); --pc-chrome-hi: var(--d-pc-chrome-hi);
  --pc-line: var(--d-pc-line); --pc-ink: var(--d-pc-ink);
  --pc-ink-soft: var(--d-pc-ink-soft); --pc-ink-faint: var(--d-pc-ink-faint);
  --pc-sys: var(--d-pc-sys); --pc-sys-ink: var(--d-pc-sys-ink);
  --pc-panel: var(--d-pc-panel); --pc-panel-2: var(--d-pc-panel-2);
  --pc-card: var(--d-pc-card); --pc-card-2: var(--d-pc-card-2);
  --pc-card-hover: var(--d-pc-card-hover); --pc-divider: var(--d-pc-divider);
  --pc-me-bg: var(--d-pc-me-bg); --pc-accent: var(--d-pc-accent);
  --pc-heading: var(--d-pc-heading); --pc-emboss: var(--d-pc-emboss);
  --img-filter: var(--d-img-filter);
}

/* ---- the shells the DS actually shipped in ---- */
:root[data-shell="onyx"] {
  --plastic: #35373d; --plastic-hi: #4b4e56; --plastic-lo: #212327;
  --plastic-edge: #131418; --brand-ink: #8c909b;
  --btn-hi: #7c808a; --btn-lo: #585c66; --btn-edge: #2c2e34;
}
:root[data-shell="cobalt"] {
  --plastic: #2f5fb0; --plastic-hi: #4d7ed4; --plastic-lo: #21437c;
  --plastic-edge: #16305a; --brand-ink: #bdd1f0;
  --btn-hi: #7f9fd4; --btn-lo: #4b6ba6; --btn-edge: #1d3a66;
}
:root[data-shell="crimson"] {
  --plastic: #b23440; --plastic-hi: #d45b66; --plastic-lo: #85222c;
  --plastic-edge: #5d161e; --brand-ink: #f3c8cc;
  --btn-hi: #c9848c; --btn-lo: #9a5058; --btn-edge: #4f1a20;
}
:root[data-shell="candy"] {
  --plastic: #e480ac; --plastic-hi: #f4a7c8; --plastic-lo: #bd5f8a;
  --plastic-edge: #8f4265; --brand-ink: #ffffff;
  --btn-hi: #d996b4; --btn-lo: #a96385; --btn-edge: #7a3c58;
}
:root[data-shell="turquoise"] {
  --plastic: #2fa39c; --plastic-hi: #56c6bf; --plastic-lo: #1f7a74;
  --plastic-edge: #145651; --brand-ink: #d3f2ef;
  --btn-hi: #74bdb8; --btn-lo: #48857f; --btn-edge: #17514c;
}

* { box-sizing: border-box; }

/* Our own display rules outrank the UA [hidden] rule, so restate it. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  min-height: 100%;
  /* Drawing near the top of the canvas shouldn't pull-to-refresh the page. */
  overscroll-behavior-y: contain;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  color: var(--pc-ink);
  background:
    radial-gradient(120% 80% at 50% 0%, var(--desk-1) 0%, var(--desk-2) 55%, var(--desk-3) 100%);
}

/* ------------------------------- console ------------------------------- */

.ds {
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  justify-content: safe center;
  gap: 0;
  padding: 12px;
}

.ds-half {
  position: relative;
  display: flex;
  align-items: stretch;
  justify-content: center;
  gap: 0;
  padding: var(--bezel);
  background: linear-gradient(180deg, var(--plastic-hi), var(--plastic) 42%, var(--plastic-lo));
  border: 1px solid var(--plastic-edge);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, .65),
    inset 0 -1px 0 rgba(0, 0, 0, .28),
    inset 6px 0 14px -8px rgba(0, 0, 0, .35),
    inset -6px 0 14px -8px rgba(0, 0, 0, .35),
    0 18px 42px -14px rgba(0, 0, 0, .75),
    0 10px 24px rgba(0, 0, 0, .45);
}

/* Moulded-plastic speckle. Decoration only - never eat a pointer event. */
.ds-half::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  border-radius: inherit;
  opacity: .085;
  background-image:
    radial-gradient(rgba(255, 255, 255, .9) .5px, transparent .6px),
    radial-gradient(rgba(0, 0, 0, .85) .5px, transparent .6px);
  background-size: 5px 5px, 7px 7px;
  background-position: 0 0, 2px 3px;
}
.ds-half > * { position: relative; z-index: 1; }

.ds-half--top {
  border-radius: 16px 16px 5px 5px;
  padding-bottom: calc(var(--bezel) + 2px);
}

.ds-half--bottom {
  border-radius: 5px 5px 18px 18px;
  padding-top: calc(var(--bezel) + 2px);
}


.ds-side {
  flex: 0 0 var(--side);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 4px;
}

.ds-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: .16em;
  line-height: 1.25;
  color: var(--brand-ink);
  text-shadow: 0 -1px 0 rgba(0, 0, 0, .45), 0 1px 0 rgba(255, 255, 255, .30);
  opacity: .92;
}

.ds-speaker {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background-image: radial-gradient(circle at 50% 50%, rgba(0, 0, 0, .40) 0 1.05px, transparent 1.15px);
  background-size: 6px 6px;
  background-position: 1px 1px;
  box-shadow:
    inset 0 1px 3px rgba(0, 0, 0, .30),
    inset 0 -1px 0 rgba(255, 255, 255, .22),
    0 1px 0 rgba(255, 255, 255, .28);
  opacity: .9;
}

.ds-led {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #7bd47b;
  box-shadow: 0 0 7px #6ddc6d, inset 0 -1px 2px rgba(0, 0, 0, .35);
  transition: background .2s, box-shadow .2s;
  animation: led-breathe 3.8s ease-in-out infinite;
}
@keyframes led-breathe {
  50% { box-shadow: 0 0 13px #7bec7b, inset 0 -1px 2px rgba(0, 0, 0, .35); }
}
.ds-led[data-state="off"] { background: #b03b3b; box-shadow: 0 0 7px #d24d4d; }
.ds-led[data-state="wait"] { background: #e0b52a; box-shadow: 0 0 7px #e8c85a; }

.ds-hinge {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: calc(var(--screen-w) * .58);
  height: 14px;
  margin: -1px 0;
  padding: 0;
  z-index: 3;
}
.ds-hinge__barrel {
  flex: 0 0 32%;
  height: 100%;
  border-radius: 2px;
  position: relative;
  background: linear-gradient(180deg, var(--plastic-lo), var(--plastic-hi) 38%, var(--plastic) 62%, var(--plastic-lo));
  border: 1px solid var(--plastic-edge);
  border-top: 0;
  border-bottom: 0;
  box-shadow: inset 1px 0 0 rgba(255, 255, 255, .5), inset -1px 0 0 rgba(0, 0, 0, .18);
}
.ds-hinge__barrel::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 4px;
  height: 4px;
  margin: -2px 0 0 -2px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 35%, rgba(255, 255, 255, .55), rgba(0, 0, 0, .45));
  opacity: .55;
}
.ds-hinge__gap { flex: 1 1 auto; }

/* screens ---------------------------------------------------------------- */

.screen {
  position: relative;
  width: var(--screen-w);
  height: var(--screen-h);
  touch-action: manipulation;
  flex: 0 0 auto;
  overflow: hidden;
  background: var(--pc-page);
  border-radius: 3px;
  outline: var(--bezel) solid var(--bezel-color);
  outline-offset: 0;
  box-shadow:
    0 0 0 calc(var(--bezel) + 1px) #14151a,
    0 0 38px -4px var(--screen-glow),
    inset 0 0 22px rgba(40, 60, 90, .13);
}

/* Glass. Sits over everything on the screen, including Excalidraw's own UI,
   and must stay click-through or it would swallow every stroke. */
.screen::after {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 30;
  pointer-events: none;
  background:
    linear-gradient(114deg, var(--gloss) 0 5%, rgba(255, 255, 255, .035) 11%, transparent 21%),
    radial-gradient(120% 42% at 50% -18%, var(--gloss), transparent 62%);
}

/* A whisper of LCD texture, on the log only - over the canvas it would just
   sit in the way of the drawing. */
.screen--top::before {
  content: "";
  position: absolute;
  inset: 0;
  z-index: 29;
  pointer-events: none;
  opacity: .32;
  background: repeating-linear-gradient(180deg, rgba(60, 80, 110, .045) 0 1px, transparent 1px 3px);
}

/* Backlight kicking in when you join a room. */
.screen-flash {
  position: absolute;
  inset: 0;
  z-index: 31;
  pointer-events: none;
  opacity: 0;
  background: linear-gradient(180deg, #fff, rgba(255, 255, 255, .35));
}
.ds.is-booting .screen-flash { animation: screen-boot .55s ease-out; }
@keyframes screen-boot {
  0% { opacity: .85; }
  35% { opacity: .35; }
  100% { opacity: 0; }
}

/* Same size as the top screen everywhere except phones, where the drawing
   screen gets the lion's share of the height. Must come after `.screen`. */
.screen--bottom { height: var(--screen-h2); }

/* ------------------------- top screen: the log ------------------------- */

.pc-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 24px;
  padding: 0 8px;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .02em;
  color: var(--pc-heading);
  background: linear-gradient(180deg, var(--pc-chrome-hi), var(--pc-chrome));
  border-bottom: 1px solid var(--pc-line);
}
.pc-bar__spacer { flex: 1 1 auto; }
.pc-bar__people { font-variant-numeric: tabular-nums; font-weight: 600; }
.pc-bar__clock { font-variant-numeric: tabular-nums; font-weight: 600; }
.pc-bar__wifi { display: inline-flex; align-items: flex-end; gap: 1px; height: 11px; }
.pc-bar__wifi i {
  width: 3px;
  background: var(--pc-ink-faint);
  border-radius: 1px;
}
.pc-bar__wifi i:nth-child(1) { height: 4px; }
.pc-bar__wifi i:nth-child(2) { height: 7px; }
.pc-bar__wifi i:nth-child(3) { height: 10px; }
.pc-bar__wifi[data-on="1"] i { background: var(--pc-accent); }

.pc-log {
  list-style: none;
  margin: 0;
  padding: 0;
  height: calc(100% - 24px);
  overflow-y: auto;
  overscroll-behavior: contain;
  background:
    repeating-linear-gradient(180deg, transparent 0 23px, var(--pc-rule) 23px 24px),
    var(--pc-page);
  scrollbar-width: thin;
}

.entry {
  display: flex;
  align-items: flex-start;
  gap: 7px;
  padding: 7px 8px;
  border-bottom: 1px dashed var(--pc-divider);
  animation: entry-in .18s ease-out;
}
@keyframes entry-in { from { opacity: 0; transform: translateY(4px); } }
@media (prefers-reduced-motion: reduce) {
  .entry, .ds-led, .ds.is-booting .screen-flash { animation: none; }
}

.entry__tag {
  flex: 0 0 auto;
  max-width: 84px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  padding: 3px 6px;
  border-radius: 4px;
  background: var(--tag, #8c8f94);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  line-height: 1.2;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .35);
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18), 0 1px 1px rgba(0, 0, 0, .15);
}

.entry__strip { flex: 1 1 auto; min-width: 0; }
.entry__strip img {
  display: block;
  max-width: 100%;
  max-height: 190px; /* messages are a whole page now, so give them room */
  object-fit: contain;
  object-position: left center;
  filter: var(--img-filter);
}
.entry__copy {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  display: grid;
  place-items: center;
  padding: 0;
  font: inherit;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  color: var(--pc-ink-soft);
  background: var(--pc-card);
  border: 1px solid var(--pc-line);
  border-radius: 5px;
  opacity: .45;
  transition: opacity .12s, color .12s;
}
.entry:hover .entry__copy, .entry__copy:focus-visible { opacity: 1; color: var(--pc-accent); }
.entry__copy:active { transform: translateY(1px); }

.entry__anim {
  flex: 0 0 auto;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .04em;
  color: var(--pc-accent);
  border: 1px solid var(--pc-accent);
  border-radius: 4px;
  padding: 1px 3px;
  align-self: center;
}

.entry__time {
  flex: 0 0 auto;
  font-size: 10px;
  color: var(--pc-ink-faint);
  font-variant-numeric: tabular-nums;
  padding-top: 4px;
}

.entry--me { background: var(--pc-me-bg); }
.entry--me .entry__tag {
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .18), 0 0 0 2px var(--pc-page), 0 0 0 3px var(--tag);
}

.entry--sys {
  justify-content: center;
  gap: 0;
  background: var(--pc-sys);
  color: var(--pc-sys-ink);
  font-size: 11px;
  font-style: italic;
  border-bottom: 1px solid var(--pc-divider);
}

.pc-empty {
  position: absolute;
  inset: 24px 0 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  text-align: center;
  color: var(--pc-ink-faint);
  font-size: 12px;
  pointer-events: none;
}
.pc-empty__title { margin: 0; font-size: 13px; font-weight: 700; color: var(--pc-ink-soft); }
.pc-empty p { margin: 0; }
.pc-empty b { color: var(--pc-ink); }

/* ----------------------- bottom screen: the lobby ---------------------- */

.pc-lobby {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 12px 14px;
  overflow-y: auto;
  background: linear-gradient(180deg, var(--pc-panel), var(--pc-panel-2));
}
.pc-lobby__head { text-align: center; }
.pc-lobby__head h1 {
  margin: 0;
  font-size: 20px;
  letter-spacing: .04em;
  color: var(--pc-heading);
  text-shadow: 0 1px 0 var(--pc-emboss);
}
.pc-lobby__head p { margin: 2px 0 0; font-size: 11px; color: var(--pc-ink-soft); }

.pc-field { display: flex; flex-direction: column; gap: 4px; }
.pc-field > span {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: .08em;
  text-transform: uppercase;
  color: var(--pc-ink-soft);
}
.pc-field input {
  font: inherit;
  font-size: 14px;
  padding: 5px 8px;
  border: 1px solid var(--pc-line);
  border-radius: 5px;
  background: var(--pc-card);
  color: var(--pc-ink);
}
.pc-field input:focus-visible { outline: 2px solid var(--pc-accent); outline-offset: 1px; }

.pc-swatches { display: grid; grid-template-columns: repeat(16, 1fr); gap: 3px; }
.pc-swatch {
  aspect-ratio: 1;
  border: 1px solid rgba(0, 0, 0, .25);
  border-radius: 3px;
  padding: 0;
  cursor: pointer;
  box-shadow: inset 0 -2px 0 rgba(0, 0, 0, .2);
}
.pc-swatch[aria-checked="true"] { box-shadow: 0 0 0 2px var(--pc-page), 0 0 0 3px var(--pc-accent); }

.pc-rooms { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; margin-top: 2px; }
.pc-room {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 14px 2px 11px;
  font: inherit;
  cursor: pointer;
  color: var(--pc-heading);
  background: linear-gradient(180deg, var(--pc-card), var(--pc-card-2));
  border: 1px solid var(--pc-line);
  border-radius: 7px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .10);
}
.pc-room:hover:not(:disabled) { background: linear-gradient(180deg, var(--pc-card), var(--pc-card-hover)); }
.pc-room:active:not(:disabled) { transform: translateY(1px); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .10); }
.pc-room:disabled { opacity: .5; cursor: not-allowed; }
.pc-room__letter { font-size: 24px; font-weight: 800; line-height: 1; }
.pc-room__count { font-size: 10px; color: var(--pc-ink-soft); font-variant-numeric: tabular-nums; }

.pc-tips {
  margin: 6px 0 0;
  padding: 8px 10px 8px 24px;
  list-style: disc;
  font-size: 11px;
  line-height: 1.55;
  color: var(--pc-sys-ink);
  background: var(--pc-sys);
  border: 1px solid var(--pc-divider);
  border-radius: 6px;
}
.pc-tips b { color: var(--pc-ink); }

.pc-hint { margin: auto 0 0; text-align: center; font-size: 11px; color: var(--pc-ink-soft); }

/* ------------------- bottom screen: the drawing board ------------------ */

.pc-board {
  position: absolute;
  inset: 0;
  display: flex;
  background: var(--pc-panel);
}

.pc-canvas {
  flex: 1 1 auto;
  min-width: 0;
  position: relative;
  background: var(--pc-page);
  border-right: 1px solid var(--pc-line);
}
.pc-canvas .excalidraw { --ui-font: system-ui, sans-serif; }

.pc-tools {
  flex: 0 0 74px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 7px 6px;
  overflow-y: auto;
  scrollbar-width: thin;
  background: linear-gradient(180deg, var(--pc-chrome-hi), var(--pc-chrome));
}

.pc-btn {
  position: relative;
  padding: 8px 4px;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: .06em;
  color: var(--pc-heading);
  cursor: pointer;
  background: linear-gradient(180deg, var(--pc-card), var(--pc-card-2));
  border: 1px solid var(--pc-line);
  border-radius: 6px;
  box-shadow: inset 0 -3px 0 rgba(0, 0, 0, .10);
}
.pc-btn:hover { background: linear-gradient(180deg, var(--pc-card), var(--pc-card-hover)); }
.pc-btn:active, .pc-btn.is-pressed { transform: translateY(1px); box-shadow: inset 0 -1px 0 rgba(0, 0, 0, .10); }
.pc-btn__key {
  position: absolute;
  top: -5px;
  right: -5px;
  width: 15px;
  height: 15px;
  display: grid;
  place-items: center;
  font-size: 9px;
  color: #fff;
  background: #6b7789;
  border-radius: 50%;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .3);
}
.pc-btn--send {
  background: linear-gradient(180deg, var(--pc-accent-hi), var(--pc-accent));
  border-color: var(--pc-accent);
  color: #fff;
  text-shadow: 0 1px 1px rgba(0, 0, 0, .3);
}
.pc-btn--send:hover { filter: brightness(1.08); background: linear-gradient(180deg, var(--pc-accent-hi), var(--pc-accent)); }
.pc-btn--send .pc-btn__key { background: #1c4a8f; }
.pc-btn--leave { margin-top: auto; font-size: 10px; }

/* Minimal mode: Excalidraw's floating menus get out of the way of the paper.
   Selectors are 0.18's real ones - there is no .layer-ui__wrapper any more. */
.pc-canvas.is-minimal .excalidraw .FixedSideContainer,
.pc-canvas.is-minimal .excalidraw .App-bottom-bar,
.pc-canvas.is-minimal .excalidraw .App-menu,
.pc-canvas.is-minimal .excalidraw .HintViewer { display: none !important; }

.pc-mini { display: grid; grid-template-columns: repeat(2, 1fr); gap: 3px; }
.pc-icon {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  font: inherit;
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  color: var(--pc-heading);
  background: var(--pc-card);
  border: 1px solid var(--pc-line);
  border-radius: 5px;
}
.pc-icon:hover { background: var(--pc-card-hover); }
.pc-icon:active { transform: translateY(1px); }
.pc-icon[aria-pressed="true"] {
  color: #fff;
  background: var(--pc-accent);
  border-color: var(--pc-accent);
}

.pc-pens {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 3px;
}
.pc-pen {
  aspect-ratio: 1;
  display: grid;
  place-items: center;
  padding: 0;
  cursor: pointer;
  background: var(--pc-card);
  border: 1px solid var(--pc-line);
  border-radius: 5px;
}
.pc-pen i {
  display: block;
  border-radius: 50%;
  background: var(--pc-ink);
}
.pc-pen:hover { background: var(--pc-card-hover); }
.pc-pen[aria-checked="true"] {
  border-color: var(--pc-accent);
  box-shadow: inset 0 0 0 1px var(--pc-accent);
}

.pc-frames {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 3px;
  font-size: 10px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--pc-accent);
  background: var(--pc-card);
  border: 1px solid var(--pc-accent);
  border-radius: 5px;
}
/* One bar rather than a dot per frame: at a 24-frame cap the dots were ~190px
   wide and did not fit the toolbar on a phone. This is fixed-width at any cap. */
.pc-frames i {
  display: block;
  width: 34px;
  height: 5px;
  border-radius: 3px;
  background: color-mix(in srgb, var(--pc-accent) 25%, transparent);
  overflow: hidden;
}
.pc-frames i > b {
  display: block;
  height: 100%;
  border-radius: 3px;
  background: var(--pc-accent);
  transition: width 120ms ease-out;
}

.pc-roomtag {
  display: grid;
  place-items: center;
  gap: 0;
  padding: 3px 4px 4px;
  font-size: 18px;
  font-weight: 800;
  color: var(--pc-heading);
  background: var(--pc-card);
  border: 1px solid var(--pc-line);
  border-radius: 6px;
  line-height: 1;
}
.pc-roomtag small {
  font-size: 8px;
  font-weight: 700;
  letter-spacing: .1em;
  color: var(--pc-ink-soft);
}

.pc-toast {
  position: absolute;
  left: 50%;
  bottom: 10px;
  transform: translateX(-50%);
  max-width: 82%;
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  background: rgba(28, 34, 46, .92);
  border-radius: 999px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, .35);
  z-index: 20;
}

/* --------------------------- console controls -------------------------- */

.ds-dpad { position: relative; width: 58px; height: 58px; }
.ds-dpad__btn, .ds-dpad__mid {
  position: absolute;
  background: linear-gradient(180deg, var(--btn-hi), var(--btn-lo));
  border: 1px solid var(--btn-edge);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .18);
  padding: 0;
  cursor: pointer;
}
.ds-dpad__mid { left: 19px; top: 19px; width: 20px; height: 20px; cursor: default; }
.ds-dpad__btn { left: 19px; width: 20px; height: 20px; }
.ds-dpad__btn--up { top: 0; border-radius: 4px 4px 0 0; }
.ds-dpad__btn--down { top: 38px; border-radius: 0 0 4px 4px; }
.ds-dpad::before, .ds-dpad::after {
  content: "";
  position: absolute;
  top: 19px;
  width: 20px;
  height: 20px;
  background: linear-gradient(180deg, var(--btn-hi), var(--btn-lo));
  border: 1px solid var(--btn-edge);
}
.ds-dpad::before { left: 0; border-radius: 4px 0 0 4px; }
.ds-dpad::after { left: 38px; border-radius: 0 4px 4px 0; }
.ds-dpad__btn:active { filter: brightness(1.25); }

.ds-face { position: relative; width: 58px; height: 58px; }
.ds-face__btn {
  position: absolute;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  font: inherit;
  font-size: 11px;
  font-weight: 800;
  color: var(--btn-ink);
  cursor: pointer;
  background:
    radial-gradient(120% 90% at 50% 10%, rgba(255, 255, 255, .30), transparent 55%),
    linear-gradient(180deg, var(--btn-hi), var(--btn-lo));
  border: 1px solid var(--btn-edge);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .25), 0 2px 4px -1px rgba(0, 0, 0, .45);
}
.ds-face__btn:active, .ds-face__btn.is-pressed {
  filter: brightness(1.3);
  transform: translateY(1px);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, .45);
}
.ds-face__btn--a { right: 0; top: 17px; }
.ds-face__btn--b { right: 17px; top: 34px; }

.ds-power {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: linear-gradient(180deg, var(--btn-hi), var(--btn-lo));
  border: 1px solid var(--btn-edge);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, .2);
}

.ds-mic {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .38);
  box-shadow: inset 0 1px 1px rgba(0, 0, 0, .55), 0 1px 0 rgba(255, 255, 255, .25);
}

.ds-pills { display: flex; flex-direction: column; gap: 4px; align-items: center; }
.ds-pill {
  width: 34px;
  height: 11px;
  border-radius: 999px;
  background: linear-gradient(180deg, var(--btn-hi), var(--btn-lo));
  border: 1px solid var(--btn-edge);
  font-size: 7px;
  letter-spacing: .04em;
  color: var(--btn-ink);
  display: grid;
  place-items: center;
}

/* ------------------------- the shelf it sits on ------------------------ */

.ds-shelf {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 8px 16px;
  margin-top: 10px;
  padding: 8px 12px;
  font-size: 11px;
  color: #8b93a3;
  /* At Large/Huge the console outgrows the window, so the controls that got you
     there have to stay reachable. */
  position: sticky;
  bottom: 0;
  z-index: 5;
  background: linear-gradient(to top, rgba(8, 9, 12, .94), rgba(8, 9, 12, .78) 65%, rgba(8, 9, 12, 0));
}

.shelf-group { display: flex; align-items: center; gap: 6px; }
.shelf-label {
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;

  color: #798090;
}

.shell-swatches { display: flex; gap: 4px; }
.shell-swatch {
  width: 16px;
  height: 16px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .45);
  cursor: pointer;
  box-shadow: inset 0 -3px 4px -2px rgba(0, 0, 0, .5), inset 0 2px 3px -1px rgba(255, 255, 255, .55);
}
.shell-swatch[aria-checked="true"] {
  box-shadow: 0 0 0 2px var(--desk-3), 0 0 0 3px #93a1b5,
    inset 0 -3px 4px -2px rgba(0, 0, 0, .5);
}

.seg { display: flex; border: 1px solid #4a5160; border-radius: 999px; overflow: hidden; }
.seg button {
  font: inherit;
  font-size: 10px;
  padding: 3px 9px;
  border: 0;
  cursor: pointer;
  background: transparent;
  color: #98a1b1;
}
.seg button + button { border-left: 1px solid #4a5160; }
.seg button[aria-checked="true"] { background: #4a5160; color: #f2f5fa; }
.seg button:hover:not([aria-checked="true"]) { color: #cfd6e2; }

.shelf-note { display: flex; gap: 8px; }
.shelf-note span[aria-hidden] { opacity: .4; }

@media (max-width: 900px) {
  :root { --side: 62px; --bezel: 8px; }
  .ds-dpad, .ds-face { width: 46px; height: 46px; }
  .pc-tools { flex-basis: 62px; }
}

/* ------------------------------- phones -------------------------------- */
/* The D-pad and speaker grills are decoration; on a narrow screen they were
   costing a third of the width that the canvas needed. The log shrinks to a
   glance-able strip and the drawing screen takes everything that is left. */
@media (max-width: 640px) {
  :root { --bezel: 6px; }

  .ds { padding: 6px; justify-content: flex-start; }
  .ds-side { display: none; }
  .ds-hinge { width: 60%; }

  .pc-tools {
    flex-basis: 58px;
    gap: 5px;
    padding: 5px 4px;
  }
  .pc-btn { padding: 7px 2px; font-size: 10px; letter-spacing: .02em; }
  .pc-btn__key { display: none; }
  .pc-pens { grid-template-columns: repeat(2, 1fr); }
  .pc-roomtag { font-size: 15px; padding: 2px 3px 3px; }
  .pc-btn--leave { font-size: 9px; }

  .pc-lobby { padding: 10px 11px; gap: 7px; }
  .pc-lobby__head h1 { font-size: 17px; }
  .pc-tips { display: none; }
  .pc-swatches { grid-template-columns: repeat(8, 1fr); }

  .entry__strip img { max-height: 130px; }

  /* Sticky would eat the little vertical room a phone has. */
  .ds-shelf {
    position: static;
    background: none;
    gap: 6px 10px;
    padding: 8px 4px 4px;
    font-size: 10px;
  }
  .shelf-note { display: none; }
  .seg button { padding: 4px 8px; }
  .shell-swatch { width: 18px; height: 18px; }
}

/* Touch targets shouldn't wait 300ms or zoom the page on a double tap. */
button, .seg, .pc-swatch, .shell-swatch { touch-action: manipulation; }

/* ------------------- top screen while you're in the lobby ------------------ */

.pc-lobbytop {
  position: absolute;
  inset: 24px 0 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  padding: 14px 18px;
  background: linear-gradient(180deg, var(--pc-panel), var(--pc-panel-2));
}
.pc-lobbytop h2 {
  margin: 0;
  font-size: 22px;
  letter-spacing: .06em;
  color: var(--pc-heading);
  text-shadow: 0 1px 0 var(--pc-emboss);
}
.pc-lobbytop__sub { margin: 0 0 8px; font-size: 11px; color: var(--pc-ink-soft); }
.pc-lobbytop__list {
  list-style: none;
  margin: 0;
  padding: 0;
  width: min(100%, 300px);
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.pc-lobbytop__list li {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 8px;
  font-size: 12px;
  color: var(--pc-heading);
  background: var(--pc-card);
  border: 1px solid var(--pc-line);
  border-radius: 5px;
}
.pc-lobbytop__letter { font-weight: 800; width: 14px; }
.pc-lobbytop__bar {
  flex: 1 1 auto;
  height: 6px;
  border-radius: 3px;
  background: var(--pc-card-2);
  overflow: hidden;
}
.pc-lobbytop__bar i { display: block; height: 100%; background: var(--pc-accent); }
.pc-lobbytop__n { font-size: 11px; color: var(--pc-ink-soft); font-variant-numeric: tabular-nums; }
