/* Playroom: a toy box at night. Grape-purple floor, games are chunky candy-colored blocks
   with a pressed-in bottom edge, everything big enough for small fingers. Single look by choice. */
:root {
  --floor: #3b2a86;
  --floor-2: #2c1f6b;
  --floor-3: #4a37a3;
  --paper: #fffdf7;
  --ink: #241a52;
  --soft: #cfc7ff;
  --sun: #ffd23f;
  --cherry: #ff5d73;
  --tang: #ff9f1c;
  --lime: #4cd97b;
  --sky: #3fb7ff;
  --berry: #b06cff;
  --bubble: #ff7ad9;
  --font: "Baloo 2", "Chalkboard SE", "Comic Sans MS", ui-rounded, system-ui, sans-serif;
  --r: 22px;
  color-scheme: dark;
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--floor) radial-gradient(circle at 20% 0%, var(--floor-3), transparent 60%);
  color: #fff; font-family: var(--font); font-size: 18px; line-height: 1.3;
  overflow: hidden; overscroll-behavior: none;
  user-select: none; -webkit-user-select: none; -webkit-tap-highlight-color: transparent;
  -webkit-touch-callout: none;
}
button, input { font-family: inherit; font-size: inherit; color: inherit; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
button:focus-visible, input:focus-visible { outline: 4px solid var(--sun); outline-offset: 3px; }
input { user-select: text; -webkit-user-select: text; }

#app { height: 100%; display: flex; flex-direction: column;
  padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px); }
.screen { flex: 1; min-height: 0; display: flex; flex-direction: column;
  padding-left: max(14px, env(safe-area-inset-left, 0px)); padding-right: max(14px, env(safe-area-inset-right, 0px));
  padding-block: 10px; gap: 10px; }
.scroll { overflow-y: auto; -webkit-overflow-scrolling: touch; }

