/* =====================================================================
   SchoolDays — UI design system
   Cozy school life · minimal · the scene is the star.
   One file, in this order: tokens → base → primitives → HUD → sidebar
   (chat + room music) → overlays (modals, popovers, toasts) → entry → responsive.
   Every id/class here is referenced by index.html or created by game.js.
   ===================================================================== */

/* ---------- 1. tokens ---------- */
:root {
  /* colour: warm paper + brick-red school accent */
  --paper: #f3ece0;          /* page */
  --surface: #fffcf7;        /* cards, panels */
  --surface-2: #f7f0e5;      /* insets, hover rows */
  --surface-glass: rgba(255, 252, 247, .9);
  --ink: #3b2a1a;            /* main text */
  --ink-2: #7a6650;          /* secondary text */
  --ink-3: #a8957d;          /* hints, disabled */
  --line: #ebdfcd;
  --line-strong: #dccab1;
  --accent: #c8553d;
  --accent-hover: #b0472f;
  --accent-soft: #fbe6da;
  --accent-line: #efc4b2;
  --wood: #4d3a2c;           /* radio / on-air */
  --wood-2: #6c5542;
  --gold: #d3a531;
  --live: #4fa868;
  --notice: #fff6e3;
  --notice-line: #f0d08a;
  --scrim: rgba(42, 31, 22, .42);

  /* shape */
  --r-xs: 8px; --r-sm: 10px; --r-md: 14px; --r-lg: 18px; --r-xl: 24px; --r-pill: 999px;
  /* space */
  --s-1: 4px; --s-2: 8px; --s-3: 12px; --s-4: 16px; --s-5: 20px; --s-6: 24px;
  /* type */
  --font: 'Prompt', system-ui, sans-serif;
  --fs-xs: 11px; --fs-sm: 12.5px; --fs-md: 14px; --fs-lg: 16px; --fs-xl: 19px;
  /* depth */
  --shadow-1: 0 2px 8px rgba(60, 40, 20, .08);
  --shadow-2: 0 8px 24px rgba(60, 40, 20, .11);
  --shadow-3: 0 24px 64px rgba(60, 35, 15, .22);
  --ring: 0 0 0 3px rgba(200, 85, 61, .18);
  --blur: blur(12px);
  --ease: .16s ease;

  /* layout */
  --gutter: 14px;            /* space inside the scene card, around HUD groups */
  --frame: 14px;             /* space around the scene card and the sidebar cards */
  --scene-right: calc(var(--sidebar-w) + var(--frame)); /* scene card's distance from the right edge */
  --scene-bg: #efe7da;       /* the current room's edge colour, set by game.js */
  --hud-h: 44px;
  --sidebar-w: clamp(320px, 28vw, 400px);
}