/* ---------- chunky buttons */
.block {
  --c: var(--sun); --edge: color-mix(in srgb, var(--c), #000 28%);
  background: var(--c); color: var(--ink); font-weight: 800; border-radius: 18px;
  padding: 10px 18px; box-shadow: 0 5px 0 var(--edge); transition: transform .06s, box-shadow .06s;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px; min-height: 48px;
}
.block:active, .block.pressed { transform: translateY(4px); box-shadow: 0 1px 0 var(--edge); }
.block.ghost { --c: var(--floor-3); color: #fff; }
.block.small { min-height: 40px; padding: 6px 14px; font-size: 16px; border-radius: 14px; }
.block[disabled] { opacity: .5; pointer-events: none; }
.round { width: 48px; padding: 0; font-size: 24px; }

/* ---------- top bar used by every game */
.bar { display: flex; align-items: center; gap: 10px; min-height: 52px; }
.bar h1 { margin: 0; font-size: clamp(20px, 5vw, 28px); font-weight: 800; flex: 1; min-width: 0;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pill { background: var(--floor-2); border-radius: 999px; padding: 4px 14px; font-weight: 800;
  font-variant-numeric: tabular-nums; white-space: nowrap; }
.me { display: inline-flex; align-items: center; gap: 6px; background: var(--floor-2); border-radius: 999px;
  padding: 4px 12px 4px 4px; font-weight: 700; }
.face { width: 40px; height: 40px; border-radius: 50%; display: grid; place-items: center; font-size: 24px;
  background: var(--pc, var(--berry)); flex: none; }

/* ---------- home */
.hero { display: flex; align-items: center; gap: 12px; }
.logo { font-size: clamp(34px, 9vw, 54px); font-weight: 800; letter-spacing: -.5px; line-height: 1; flex: 1; }
.logo span { display: inline-block; }
.logo span:nth-child(6n+1) { color: var(--cherry); } .logo span:nth-child(6n+2) { color: var(--tang); }
.logo span:nth-child(6n+3) { color: var(--sun); } .logo span:nth-child(6n+4) { color: var(--lime); }
.logo span:nth-child(6n+5) { color: var(--sky); } .logo span:nth-child(6n+6) { color: var(--bubble); }
.stars { color: var(--sun); }
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(150px, 44vw), 1fr)); gap: 14px; padding-bottom: 8px; }
.tile {
  --c: var(--sky); --edge: color-mix(in srgb, var(--c), #000 30%);
  background: var(--c); color: var(--ink); border-radius: var(--r); box-shadow: 0 7px 0 var(--edge);
  padding: 14px; text-align: left; display: flex; flex-direction: column; gap: 2px; min-height: 150px;
  position: relative; overflow: hidden; transition: transform .07s, box-shadow .07s;
}
.tile:active { transform: translateY(5px); box-shadow: 0 2px 0 var(--edge); }
.tile .art { font-size: 52px; line-height: 1; margin-bottom: auto; filter: drop-shadow(0 3px 0 rgba(0,0,0,.15)); }
.tile b { font-size: 22px; line-height: 1.05; }
.tile small { font-size: 14px; font-weight: 700; opacity: .75; }
.tile .best { position: absolute; top: 10px; right: 10px; background: rgba(255,255,255,.55); border-radius: 999px;
  padding: 0 10px; font-size: 14px; font-weight: 800; }
.section-title { font-size: 20px; font-weight: 800; margin: 6px 0 0; color: var(--soft); }

/* ---------- player chooser */
.players { display: flex; flex-wrap: wrap; gap: 12px; }
.player { display: flex; flex-direction: column; align-items: center; gap: 4px; width: 92px; font-weight: 800; }
.player .face { width: 76px; height: 76px; font-size: 44px; box-shadow: 0 5px 0 rgba(0,0,0,.25); }
.player.on .face { outline: 5px solid #fff; }
.player small { color: var(--sun); font-size: 14px; }
.picker { display: flex; flex-wrap: wrap; gap: 8px; }
.picker button { width: 52px; height: 52px; border-radius: 50%; font-size: 30px; background: var(--floor-2); }
.picker button.on { outline: 4px solid #fff; }
.field { width: 100%; border: 0; border-radius: 16px; padding: 12px 16px; background: var(--paper); color: var(--ink);
  font-size: 22px; font-weight: 700; }

/* ---------- panels, sheets */
.sheet-back { position: fixed; inset: 0; background: rgba(20,12,50,.6); display: grid; place-items: center; z-index: 50;
  padding: 16px; animation: fade .15s; }
.sheet { background: var(--floor); border-radius: 26px; padding: 20px; width: min(520px, 100%); max-height: 90%;
  overflow-y: auto; display: grid; gap: 14px; box-shadow: 0 10px 0 var(--floor-2); }
.sheet h2 { margin: 0; font-size: 26px; }
.sheet p { margin: 0; color: var(--soft); }
.row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }
.row.end { justify-content: flex-end; }
@keyframes fade { from { opacity: 0; } }

/* ---------- toasts + confetti */
#toasts { position: fixed; left: 0; right: 0; top: calc(env(safe-area-inset-top, 0px) + 12px); display: grid; justify-items: center;
  gap: 8px; z-index: 80; pointer-events: none; }
.toast { background: var(--paper); color: var(--ink); font-weight: 800; border-radius: 999px; padding: 8px 20px;
  box-shadow: 0 5px 0 rgba(0,0,0,.25); animation: pop .25s cubic-bezier(.3,1.6,.6,1); max-width: 90vw; text-align: center; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 90; }

/* ---------- paper areas */
.paper { flex: 1; min-height: 0; position: relative; background: var(--paper); border-radius: var(--r); overflow: hidden;
  box-shadow: 0 6px 0 var(--floor-2); }
.paper canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }

/* ---------- doodle toolbar */
.toolbar { display: flex; gap: 8px; overflow-x: auto; padding: 4px 2px 8px; scrollbar-width: none; align-items: center; }
.toolbar::-webkit-scrollbar { display: none; }
.toolbar .sep { flex: none; width: 3px; height: 38px; border-radius: 2px; background: var(--floor-3); }
.sw { flex: none; width: 46px; height: 46px; border-radius: 50%; border: 4px solid transparent;
  box-shadow: inset 0 -5px 0 rgba(0,0,0,.2); }
.sw.on { border-color: #fff; transform: scale(1.1); }
.tl { flex: none; min-width: 48px; height: 48px; border-radius: 14px; background: var(--floor-3); display: grid;
  place-items: center; font-size: 24px; font-weight: 800; padding: 0 8px; }
.tl.on { background: #fff; color: var(--ink); }
.tl small { font-size: 11px; display: block; line-height: 1; font-weight: 800; }
.tl .dot { background: currentColor; border-radius: 50%; display: block; }
.rainbow { background: conic-gradient(#ff5d73, #ff9f1c, #ffd23f, #4cd97b, #3fb7ff, #b06cff, #ff5d73); }
.drawer { display: flex; gap: 8px; flex-wrap: wrap; justify-content: center; background: var(--floor-2); border-radius: 18px; padding: 8px; }
.drawer .tl { background: var(--floor-3); }
.prompt { display: flex; align-items: center; gap: 8px; background: var(--floor-2); border-radius: 18px; padding: 4px 6px 4px 14px; min-width: 0; flex: 1; }
.prompt span { flex: 1; min-width: 0; font-weight: 800; font-size: clamp(16px, 4.4vw, 22px); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.timer { position: absolute; top: 10px; right: 10px; background: var(--ink); color: #fff; border-radius: 999px; padding: 2px 14px;
  font-size: 22px; font-weight: 800; pointer-events: none; font-variant-numeric: tabular-nums; }

/* ---------- bubbles */
.pond { flex: 1; min-height: 0; position: relative; border-radius: var(--r); overflow: hidden;
  background: linear-gradient(#1b8fd8, #0b4f9c); box-shadow: 0 6px 0 var(--floor-2); }
.pond canvas { position: absolute; inset: 0; width: 100%; height: 100%; touch-action: none; }
.center-card { position: absolute; inset: 0; display: grid; place-items: center; text-align: center; padding: 16px; }
.center-card > div { display: grid; gap: 12px; justify-items: center; background: rgba(36,26,82,.75); padding: 22px; border-radius: 26px; }
.center-card h2 { margin: 0; font-size: 34px; line-height: 1; }
.center-card p { margin: 0; color: var(--soft); max-width: 30ch; }
.big-num { font-size: 64px; font-weight: 800; line-height: 1; color: var(--sun); }

/* ---------- pairs */
.board { flex: 1; min-height: 0; display: grid; gap: 10px; align-content: center; justify-content: center; }
.card { perspective: 600px; }
.card .in { width: 100%; height: 100%; position: relative; transform-style: preserve-3d; transition: transform .35s; }
.card.up .in, .card.done .in { transform: rotateY(180deg); }
.card .f, .card .b { position: absolute; inset: 0; border-radius: 16px; display: grid; place-items: center; backface-visibility: hidden; }
.card .b { background: var(--berry) repeating-linear-gradient(45deg, transparent 0 10px, rgba(255,255,255,.12) 10px 20px);
  box-shadow: 0 5px 0 color-mix(in srgb, var(--berry), #000 30%); font-size: 26px; }
.card .f { background: var(--paper); transform: rotateY(180deg); box-shadow: 0 5px 0 #d8d2bd; }
.card.done .f { background: #e8ffe9; animation: bounce .4s; }
@keyframes bounce { 50% { transform: rotateY(180deg) scale(1.12); } }

/* ---------- echo */
.pads { flex: 1; min-height: 0; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; aspect-ratio: 1; max-width: 100%;
  max-height: 100%; margin: auto; width: min(100%, 520px); }
.pad { --c: var(--cherry); border-radius: 30px; background: color-mix(in srgb, var(--c), #000 25%);
  box-shadow: 0 8px 0 color-mix(in srgb, var(--c), #000 45%); font-size: 56px; transition: background .08s, transform .08s;
  display: grid; place-items: center; }
.pad.lit { background: var(--c); transform: translateY(3px) scale(.98); box-shadow: 0 0 40px var(--c), 0 5px 0 color-mix(in srgb, var(--c), #000 45%); }
.echo-wrap { flex: 1; min-height: 0; display: flex; flex-direction: column; justify-content: center; }

/* ---------- gallery */
.grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(min(160px, 44vw), 1fr)); gap: 12px; }
.frame { background: var(--paper); border-radius: 18px; padding: 8px 8px 6px; color: var(--ink); text-align: left;
  box-shadow: 0 6px 0 var(--floor-2); display: grid; gap: 4px; transform: rotate(var(--tilt, 0deg)); }
.frame img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 12px; background: #fff; display: block; }
.frame b { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.frame small { font-size: 13px; opacity: .7; font-weight: 700; }
.viewer img { width: 100%; max-height: 62vh; object-fit: contain; background: #fff; border-radius: 16px; }
.empty { text-align: center; color: var(--soft); padding: 40px 10px; display: grid; gap: 12px; justify-items: center; }
.empty .art { font-size: 64px; }

/* ---------- together */
.room-code { font-size: 40px; font-weight: 800; letter-spacing: 8px; color: var(--sun); }
.code-in { font-size: 34px; letter-spacing: 10px; text-align: center; text-transform: uppercase; }
.people { display: flex; gap: 4px; }
.people .face { width: 32px; height: 32px; font-size: 18px; }
.float-emoji { position: absolute; bottom: 10px; font-size: 60px; pointer-events: none; animation: rise 2.2s ease-out forwards; }
@keyframes rise { to { transform: translateY(-70vh) rotate(20deg); opacity: 0; } }
.reacts { display: flex; gap: 6px; }

/* ---------- scores */
.scores { display: grid; gap: 6px; }
.score-row { display: flex; align-items: center; gap: 10px; background: var(--floor-2); border-radius: 16px; padding: 6px 12px 6px 6px; }
.score-row .face { width: 36px; height: 36px; font-size: 20px; }
.score-row b { flex: 1; min-width: 0; }
.score-row span { font-weight: 800; color: var(--sun); font-variant-numeric: tabular-nums; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; }
.tabs button { background: var(--floor-2); border-radius: 999px; padding: 4px 14px; font-weight: 800; }
.tabs button.on { background: #fff; color: var(--ink); }

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

/* narrow phones: the game title needs the room more than the player badge does */
@media (max-width: 430px) {
  .bar > .face { display: none; }
  .bar { gap: 8px; }
}
.pill:empty { display: none; }

/* ---------- family chat */
.chat-note { margin: 0; font-size: 14px; color: var(--soft); text-align: center; }
.chat-list { flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 8px;
  background: var(--floor-2); border-radius: var(--r); padding: 12px; user-select: text; -webkit-user-select: text; }
.chat-day { align-self: center; font-size: 13px; font-weight: 800; color: var(--soft); background: var(--floor); border-radius: 999px; padding: 2px 12px; margin: 4px 0; }
.msg { display: flex; align-items: flex-end; gap: 8px; max-width: 86%; }
.msg.me { align-self: flex-end; flex-direction: row-reverse; }
.msg .face { width: 34px; height: 34px; font-size: 20px; }
.msg.new { animation: pop .25s cubic-bezier(.3,1.6,.6,1); }
.bubble { background: var(--paper); color: var(--ink); border-radius: 20px 20px 20px 6px; padding: 6px 12px 4px;
  display: grid; min-width: 0; box-shadow: 0 3px 0 rgba(0,0,0,.2); border-left: 5px solid var(--pc, var(--berry)); }
.msg.me .bubble { background: var(--pc, var(--sun)); border-radius: 20px 20px 6px 20px; border-left: 0; }
.bubble b { font-size: 13px; color: color-mix(in srgb, var(--pc), #000 35%); }
.bubble .txt { font-size: 18px; font-weight: 600; overflow-wrap: anywhere; white-space: pre-wrap; }
.bubble.big { background: transparent !important; box-shadow: none; border-left: 0; padding: 0; }
.bubble.big .txt { font-size: 46px; line-height: 1.1; }
.bubble.big b, .bubble.big time { color: var(--soft); }
.bubble time { font-size: 11px; opacity: .6; justify-self: end; font-weight: 700; }
.chat-quick { padding-bottom: 2px; }
.chat-form { display: flex; gap: 8px; }
.chat-in { flex: 1; min-width: 0; font-size: 19px; }
.chat-form .block { width: 56px; font-size: 22px; }
.tile .badge { position: absolute; top: 10px; right: 10px; background: var(--cherry); color: #fff; border-radius: 999px;
  min-width: 28px; height: 28px; display: grid; place-items: center; font-weight: 800; font-size: 15px; padding: 0 8px;
  box-shadow: 0 3px 0 rgba(0,0,0,.25); }
.tile .badge:empty { display: none; }