/* ---------- 2. base ---------- */
* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; background: var(--paper); color: var(--ink); font-family: var(--font); }
body { overflow: hidden; }
button, input, textarea, select { font: inherit; color: inherit; }
button { cursor: pointer; -webkit-tap-highlight-color: transparent; }
button:disabled { cursor: not-allowed; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
::selection { color: var(--ink); background: #f3cdbb; }
* { scrollbar-width: thin; scrollbar-color: var(--line-strong) transparent; }
*::-webkit-scrollbar { width: 7px; height: 7px; }
*::-webkit-scrollbar-thumb { background: var(--line-strong); border-radius: var(--r-pill); }
.hidden { display: none !important; }

/* ---------- 3. primitives ---------- */
/* text inputs share one look everywhere */
.field, #chatInput, .w-form input, .r-panel input, .r-panel textarea, .entry-card input {
  width: 100%; min-width: 0; padding: 10px 13px; font-size: var(--fs-md);
  background: #fff; border: 1px solid var(--line); border-radius: var(--r-md);
  outline: none; transition: border-color var(--ease), box-shadow var(--ease);
}
.field:focus, #chatInput:focus, .w-form input:focus, .r-panel input:focus,
.r-panel textarea:focus, .entry-card input:focus { border-color: var(--accent); box-shadow: var(--ring); }
input[type=range] { accent-color: var(--accent); }

/* buttons: primary (filled), secondary (outlined), icon (round, quiet) */
.btn, .entry-go, .class-row .join, .w-form button, .notice button, .send {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  border: 0; border-radius: var(--r-md); padding: 9px 16px;
  font-weight: 600; font-size: var(--fs-md); background: var(--accent); color: #fff;
  transition: background-color var(--ease), transform var(--ease), box-shadow var(--ease);
}
.btn:hover, .entry-go:hover, .class-row .join:hover, .w-form button:hover, .notice button:hover, .send:hover { background: var(--accent-hover); }
.btn:active, .entry-go:active, .class-row .join:active, .send:active { transform: translateY(1px); }
.btn.big, .entry-go { width: 100%; min-height: 46px; font-size: var(--fs-lg); }
.btn-secondary, .notice button.ghost { background: #fff; color: var(--ink); border: 1px solid var(--line); }
.btn-secondary:hover, .notice button.ghost:hover { background: var(--surface-2); border-color: var(--line-strong); }
.class-row .join:disabled { background: var(--surface-2); color: var(--ink-3); }

.icon-btn, .close-btn, .modal-head button, .fold {
  display: inline-grid; place-items: center; flex: none;
  width: 36px; height: 36px; padding: 0; border-radius: var(--r-pill);
  border: 1px solid transparent; background: transparent; color: var(--ink); font-size: 16px; line-height: 1;
  transition: background-color var(--ease), border-color var(--ease);
}
.icon-btn:hover, .close-btn:hover, .modal-head button:hover, .fold:hover { background: var(--surface-2); }
.close-btn, .modal-head button, .fold { width: 30px; height: 30px; font-size: 13px; background: var(--surface-2); }
.close-btn:hover, .modal-head button:hover, .fold:hover { background: var(--accent-soft); color: var(--accent); }

.link { border: 0; background: none; padding: 0; color: var(--accent); text-decoration: underline; }
.chip-btn {
  border: 1.5px solid var(--line); background: #fff; border-radius: var(--r-pill);
  padding: 4px 12px; font-size: 13px; transition: background-color var(--ease), border-color var(--ease);
}
.chip-btn:hover { border-color: var(--line-strong); }
.chip-btn.on { background: var(--ink); color: #fff; border-color: var(--ink); }

/* a floating glass surface used by every HUD group */
.hud-surface, .room-switch, .place-btn, .top-actions {
  background: var(--surface-glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid rgba(59, 42, 26, .08); box-shadow: var(--shadow-1);
}

/* ---------- 4. scene + HUD ---------- */
#app { position: fixed; inset: 0; }
/* the scene is a card of its own; the school picture sits centred inside it */
#game {
  position: fixed; top: var(--frame); left: var(--frame); display: block; touch-action: none;
  width: calc(100% - var(--scene-right) - var(--frame)); height: calc(100% - 2 * var(--frame));
  background: var(--scene-bg); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
}

.hud-top {
  position: fixed; z-index: 5; top: calc(var(--frame) + var(--gutter)); left: calc(var(--frame) + var(--gutter)); right: calc(var(--scene-right) + var(--gutter));
  display: flex; justify-content: space-between; align-items: flex-start; gap: var(--s-2); pointer-events: none;
}
.hud-top > * { pointer-events: auto; }
.hud-left { display: flex; align-items: flex-start; gap: var(--s-2); min-width: 0; }

/* 🔀 switch room: hop to another open classroom, or open a new one */
.room-switch {
  display: inline-flex; align-items: center; gap: 7px; height: var(--hud-h); padding: 0 14px 0 12px; flex: none;
  border-radius: var(--r-pill); color: var(--ink); font-weight: 600; font-size: var(--fs-md); white-space: nowrap;
  transition: border-color var(--ease), box-shadow var(--ease), transform var(--ease);
}
.room-switch:hover { border-color: var(--accent-line); }
.room-switch:active { transform: translateY(1px); }
.room-switch:disabled { opacity: .6; cursor: progress; }
/* 🔒 classroom lock, beside the room name above the chat */
.room-lock { display: inline-flex; align-items: center; gap: 4px; height: 30px; padding: 0 8px; border: 1px solid var(--line); border-radius: var(--r-pill); background: #fff; color: var(--ink-2); font-size: 12px; font-weight: 600; cursor: pointer; white-space: nowrap; }
.room-lock .ui-ico { width: 18px; height: 18px; }
.room-lock:hover { border-color: var(--accent-line); color: var(--accent); }
.room-lock.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.room-lock.hidden { display: none; }
/* classroom look picker (under the "แบบห้อง" button) */
.chat-tools { position: relative; }
.look-menu {
  position: absolute; z-index: 20; top: calc(100% + 6px); right: 0; min-width: 200px; display: flex; flex-direction: column; gap: 2px; padding: 6px;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-md); box-shadow: var(--shadow-2);
}
.look-menu.hidden { display: none; }
#lookBtn, #inviteRoomBtn { padding: 0 7px; }   /* icon only (the title says what each does): the head row is full with table and lock */
#lookBtn .room-lock-label, #inviteRoomBtn .room-lock-label { display: none; }
.look-menu button { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 0; border-radius: 10px; background: transparent; color: var(--ink); font: inherit; font-size: 14px; text-align: left; cursor: pointer; }
.look-menu button:hover { background: var(--accent-soft, #f3ece4); }
.look-menu button.on { font-weight: 700; color: var(--accent); }
.look-menu button.on::after { content: '✓'; margin-left: auto; }
.chat-panel.folded .room-lock { display: none; }
/* 🚪 leave the classroom: the one HUD button with a filled colour, so it is easy to find */
.room-leave {
  display: inline-flex; align-items: center; gap: 6px; height: var(--hud-h); padding: 0 14px 0 11px; flex: none;
  border: 0; border-radius: var(--r-pill); background: var(--accent); color: #fff; font-weight: 700; font-size: var(--fs-md);
  white-space: nowrap; box-shadow: var(--shadow-1); transition: filter var(--ease), transform var(--ease);
}
.room-leave:hover { filter: brightness(1.06); }
.room-leave:active { transform: translateY(1px); }
/* 🏫 open / join a classroom: always on the HUD, so nobody has to dig through the place picker */
.class-hud {
  display: inline-flex; align-items: center; gap: 6px; height: var(--hud-h); padding: 0 14px 0 11px; flex: none;
  border: 1.5px solid var(--accent-line); border-radius: var(--r-pill); background: var(--accent-soft); color: var(--accent);
  font-weight: 700; font-size: var(--fs-md); white-space: nowrap; box-shadow: var(--shadow-1); transition: filter var(--ease), transform var(--ease);
}
.class-hud:hover { filter: brightness(1.04); }
.class-hud:active { transform: translateY(1px); }
.class-hud-short { display: none; }

.place-nav { position: relative; min-width: 0; }
.place-btn {
  display: inline-flex; align-items: center; gap: 8px; height: var(--hud-h); max-width: 100%;
  padding: 0 12px 0 14px; border-radius: var(--r-pill); font-size: var(--fs-md);
  transition: border-color var(--ease), box-shadow var(--ease);
}
.place-btn b { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.place-btn .caret { color: var(--ink-2); font-size: 12px; transition: transform var(--ease); }
.place-btn[aria-expanded=true] { border-color: var(--accent-line); box-shadow: var(--ring); }
.place-btn[aria-expanded=true] .caret { transform: rotate(180deg); }
.place-btn:hover { border-color: var(--accent-line); }

.top-actions {
  display: flex; align-items: center; gap: 2px; height: var(--hud-h); padding: 0 4px; border-radius: var(--r-pill); flex: none;
}
.stat {
  display: inline-flex; align-items: center; gap: 5px; height: 36px; padding: 0 10px;
  border: 0; border-radius: var(--r-pill); background: transparent;
  font-weight: 600; font-size: var(--fs-md); color: var(--ink); font-variant-numeric: tabular-nums;
}
button.stat:hover { background: var(--surface-2); }
.hud-sep { width: 1px; height: 20px; background: var(--line-strong); margin: 0 4px; }
.icon-label { display: none; }
/* pastel 3D icons (public/art/ui/icons, cut from the icon sheet); sized per spot below */
.ui-ico { display: inline-block; width: 1.3em; height: 1.3em; object-fit: contain; vertical-align: -.3em; flex: none; pointer-events: none; user-select: none; }
.icon-btn .ui-ico { width: 26px; height: 26px; }
.stat .ui-ico { width: 22px; height: 22px; }
.room-switch .ui-ico { width: 22px; height: 22px; }
.modal-head .ui-ico, .popover-head .ui-ico { width: 24px; height: 24px; vertical-align: -.35em; margin-right: 2px; }
.r-opt span .ui-ico { width: 30px; height: 30px; }
.chat-tool-btn .ui-ico { width: 20px; height: 20px; }
/* top-bar buttons are icon-only; the radio shows a red dot while something is on air, and the mail button a count */
.icon-btn { position: relative; }
.hud-dot { position: absolute; top: 2px; right: 2px; min-width: 9px; height: 9px; border-radius: 99px; background: #e5484d; box-shadow: 0 0 0 2px var(--surface); pointer-events: none; }
.radio-btn.on-air .hud-dot { animation: onair 1.6s ease-in-out infinite; }
@keyframes onair { 50% { transform: scale(1.35); opacity: .7; } }
.hud-badge { position: absolute; top: -1px; right: -2px; min-width: 16px; height: 16px; padding: 0 4px; border-radius: 99px; background: #e5484d; color: #fff; font-size: 10px; font-weight: 700; line-height: 16px; text-align: center; box-shadow: 0 0 0 2px var(--surface); pointer-events: none; }

/* centred status stack: marquee, ON AIR bar, radio notice, toasts */
.hud-center {
  position: fixed; z-index: 4; top: calc(var(--frame) + var(--gutter) + var(--hud-h) + 10px);
  left: calc((100% - var(--sidebar-w)) / 2); transform: translateX(-50%);
  width: min(460px, calc(100% - var(--scene-right) - var(--frame) - 2 * var(--gutter)));
  display: flex; flex-direction: column; gap: 6px; pointer-events: none;
}
.hud-center > * { pointer-events: auto; }
/* GM events running now (fishing egg chance, fusion odds), with the time left */
.event-bar { display: flex; flex-direction: column; gap: 2px; padding: 5px 10px; font-size: var(--fs-sm); color: #4a2a6b;
  background: linear-gradient(90deg, #efe3ff, #ffe3f1); border: 1px solid #d7b8f2; border-radius: var(--r-md); box-shadow: var(--shadow-1); }
.event-bar small { color: #7a5a96; margin-left: 4px; }

.marquee {
  display: flex; align-items: center; gap: 8px; overflow: hidden; padding: 4px 6px;
  background: linear-gradient(90deg, #ffefc2, #ffe3b3); border: 1px solid #f2c86b; border-radius: var(--r-md); box-shadow: var(--shadow-1);
}
.mq-tag { flex: none; font-weight: 700; font-size: 12px; background: var(--accent); color: #fff; border-radius: var(--r-xs); padding: 2px 8px; }
.mq-track { flex: 1; overflow: hidden; white-space: nowrap; position: relative; height: 22px; }
#marqueeText { position: absolute; left: 0; top: 0; font-weight: 600; font-size: var(--fs-md); line-height: 22px; color: #5a3410; white-space: nowrap; }
@keyframes marquee { from { left: 100%; transform: translateX(0); } to { left: 0; transform: translateX(-100%); } }
.mq-wait { flex: none; font-size: var(--fs-xs); color: #8a5a20; }

.radio-bar {
  display: flex; align-items: center; gap: 8px; padding: 5px 6px 5px 8px;
  background: var(--wood); color: #fff; border-radius: var(--r-md); box-shadow: var(--shadow-2);
}
.onair { flex: none; font-weight: 700; font-size: var(--fs-xs); letter-spacing: .5px; background: var(--accent); border-radius: 6px; padding: 2px 7px; animation: blink 1.6s infinite; }
@keyframes blink { 50% { opacity: .55; } }
.radio-bar img { width: 40px; height: 30px; object-fit: cover; border-radius: 6px; flex: none; background: var(--wood-2); }
.r-info { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.25; }
.r-info b, .r-info small { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-info b { font-size: 13.5px; }
.r-info small { font-size: var(--fs-xs); color: #e7d8c8; }
.r-btn { flex: none; border: 0; border-radius: var(--r-pill); padding: 5px 12px; background: #fff; color: var(--wood); font-weight: 600; font-size: var(--fs-sm); }
.r-vol { width: 80px; flex: none; accent-color: #e7b36a; }

.notice {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap; gap: 8px;
  background: var(--notice); border: 1px solid var(--notice-line); border-radius: var(--r-md); padding: 8px 10px; font-size: 13px; box-shadow: var(--shadow-2);
}
.notice div { display: flex; gap: 6px; }
.tap-listen { align-self: center; border: 0; border-radius: var(--r-pill); background: var(--accent); color: #fff; font-weight: 700; font-size: var(--fs-sm); padding: 8px 16px; cursor: pointer; box-shadow: var(--shadow-2); animation: tap-listen-pulse 1.6s ease-in-out infinite; }
.tap-listen:hover { background: var(--accent-hover); }
@keyframes tap-listen-pulse { 50% { transform: scale(1.05); } }
.notice button { padding: 5px 10px; font-size: var(--fs-sm); border-radius: var(--r-sm); }

#toasts { display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none !important; }
/* notes shown while a window is open: their own layer above the windows (.modal is z-index 20) */
.toasts-top { position: fixed; z-index: 30; top: max(10px, env(safe-area-inset-top)); left: 50%; transform: translateX(-50%); width: min(460px, calc(100% - 24px));
  display: flex; flex-direction: column; gap: 6px; align-items: center; pointer-events: none; }
.toast {
  background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2);
  border-radius: var(--r-pill); padding: 6px 16px; font-weight: 600; font-size: var(--fs-md); animation: pop .25s ease-out;
  max-width: 100%; text-align: center;
}
@keyframes pop { from { transform: scale(.88); opacity: 0; } }

/* the classroom TV: YouTube needs at least 200px tall */
.tv {
  position: fixed; z-index: 3; right: calc(var(--scene-right) + var(--gutter)); top: calc(var(--frame) + var(--gutter) + var(--hud-h) + 10px);
  width: 356px; height: 200px; border-radius: var(--r-md); overflow: hidden;
  background: #111; border: 4px solid var(--wood); box-shadow: 0 8px 20px rgba(40, 25, 10, .3);
}
.tv.idle { display: none; }
/* phones only: what is playing, next to the docked video (see --tv-band) */
.tv-caption {
  display: none; position: fixed; z-index: 7; left: calc(var(--gutter) + 210px); right: var(--gutter); bottom: max(8px, env(safe-area-inset-bottom));
  height: 112px; flex-direction: column; justify-content: center; gap: 2px; min-width: 0; font-size: 13px; line-height: 1.4; color: var(--ink-2);
}
.tv-caption b { color: var(--ink); font-size: 14px; display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
/* taps never reach YouTube: tapping the video would play or pause it on this screen only, out of step with the room
   (play, pause and seeking go through the room's own buttons) */
.tv iframe { width: 100%; height: 100%; display: block; pointer-events: none; }
.tv-hide {
  position: absolute; top: 6px; right: 6px; width: 28px; height: 28px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(0, 0, 0, .55); color: #fff; font-size: 14px; line-height: 1; display: grid; place-items: center;
}
.tv-hide:hover { background: rgba(0, 0, 0, .8); }
/* video hidden: the player keeps playing, just invisible and out of the way (kept on screen at full size so phones keep playing it) */
.tv.tv-off:not(.idle) {
  left: 0 !important; right: auto !important; top: auto !important; bottom: 0 !important; width: 200px !important; height: 200px !important;
  z-index: 0 !important; opacity: 0; pointer-events: none; border: 0; box-shadow: none;
}

#hint {
  position: fixed; z-index: 4; bottom: calc(var(--frame) + 20px); left: calc((100% - var(--sidebar-w)) / 2); transform: translateX(-50%);
  background: var(--surface-glass); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--line); box-shadow: var(--shadow-2); border-radius: var(--r-pill);
  padding: 7px 16px; font-weight: 600; font-size: var(--fs-md); pointer-events: none; white-space: nowrap;
}
#actBtn {
  position: fixed; z-index: 4; right: calc(var(--scene-right) + var(--gutter)); bottom: calc(var(--frame) + var(--gutter)); width: 58px; height: 58px;
  border-radius: 50%; border: 0; background: var(--accent); color: #fff; font-weight: 700; font-size: 22px; box-shadow: var(--shadow-2);
}

/* ---------- 5. sidebar: chat card + classroom music card ---------- */
.social-sidebar {
  position: fixed; z-index: 6; top: 0; right: 0; bottom: 0; width: var(--sidebar-w);
  display: flex; flex-direction: column; gap: var(--s-3); padding: var(--frame) var(--frame) var(--frame) 0;
}
.social-chat-section { display: flex; flex-direction: column; flex: 1 1 auto; min-height: 0; }
.social-chat-section:has(.chat-panel.folded) { flex: 0 0 auto; }

.chat-panel, .float-widget {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-2);
}
.chat-panel { position: relative; display: flex; flex-direction: column; flex: 1; min-height: 0; overflow: hidden; padding: 10px 12px 12px; }
/* computer screens, classrooms: chat and room music are two tabs; each fills the whole panel */
.side-tabs { display: none; }
@media (min-width: 701px) {
  :root:not(.layout-yard) .social-sidebar.has-music .side-tabs { display: flex; flex: none; gap: 4px; padding: 4px; background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-pill); box-shadow: var(--shadow-1); }
  .side-tab { flex: 1; border: 0; background: transparent; border-radius: var(--r-pill); padding: 7px 10px; font-weight: 700; font-size: var(--fs-sm); color: var(--ink-2); cursor: pointer; position: relative; white-space: nowrap; }
  .side-tab:hover { color: var(--accent); }
  .side-tab.on { background: var(--accent); color: #fff; }
  .side-tab small { font-weight: 600; opacity: .85; }
  .side-tab.unread::after { content: ''; position: absolute; top: 6px; right: 12px; width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
  .side-tab.on.unread::after { display: none; }
  :root:not(.layout-yard) .social-sidebar.has-music:not(.music) #roomWidget { display: none; }
  :root:not(.layout-yard) .social-sidebar.has-music.music .social-chat-section { display: none; }
  :root:not(.layout-yard) .social-sidebar.has-music.music #roomWidget { flex: 1 1 auto; min-height: 0; max-height: none; overflow: hidden; }
  /* the music tab: now playing on top, the whole queue below it (no inner tabs) */
  :root:not(.layout-yard) .social-sidebar.has-music #roomWidget .w-top { display: none; }   /* the tab already names it */
  :root:not(.layout-yard) .social-sidebar.has-music #roomWidget .w-panes { display: flex; flex-direction: column; gap: 8px; flex: 1 1 auto; min-height: 0; }
  :root:not(.layout-yard) .social-sidebar.has-music #roomWidget .w-pane-now,
  :root:not(.layout-yard) .social-sidebar.has-music #roomWidget .w-list { visibility: visible; }
  :root:not(.layout-yard) .social-sidebar.has-music #roomWidget .w-list { contain: none; flex: 1 1 auto; min-height: 0; overflow-y: auto; }
}
/* reading older messages: new ones don't pull you down, this chip says they arrived */
.chat-new { position: absolute; z-index: 2; left: 50%; bottom: 72px; transform: translateX(-50%); border: 0; border-radius: var(--r-pill); background: var(--accent); color: #fff; font-weight: 700; font-size: var(--fs-sm); padding: 6px 14px; cursor: pointer; box-shadow: var(--shadow-2); white-space: nowrap; }
.chat-new:hover { background: var(--accent-hover); }
.chat-panel.folded .chat-new { display: none; }
.chat-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; flex: none; padding: 2px 2px 10px; border-bottom: 1px solid var(--line); }
.chat-title-row { display: flex; flex-direction: column; min-width: 0; flex: 1 1 110px; line-height: 1.3; }   /* too narrow for the room buttons too: they go on a row of their own */
.chat-title { font-weight: 700; font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.chat-sub { font-size: var(--fs-xs); color: var(--ink-2); white-space: nowrap; }
.chat-sub::before { content: ''; display: inline-block; width: 6px; height: 6px; margin-right: 5px; border-radius: 50%; background: var(--live); vertical-align: 1px; }
.chat-tools { display: flex; flex-wrap: wrap; justify-content: flex-end; align-items: center; gap: 4px; flex: 0 1 auto; margin-left: auto; }
/* new messages while folded: a dot on the unfold button */
.fold { position: relative; }
.fold.unread::after {
  content: ''; position: absolute; top: 0; right: 0; width: 9px; height: 9px; border-radius: 50%;
  background: var(--accent); box-shadow: 0 0 0 2px var(--surface);
}
/* moving between the yard and other places: the chat slides into its new spot */
.social-sidebar.chat-move { animation: chat-in .3s ease-out; }
@keyframes chat-in { from { opacity: 0; transform: translateY(12px); } }

.people { list-style: none; margin: 0; padding: 8px 0; display: flex; gap: 6px; overflow-x: auto; flex: none; border-bottom: 1px solid var(--line); }
.people li { flex: none; display: flex; align-items: center; gap: 6px; min-height: 28px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-pill); padding: 2px 10px 2px 2px; font-size: var(--fs-sm); }
.people img { width: 30px; height: 30px; object-fit: cover; object-position: top; border-radius: 50%; background: var(--accent-soft); }
.people li.me { border-color: var(--accent-line); background: var(--accent-soft); }
.people li.more { padding: 2px 10px; color: var(--ink-2); cursor: pointer; border-style: dashed; }
.people .star { border: 0; background: none; color: var(--ink-3); font-size: 15px; padding: 0 0 0 2px; line-height: 1; }
.people .star.on { color: var(--gold); }

.chat-log { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: 10px 0; display: flex; flex-direction: column; gap: 8px; }
.msg { display: flex; gap: 6px; align-items: flex-start; }
.msg > img { width: 36px; height: 36px; object-fit: cover; object-position: top; border-radius: 50%; background: var(--accent-soft); flex: none; }
.msg > img.msg-ava { cursor: pointer; }
.msg > img.msg-ava:hover { outline: 2px solid var(--accent); outline-offset: -2px; }   /* drawn inside the circle: the chat's edge would clip a ring outside it */
.ps-invite { width: 100%; margin-top: 10px; }
.msg .body { background: #fff; border: 1px solid var(--line); border-radius: 4px 13px 13px 13px; padding: 5px 10px; max-width: 100%; overflow-wrap: anywhere; line-height: 1.5; }
.msg .name { font-size: var(--fs-xs); font-weight: 600; color: var(--ink-2); }
.msg .text { font-size: var(--fs-md); }
.msg.me { flex-direction: row-reverse; }
.msg.me .body { background: var(--accent-soft); border-color: var(--accent-line); border-radius: 13px 4px 13px 13px; }
/* a follow-up from the same person: the avatar keeps its space (so bubbles line up), the name goes */
.msg.cont { margin-top: -5px; }
.msg.cont > img { visibility: hidden; height: 0; }
.msg.cont .name { display: none; }
.msg.cont .body { border-radius: 13px; }
.sys { align-self: center; font-size: var(--fs-xs); color: var(--ink-2); background: var(--surface-2); border-radius: var(--r-pill); padding: 3px 12px; text-align: center; }

.chat-compose-tools { display: flex; align-items: center; gap: 5px; flex: none; padding-top: 8px; }
.chat-form { display: flex; gap: 6px; flex: none; padding-top: 5px; }
#chatInput { flex: 1; min-width: 0; border-radius: var(--r-pill); min-height: 40px; }
.send { width: 40px; height: 40px; padding: 0; border-radius: 50%; flex: none; }
.chat-tool-btn { flex: none; width: 29px; min-width: 29px; height: 28px; padding: 0; border: 1px solid var(--line); border-radius: 9px; background: #fff; color: var(--ink-2); font-size: 14px; font-weight: 700; line-height: 1; }
.chat-gif-tool { font-size: 10px; letter-spacing: -.3px; }
.chat-tool-btn:hover { border-color: var(--accent-line); color: var(--accent); background: var(--accent-soft); }
.chat-emoji-picker { display: grid; grid-template-columns: repeat(8, 1fr); gap: 3px; padding: 8px; margin-top: 6px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-1); }
.chat-emoji-picker button { border: 0; border-radius: 8px; background: transparent; font-size: 21px; padding: 4px 0; }
.chat-emoji-picker button:hover { background: var(--surface-2); }
.chat-gif-picker { margin-top: 6px; padding: 9px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-1); }
.chat-gif-picker > input { width: 100%; min-width: 0; padding: 8px 11px; border: 1px solid var(--line); border-radius: var(--r-pill); font-size: var(--fs-sm); }
.chat-gif-status { padding: 7px 2px 5px; color: var(--ink-2); font-size: var(--fs-xs); }
.chat-gif-results { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); grid-auto-rows: max-content; gap: 5px; max-height: 190px; min-height: 0; overflow-y: auto; }
/* the pickers give way when the panel is short (phones, the floating yard chat): they shrink and scroll inside,
   so the type box under them never gets pushed off the screen */
.chat-emoji-picker, .chat-gif-picker { min-height: 0; overflow-y: auto; flex: 0 1 auto; }
.chat-gif-picker { display: flex; flex-direction: column; overflow: hidden; }
.chat-gif-picker > input, .chat-gif-head { flex: none; }
.chat-gif-picker .chat-gif-results { flex: 0 1 auto; }
.chat-gif-tile { position: relative; min-width: 0; }
.chat-gif-tile .chat-gif-result { width: 100%; }
.chat-gif-star { position: absolute; top: 3px; right: 3px; width: 22px; height: 22px; padding: 0; border: 0; border-radius: 50%; background: rgba(255,255,255,.85); color: var(--ink-2); font-size: 13px; line-height: 22px; cursor: pointer; box-shadow: 0 1px 3px rgba(0,0,0,.18); }
.chat-gif-star.on { color: #e8a317; }
.chat-gif-star:hover { color: #e8a317; }
.chat-gif-section { grid-column: 1 / -1; padding: 4px 2px 0; color: var(--ink-2); font-size: var(--fs-xs); font-weight: 600; }
.chat-gif-result { min-width: 0; height: 76px; padding: 0; overflow: hidden; border: 1px solid var(--line); border-radius: 8px; background: var(--surface-2); cursor: pointer; }
.chat-gif-result img, .chat-gif-result video { display: block; width: 100%; height: 100%; object-fit: cover; }
/* GIPHY requires "Powered By GIPHY" to be shown conspicuously where its search is used */
.chat-gif-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.chat-gif-head .chat-gif-status { flex: 1; min-width: 0; }
.giphy-attribution { flex: none; display: block; text-align: right; font-size: 11px; white-space: nowrap; letter-spacing: .2px; color: var(--ink-2); text-decoration: none; }
.giphy-attribution b { font-weight: 800; color: var(--ink); letter-spacing: .6px; }
.giphy-attribution:hover b { color: var(--accent); }
.chat-gif-result:hover { border-color: var(--accent); }
.chat-media { display: block; width: min(180px, 55vw); max-width: none; max-height: 220px; object-fit: contain; border-radius: 10px; margin-top: 4px; background: var(--surface-2); }
.chat-media.zoomable { cursor: zoom-in; }

/* full-screen photo viewer (tap a chat photo) */
.img-viewer { position: fixed; inset: 0; z-index: 10000; background: rgba(0,0,0,.92); animation: imgViewerIn .15s ease-out; }
@keyframes imgViewerIn { from { opacity: 0; } to { opacity: 1; } }
.img-viewer-stage { position: absolute; inset: 0; overflow: auto; display: flex; align-items: center; justify-content: center; touch-action: pan-x pan-y pinch-zoom; }
.img-viewer-stage img { max-width: 100vw; max-height: 100vh; max-height: 100dvh; object-fit: contain; cursor: zoom-in; user-select: none; -webkit-user-select: none; }
.img-viewer.zoomed .img-viewer-stage { display: block; }
.img-viewer.zoomed .img-viewer-stage img { max-width: none; max-height: none; height: auto; cursor: grab; }
.img-viewer-bar { position: absolute; top: max(12px, env(safe-area-inset-top)); right: 12px; display: flex; gap: 8px; }
.img-viewer-bar button { width: 40px; height: 40px; border-radius: 50%; border: 0; background: rgba(0,0,0,.55); box-shadow: 0 0 0 1px rgba(255,255,255,.35); color: #fff; font-size: 20px; line-height: 1; cursor: pointer; }
.img-viewer-bar button:hover { background: rgba(0,0,0,.8); }

/* chat collapses to its header only; the music card below stays */
.chat-panel.folded { flex: 0 0 auto; }
.chat-panel.folded .chat-head { padding-bottom: 2px; border-bottom: 0; }
.chat-panel.folded .people, .chat-panel.folded .chat-log, .chat-panel.folded .chat-form, .chat-panel.folded .chat-reply-bar, .chat-panel.folded .chat-mention, .chat-panel.folded .chat-compose-tools, .chat-panel.folded .chat-emoji-picker, .chat-panel.folded .chat-gif-picker { display: none !important; }

/* classroom music card */
.float-widget { flex: none; display: flex; flex-direction: column; gap: 8px; padding: 12px; max-height: min(34vh, 300px); overflow-y: auto; }
.w-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.w-head { font-size: var(--fs-md); }
.w-toggle { display: none; border: 1px solid var(--line); background: #fff; color: var(--ink-2); border-radius: var(--r-pill); padding: 3px 10px; font-size: 12px; }
.w-toggle:hover { border-color: var(--accent); color: var(--accent); }
.w-note { font-size: var(--fs-sm); color: var(--ink-2); background: var(--accent-soft); border-radius: var(--r-sm); padding: 5px 10px; }
.w-now { display: grid; grid-template-columns: 68px minmax(0, 1fr); gap: 10px; align-items: center; background: var(--surface-2); border-radius: var(--r-md); padding: 8px; }
.w-now img { width: 68px; height: 68px; object-fit: cover; border-radius: var(--r-sm); background: var(--line); }
.w-info { min-width: 0; display: flex; flex-direction: column; }
.w-info small, .w-info > span { font-size: var(--fs-xs); color: var(--ink-2); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-info b { font-size: var(--fs-md); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-ctrl { display: flex; align-items: center; gap: 6px; margin-top: 4px; }
/* seek bar: moves the song for the whole room */
.w-seek { display: flex; align-items: center; gap: 6px; margin-top: 2px; font-size: 11px; color: var(--ink-2); font-variant-numeric: tabular-nums; }
.w-seek input { flex: 1; min-width: 0; accent-color: var(--accent); height: 14px; }
.w-seek input:disabled { opacity: .4; }
.w-seek.hidden { display: none; }
/* an off-screen player that only reads which songs are in a pasted playlist */
.yt-reader { position: fixed; left: -10000px; top: 0; width: 200px; height: 200px; overflow: hidden; pointer-events: none; }
.w-ctrl button { width: 30px; height: 30px; border-radius: 50%; border: 0; background: #fff; font-size: 13px; box-shadow: var(--shadow-1); flex: none; }
.w-ctrl button:disabled { opacity: .4; }
.w-ctrl button.pulse { background: var(--accent); color: #fff; animation: pulse 1.4s infinite; }
@keyframes pulse { 50% { box-shadow: 0 0 0 6px rgba(200, 85, 61, .18); } }
.w-ctrl .vol { font-size: 12px; }
.w-ctrl input { flex: 1; min-width: 40px; }
.w-queue { font-size: var(--fs-xs); color: var(--ink-2); }
.w-list { flex: none; list-style: none; margin: 0; padding: 4px; align-content: start; background: var(--surface-2); border-radius: var(--r-md); box-sizing: border-box; overflow-y: auto; overflow-x: hidden; display: grid; grid-template-columns: minmax(0, 1fr); gap: 2px; }
.w-list .wl-empty { justify-content: center; height: 100%; color: var(--ink-3); }
.w-list li { min-width: 0; display: flex; align-items: center; gap: 4px; font-size: var(--fs-xs); color: var(--ink-2); }
.w-list .wl-thumb { width: 32px; height: 18px; object-fit: cover; border-radius: 3px; flex: none; }
.w-list .wl-title { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.w-list button { flex: none; width: 22px; height: 22px; border: 1px solid var(--line); border-radius: 6px; background: var(--surface); color: var(--ink-2); font-size: 11px; cursor: pointer; padding: 0; }
.w-list button:hover:not(:disabled) { border-color: var(--accent-line); color: var(--accent); }
.w-list button:disabled { opacity: .35; cursor: default; }
/* two tabs in the same space: what is playing, or the queue (the card keeps its height, the chat above keeps its room) */
/* both tabs share one grid cell: the cell is as tall as "now playing", the queue fills it and scrolls,
   so switching tabs never changes the card's height */
.w-panes { display: grid; }
.w-pane-now, .w-list { grid-area: 1 / 1; min-width: 0; }
.w-pane-now { display: flex; flex-direction: column; gap: 8px; }
.w-list { align-self: stretch; contain: size; }
#roomWidget:not(.q-open) .w-list, #roomWidget.q-open .w-pane-now { visibility: hidden; }
.w-tabs { display: flex; gap: 2px; background: var(--surface-2); border-radius: var(--r-pill); padding: 2px; }
.w-tabs .w-qbtn { border-color: transparent; background: transparent; }
.w-top-btns { display: flex; align-items: center; gap: 6px; }
.w-qbtn { border: 1px solid var(--line); background: #fff; color: var(--ink-2); border-radius: var(--r-pill); padding: 3px 10px; font-size: 12px; cursor: pointer; white-space: nowrap; }
.w-qbtn:hover { border-color: var(--accent); color: var(--accent); }
.w-qbtn.on { background: var(--accent); border-color: var(--accent); color: #fff; }
.here-class { border: 1px solid var(--accent-line); border-radius: var(--r-md); padding: 10px 12px; margin: 0 0 14px; background: var(--surface); }
.here-top { display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap; }
.here-cap { display: flex; align-items: center; gap: 6px; }
.here-cap button { width: 30px; height: 30px; border-radius: 50%; border: 1px solid var(--line); background: #fff; font-size: 16px; cursor: pointer; }
.here-cap button:disabled { opacity: .4; cursor: default; }
.here-cap output { min-width: 64px; text-align: center; font-weight: 600; }
.here-invite { display: flex; flex-wrap: wrap; gap: 6px; }
.here-lock { display: flex; align-items: flex-start; gap: 8px; margin-top: 8px; font-size: var(--fs-sm); cursor: pointer; }
.here-lock input { margin-top: 3px; }
.here-invite .btn { padding: 6px 10px; font-size: 13px; }
.ps-idle { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-top: 10px; font-size: var(--fs-sm); color: var(--ink-2); }
.w-form, .w-row { display: flex; gap: 6px; }
.w-form input { padding: 8px 12px; font-size: 13px; border-radius: var(--r-sm); }
.w-form button { flex: none; padding: 0 14px; font-size: 13px; border-radius: var(--r-sm); }
.w-row { flex: 1; }

/* ---------- 6. overlays ---------- */
/* popover: anchored under a HUD button (place picker, bag) */
.popover {
  position: absolute; z-index: 10; top: calc(100% + 8px); left: 0; width: 300px; max-height: min(70vh, 460px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-lg); box-shadow: var(--shadow-3);
  padding: 10px; animation: drop .16s ease-out;
}
@keyframes drop { from { opacity: 0; transform: translateY(-4px); } }
.popover-head { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; padding: 2px 4px 8px; }
.popover-head b { font-size: var(--fs-md); }
.popover-head small { font-size: var(--fs-xs); color: var(--ink-2); }

/* "ไปไหนกันดี?": place list (left) + preview of the chosen place (right) */
.modal-card.place-card { width: min(860px, 100%); }
.place-cols { display: grid; grid-template-columns: 280px minmax(0, 1fr); gap: 20px; margin-top: 14px; }
.room-list { display: flex; flex-direction: column; gap: 4px; }
.room-btn {
  --tone: var(--surface-2);
  display: flex; align-items: center; gap: 12px; width: 100%; text-align: left;
  border: 1px solid transparent; background: transparent; border-radius: var(--r-md); padding: 9px 10px;
  transition: background-color var(--ease), border-color var(--ease), box-shadow var(--ease);
}
.room-btn[data-tone=red] { --tone: #fbe6da; }
.room-btn[data-tone=green] { --tone: #e5f0dc; }
.room-btn[data-tone=blue] { --tone: #dfecf3; }
.room-btn[data-tone=amber] { --tone: #f8ecd2; }
.room-btn:hover { background: var(--surface-2); }
.room-btn.sel { background: #fff; border-color: var(--accent-line); box-shadow: var(--shadow-1), inset 3px 0 0 var(--accent); }
.room-ico { display: grid; place-items: center; width: 38px; height: 38px; flex: none; border-radius: 50%; background: var(--tone); font-size: 18px; }
.room-txt { display: flex; flex-direction: column; flex: 1; min-width: 0; gap: 1px; line-height: 1.35; }
.room-txt b { font-size: 15px; font-weight: 600; }
.room-txt small { font-size: 12px; color: var(--ink-2); }
.room-btn.sel .room-txt b { color: var(--accent); }
.here { flex: none; font-size: var(--fs-xs); font-weight: 600; color: var(--accent); background: var(--accent-soft); border-radius: var(--r-pill); padding: 2px 9px; }

.place-preview { display: flex; flex-direction: column; min-width: 0; }
.pp-img { position: relative; aspect-ratio: 16 / 9; border-radius: var(--r-md); overflow: hidden; background: var(--surface-2); border: 1px solid var(--line); }
.pp-img img { width: 100%; height: 100%; object-fit: cover; display: block; animation: fade .25s ease-out; }
@keyframes fade { from { opacity: .3; } }
.pp-img .here { position: absolute; top: 10px; left: 10px; box-shadow: var(--shadow-1); }
.place-preview h3 { margin: 14px 0 4px; font-size: 18px; }
.place-preview p { margin: 0; color: var(--ink-2); font-size: var(--fs-md); line-height: 1.65; }
.pp-tags { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 12px; }
.pp-tags span { font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px 10px; }
#ppDesc { white-space: pre-line; }   /* a premium pond's bonuses go on their own line */
/* my own pond: who may come in (just me / friends / everyone) */
.pp-access { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin-top: 10px; font-size: 13px; }
.pp-access.hidden { display: none; }
.pp-acc { font: inherit; font-size: 12px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-pill); padding: 4px 12px; cursor: pointer; color: inherit; }
.pp-acc.on { background: var(--accent, #e07a3f); border-color: var(--accent, #e07a3f); color: #fff; }
.pp-cap { font: inherit; font-size: 12px; border: 1px solid var(--line); border-radius: var(--r-pill); padding: 3px 8px; background: var(--surface-2); color: inherit; }
/* a premium pond's row in the place picker: the ponds open now, and opening my own */
.pp-pond { margin-top: 12px; display: flex; flex-direction: column; gap: 6px; }
.pp-pond.hidden { display: none; }
.pp-pond-h { font-size: 13px; margin-top: 4px; }
.pp-pond-list { display: flex; flex-direction: column; gap: 4px; max-height: 150px; overflow: auto; }
.pp-pond-item { display: flex; justify-content: space-between; align-items: center; gap: 8px; font: inherit; font-size: 13px; text-align: left; background: var(--surface-2); border: 1px solid var(--line); border-radius: 10px; padding: 6px 10px; cursor: pointer; color: inherit; }
.pp-pond-item small { color: var(--ink-2, #7a756c); white-space: nowrap; }
.pp-pond-item.here { opacity: .7; cursor: default; }
.pp-pond-none { color: var(--ink-2, #7a756c); font-size: 12px; }
.pp-pond-go { align-self: flex-start; margin-top: 4px; }
.pp-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: auto; padding-top: 16px; }
.pp-actions .btn { min-width: 112px; min-height: 42px; }
.pp-actions .btn:disabled { background: var(--surface-2); color: var(--ink-3); }
.pp-keys { margin: 12px 0 0; text-align: right; color: var(--ink-3); }

/* patch notes: what changed in each update */
.patch-card { width: min(520px, calc(100vw - 32px)); }
.patch-list { display: grid; gap: 14px; max-height: min(70vh, 560px); overflow-y: auto; padding-right: 4px; }
.patch-entry { border: 1px solid var(--line); border-radius: var(--r-md); padding: 10px 12px; background: var(--surface); }
.patch-entry.new { border-color: var(--accent-line); box-shadow: 0 0 0 2px var(--accent-soft); }
.patch-entry small { color: var(--ink-2); font-size: var(--fs-xs); }
.patch-entry h5 { margin: 2px 0 6px; font-size: var(--fs-md); }
.patch-entry ul { margin: 0; padding-left: 18px; display: grid; gap: 4px; font-size: var(--fs-sm); line-height: 1.5; }
.patch-new-tag { display: inline-block; margin-left: 6px; padding: 1px 8px; border-radius: var(--r-pill); background: var(--accent); color: #fff; font-size: 11px; font-weight: 700; }
.sound-pop { position: fixed; left: auto; right: calc(var(--scene-right) + var(--gutter)); top: calc(var(--frame) + var(--gutter) + var(--hud-h) + 8px); width: 280px; }
.sound-row { display: flex; align-items: flex-start; gap: 10px; padding: 8px 6px; border-radius: var(--r-md); cursor: pointer; }
.sound-row:hover { background: var(--surface-2); }
.sound-row input { margin-top: 3px; width: 18px; height: 18px; accent-color: var(--accent); flex: none; }
.sound-row span { display: flex; flex-direction: column; gap: 2px; }
.sound-row small { font-size: var(--fs-xs); color: var(--ink-2); line-height: 1.4; }
.bag-pop { position: fixed; left: auto; right: calc(var(--scene-right) + var(--gutter)); top: calc(var(--frame) + var(--gutter) + var(--hud-h) + 8px); width: 260px; }
.bag-list { font-size: var(--fs-md); color: var(--ink-2); padding: 0 4px 2px; }
.bag-row { display: flex; justify-content: space-between; padding: 7px 0; border-bottom: 1px dashed var(--line); color: var(--ink); }
.bag-row:last-child { border-bottom: 0; }

/* modal */
.modal { position: fixed; inset: 0; z-index: 20; display: grid; place-items: center; padding: 16px; background: var(--scrim); -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }
.modal-card {
  width: min(440px, 100%); max-height: calc(100dvh - 32px); overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--r-xl); padding: 18px 20px 20px; box-shadow: var(--shadow-3);
  animation: pop .2s ease-out;
}
.modal-card.wide { width: min(780px, 100%); }
.krathong-card { width: min(620px, 100%); }
/* ---------- student hall of fame ---------- */
.hall-card { width: min(620px, 100%); }
.hall-intro { margin: -4px 0 14px; color: var(--ink-2); font-size: var(--fs-sm); }
.hall-board { display: grid; gap: 12px; }
.hall-tabs { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; }
.hall-tab { display: grid; justify-items: center; gap: 2px; min-width: 0; padding: 8px 4px; border: 1px solid var(--line); border-radius: 12px; background: var(--surface); color: var(--ink-2); font-size: var(--fs-xs); line-height: 1.2; cursor: pointer; }
.hall-tab span:last-child { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.hall-tab-icon { font-size: 22px; }
.hall-tab:hover { background: var(--surface-2); }
.hall-tab.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--ink); font-weight: 700; }
.hall-award { min-width: 0; padding: 12px; border: 1px solid var(--line); border-radius: var(--r-lg); background: linear-gradient(145deg, var(--surface), var(--surface-2)); }
.hall-award-head { display: flex; align-items: center; gap: 10px; margin-bottom: 9px; }
.hall-award-icon { display: grid; place-items: center; width: 40px; height: 40px; flex: none; border-radius: 13px; background: var(--accent-soft); font-size: 23px; }
.hall-award-head div { display: grid; gap: 1px; min-width: 0; }
.hall-award-head b { color: var(--ink); font-size: var(--fs-md); }
.hall-award-head small { color: var(--accent); font-size: var(--fs-xs); }
.hall-ranks { display: grid; gap: 5px; margin: 0; padding: 0; list-style: none; }
.hall-rank { display: grid; grid-template-columns: 22px 30px minmax(0, 1fr) auto; align-items: center; gap: 8px; min-height: 39px; padding: 5px 7px; border-radius: 10px; background: rgba(255,255,255,.58); }
.hall-rank-num { color: var(--ink-3); font-size: var(--fs-sm); font-weight: 700; text-align: center; }
.hall-rank.rank-1 .hall-rank-num, .hall-rank.rank-2 .hall-rank-num, .hall-rank.rank-3 .hall-rank-num { font-size: 18px; }
.hall-avatar { width: 30px; height: 30px; object-fit: contain; border-radius: 50%; background: var(--paper); }
.hall-name { min-width: 0; overflow: hidden; color: var(--ink); font-size: var(--fs-sm); text-overflow: ellipsis; white-space: nowrap; }
.hall-value { color: var(--ink-2); font-size: var(--fs-xs); font-variant-numeric: tabular-nums; white-space: nowrap; }
.hall-rank.rank-1 { background: #fff1c9; }
.hall-rank.rank-1 .hall-rank-num { color: #a47712; }
.hall-rank.rank-2 { background: #edf0f2; }
.hall-rank.rank-3 { background: #f7e8dd; }
.hall-empty, .hall-loading { padding: 14px; color: var(--ink-3); text-align: center; font-size: var(--fs-sm); }
.hall-footnote { display: block; margin-top: 12px; color: var(--ink-3); font-size: var(--fs-xs); }
@media (max-width: 560px) { .hall-tabs { grid-template-columns: repeat(3, minmax(0, 1fr)); } .hall-card { padding: 14px; } }

/* ---------- the school map ---------- */
.map-title { display: inline-flex; align-items: center; gap: 8px; }
.map-title .ui-ico { width: 26px; height: 26px; }
.map-card { width: min(1040px, 100%); }
.map-scroll { overflow-x: auto; margin: 0 -4px; padding: 4px; }
.map-board { position: relative; width: 100%; min-width: 620px; aspect-ratio: 1000 / 620; border-radius: var(--r-lg);
  background: radial-gradient(circle at 30% 40%, #e7efd6, #d6e3bf 60%, #c9d8b0); border: 1px solid var(--line); overflow: hidden; }
.map-lines { position: absolute; inset: 0; width: 100%; height: 100%; }
.map-lines .walk { stroke: #a2875f; stroke-width: 5; stroke-dasharray: 2 9; stroke-linecap: round; fill: none; vector-effect: non-scaling-stroke; }
.map-lines .area { fill: rgba(255, 233, 196, .55); stroke: #d9a35c; stroke-width: 2; stroke-dasharray: 8 6; vector-effect: non-scaling-stroke; }
.map-lines .spooky { fill: rgba(70, 60, 90, .16); stroke: #8a7aa8; }
.map-area-label { position: absolute; transform: translate(-50%, 0); font-size: 12px; font-weight: 700; color: #8a5a2a; white-space: nowrap; pointer-events: none; }
.map-node { position: absolute; width: 14.5%; transform: translate(-50%, -50%); display: flex; flex-direction: column; align-items: stretch; gap: 3px;
  padding: 4px; border: 2px solid transparent; border-radius: 14px; background: var(--surface); color: var(--ink); box-shadow: var(--shadow-2);
  cursor: pointer; text-align: center; transition: transform .15s ease, box-shadow .15s ease; }
.map-node:hover, .map-node:focus-visible { transform: translate(-50%, -50%) scale(1.06); box-shadow: var(--shadow-3); z-index: 3; outline: none; border-color: var(--accent-line); }
.map-node.here { border-color: var(--accent); box-shadow: 0 0 0 4px var(--accent-soft), var(--shadow-3); z-index: 2; }
.map-node img.map-thumb { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 10px; background: var(--surface-2); }
.map-node b { font-size: 12px; line-height: 1.25; }
.map-count { position: absolute; top: -8px; right: -8px; min-width: 22px; height: 22px; padding: 0 6px; border-radius: 11px; background: var(--accent); color: #fff;
  font-size: 11px; font-weight: 700; line-height: 22px; box-shadow: var(--shadow-1); }
.map-count.zero { background: var(--surface-2); color: var(--ink-2); border: 1px solid var(--line); line-height: 20px; }
.map-pin { position: absolute; top: -14px; left: 50%; transform: translateX(-50%); font-size: 20px; filter: drop-shadow(0 2px 2px rgba(0,0,0,.25)); animation: map-bob 1.4s ease-in-out infinite; }
@keyframes map-bob { 50% { transform: translateX(-50%) translateY(-4px); } }
.map-friends { display: flex; justify-content: center; gap: 2px; }
.map-friends img { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--surface); background: var(--surface-2); margin-top: -2px; }
.map-friends span { font-size: 10px; color: var(--ink-2); align-self: center; }
@media (prefers-reduced-motion: reduce) { .map-pin { animation: none; } .map-node { transition: none; } }
@media (max-width: 700px) { .map-node b { font-size: 11px; } }
.krathong-grid { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 8px; }
.krathong-choice { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 10px 6px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); color: var(--ink); text-align: center; }
.krathong-choice:hover { border-color: var(--accent-line); background: var(--accent-soft); }
.krathong-choice > img { width: 76px; height: 76px; object-fit: contain; }
.krathong-choice b { font-size: 12px; line-height: 1.3; }
.krathong-choice small { min-height: 32px; color: var(--ink-2); font-size: 10px; line-height: 1.35; }
.krathong-choice:disabled { opacity: .5; cursor: not-allowed; }
.krathong-choice:disabled:hover { border-color: var(--line); background: var(--surface-2); }
.krathong-note { position: relative; display: flex; flex-direction: column; gap: 4px; margin: 0 0 10px; font-size: 12px; font-weight: 600; color: var(--ink); }
.krathong-note small { font-weight: 400; color: var(--ink-2); }
.krathong-note textarea { width: 100%; box-sizing: border-box; resize: none; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); color: var(--ink); font: inherit; font-size: 16px; font-weight: 400; line-height: 1.4; }
.krathong-note textarea:focus { outline: 2px solid var(--accent-line); border-color: var(--accent-line); }
.krathong-count { position: absolute; right: 8px; bottom: 6px; font-size: 10px; }
.krathong-choice span .ui-ico { width: 16px; height: 16px; vertical-align: -3px; }
.krathong-choice span { margin-top: 3px; padding: 4px 8px; border-radius: var(--r-pill); background: var(--accent); color: #fff; font-size: 11px; font-weight: 600; }
@media (max-width: 560px) { .krathong-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } .krathong-choice > img { width: 68px; height: 68px; } }
.modal-head { display: flex; justify-content: space-between; align-items: center; gap: 12px; font-size: var(--fs-xl); }
.modal-sub { margin: 4px 0 14px; color: var(--ink-2); font-size: var(--fs-md); line-height: 1.55; }
.section-title { margin: 16px 0 0; font-size: 13px; color: var(--ink-2); text-transform: none; letter-spacing: .2px; }
.modal-foot { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; padding-top: 14px; border-top: 1px solid var(--line); }
.hint-sm { font-size: var(--fs-sm); color: var(--ink-2); margin: 6px 0 10px; line-height: 1.5; }
.cap { display: block; font-weight: 600; font-size: var(--fs-md); margin: 6px 0; }
.cap output { float: right; color: var(--accent); }
.cap input { width: 100%; margin-top: 8px; }
.check { display: flex; gap: 8px; align-items: center; font-weight: 600; margin: 12px 0 4px; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); }

/* slimes (PETS_SPEC.md): tabs, slime cards with affection and fullness bars, eggs, the collection, hatching, click menu */
.modal-card.pets-card { width: min(720px, 100%); position: relative; }
.modal-head .ui-ico { width: 22px; height: 22px; vertical-align: -5px; }
.slime-tabs { display: flex; gap: 6px; margin: 2px 0 12px; }
.slime-tab-n:empty { display: none; }
.slime-tab-n { display: inline-block; min-width: 18px; padding: 0 5px; margin-left: 2px; border-radius: 99px; background: #e2735f; color: #fff; font-size: 11px; line-height: 18px; }
.slime-pane { display: flex; flex-direction: column; gap: 10px; }
.slime-list { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 10px; }
.slime-card { display: flex; align-items: center; gap: 12px; min-width: 0; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.slime-card.out { border-color: #d58c78; box-shadow: 0 0 0 2px rgba(213,140,120,.25) inset; }
.slime-card > img { width: 84px; height: 76px; object-fit: contain; flex: none; }
.slime-detail { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 4px; }
.slime-detail > b { font-size: var(--fs-md); }
.slime-detail small { color: var(--ink-2); font-size: var(--fs-xs); }
.slime-tier { display: inline-block; padding: 0 6px; border-radius: 99px; color: #fff; font-size: 11px; font-weight: 700; }
.slime-meter { display: grid; grid-template-columns: 16px 1fr; align-items: center; gap: 5px; font-size: 11px; }
.slime-meter .ui-ico { width: 15px; height: 15px; }
.slime-bar { height: 7px; overflow: hidden; border-radius: 99px; background: #e5d9c8; }
.slime-bar i { display: block; height: 100%; border-radius: inherit; background: #d58c78; }
.slime-bar.full i { background: #7fb2d6; }
.slime-bar.hungry i { background: #e0a23c; }
.slime-food { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 8px 10px; border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.slime-food b { margin-right: auto; }
.slime-eggs { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }
.slime-egg { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); text-align: center; }
.slime-egg img { width: 72px; height: 72px; object-fit: contain; }
.slime-egg small { color: var(--ink-2); font-size: var(--fs-xs); }
.slime-dex { display: flex; flex-direction: column; gap: 10px; }
.slime-dex h5 { margin: 0 0 4px; font-size: var(--fs-sm); }
.slime-dex-row { display: grid; grid-template-columns: repeat(auto-fill, minmax(84px, 1fr)); gap: 8px; }
.slime-dex-slot { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border-radius: var(--r-md); background: var(--surface-2); font-size: 11px; text-align: center; }
.slime-dex-slot img { width: 70px; height: 62px; object-fit: contain; }
.slime-dex-slot.missing img { filter: brightness(0) opacity(.35); }
.slime-dex-slot.missing span { color: var(--ink-2); }
.slime-actions { display: flex; flex-wrap: wrap; gap: 5px; }
.slime-actions .btn, .slime-actions .chip-btn, .slime-egg .btn, .slime-food .btn { padding: 5px 9px; font-size: var(--fs-xs); }
.slime-actions .ui-ico, .slime-food .ui-ico, .slime-egg .ui-ico { width: 16px; height: 16px; vertical-align: -3px; }
.slime-actions button:disabled, .slime-egg button:disabled, .slime-food button:disabled { opacity: .48; }
/* hatching: an overlay on the panel; the egg shakes, turns cracked, bursts, the slime pops out */
.slime-hatch { position: absolute; inset: 0; z-index: 2; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; border-radius: inherit; background: rgba(255,250,243,.96); text-align: center; }
.slime-hatch .hatch-stage { position: relative; width: 220px; height: 200px; display: grid; place-items: center; }
.slime-hatch .hatch-glow { position: absolute; inset: 10px; border-radius: 50%; opacity: 0; transition: opacity .3s; }
.slime-hatch img { position: relative; max-width: 200px; max-height: 190px; }
.slime-hatch .hatch-egg { animation: hatch-shake .45s ease-in-out 3; }
.slime-hatch .hatch-pop { animation: hatch-pop .55s cubic-bezier(.3,1.6,.5,1) both; }
.slime-hatch.done .hatch-glow { opacity: .55; }
.slime-hatch b { font-size: var(--fs-lg); }
@keyframes hatch-shake { 0%,100% { transform: rotate(0); } 25% { transform: rotate(-9deg); } 75% { transform: rotate(9deg); } }
@keyframes hatch-pop { 0% { transform: scale(.2, .2) translateY(30px); } 60% { transform: scale(1.18, .82); } 100% { transform: scale(1); } }
/* the gacha machine (egg tab) and its results */
.slime-gacha { display: flex; gap: 14px; align-items: center; padding: 12px 14px; margin-bottom: 12px; border: 1.5px solid #e2c27a; border-radius: var(--r-md); background: linear-gradient(135deg, #fff6df, #fdebd6); }
.slime-gacha > img { width: 92px; height: 92px; object-fit: contain; flex: none; animation: gacha-idle 2.4s ease-in-out infinite; }
.gacha-text { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.gacha-text b { font-size: var(--fs-lg); }
.gacha-text small { color: var(--ink-2); font-size: var(--fs-xs); }
.gacha-acts { display: flex; flex-wrap: wrap; gap: 6px; }
.gacha-acts .btn { padding: 6px 11px; font-size: var(--fs-xs); }
.gacha-acts .ui-ico { width: 16px; height: 16px; vertical-align: -3px; }
.gacha-acts button:disabled { opacity: .48; }
.gacha-sure { color: #a8730c !important; font-weight: 600; }
.slime-egg.choose { border-color: #c9a7ff; background: #f6f0ff; }
.gacha-odds { margin-top: 10px; font-size: var(--fs-xs); color: var(--ink-2); }
.gacha-odds summary { cursor: pointer; font-weight: 600; }
.gacha-odds ul { margin: 6px 0; padding-left: 18px; columns: 2; }
@keyframes gacha-idle { 0%, 100% { transform: rotate(-3deg); } 50% { transform: rotate(3deg) translateY(-3px); } }
.slime-hatch.gacha { justify-content: safe center; padding: 16px; overflow-y: auto; }
.gacha-grid { display: grid; grid-template-columns: repeat(auto-fit, 112px); justify-content: center; gap: 8px; width: 100%; max-width: 600px; }
.gacha-grid.ten { grid-template-columns: repeat(5, minmax(0, 1fr)); }
.gacha-prize { display: flex; flex-direction: column; align-items: center; gap: 3px; padding: 8px 6px; border: 1.5px solid var(--line); border-radius: var(--r-md); background: #fff; text-align: center; font: inherit; color: var(--ink); animation: hatch-pop .5s cubic-bezier(.3,1.6,.5,1) both; }
.gacha-prize img { width: 58px; height: 58px; object-fit: contain; }
.gacha-prize b { font-size: var(--fs-xs); font-weight: 600; line-height: 1.25; }
.gacha-prize small { font-size: 11px; color: var(--ink-2); }
.gacha-prize .slime-tier { font-size: 10px; }
.gacha-prize.slime { border-color: var(--tier); }
.gacha-prize.t2, .gacha-prize.t3, .gacha-prize.t4, .gacha-prize.rare { box-shadow: 0 0 0 2px #fff, 0 0 14px 2px color-mix(in srgb, var(--tier, #b07cff) 60%, transparent); }
.gacha-prize.jackpot { border-color: #e2b23a; background: linear-gradient(160deg, #fffbe9, #ffeec2); }
.gacha-grid.choose .gacha-prize { cursor: pointer; animation: none; }
.gacha-grid.choose .gacha-prize:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent); }
.gacha-prize.locked { cursor: not-allowed !important; opacity: .5; filter: grayscale(.6); box-shadow: none !important; }
/* tap-twice confirm: the button shows what the second tap does */
.armed { position: relative; outline: 2px solid #e2a23a; outline-offset: 2px; }
.btn.armed, .gacha-prize.armed { animation: armed-pulse .7s ease-in-out infinite alternate; }
.armed::after { content: attr(data-ask); position: absolute; left: 50%; bottom: calc(100% + 6px); transform: translateX(-50%); white-space: nowrap; padding: 3px 8px; border-radius: var(--r-pill); background: #3a2a00; color: #fff; font-size: 11px; font-weight: 600; pointer-events: none; z-index: 3; }
@keyframes armed-pulse { to { transform: scale(1.04); } }
.gacha-prize.armed::after { bottom: 4px; white-space: normal; width: 90%; text-align: center; }
.gacha-prize.armed { border-color: #e2a23a !important; }
@media (max-width: 560px) { .gacha-grid.ten { grid-template-columns: repeat(3, minmax(0, 1fr)); } .slime-gacha { flex-direction: column; text-align: center; } .gacha-acts { justify-content: center; } }
/* fusion: the ghost teacher's pot (haunted house) */
.modal-card.fuse-card { width: min(680px, 100%); position: relative; }
.fuse-body { display: flex; flex-direction: column; gap: 10px; margin-top: 10px; }
.fuse-hint { margin: 0; padding: 8px 12px; border-radius: var(--r-md); background: #eef7ea; color: #3c6a2c; font-size: var(--fs-xs); }
.fuse-slots { display: flex; align-items: center; justify-content: center; gap: 10px; flex-wrap: wrap; }
.fuse-slot { width: 128px; min-height: 120px; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px; padding: 8px; border: 2px dashed var(--line-strong, #cbbca8); border-radius: var(--r-md); background: var(--surface-2); text-align: center; cursor: pointer; }
.fuse-slot.keep { border-color: #4f8fc0; } .fuse-slot.use { border-color: #c8553d; }
.fuse-slot img { width: 84px; height: 76px; object-fit: contain; }
.fuse-slot b { font-size: var(--fs-xs); } .fuse-slot small { font-size: 11px; color: var(--ink-2); }
.fuse-empty { font-size: 30px; font-weight: 700; color: var(--ink-3, #b9ad9f); }
.fuse-op { font-size: 24px; font-weight: 700; color: var(--ink-3, #b9ad9f); }
.fuse-pot { font-size: 40px; } .fuse-pot.big { font-size: 72px; animation: hatch-shake .4s ease-in-out infinite; }
.fuse-warn { margin: 0; text-align: center; font-size: var(--fs-xs); color: #b0432d; font-weight: 600; }
.fuse-body > .gacha-acts { justify-content: center; }
.fuse-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(100px, 1fr)); gap: 6px; max-height: 260px; overflow-y: auto; padding: 2px; }
.fuse-pick { display: flex; flex-direction: column; align-items: center; gap: 2px; padding: 6px 4px; border: 1.5px solid var(--line); border-radius: var(--r-md); background: #fff; font: inherit; color: var(--ink); cursor: pointer; }
.fuse-pick img { width: 56px; height: 50px; object-fit: contain; }
.fuse-pick b { font-size: 11px; font-weight: 600; line-height: 1.2; } .fuse-pick small { font-size: 10px; color: var(--ink-2); } .fuse-pick .slime-tier { font-size: 9px; }
.fuse-pick.keep { border-color: #4f8fc0; background: #eaf3fb; } .fuse-pick.use { border-color: #c8553d; background: #fbeee9; }
.fuse-pick:disabled { opacity: .45; cursor: default; }
.fuse-stage { position: relative; width: 240px; height: 200px; display: grid; place-items: center; }
.slime-hatch .fuse-in { position: absolute; width: 80px; height: 72px; object-fit: contain; top: 20px; }
.fuse-in.l { left: 0; animation: fuse-in-l 1.6s ease-in forwards; } .fuse-in.r { right: 0; animation: fuse-in-r 1.6s ease-in forwards; }
@keyframes fuse-in-l { to { transform: translate(80px, 70px) scale(.2); opacity: 0; } }
@keyframes fuse-in-r { to { transform: translate(-80px, 70px) scale(.2); opacity: 0; } }
.slime-looks { display: flex; gap: 4px; flex-wrap: wrap; }
.slime-looks .chip-btn { padding: 2px 8px; font-size: 11px; }
.slime-looks .chip-btn.on { border-color: var(--accent); background: var(--accent-soft); color: var(--ink); font-weight: 600; }
.slime-dex-vars { font-size: 11px; }
/* the ghost's quiz (haunted house) */
.modal-card.quiz-card { width: min(520px, 100%); }
.quiz-body { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.quiz-head { display: flex; justify-content: space-between; font-size: var(--fs-xs); color: var(--ink-2); }
.quiz-q { margin: 0; font-size: var(--fs-lg); font-weight: 600; line-height: 1.5; }
.quiz-choices { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.quiz-choice { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border: 1.5px solid var(--line); border-radius: var(--r-md); background: #fff; font: inherit; color: var(--ink); text-align: left; cursor: pointer; }
.quiz-choice i { font-style: normal; display: grid; place-items: center; width: 24px; height: 24px; flex: none; border-radius: 50%; background: var(--surface-2); font-size: var(--fs-xs); font-weight: 700; }
.quiz-choice:hover:not(:disabled) { border-color: var(--accent); }
.quiz-choice:disabled { cursor: default; }
/* the crystal ball's house sorting (castle) */
.house-choices { grid-template-columns: 1fr; }
.house-row { display: flex; flex-wrap: wrap; gap: 6px; }
.house-chip, .house-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 9px; border-radius: 999px; font-size: var(--fs-xs); font-weight: 600; color: #fff; background: var(--house); }
.house-badge { margin-top: 3px; align-self: flex-start; }
.house-result { border-top: 4px solid var(--house); padding-top: 8px; }
.house-big { font-size: 46px; line-height: 1; }
.quiz-say { margin: 0; font-size: var(--fs-xs); color: var(--ink-2); }
.quiz-say.good { color: #2d7a4a; font-weight: 600; font-size: var(--fs-md, 15px); }
.quiz-say.bad { color: #b0432d; font-weight: 600; font-size: var(--fs-md, 15px); }
.quiz-say .ui-ico { width: 16px; height: 16px; vertical-align: -3px; }
.quiz-body > .btn { align-self: flex-end; }
.quiz-head .slime-bar { flex: 1; margin-left: 12px; align-self: center; }
.quiz-choices { grid-template-columns: 1fr; }
.quiz-result { display: flex; flex-direction: column; align-items: center; gap: 6px; text-align: center; }
.quiz-result b { font-size: var(--fs-lg); }
.quiz-slime { width: 150px; height: 135px; object-fit: contain; animation: hatch-pop .55s cubic-bezier(.3,1.6,.5,1) both; }
/* clicking a slime in the scene: a small menu next to it */
.slime-menu { position: fixed; z-index: 60; display: flex; gap: 4px; padding: 5px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface); box-shadow: var(--shadow-1); }
.slime-menu button { display: flex; align-items: center; gap: 4px; padding: 5px 9px; border: 0; border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink); font: inherit; font-size: var(--fs-xs); cursor: pointer; }
.slime-menu button:hover { background: var(--line); }
.slime-menu .ui-ico { width: 16px; height: 16px; }
@media (max-width: 700px) {
  .slime-list { grid-template-columns: 1fr; }
  .slime-card > img { width: 68px; height: 62px; }
}

/* wardrobe: live preview (left) + slot tabs and item cards (right) */
.modal-card.wardrobe-card { width: min(800px, 100%); }
.wardrobe-cols { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 20px; margin-top: 14px; }
.wd-preview { align-self: start; display: flex; flex-direction: column; align-items: center; gap: 10px; background: var(--surface-2); border: 1px solid var(--line); border-radius: var(--r-md); padding: 12px; }
.wd-preview canvas { width: 100%; aspect-ratio: 240 / 348; display: block; }
.wd-preview .btn { width: 100%; }
.wd-shelf { display: flex; flex-direction: column; min-width: 0; }
.wd-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 12px; }
.wd-tab { border: 1px solid var(--line); background: #fff; border-radius: var(--r-pill); padding: 5px 12px; font-size: 13px; transition: background-color var(--ease), border-color var(--ease); }
.wd-tab:hover:not(:disabled) { border-color: var(--accent-line); }
.wd-tab.on { background: var(--accent); border-color: var(--accent); color: #fff; font-weight: 600; }
.wd-tab:disabled { color: var(--ink-3); background: var(--surface-2); }
.wd-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(118px, 1fr)); gap: 8px; max-height: min(52vh, 420px); overflow-y: auto; padding: 2px; }
.wd-item { display: flex; flex-direction: column; align-items: center; gap: 4px; padding: 8px 6px 9px; text-align: center; background: #fff; border: 1.5px solid var(--line); border-radius: var(--r-md); transition: border-color var(--ease), transform var(--ease); }
.wd-item:hover { border-color: var(--line-strong); transform: translateY(-1px); }
.wd-thumb { display: block; width: 100%; height: 132px; border-radius: var(--r-sm); background: var(--surface-2); font-size: 26px; color: var(--ink-3); overflow: hidden; }
.wd-fig { display: block; width: 100%; height: 100%; }
.wd-item b { font-size: 13px; font-weight: 600; line-height: 1.3; }
.wd-badge { font-size: 11px; color: var(--ink-2); min-height: 14px; }
.wd-item.on { border-color: var(--accent); background: var(--accent-soft); }
.wd-item.on .wd-badge { color: var(--accent); font-weight: 600; }
.wd-item.locked .wd-fig { filter: grayscale(.85) opacity(.55); }
.wd-item.locked b { color: var(--ink-2); }
.wd-item.limited .wd-badge { color: #a8730c; font-weight: 600; }

/* classroom picker */
.class-cols { display: grid; grid-template-columns: 1.3fr 1fr; gap: 16px; }
.class-cols h4 { margin: 0 0 8px; font-size: 15px; }
.class-list { display: flex; flex-direction: column; gap: 6px; max-height: 240px; overflow-y: auto; }
.class-row { display: flex; align-items: center; gap: 10px; background: #fff; border: 1px solid var(--line); border-radius: var(--r-md); padding: 8px 10px; transition: border-color var(--ease); }
.class-row:hover { border-color: var(--accent-line); }
.class-row b { flex: 1; font-size: var(--fs-lg); }
.class-row img { width: 56px; height: 32px; object-fit: cover; border-radius: 6px; flex: none; }
.class-row .count { font-size: 13px; color: var(--ink-2); }
.class-row .count.full { color: var(--accent); font-weight: 600; }
.class-row .join { padding: 6px 12px; font-size: 13px; border-radius: var(--r-sm); }
.empty { color: var(--ink-2); font-size: var(--fs-md); margin: 6px 0; }
.create { background: var(--surface-2); border-radius: var(--r-md); padding: 14px; }

/* radio modal */
.r-choice { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-bottom: 12px; }
.r-opt {
  text-align: left; display: flex; flex-direction: column; gap: 2px; padding: 10px 12px;
  border: 2px solid var(--line); background: #fff; border-radius: var(--r-md); transition: border-color var(--ease), background-color var(--ease);
}
.r-opt:hover { border-color: var(--line-strong); }
.r-opt span { font-size: 22px; }
.r-opt b { font-size: 15px; }
.r-opt small { font-size: 12px; color: var(--ink-2); line-height: 1.4; }
.r-opt em { font-style: normal; font-weight: 700; color: var(--accent); margin-top: 4px; }
.r-opt.on { border-color: var(--accent); background: var(--accent-soft); }
.r-panel { display: flex; flex-direction: column; gap: 8px; }
.r-panel textarea { resize: none; }
.shout-foot { display: flex; justify-content: space-between; font-size: 13px; color: var(--ink-2); margin: 0 0 4px; }

/* ---------- 7. entry (login + "open elsewhere") ---------- */
.entry {
  position: fixed; inset: 0; z-index: 30; display: flex; align-items: center; justify-content: flex-end;
  padding: 24px clamp(16px, 6vw, 96px); overflow: auto; background: #e1ddd6;
}
.entry::before {
  content: ''; position: fixed; left: 2vw; top: 50%; transform: translateY(-50%); width: min(70vw, 1180px); aspect-ratio: 1024 / 572;
  background: url(art/rooms/flagyard.webp) center / cover no-repeat; pointer-events: none;
  -webkit-mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 70%, transparent 100%);
  mask-image: radial-gradient(ellipse 50% 50% at 50% 50%, #000 70%, transparent 100%);
}
.entry.hidden::before { display: none; }
.entry-card {
  position: relative; width: min(400px, 100%); padding: 28px 26px 22px;
  background: rgba(255, 252, 247, .94); -webkit-backdrop-filter: var(--blur); backdrop-filter: var(--blur);
  border: 1px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-3);
}
.entry-brand { display: flex; align-items: center; gap: 8px; font-weight: 600; font-size: var(--fs-md); color: var(--ink-2); }
.entry-brand .dot { width: 8px; height: 8px; border-radius: 50%; background: var(--accent); }
.entry-card h1 { margin: 14px 0 4px; font-size: 32px; line-height: 1.15; font-weight: 700; letter-spacing: -.3px; }
.entry-card .sub { margin: 0 0 14px; color: var(--ink-2); font-size: 15px; }
.live { display: flex; align-items: center; gap: 8px; margin: 0 0 18px; font-size: 13px; color: var(--ink-2); }
.live i { width: 8px; height: 8px; border-radius: 50%; background: var(--live); box-shadow: 0 0 0 4px rgba(79, 168, 104, .15); }
.entry-fields { display: grid; grid-template-columns: minmax(0, 1.4fr) minmax(0, 1fr); gap: 10px; }
.entry-card label { display: flex; flex-direction: column; gap: 5px; min-width: 0; font-size: 13px; font-weight: 600; color: var(--ink-2); }
.entry-card input { min-height: 44px; font-size: 15px; color: var(--ink); }
.lbl { font-size: 13px; font-weight: 600; color: var(--ink-2); margin: 16px 0 6px; }
.muted { font-weight: 400; opacity: .75; }
#animalPick { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.pick {
  display: flex; flex-direction: column; align-items: center; gap: 2px; min-height: 94px; padding: 6px 4px 4px;
  background: #fff; border: 1.5px solid var(--line); border-radius: var(--r-md);
  transition: border-color var(--ease), transform var(--ease);
}
.pick:hover { transform: translateY(-1px); border-color: var(--line-strong); }
.pick-fig { position: relative; display: block; height: 76px; aspect-ratio: 512 / 720; }
.pick-fig img { position: absolute; left: 0; bottom: 0; width: 100%; height: 100%; object-fit: contain; }
.pick-fig.plain img { height: calc(100% * 640 / 720); }   /* the uniform frame has no headroom */
.pick span { font-size: 12px; font-weight: 500; }
.pick.on { border-color: var(--accent); background: var(--accent-soft); }
/* outfit: a segmented control, selected = the same accent as the character picker */
#outfitPick { display: inline-flex; gap: 2px; margin-top: 8px; padding: 3px; background: var(--surface-2); border-radius: var(--r-pill); }
#outfitPick .chip-btn { border: 0; background: transparent; padding: 5px 14px; color: var(--ink-2); font-weight: 500; }
#outfitPick .chip-btn:hover { color: var(--ink); }
#outfitPick .chip-btn.on { background: #fff; color: var(--accent); font-weight: 600; box-shadow: var(--shadow-1); }
.field-hint { margin: 8px 0 0; font-size: 12px; color: var(--ink-2); line-height: 1.5; }
/* Sign in with Google: Google's own button on top, then "or nickname + PIN" */
.google-area { margin: 0 0 4px; }
.google-btn { display: flex; justify-content: center; min-height: 44px; }
.or { display: flex; align-items: center; gap: 10px; margin: 14px 0 12px; font-size: 12px; color: var(--ink-2); }
.or::before, .or::after { content: ''; flex: 1; height: 1px; background: var(--line); }
.profile-note { margin: 0 0 12px; padding: 10px 12px; font-size: 13px; line-height: 1.5; background: var(--accent-soft); border: 1px solid var(--accent-line); border-radius: var(--r-md); }
.google-profile .entry-fields { grid-template-columns: 1fr; }
/* Google is the way in: the main card is just the button; the form returns only for first-time sign-up */
.google-only .or, .google-only .entry-fields, .google-only .field-hint, .google-only .lbl,
.google-only #animalPick, .google-only #outfitPick, .google-only #enterBtn { display: none; }
.google-only .google-area { margin: 6px 0 2px; }
.google-profile .field-hint { display: none; }
.profile-cancel { display: block; margin: 10px auto 0; font-size: 13px; }
#accountSection .google-btn { justify-content: flex-start; }
#loginErr { color: var(--accent); min-height: 20px; margin: 10px 0 2px; font-size: 13px; font-weight: 600; }
.fine { font-size: 12px; color: var(--ink-2); margin: 12px 0 0; text-align: center; opacity: .8; }

/* ---------- 8. responsive ---------- */
/* mid widths: narrower sidebar, the radio button loses its label */
@media (max-width: 1000px) {
  :root { --sidebar-w: 300px; }
  .radio-btn { width: 36px; padding: 0; }
  .radio-btn .icon-label { display: none; }
  .room-switch { width: var(--hud-h); padding: 0; justify-content: center; }
  .room-switch-label { display: none; }   /* icon only on narrower screens */
  .place-nav { flex: 1; }
  .stat { padding: 0 7px; }
}

/* flagpole yard (desktop): the open plaza. Full-screen scene, no sidebar; the chat floats
   bottom-left as a see-through panel; each player sets its opacity in Settings. */
@media (min-width: 701px) {
  :root.layout-yard { --sidebar-w: 0px; --frame: 0px; }
  .layout-yard #game { border: 0; border-radius: 0; box-shadow: none; }
  .layout-yard .social-sidebar {
    top: auto; right: auto; left: var(--gutter); bottom: var(--gutter);
    width: 360px; height: min(560px, 70vh); padding: 0;
  }
  .layout-yard .social-sidebar:has(.chat-panel.folded) { height: auto; }
  .layout-yard .chat-panel {
    background: rgba(255, 252, 247, var(--chat-a, .72));
    -webkit-backdrop-filter: blur(6px); backdrop-filter: blur(6px);
    border-color: rgba(59, 42, 26, .08);
  }
  .layout-yard .chat-head, .layout-yard .people, .layout-yard .chat-form { border-color: rgba(59, 42, 26, .08); }
  .layout-yard #hint { left: calc(50% + 190px); }
  /* outdoors the chat floats on the left: centre in the open part, but never past the right edge */
  .layout-yard .fish-ring { left: min(calc(50% + 190px), calc(100% - 110px)); }
  .layout-yard .catch { left: min(calc(50% + 190px), calc(100% - 185px)); }
}

/* phone / small tablet: scene full width, chat becomes a bottom sheet */
@media (max-width: 700px) {
  :root { --sidebar-w: 0px; --frame: 0px; --gutter: 8px; --hud-h: 40px; --sheet-h: 52dvh; --tv-band: 0px; }
  /* a YouTube video is showing: it docks in a band at the bottom of the chat sheet (never over the scene), and the
     sheet grows by that band so the chat keeps its height. YouTube needs the player visible, so it is never hidden */
  :root.tv-on { --tv-band: 124px; }
  #game { border: 0; border-radius: 0; box-shadow: none; }
  .hud-top { right: var(--gutter); }
  .hud-left { flex: 1; }
  .place-nav { flex: 1; min-width: 0; }
  .place-btn { width: 100%; }
  .popover { width: min(320px, calc(100vw - 2 * var(--gutter))); }
  .place-btn { padding: 0 10px 0 12px; gap: 6px; }
  .place-ico { display: none; }
  .top-actions { gap: 0; }
  .hud-sep { display: none; }
  .stat { padding: 0 6px; font-size: 13px; }
  .icon-btn { width: 32px; height: 32px; font-size: 15px; }
  .radio-btn { width: 32px; }
  .hud-sep { margin: 0 2px; }

  .hud-center { left: 50%; width: calc(100% - 2 * var(--gutter)); }
  .tv { z-index: 7; left: var(--gutter); right: auto; top: auto; bottom: max(8px, env(safe-area-inset-bottom)); width: 200px; height: 112px; border-width: 3px; box-shadow: none; }
  .tv-caption:not(.hidden) { display: flex; }
  .bag-pop, .sound-pop { right: var(--gutter); }

  .social-sidebar {
    top: auto; left: 0; height: calc(var(--sheet-h) + var(--tv-band)); min-height: calc(300px + var(--tv-band)); width: 100%;
    padding: 8px 8px calc(max(8px, env(safe-area-inset-bottom)) + var(--tv-band)); gap: 8px;
    background: var(--paper); border-top: 1px solid var(--line); border-radius: var(--r-lg) var(--r-lg) 0 0;
    box-shadow: 0 -8px 24px rgba(60, 40, 20, .12);
  }
  .social-sidebar:has(.chat-panel.folded) { height: auto; min-height: 0; }
  .chat-panel { padding: 6px 10px 8px; border-radius: var(--r-md); box-shadow: none; }
  .chat-head { padding-bottom: 6px; }
  .people { padding: 5px 0; }
  .chat-log { padding: 6px 0; }
  .chat-form { padding-top: 6px; }
  /* a real-size type box: 16px text keeps iOS from zooming in on focus */
  #chatInput { min-height: 44px; font-size: 16px; }
  .send { width: 44px; height: 44px; }
  .msg .text { font-size: 15px; }
  /* open chat on a phone: the room name is already on the HUD, so the head row goes and the fold button floats in
     the corner; the emoji / GIF / picture buttons share the type box's row. Grid rows: people, log, pickers, compose */
  .chat-panel { position: relative; display: grid; grid-template-columns: auto minmax(0, 1fr); grid-template-rows: auto auto minmax(0, 1fr) auto auto auto; }
  .chat-panel > * { grid-column: 1 / -1; }
  .chat-head { grid-row: 1; }
  .people { grid-row: 2; padding-right: 44px; min-height: 44px; }
  .chat-panel:has(.room-lock:not(.hidden)) .people { padding-right: 206px; }   /* invite, look, table and lock sit beside the fold button */
  .room-lock { width: 36px; height: 36px; padding: 0; justify-content: center; }
  .room-lock-label { display: none; }
  .chat-log { grid-row: 3; }
  .chat-emoji-picker { grid-row: 4; }
  .chat-gif-picker { grid-row: 5; }
  .chat-compose-tools { grid-row: 6; grid-column: 1; padding-top: 6px; gap: 4px; }
  .chat-form { grid-row: 6; grid-column: 2; }
  .chat-compose-tools .chat-tool-btn { width: 32px; min-width: 32px; height: 44px; border-radius: 12px; }
  .chat-panel:not(.folded) .chat-head { position: absolute; z-index: 1; top: 6px; right: 8px; padding: 0; border: 0; }
  .chat-panel:not(.folded) .chat-title-row { display: none; }
  .fold { width: 36px; height: 36px; font-size: 15px; }
  .chat-panel.folded { display: flex; }
  .chat-panel:has(#chatInput:focus, .chat-gif-picker:not(.hidden), .chat-emoji-picker:not(.hidden)):not(.folded) .chat-head { display: none; }
  /* classrooms: the music row needs room too. :where keeps this weak, so typing and the pickers still win */
  .social-sidebar:where(:has(#roomWidget:not(.hidden)):not(:has(.chat-panel.folded))) { height: calc(max(var(--sheet-h), 58dvh) + var(--tv-band)); }
  /* video docked: the music row moves into the band beside it (instead of the caption), so the sheet gives its row back */
  :root.tv-on .social-sidebar:where(:has(#roomWidget:not(.hidden, .open)):not(:has(.chat-panel.folded))) { height: calc(max(var(--sheet-h), 58dvh) - 70px + var(--tv-band)); }
  :root.tv-on:has(#roomWidget:not(.hidden, .open)) #tvCaption { display: none; }
  :root.tv-on #roomWidget:not(.hidden, .open) {
    position: fixed; z-index: 7; left: calc(var(--gutter) + 210px); right: var(--gutter); bottom: max(8px, env(safe-area-inset-bottom));
    height: 112px; max-height: none; flex-direction: column; align-items: stretch; justify-content: center; gap: 6px;
    padding: 4px 0; background: transparent; border: 0; overflow: visible;
  }
  :root.tv-on #roomWidget:not(.open) .w-now { grid-template-columns: minmax(0, 1fr); padding: 0; background: transparent; }
  :root.tv-on #roomWidget:not(.open) .w-now img { display: none; }
  :root.tv-on #roomWidget:not(.open) .w-info { flex-direction: column; align-items: stretch; gap: 4px; }
  :root.tv-on #roomWidget:not(.open) .w-info b { white-space: normal; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; }
  :root.tv-on #roomWidget:not(.open) .w-top { order: 2; }
  /* typing: the keyboard takes half the screen, so the sheet takes most of what is left and the people strip steps aside */
  .social-sidebar:has(#chatInput:focus) { height: min(calc(max(var(--sheet-h), 72dvh) + var(--tv-band)), calc(100dvh - 56px)); }
  .chat-panel:has(#chatInput:focus) .people { display: none; }
  .social-sidebar:has(#chatInput:focus) .float-widget { display: none; }
  /* classroom music card, folded: one slim row (song + play + "add"), so the chat above keeps its room */
  .float-widget:not(.open) { flex-direction: row; align-items: center; gap: 8px; }
  .float-widget:not(.open) .w-top { order: 2; flex: none; }
  .float-widget:not(.open) .w-tabs, .float-widget:not(.open) .w-list, .float-widget:not(.open) .w-seek { display: none; }   /* folded row: open the card (＋) to see the queue */
  .float-widget:not(.open) .w-panes, .float-widget:not(.open) .w-pane-now { display: contents; }   /* folded row: the old one-line layout */
  #roomWidget.q-open:not(.open) .w-pane-now { visibility: visible; }
  .float-widget:not(.open) .w-head, .float-widget:not(.open) .w-info > small, .float-widget:not(.open) #wBy { display: none; }
  .float-widget:not(.open) .w-now { flex: 1; min-width: 0; grid-template-columns: 36px minmax(0, 1fr); padding: 4px 6px; gap: 8px; }
  .float-widget:not(.open) .w-now img { width: 36px; height: 36px; }
  .float-widget:not(.open) .w-info { display: flex; flex-direction: row; align-items: center; gap: 6px; min-width: 0; }
  .float-widget:not(.open) .w-info b { flex: 1; min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; font-size: 13px; }
  .float-widget:not(.open) .w-ctrl { margin-top: 0; }
  .float-widget:not(.open) #wVol { display: none; }
  /* while a picker is open, the people strip steps aside to give the picker and the type box room */
  .chat-panel:has(.chat-gif-picker:not(.hidden), .chat-emoji-picker:not(.hidden)) .people { display: none; }
  .social-sidebar:has(.chat-gif-picker:not(.hidden), .chat-emoji-picker:not(.hidden)) { height: min(calc(max(var(--sheet-h), 68dvh) + var(--tv-band)), calc(100dvh - 56px)); }
  .float-widget { max-height: 120px; padding: 8px 10px; border-radius: var(--r-md); box-shadow: none; }
  .float-widget:not(.open) .w-form, .float-widget .w-queue { display: none; }
  .w-toggle { display: inline-block; }
  .w-now { grid-template-columns: 48px minmax(0, 1fr); padding: 6px; }
  .w-now img { width: 48px; height: 48px; }
  .w-ctrl .vol { display: none; }

  #hint { left: 50%; bottom: calc(var(--sheet-h) + var(--tv-band) + 12px); }
  #actBtn { right: 12px; bottom: calc(var(--sheet-h) + var(--tv-band) + 8px); }
  .r-vol { display: none; }
  .r-choice, .class-cols, .place-cols { grid-template-columns: 1fr; }
  .wardrobe-cols { grid-template-columns: 1fr; gap: 12px; }
  .wd-preview { flex-direction: row; padding: 8px; }
  .wd-preview canvas { width: 110px; flex: none; }
  .wd-grid { grid-template-columns: repeat(3, 1fr); max-height: 40vh; }
  .wd-thumb { height: 104px; }
  .place-cols { gap: 12px; margin-top: 10px; }
  .room-btn { padding: 7px 8px; }
  .room-ico { width: 32px; height: 32px; font-size: 16px; }
  .pp-img { aspect-ratio: 2 / 1; }
  .place-preview h3 { margin-top: 10px; font-size: 16px; }
  .place-preview p { font-size: 13px; line-height: 1.55; }
  .pp-actions .btn { flex: 1; }
  /* the place list is long on a phone: keep "ไปที่นี่" pinned to the bottom of the card, so tapping a place visibly does something */
  .pp-actions { position: sticky; bottom: -16px; margin: 0 -16px -16px; padding: 10px 16px 16px; background: var(--surface); border-top: 1px solid var(--line); }
  .pp-actions [data-close] { display: none; }
  .room-leave { padding: 0 11px 0 9px; font-size: 13px; gap: 4px; }
  .class-hud { padding: 0 11px 0 9px; font-size: 13px; gap: 4px; }
  .class-hud-long { display: none; }
  .class-hud-short { display: inline; }
  .pp-keys { display: none; }
  .modal { padding: 10px; }
  .modal-card { max-height: calc(100dvh - 20px); padding: 16px; border-radius: var(--r-lg); }

  .entry { align-items: flex-end; justify-content: center; padding: max(10px, env(safe-area-inset-top)) 12px max(12px, env(safe-area-inset-bottom)); }
  .entry::before { left: 50%; top: 2vh; transform: translateX(-50%); width: 150vw; }
  .entry-card { max-height: calc(100dvh - 24px); overflow-y: auto; padding: 22px 18px 16px; border-radius: var(--r-lg); }
  .entry-card h1 { font-size: 26px; }
}
@media (max-width: 400px) {
  .stat { font-size: 12px; }
  .entry-card h1 { font-size: 24px; }
  .pick-fig { height: 64px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { scroll-behavior: auto !important; animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }
}

/* ---------- start-a-game page (marble tables) and the co-op shop ---------- */
.game-pick { display: grid; grid-template-columns: repeat(2, 1fr); gap: 8px; }
.game-opt {
  display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; column-gap: 10px; align-items: center;
  text-align: left; padding: 10px 12px; border: 1px solid var(--line); border-radius: 12px; background: #fff; cursor: pointer; font: inherit; color: inherit;
}
.game-opt:hover { background: var(--surface-2); }
.game-opt.on { border-color: var(--accent); background: var(--accent-soft); box-shadow: inset 0 0 0 1px var(--accent); }
.game-opt .game-ico { grid-row: span 2; font-size: 24px; line-height: 1; }
.game-opt small { color: var(--ink-2); }
.game-open { display: flex; gap: 8px; align-items: center; margin-top: 12px; color: var(--ink-2); font-size: var(--fs-md); }
.game-opt:disabled { opacity: .55; cursor: not-allowed; }
/* the picker: every game the same height, every icon in the same 44px box */
#gameModal .modal-card { width: min(560px, 100%); }
.game-pick { gap: 8px; }
.game-opt { grid-template-columns: 44px minmax(0, 1fr); min-height: 64px; padding: 9px 12px; }
.game-opt .game-ico { width: 44px; height: 44px; display: grid; place-items: center; border-radius: 12px; background: var(--surface-2); font-size: 24px; overflow: hidden; }
.game-opt.on .game-ico { background: #fff; }
.game-opt .game-ico .ui-ico { width: 32px; height: 32px; vertical-align: 0; }
.game-opt b, .game-opt small { min-width: 0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.game-opt:disabled { opacity: 1; background: transparent; border-style: dashed; }
.game-opt:disabled .game-ico { filter: grayscale(1); opacity: .5; }
.game-opt:disabled b, .game-opt:disabled small { color: var(--ink-2); }
.game-fan { position: relative; display: block; width: 34px; height: 34px; }
.game-fan .pd-card.pd-mini { --cw: 21px; position: absolute; top: 2px; box-shadow: 0 1px 2px rgba(30, 20, 10, .35); }
.game-fan .pd-card.pd-mini:first-child { left: 1px; transform: rotate(-10deg); }
.game-fan .pd-card.pd-mini:last-child { right: 1px; transform: rotate(9deg); }
.game-fan .pd-card.pd-mini .pd-art { border-radius: .3em; }
.game-fan .pd-card.pd-mini .pd-suit { font-size: 2em; }
.game-fan .cc-card.pd-mini .cc-sym { font-size: 1.9em; }
.game-fan .cc-card.pd-mini .pd-art { background: var(--house); }
.game-opt .dm-tile.dm-mini { --tw: 17px; transform: rotate(-12deg); }
.game-tables { display: grid; gap: 7px; margin-top: 12px; }
.game-table-row { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 10px; font-size: var(--fs-sm); }
.game-table-row .btn { flex: 0 0 auto; }
.checkers-card { width: min(940px, 100%); }
/* the game window: the game on the left, the table's own chat on the right */
.tg-layout { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 14px; align-items: start; }
.tg-main { min-width: 0; }
.tg-chat { position: sticky; top: 0; display: flex; flex-direction: column; gap: 8px; height: min(560px, calc(100dvh - 140px)); padding: 10px; border: 1px solid var(--line); border-radius: 14px; background: var(--surface-2); }
.tg-chat-head { font-size: var(--fs-md); }
.tg-chat-head small { display: block; font-weight: 400; color: var(--ink-2); font-size: var(--fs-sm); }
.tg-chat-log { flex: 1 1 auto; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 6px; }
.tg-chat-msg { align-self: flex-start; max-width: 92%; padding: 6px 9px; border-radius: 12px 12px 12px 4px; background: var(--surface); border: 1px solid var(--line); font-size: var(--fs-sm); line-height: 1.4; overflow-wrap: anywhere; }
.tg-chat-msg b { display: block; font-size: 12px; color: var(--ink-2); }
.tg-chat-msg.mine { align-self: flex-end; border-radius: 12px 12px 4px 12px; background: var(--accent-soft); border-color: var(--accent-line, var(--line)); }
.tg-chat-msg.mine b { display: none; }
.tg-chat-empty { margin: auto 0; text-align: center; }
.tg-chat-form { display: flex; gap: 6px; }
.tg-chat-form input { flex: 1 1 auto; min-width: 0; min-height: 40px; padding: 0 10px; border: 1px solid var(--line); border-radius: 10px; font: inherit; font-size: 16px; background: var(--surface); color: inherit; }
.tg-chat-form .btn { flex: 0 0 auto; min-height: 40px; }
@media (max-width: 760px) {
  .tg-layout { grid-template-columns: 1fr; }
  .tg-chat { position: static; height: 240px; }
}
.checkers-board {
  position: relative; width: min(100%, 540px); aspect-ratio: 1; margin: 8px auto 12px;
  background: url('/art/games/checkers_board.png') center / contain no-repeat;
  isolation: isolate;
}
.checker-grid {
  position: absolute; left: 16.67%; top: 18.8%; width: 66.66%; height: 60.44%;
  display: grid; grid-template-columns: repeat(8, minmax(0, 1fr)); grid-template-rows: repeat(8, minmax(0, 1fr));
}
.checker-cell { display: grid; place-items: center; min-width: 0; min-height: 0; padding: 0; border: 0; border-radius: 0; background: transparent; appearance: none; }
.checker-cell.selected { background: rgba(255, 211, 91, .3); box-shadow: inset 0 0 0 3px #f4d35e; }
.checker-cell:focus-visible { outline: 2px solid #fff2b8; outline-offset: -3px; }
.checker-cell:disabled { opacity: 1; cursor: default; }
.checker-piece { display: block; width: 92%; aspect-ratio: 1; background-position: center; background-repeat: no-repeat; background-size: contain; }
.checker-piece.red { background-image: url('/art/games/checker_red.png'); }
.checker-piece.black { background-image: url('/art/games/checker_black.png'); }
.checker-piece.red.king { background-image: url('/art/games/checker_red_king.png'); }
.checker-piece.black.king { background-image: url('/art/games/checker_black_king.png'); }
.xo-board { background: none; }
.xo-grid { width: min(100%, 420px); aspect-ratio: 1; margin: 10px auto; display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); gap: 8px; }
.xo-cell { display: grid; place-items: center; min-width: 0; border: 2px solid #b99b76; border-radius: 16px; background: linear-gradient(145deg, #fff8e9, #eadcc4); color: #6c5140; font-size: clamp(36px, 10vw, 76px); font-weight: 800; box-shadow: 0 3px 0 rgba(93, 66, 42, .18); }
.xo-cell.x { color: #bd5146; }
.xo-cell.o { color: #557c83; }
.xo-cell:disabled { opacity: 1; cursor: default; }
/* Pok Deng table: cards drawn in CSS, the viewer's own hand at the bottom */
.pd-board { aspect-ratio: auto; width: 100%; display: grid; gap: 10px; }
.pd-others { display: grid; grid-template-columns: repeat(auto-fit, minmax(140px, 1fr)); gap: 8px; }
.pd-seat { position: relative; display: grid; gap: 6px; justify-items: center; padding: 10px 8px; border-radius: 14px; background: linear-gradient(160deg, #2f6b4f, #24533e); color: #f3efe2; box-shadow: inset 0 0 0 2px rgba(255,255,255,.08); }
.pd-seat.mine { padding: 14px 10px; }
.pd-seat.dealer { box-shadow: inset 0 0 0 2px #e8c65a; }
.pd-seat.turn { box-shadow: inset 0 0 0 3px #fff2b8, 0 0 0 3px rgba(255, 226, 120, .35); }
.pd-name { display: flex; gap: 8px; align-items: baseline; justify-content: center; flex-wrap: wrap; font-size: var(--fs-sm); font-weight: 700; text-align: center; }
.pd-pts { font-weight: 400; opacity: .85; }
.pd-cards { display: flex; gap: 4px; min-height: 76px; align-items: center; }
/* cards (public/cards.js): a picture on top, one label below; 1em = a fifth of the card's width (--cw) */
.pd-card {
  --cw: 52px; position: relative; display: inline-flex; flex-direction: column; flex: 0 0 auto;
  width: var(--cw); height: calc(var(--cw) * 1.4); padding: .3em .3em 0; box-sizing: border-box;
  font-size: calc(var(--cw) / 5); line-height: 1; border-radius: .55em; overflow: hidden;
  background: #fffaf1; box-shadow: 0 .08em .2em rgba(30, 20, 10, .28); color: #2a2a2a;
}
.pd-seat.mine .pd-card { --cw: 72px; }
/* each suit is a school sports house: brick red, mustard, olive, navy */
.pd-card.s-h { color: #b5463a; --house: #f6e3dd; }
.pd-card.s-d { color: #a2710b; --house: #f6ecd0; }
.pd-card.s-c { color: #5b6a28; --house: #e8ecd6; }
.pd-card.s-s { color: #2f3b63; --house: #e1e5ef; }
.pd-art { position: relative; flex: 1 1 auto; display: grid; place-items: center; overflow: hidden; border-radius: .35em; background: var(--house); }
.pd-suit { font-size: 2.2em; opacity: .9; }
.pd-face { position: absolute; left: 50%; bottom: 0; height: 100%; width: auto; max-width: none; transform: translateX(-50%); }
.pd-medal { width: 74%; }
.pd-label { flex: 0 0 auto; display: flex; align-items: baseline; justify-content: center; gap: .14em; height: 1.95em; padding-top: .3em; box-sizing: border-box; }
.pd-label b { font-size: 1.5em; font-weight: 700; font-family: inherit; }
.pd-label b.ten { letter-spacing: -.06em; }
.pd-label i { font-style: normal; font-size: 1.05em; }
.pd-card.back { padding: 0; background: #a8473b url('/art/cards/back-classic.webp') center / 100% 100% no-repeat; }
.pd-card.pd-mini { --cw: 22px; box-shadow: 0 0 0 1px var(--line); }
.pd-card.pd-mini .pd-label { display: none; }
.pd-card.pd-mini .pd-art { background: none; }
.pd-card.pd-mini .pd-medal { width: 100%; }
.pd-tag { min-height: 1.2em; font-size: var(--fs-sm); color: #fff2b8; }
.pd-res { padding: 2px 10px; border-radius: 999px; font-size: var(--fs-sm); font-weight: 700; background: rgba(0,0,0,.25); }
.pd-res.win { background: #e8c65a; color: #3b2d06; }
.pd-res.lose { background: rgba(0,0,0,.35); color: #ffd1c9; }
.pd-actions { display: flex; gap: 8px; }
.pd-actions .btn { min-width: 110px; min-height: 44px; }
.pd-wait { display: grid; gap: 6px; }
.pd-wait-seat { padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px; }
.pd-wait-seat.empty { color: var(--ink-2); border-style: dashed; }
.pd-start { justify-self: center; min-width: 160px; }
.pd-help { text-align: center; margin: 0; }
/* ---------- table games (public/tablegames.js): poker, ไพ่สีเปลี่ยนวง, dominoes ---------- */
.tg-middle { display: grid; gap: 6px; justify-items: center; padding: 10px 8px; border-radius: 14px; background: radial-gradient(ellipse at 50% 40%, #3a7a5b, #24533e); color: #f3efe2; }
.tg-community .pd-card { --cw: 52px; }
.tg-slot { background: rgba(255, 255, 255, .08); box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, .25); }
.tg-pot { display: flex; align-items: center; gap: 4px; font-size: var(--fs-sm); color: #fff2b8; text-align: center; }
.tg-more { align-self: center; font-size: var(--fs-sm); color: #fff2b8; }
.pd-actions.tg-wrap { flex-wrap: wrap; justify-content: center; }
.pd-actions.tg-wrap .btn { min-width: 0; }
.pd-cards.tg-hand { flex-wrap: wrap; justify-content: center; max-width: 100%; padding-top: 12px; row-gap: 16px; }
.pd-seat.mine .tg-hand .pd-card { --cw: 56px; }
.tg-playable { cursor: pointer; transform: translateY(-10px); box-shadow: 0 0 0 3px #f2c94c, 0 6px 10px rgba(0, 0, 0, .35); transition: transform .12s ease; }
.tg-playable:hover, .tg-playable:focus-visible { transform: translateY(-14px); outline: none; }
.tg-playable:focus-visible { box-shadow: 0 0 0 3px #fff, 0 4px 8px rgba(0, 0, 0, .3); }
.tg-dim { opacity: .62; }
/* face-down hands of the other seats fan out instead of overflowing */
.pd-others .pd-cards { flex-wrap: nowrap; justify-content: center; min-width: 0; }
.pd-others .pd-card.back + .pd-card.back { margin-left: calc(var(--cw) * -.62); }
.pd-others .dm-tile.back + .dm-tile.back { margin-left: calc(var(--tw) * -1.2); }
.pd-others .pd-seat { min-width: 0; overflow: hidden; }
.cc-middle .pd-card.tg-playable { transform: none; }
.tg-picked { transform: translateY(-6px); box-shadow: 0 0 0 3px #fff2b8; }
/* colour cards: the picture area takes the strong house colour */
.cc-card.cc-r { --house: #b5463a; color: #b5463a; }
.cc-card.cc-y { --house: #c8951b; color: #a2710b; }
.cc-card.cc-g { --house: #6b7c33; color: #5b6a28; }
.cc-card.cc-b { --house: #2f3b63; color: #2f3b63; }
.cc-card.cc-w { --house: #2a2a33; color: #2a2a33; }
.cc-sym { position: relative; z-index: 1; font-size: 2.4em; font-weight: 800; color: #fffaf1; font-family: inherit; }
.cc-sym.wide { font-size: 1.8em; letter-spacing: -.04em; }
.cc-wheel { position: absolute; width: 70%; aspect-ratio: 1; border-radius: 50%; background: conic-gradient(#b5463a 0 25%, #c8951b 0 50%, #6b7c33 0 75%, #2f3b63 0); box-shadow: 0 0 0 .12em #fffaf1; }
.cc-label { font-size: .85em; font-weight: 700; white-space: nowrap; align-items: center; }
.pd-card.cc-back { background: #2f3b63 url('/art/cards/back-colour.webp') center / 100% 100% no-repeat; }
.cc-middle .pd-cards { gap: 14px; }
.cc-middle .pd-card { --cw: 60px; }
.cc-dot { display: inline-block; width: 12px; height: 12px; border-radius: 50%; box-shadow: 0 0 0 2px #fffaf1; }
.cc-dot.cc-r { background: #b5463a; } .cc-dot.cc-y { background: #c8951b; } .cc-dot.cc-g { background: #6b7c33; } .cc-dot.cc-b { background: #2f3b63; }
.btn.cc-pick { color: #fffaf1; border: 0; min-width: 64px; }
.btn.cc-pick.cc-r { background: #b5463a; } .btn.cc-pick.cc-y { background: #c8951b; } .btn.cc-pick.cc-g { background: #6b7c33; } .btn.cc-pick.cc-b { background: #2f3b63; }
/* dominoes: --tw is the width of one half; a tile lies flat, two halves side by side */
.dm-tile { --tw: 26px; display: inline-flex; flex: 0 0 auto; border-radius: calc(var(--tw) * .18); background: linear-gradient(170deg, #fffdf7, #efe6d3); box-shadow: 0 1px 2px rgba(30, 20, 10, .35); }
.dm-tile.back { width: calc(var(--tw) * 2); height: var(--tw); background: #a8473b; box-shadow: inset 0 0 0 2px #f3e6cf, 0 1px 2px rgba(30, 20, 10, .35); }
.dm-half { display: grid; grid-template-columns: repeat(3, 1fr); grid-template-rows: repeat(3, 1fr); width: var(--tw); height: var(--tw); padding: calc(var(--tw) * .14); box-sizing: border-box; place-items: center; }
.dm-half + .dm-half { box-shadow: inset 1px 0 0 rgba(60, 40, 20, .3); }
.dm-half i { width: 70%; aspect-ratio: 1; border-radius: 50%; }
.dm-half i.on { background: #2a2a33; }
.pd-seat.mine .dm-tile { --tw: 34px; }
.dm-tile.dm-sm { --tw: 16px; }
.dm-tile.dm-mini { --tw: 14px; }
.dm-line { display: flex; flex-wrap: wrap; justify-content: center; gap: 3px; max-height: 190px; overflow-y: auto; padding: 4px; }
.dm-line .dm-tile { --tw: 24px; }
@media (max-width: 480px) {
  .pd-others { grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 6px; }
  .pd-seat { padding: 8px 4px; }
  .pd-others .pd-card { --cw: 34px; }
  .tg-community .pd-card { --cw: 44px; }
  .pd-seat.mine .tg-hand .pd-card { --cw: 46px; }
  .cc-middle .pd-card { --cw: 50px; }
  .pd-seat.mine .dm-tile { --tw: 28px; }
  .dm-tile.dm-sm { --tw: 11px; }
  .dm-line .dm-tile { --tw: 19px; }
  .pd-others .pd-cards { min-height: 50px; gap: 2px; }
}
.xo-cell:not(:disabled):hover { background: #fffdf7; transform: translateY(-1px); }
.shop-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.shop-item { display: grid; justify-items: center; gap: 2px; padding: 12px 6px; border: 1px dashed var(--line-strong, var(--line)); border-radius: 12px; background: var(--surface-2); }
.shop-item span { font-size: 26px; filter: grayscale(.35); }
.shop-item small { color: var(--ink-3, var(--ink-2)); }
@media (max-width: 700px) { .shop-grid { grid-template-columns: repeat(2, 1fr); } }

/* links in small print */
.fine a { color: inherit; }
.foot-link { margin-right: auto; align-self: center; font-size: 13px; color: var(--ink-2); }

/* ---------- profile cards ---------- */
/* a ring around a head portrait: the ring colour is the frame you wear (wardrobe), plain line colour without one */
.ring-avatar { display: inline-grid; place-items: center; flex: none; width: 44px; height: 44px; padding: 3px; border: 0; border-radius: 50%; background: var(--ring, var(--line)); }
.ring-avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; background: var(--surface-2); border: 2px solid #fff; display: block; }
.ring-avatar.big { width: 104px; height: 104px; padding: 5px; margin: 4px auto 6px; }
.ring-avatar.big img { border-width: 3px; }
button.ring-avatar { cursor: pointer; transition: transform var(--ease); }
button.ring-avatar:hover { transform: scale(1.06); }

/* ---------- public profile card + personal editor ---------- */
.profile-showcase { padding: 5px; border-radius: 20px; background: var(--card-frame, var(--line)); box-shadow: 0 5px 18px rgba(45,32,20,.12); }
.profile-showcase-inner { min-width: 0; padding: 16px; border-radius: 15px; color: var(--ink); }
.profile-showcase.dark .profile-showcase-inner { color: #fff; }
.profile-showcase-head { display: flex; align-items: center; gap: 12px; }
.profile-portrait { width: 64px; height: 64px; padding: 4px; }
.profile-identity { min-width: 0; display: flex; flex-direction: column; gap: 3px; text-align: left; }
.profile-identity b { overflow-wrap: anywhere; font-size: 18px; line-height: 1.3; }
.profile-identity small { opacity: .72; font-size: 13px; }
.profile-selected-title { display: inline-flex; align-self: flex-start; padding: 3px 8px; border: 1px solid rgba(180,135,40,.3); border-radius: 999px; background: #fff1c9; color: #805b13; font-size: 12px; font-weight: 700; }
.profile-showcase-thought { margin: 14px 0 8px; padding: 9px 12px; border: 1px solid rgba(80,70,60,.18); border-radius: 13px 13px 13px 4px; background: rgba(255,255,255,.72); color: #493b31; font-size: 14px; line-height: 1.5; overflow-wrap: anywhere; }
.profile-showcase-bio { margin: 0; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; white-space: pre-wrap; }
.profile-showcase-friend { width: 100%; margin-top: 14px; padding: 8px 12px; border: 1px solid rgba(80,70,60,.2); border-radius: var(--r-pill); background: rgba(255,255,255,.72); color: #493b31; font: inherit; font-size: 13px; font-weight: 600; cursor: pointer; }
.profile-showcase-friend.on { border-color: #f0d08a; background: #fff8e6; color: #a8730c; }
.profile-showcase-friend:disabled { cursor: default; opacity: .75; }
.profile-showcase .empty { opacity: .6; }
.profile-editor { width: min(850px, 100%); }
.profile-editor-cols { display: grid; grid-template-columns: minmax(230px, .8fr) minmax(0, 1.2fr); gap: 20px; margin-top: 16px; }
.profile-preview-pane { align-self: start; padding: 14px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); }
.profile-kicker { display: block; margin-bottom: 10px; color: var(--ink-2); font-size: 12px; font-weight: 600; }
.profile-tabs { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 14px; }
.profile-tabs button { padding: 7px 11px; border: 1px solid var(--line); border-radius: var(--r-pill); background: var(--surface-2); color: var(--ink-2); font: inherit; font-size: 13px; }
.profile-tabs button.on { border-color: var(--accent-line); background: var(--accent-soft); color: var(--accent); font-weight: 600; }
.profile-info label { display: block; margin: 10px 0; font-size: 13px; font-weight: 600; }
.profile-info input, .profile-info textarea { display: block; width: 100%; margin-top: 5px; padding: 10px 12px; border: 1px solid var(--line); border-radius: var(--r-md); background: #fff; color: var(--ink); font: inherit; font-size: 14px; }
.profile-info textarea { resize: vertical; }
.profile-info .btn { width: 100%; margin-top: 8px; }
.profile-decor-grid { display: grid; grid-template-columns: repeat(3, minmax(0,1fr)); gap: 8px; max-height: 420px; overflow-y: auto; }
.profile-decor-item { min-width: 0; display: flex; flex-direction: column; align-items: center; gap: 5px; padding: 9px 6px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); color: var(--ink); font: inherit; cursor: pointer; }
.profile-decor-item.on { border: 2px solid var(--accent); padding: 8px 5px; background: var(--accent-soft); }
.profile-decor-item.locked { opacity: .62; }
.profile-decor-sample { display: grid; place-items: center; width: 100%; height: 54px; border: 1px solid var(--line); border-radius: 8px; color: #493b31; font-weight: 700; }
.profile-decor-item b { font-size: 12px; text-align: center; }
.profile-decor-item small { color: var(--ink-2); font-size: 11px; }
.modal-card.person-card { width: min(360px, 100%); text-align: center; }
.person-card .profile-showcase { margin: 8px 0 14px; text-align: left; }
.wd-ring { width: 84px; height: 84px; padding: 5px; margin: 6px auto; display: grid; }
#hint { bottom: calc(var(--frame) + 20px); }
@media (max-width: 700px) {
  .profile-btn { width: 32px; padding: 0; }
  .profile-btn .icon-label { display: none; }
  .profile-editor-cols { grid-template-columns: 1fr; gap: 12px; }
  .profile-preview-pane { padding: 10px; }
  .profile-decor-grid { grid-template-columns: repeat(3, minmax(0,1fr)); max-height: 32vh; }
  .profile-showcase-inner { padding: 13px; }
  .profile-portrait { width: 56px; height: 56px; }
}

.wd-item.locked .wd-ring { filter: grayscale(.85) opacity(.55); }

/* ---------- mail (letters and gifts from the school) ---------- */
.mail-card { width: min(460px, 100%); }
/* friends (MSN style) */
.hud-badge.online { background: #2f9e5c; }
.friends-card { width: min(460px, 100%); }
.friends-list { display: grid; gap: 6px; max-height: min(62vh, 560px); overflow-y: auto; }
.friends-h { margin: 10px 0 2px; font-size: var(--fs-sm); color: var(--ink-2); font-weight: 700; }
.friends-h:first-child { margin-top: 0; }
.friends-empty { margin: 4px 0 8px; color: var(--ink-2); font-size: var(--fs-sm); }
.friend-row { display: flex; align-items: center; gap: 8px; padding: 6px 8px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.friend-row.pending { padding: 8px 12px; }
.friend-who { display: flex; align-items: center; gap: 10px; flex: 1; min-width: 0; padding: 0; border: 0; background: none; text-align: left; color: var(--ink); cursor: pointer; }
.friend-who > img { width: 38px; height: 38px; flex: none; object-fit: cover; object-position: top; border-radius: 50%; background: var(--accent-soft); }
.friend-row.online .friend-who > img { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px #2f9e5c; }
.friend-row:not(.online):not(.pending) .friend-who { opacity: .6; }
.friend-txt { display: grid; min-width: 0; flex: 1; }
.friend-name { display: flex; align-items: baseline; gap: 6px; min-width: 0; white-space: nowrap; }
.friend-name b { flex: none; max-width: 60%; overflow: hidden; text-overflow: ellipsis; }
.friend-bio { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; font-style: normal; font-size: var(--fs-xs); color: var(--ink-2); }
.friend-bio::before { content: '— '; }
.friend-txt small .ui-ico { width: 16px; height: 16px; vertical-align: -3px; }
.friend-txt small { color: var(--ink-2); font-size: var(--fs-xs); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.friend-acts { display: flex; gap: 6px; flex: none; }
.friend-row .btn { flex: none; min-height: 34px; padding: 0 12px; font-size: var(--fs-sm); }
.friend-row .btn:disabled { background: var(--surface-2); color: var(--ink-3); }
.mail-list { display: grid; gap: 8px; margin-top: 10px; max-height: min(60vh, 520px); overflow-y: auto; }
.mail-empty { margin: 18px 0; color: var(--ink-2); text-align: center; font-size: var(--fs-sm); }
.mail-item { border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); overflow: hidden; }
.mail-item.unread { border-color: var(--accent-line); background: var(--accent-soft); }
.mail-head { display: flex; align-items: center; gap: 10px; width: 100%; padding: 10px 12px; border: 0; background: transparent; text-align: left; cursor: pointer; color: var(--ink); }
.mail-head .ui-ico { width: 30px; height: 30px; }
.mail-text { display: grid; flex: 1; min-width: 0; }
.mail-title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.mail-item.unread .mail-title::before { content: ''; display: inline-block; width: 7px; height: 7px; margin-right: 6px; border-radius: 50%; background: #e5484d; vertical-align: .15em; }
.mail-meta { color: var(--ink-2); font-size: var(--fs-xs); }
.mail-tag { flex: none; padding: 2px 8px; border-radius: 99px; background: #fff1c9; color: #8a5a00; font-size: var(--fs-xs); font-weight: 700; }
.mail-body { display: grid; gap: 10px; padding: 0 12px 12px 52px; }
.mail-body p { margin: 0; white-space: pre-wrap; line-height: 1.6; font-size: var(--fs-sm); }
.mail-gift { display: flex; flex-wrap: wrap; gap: 6px; }
.gift-chip { display: inline-flex; align-items: center; gap: 5px; padding: 4px 10px 4px 6px; border: 1px solid var(--line); border-radius: 99px; background: #fff; font-size: var(--fs-sm); font-weight: 600; }
.gift-chip .ui-ico { width: 20px; height: 20px; }
.mail-body .btn { justify-self: start; }
.mail-exp { color: var(--ink-2); font-size: var(--fs-xs); }
@media (max-width: 700px) { .mail-body { padding-left: 12px; } }

/* ---------- animated decorations (catalog items with fx; reduced-motion users get them still) ---------- */
/* spin: a ring written as conic-gradient(from var(--fx-a, 0deg), ...) turns slowly */
@property --fx-a { syntax: '<angle>'; inherits: false; initial-value: 0deg; }
.fx-spin { animation: fx-spin 9s linear infinite; }
@keyframes fx-spin { to { --fx-a: 360deg; } }
/* shimmer: a 45deg striped border (stripe period 56px) slides along; 79.2px = 56px / cos 45deg keeps it seamless */
.fx-shimmer { animation: fx-shimmer 3.2s linear infinite; }
@keyframes fx-shimmer { from { background-position: 0 0; } to { background-position: 79.2px 0; } }
/* drift: two bubble layers (26px and 40px tiles) float up at different speeds over a fixed paper layer */
.fx-drift { animation: fx-drift 7s linear infinite; }
@keyframes fx-drift { from { background-position: 0 0, 20px 0, 0 0; } to { background-position: 0 -26px, 20px -40px, 0 0; } }

/* sign-in inside LINE / Facebook / ... in-app browsers: Google refuses there, so point to the real browser */
.inapp-note { display: grid; gap: 6px; margin-bottom: 12px; padding: 10px 12px; border: 1px solid #f0c36d; border-radius: var(--r-md); background: #fff7e3; color: #6b4a00; font-size: var(--fs-sm); line-height: 1.5; text-align: left; }
.inapp-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.inapp-actions .btn { flex: 1; min-width: 120px; text-align: center; text-decoration: none; }

/* narrow phones: the icon row leaves no room for the place name, so the place button (and the classroom's
   leave / switch buttons) move to a second row under the icons, full width and readable */
@media (max-width: 520px) {
  .hud-top { flex-wrap: wrap; row-gap: 6px; }
  .top-actions { order: -1; margin-left: auto; }
  .hud-left { flex: 1 1 100%; }
  .place-btn { width: auto; max-width: 100%; }
  .place-nav { flex: 0 1 auto; }
  .class-hud.in-class { display: none; }
  .hud-center { top: calc(var(--frame) + var(--gutter) + 2 * var(--hud-h) + 16px); }
}

/* the top icons: one line on a wide screen (order keeps the old left-to-right order); on a phone only mail,
   outfit and slimes stay out, and ⋯ drops the rest down as a labelled row under the bar */
.more-btn { display: none; }
.more-row { display: contents; }
#mapBtn { order: 1; } #radioBtn { order: 2; } #mailBtn { order: 3; } #friendsBtn { order: 4; } #outfitBtn { order: 5; }
#petsBtn { order: 6; } #profileBtn { order: 7; } #bagBtn { order: 8; } #soundBtn { order: 9; } #settingsBtn { order: 10; }
.more-ico { font-size: 22px; font-weight: 700; line-height: 1; transform: translateY(-3px); }
@media (max-width: 520px) {
  .top-actions { position: relative; z-index: 2; }
  .top-actions.more-open { z-index: 7; }
  .hud-top:has(.more-open) { z-index: 8; }   /* above the announcement cards under the bar */
  .more-btn { display: inline-grid; order: 11; }
  .more-btn[aria-expanded=true] { background: var(--accent-soft); color: var(--accent); }
  .more-btn[aria-expanded=true] .more-ico { font-size: 17px; transform: none; }
  .more-row {
    display: none; position: absolute; z-index: 6; top: calc(100% + 6px); right: 0; width: calc(100vw - 2 * var(--gutter));
    gap: 2px; padding: 6px; border-radius: 18px; background: var(--surface); border: 1px solid var(--line); box-shadow: var(--shadow-2);
  }
  .top-actions.more-open .more-row { display: flex; animation: moreIn .14s ease-out; }
  @keyframes moreIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: none; } }
  .more-row .icon-btn { display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px; width: auto; min-width: 58px; height: 58px; padding: 4px 6px; border-radius: 14px; font-size: 20px; }
  .more-row .icon-btn .ui-ico { width: 26px; height: 26px; }
  .more-row .icon-btn::after { content: attr(data-label); font-size: 11px; font-weight: 600; color: var(--ink-2); white-space: nowrap; line-height: 1; }
  .more-row .hud-badge { top: 2px; right: 6px; } .more-row .hud-dot { top: 4px; right: 10px; }
  /* seven labelled icons are wider than a phone: two even lines of four (sliding sideways hid the last ones) */
  .top-actions.more-open .more-row { display: grid; grid-template-columns: repeat(4, 1fr); }
  #soundBtn { font-size: 24px; }
}

/* ---------- fishing: catch card, school-wide announcements, shop, fish book ---------- */
.tier-chip { --tier: #8a7a66; display: inline-block; font-size: var(--fs-xs); font-weight: 700; color: #fff; background: var(--tier); border-radius: var(--r-pill); padding: 2px 9px; }
.catch {
  position: fixed; z-index: 8; left: calc((100% - var(--sidebar-w)) / 2); top: 42%; transform: translate(-50%, -50%);
  min-width: 230px; max-width: min(340px, calc(100% - 32px)); padding: 16px 20px 14px; display: grid; justify-items: center; gap: 4px; text-align: center;
  background: var(--surface); border: 2px solid var(--line); border-radius: var(--r-xl); box-shadow: var(--shadow-3); cursor: pointer;
}
.catch.pop { animation: catchPop .45s cubic-bezier(.2, 1.4, .4, 1); }
@keyframes catchPop { from { transform: translate(-50%, -50%) scale(.4) rotate(-6deg); opacity: 0; } }
.catch[data-tier="2"] { border-color: #8a5cc8; }
.catch[data-tier="3"] { border-color: #d36a2c; box-shadow: 0 0 0 4px rgba(211, 106, 44, .25), var(--shadow-3); }
.catch[data-tier="4"] { border-color: var(--gold); box-shadow: 0 0 0 6px rgba(211, 165, 49, .35), 0 0 40px rgba(255, 215, 90, .55), var(--shadow-3); background: linear-gradient(#fffaf0, #fff3d6); }
.catch-icon { font-size: 54px; line-height: 1.1; animation: bob 1.2s ease-in-out infinite; }
.catch-icon .fish-img { display: block; width: 132px; height: 132px; object-fit: contain; }
.catch-icon > img:not(.fish-img) { display: block; width: 110px; height: 110px; object-fit: contain; }
.catch[data-tier="4"] .catch-icon .fish-img { filter: drop-shadow(0 0 10px rgba(255, 210, 80, .8)); }
@keyframes bob { 50% { transform: translateY(-5px) rotate(4deg); } }
.catch b { font-size: var(--fs-xl); }
.catch-kg { color: var(--ink-2); font-size: var(--fs-md); }
.catch-coins { font-weight: 700; color: #a37a10; font-size: var(--fs-lg); }
.catch-notes { list-style: none; margin: 4px 0 0; padding: 0; display: grid; gap: 3px; font-size: var(--fs-sm); color: var(--accent); font-weight: 600; }

.fish-anns { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }
.fish-ann {
  --tier: var(--gold); display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; font-weight: 600; font-size: var(--fs-md);
  background: var(--surface); border: 2px solid var(--tier); border-radius: var(--r-lg); box-shadow: var(--shadow-2); animation: annIn .5s cubic-bezier(.2, 1.3, .4, 1);
  transition: opacity .5s, transform .5s;
}
.fish-ann[data-tier="4"] { background: linear-gradient(90deg, #fff6dc, #fffcf3 60%); box-shadow: 0 0 22px rgba(255, 210, 80, .55), var(--shadow-2); }
.fish-ann.out { opacity: 0; transform: translateY(-8px); }
@keyframes annIn { from { transform: translateY(-14px) scale(.9); opacity: 0; } }
.ann-text { flex: 1; min-width: 0; line-height: 1.4; }
.ann-cheer { flex: none; border: 0; border-radius: var(--r-pill); background: var(--accent); color: #fff; font-weight: 700; font-size: var(--fs-sm); padding: 6px 12px; cursor: pointer; }
.ann-cheer:hover:not(:disabled) { background: var(--accent-hover); }
.ann-cheer:disabled { background: var(--surface-2); color: var(--ink-2); cursor: default; }

#game.shake { animation: shake .35s; }
#game.shake-big { animation: shake .55s; }
@keyframes shake { 20% { transform: translate(-4px, 2px); } 40% { transform: translate(4px, -2px); } 60% { transform: translate(-3px, -1px); } 80% { transform: translate(2px, 1px); } }
@media (prefers-reduced-motion: reduce) { #game.shake, #game.shake-big, .catch-icon { animation: none; } }

.bag-pop { width: 320px; max-height: calc(100dvh - 140px); overflow: auto; }
.bag-gear { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.bag-gear select { min-width: 0; font: inherit; font-size: var(--fs-sm); padding: 5px 6px; border: 1px solid var(--line); border-radius: var(--r-xs); background: var(--surface); color: var(--ink); }
.bag-quest { font-size: var(--fs-sm); background: var(--notice); border: 1px solid var(--notice-line); border-radius: var(--r-sm); padding: 6px 9px; color: var(--ink); margin-bottom: 6px; }
.bag-quest.done { background: #eaf6ec; border-color: #b9dfc0; }
.bag-stats { font-size: var(--fs-xs); color: var(--ink-2); margin-bottom: 8px; }
.bag-dex-head { font-weight: 700; color: var(--ink); margin-bottom: 6px; }
.dex-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 5px; }
.dex-cell { --tier: #8a7a66; display: grid; justify-items: center; gap: 1px; padding: 6px 3px; border-radius: var(--r-sm); background: var(--surface-2); border: 1.5px solid var(--tier); text-align: center; min-width: 0; }
.dex-cell b { font-size: var(--fs-xs); color: var(--ink); line-height: 1.25; }
.dex-cell small { font-size: 10px; color: var(--ink-2); }
.dex-ico { font-size: 22px; line-height: 1.2; }
img.dex-ico { width: 56px; height: 56px; object-fit: contain; }
img.dex-ico.silhouette { filter: brightness(0) opacity(.28); }   /* not caught yet: just its shape */
.dex-book { width: 22px; height: 22px; object-fit: contain; vertical-align: -5px; }
.ann-ico { flex: none; width: 40px; height: 40px; object-fit: contain; margin: -4px 0; }
.dex-cell.unknown { border-style: dashed; opacity: .7; }

.shop-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 10px; }
.shop-list { display: grid; gap: 8px; max-height: min(56vh, 520px); overflow: auto; padding-right: 2px; }
.shop-sec { margin: 6px 0 0; font-size: var(--fs-sm); color: var(--ink-2); font-weight: 600; }
.shop-card { display: grid; grid-template-columns: 52px 1fr auto; align-items: center; gap: 10px; padding: 8px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); }
.shop-ico { font-size: 30px; text-align: center; }
.ui-ico.shop-ico { width: 36px; height: 36px; justify-self: center; }
.shop-img { width: 52px; height: 52px; object-fit: contain; background: var(--surface-2); border-radius: var(--r-sm); }
.shop-img.fish-img { padding: 3px; }
.chair-colors { display: flex; gap: 8px; flex-wrap: wrap; padding: 2px 4px 6px 72px; }
.chair-color { width: 28px; height: 28px; border-radius: 50%; border: 2px solid var(--surface); box-shadow: 0 0 0 1px var(--line); cursor: pointer; padding: 0; }
.shop-preview-hit { cursor: zoom-in; }
.outfit-preview { position: absolute; inset: 0; z-index: 5; display: grid; place-content: center; justify-items: center; gap: 6px; background: rgba(40,30,20,.45); cursor: pointer; }
.outfit-preview canvas { width: min(280px, 72vw); aspect-ratio: 4 / 5; height: auto; }
.outfit-preview b { color: #fff; font-size: 17px; background: var(--accent, #c4553a); padding: 6px 16px; border-radius: 999px; box-shadow: 0 3px 10px rgba(0,0,0,.25); margin-top: -6px; }
.chair-color.on { box-shadow: 0 0 0 3px var(--accent, #b5532f); }
.shop-txt { display: grid; gap: 2px; min-width: 0; }
.shop-txt small { color: var(--ink-2); font-size: var(--fs-xs); line-height: 1.45; }
.shop-buy { min-width: 84px; white-space: nowrap; }
.shop-buy:disabled { background: var(--surface-2); color: var(--ink-3); cursor: default; }
.shop-buy.owned { background: #eaf6ec; color: var(--live); }

@media (max-width: 700px) {
  .catch { left: 50%; top: 30%; }
  .bag-pop { width: min(320px, calc(100% - 16px)); }
  .shop-card { grid-template-columns: 42px 1fr; }
  .shop-buy { grid-column: 1 / -1; }
  .ann-text { font-size: var(--fs-sm); }
}
.shop-swatch { display: block; border: 1px solid var(--line); }
.shop-swatch.round { border-radius: 50%; }

/* fishing: the timing ring */
.fish-ring {
  position: fixed; z-index: 7; left: calc((100% - var(--sidebar-w)) / 2); top: 40%; transform: translate(-50%, -50%);
  width: 190px; display: grid; justify-items: center; gap: 2px; pointer-events: none; animation: ringIn .18s ease-out;
}
@keyframes ringIn { from { transform: translate(-50%, -50%) scale(.88); opacity: 0; } }   /* keeps the centring while it pops in */
.fish-ring svg { width: 170px; height: 170px; filter: drop-shadow(0 6px 14px rgba(40, 25, 10, .3)); }
.ring-grade { min-height: 30px; font-size: 24px; font-weight: 800; letter-spacing: .5px; text-shadow: 0 2px 0 #fff, 0 0 10px #fff; }
.ring-grade.perfect { color: #d3a531; animation: catchPop .35s cubic-bezier(.2, 1.4, .4, 1); }
.ring-grade.good { color: var(--live); }
.ring-grade.miss { color: var(--accent); }
.ring-hint { display: grid; justify-items: center; gap: 4px; margin-top: 2px; padding: 6px 10px 7px; border-radius: 12px; background: rgba(255, 252, 247, .94); box-shadow: 0 4px 12px rgba(40, 25, 10, .18); color: var(--ink-2); font-size: 11px; white-space: nowrap; }
.ring-how { font-weight: 600; color: var(--ink); }
.ring-chips { display: flex; gap: 5px; }
.ring-chip { padding: 1px 7px; border-radius: var(--r-pill); font-size: 10.5px; font-weight: 600; }
.ring-chip b { font-weight: 800; letter-spacing: .3px; }
.ring-chip.perfect { background: #fff3cc; color: #9a7413; }
.ring-chip.good { background: #e3f4e8; color: #23784a; }
@media (max-width: 700px) { .fish-ring { left: 50%; top: 28%; } .fish-ring svg { width: 150px; height: 150px; } }
.ring-grade.wait { color: var(--ink-2); font-size: 15px; }
/* narrow phones: the coins and nine icons stay on one line, a little smaller */
@media (max-width: 400px) { .icon-btn, .radio-btn { width: 29px; height: 30px; } .icon-btn .ui-ico { width: 23px; height: 23px; } .top-actions .stat { padding: 0 4px; font-size: 12px; } .stat .ui-ico { width: 19px; height: 19px; } }
/* game picker on narrow phones: a smaller icon box, names may wrap instead of being cut */
@media (max-width: 480px) {
  .game-opt { grid-template-columns: 34px minmax(0, 1fr); column-gap: 8px; padding: 8px 9px; }
  .game-opt .game-ico { width: 34px; height: 34px; border-radius: 10px; }
  .game-opt .game-ico .ui-ico { width: 26px; height: 26px; }
  .game-opt .game-fan { transform: scale(.82); }
  .game-opt .dm-tile.dm-mini { --tw: 14px; }
  .game-opt b, .game-opt small { white-space: normal; overflow: visible; line-height: 1.25; }
  .game-opt b { font-size: 14px; }
}

/* game-table windows are docked: no dimmed backdrop, so the map chat, megaphone and HUD stay usable around them.
   Ordinary windows (z 20) still open on top. On wide screens the card sits clear of the floating chat. */
.modal.docked { z-index: 8; background: none; -webkit-backdrop-filter: none; backdrop-filter: none; pointer-events: none; }
.modal.docked > .modal-card { pointer-events: auto; box-shadow: 0 18px 50px rgba(40, 25, 10, .28), 0 0 0 1px rgba(59, 42, 26, .08); max-height: calc(100vh - 32px); overflow: auto; }
@media (min-width: 701px) and (max-width: 1179px) { .layout-yard .modal.docked { justify-items: end; } }   /* keep clear of the floating chat on the left */
@media (min-width: 1180px) { .layout-yard .modal.docked { padding-left: 392px; } }
@media (min-width: 701px) { :root:not(.layout-yard) .modal.docked { padding-right: calc(var(--sidebar-w) + 16px); } }

/* invite bar inside the game table while it waits for players */
.tg-invite { display: grid; gap: 6px; margin: 10px 0 2px; padding: 10px 12px; border: 1px dashed var(--accent-line); border-radius: var(--r-md); background: var(--accent-soft); }
.tg-invite > b { font-size: var(--fs-sm); }
.tg-invite-row { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.tg-invite-row .btn { min-height: 32px; padding: 0 12px; font-size: var(--fs-sm); }
.tg-invite-row .ui-ico { width: 18px; height: 18px; vertical-align: -4px; }
.tg-invite-row small { color: var(--ink-2); font-size: var(--fs-xs); }
.game-invite { --tier: var(--accent); }
.game-invite .ann-ico { display: grid; place-items: center; }
.game-invite .ann-ico .ui-ico { width: 32px; height: 32px; }
.ann-x { flex: none; width: 28px; height: 28px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); cursor: pointer; }
.ann-x:hover { background: var(--accent-soft); color: var(--accent); }

/* radio: skip vote on the ON AIR bar, the queue in the radio window */
.r-skip:disabled { opacity: .55; cursor: default; }
.r-rules { margin: 2px 0 0; }
.r-queue { display: grid; gap: 4px; margin-top: 6px; }
.r-queue > b { font-size: var(--fs-sm); }
.r-q-row { display: flex; align-items: center; gap: 8px; padding: 4px 6px 4px 10px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface-2); font-size: var(--fs-sm); }
.r-q-row.playing { border-color: var(--accent-line); background: var(--accent-soft); }
.r-q-n { flex: none; width: 18px; text-align: center; font-weight: 700; color: var(--ink-2); }
.r-q-txt { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.r-q-row .btn { flex: none; min-height: 28px; padding: 0 10px; font-size: var(--fs-xs); }

/* profile: change your name */
.profile-rename { display: grid; grid-template-columns: 1fr auto; align-items: end; gap: 6px 8px; padding-bottom: 10px; margin-bottom: 4px; border-bottom: 1px dashed var(--line); }
.profile-rename label { min-width: 0; }
.profile-rename .btn { min-height: 38px; white-space: nowrap; }
.profile-rename .btn .ui-ico { width: 18px; height: 18px; vertical-align: -4px; }
.profile-rename small { grid-column: 1 / -1; }

/* haunted house and fishing pond (desktop): the music box stands on its own at the bottom right instead of under the chat */
@media (min-width: 701px) {
  .layout-yard.in-music-zone #roomWidget { position: fixed; right: var(--gutter); bottom: calc(var(--gutter) + 72px); width: 340px; z-index: 6; }
  .layout-yard.in-music-zone .social-sidebar { height: min(560px, 70vh); }
}

/* chat replies and @mentions */
.msg { position: relative; }
.msg-reply { align-self: center; flex: none; width: 26px; height: 26px; border: 0; border-radius: 50%; background: var(--surface-2); color: var(--ink-2); font-size: 13px; cursor: pointer; opacity: 0; transition: opacity var(--ease); }
.msg:hover .msg-reply, .msg:focus-within .msg-reply { opacity: 1; }
@media (hover: none) { .msg-reply { opacity: .7; } }
.msg-reply:hover { background: var(--accent-soft); color: var(--accent); }
.msg .name { cursor: pointer; }
.msg.me .name { cursor: default; }
.reply-quote { display: grid; width: 100%; margin: 2px 0 3px; padding: 3px 8px; border: 0; border-left: 3px solid var(--accent-line); border-radius: 6px; background: rgba(59, 42, 26, .05); color: var(--ink-2); font: inherit; font-size: var(--fs-xs); text-align: left; cursor: pointer; }
.reply-quote b { color: var(--ink); font-weight: 600; }
.reply-quote span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mention { color: var(--accent); font-weight: 600; }
.mention.me { padding: 0 3px; border-radius: 4px; background: #fff3cc; color: #9a7413; }
.msg.mentioned .body { box-shadow: 0 0 0 2px #f1cf6a; }
.msg.flash .body { animation: msgFlash 1.2s ease; }
@keyframes msgFlash { 30% { box-shadow: 0 0 0 3px var(--accent); } }
.chat-reply-bar { display: flex; align-items: center; gap: 6px; flex: none; margin: 4px 0 2px; padding: 4px 4px 4px 10px; border-left: 3px solid var(--accent); border-radius: 6px; background: var(--accent-soft); font-size: var(--fs-xs); color: var(--ink-2); }
.chat-reply-bar span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-reply-bar b { color: var(--ink); }
.chat-reply-bar button { flex: none; width: 22px; height: 22px; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .7); color: var(--ink-2); cursor: pointer; }
.chat-mention { display: grid; gap: 2px; flex: none; margin: 4px 0 2px; padding: 4px; border: 1px solid var(--line); border-radius: var(--r-md); background: var(--surface); box-shadow: var(--shadow-2); }
.mention-opt { display: grid; grid-template-columns: 24px 1fr auto; align-items: center; gap: 8px; padding: 4px 8px; border: 0; border-radius: 8px; background: none; color: var(--ink); font: inherit; font-size: var(--fs-sm); text-align: left; cursor: pointer; }
.mention-opt img { width: 30px; height: 30px; border-radius: 50%; object-fit: cover; object-position: top; background: var(--accent-soft); }
.mention-opt small { color: var(--ink-2); font-size: var(--fs-xs); }
.mention-opt.on, .mention-opt:hover { background: var(--accent-soft); }
/* colour swatches for a colour-pick outfit (gym kit, sports day), first row of the wardrobe grid */
.wd-dyes { grid-column: 1 / -1; display: flex; flex-wrap: wrap; align-items: center; gap: 8px; padding: 4px 2px 8px; }
.wd-dyes b { font-size: 14px; margin-right: 4px; }
.wd-dye { width: 30px; height: 30px; border-radius: 50%; border: 2px solid rgba(0, 0, 0, .15); cursor: pointer; padding: 0; }
.wd-dye.on { border-color: #333; box-shadow: 0 0 0 3px #fff, 0 0 0 5px #333; }

/* Settings: effects quality (อัตโนมัติ / สวย / ประหยัด) on one row */
.fx-quality { display: flex; flex-wrap: wrap; gap: 6px 16px; }
