@font-face { font-family: "Yellowtail"; src: url(fonts/yellowtail-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Rubik"; src: url(fonts/rubik-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Rubik"; src: url(fonts/rubik-latin-700-normal.woff2) format("woff2"); font-weight: 700; font-display: swap; }

:root {
  --night: #1c2a4a;
  --night2: #141f3a;
  --enamel: #9dc4bb;
  --enamel2: #6f9c94;
  --paper: #fbf8ee;
  --ink: #1d2433;
  --sticky: #ffe27a;
  --cyan: #46e2ff;
  --amber: #ffae2b;
  --tomato: #d44c3f;
  --sa-t: env(safe-area-inset-top, 0px);
  --sa-b: env(safe-area-inset-bottom, 0px);
  --sa-l: env(safe-area-inset-left, 0px);
  --sa-r: env(safe-area-inset-right, 0px);
}
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: var(--night2); color: #eef2f8; font: 400 16px/1.35 Rubik, "Noto Sans", system-ui, -apple-system, "Segoe UI", sans-serif; overscroll-behavior: none; -webkit-user-select: none; user-select: none; }
canvas#game { position: fixed; inset: 0; width: 100%; height: 100%; display: block; touch-action: none; outline: none; }
[hidden] { display: none !important; }
button { font: inherit; color: inherit; cursor: pointer; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); }
:focus-visible { outline: 3px solid var(--cyan); outline-offset: 2px; }

/* ---- HUD ---- */
#hud { position: fixed; top: calc(var(--sa-t) + 6px); left: calc(var(--sa-l) + 6px); right: calc(var(--sa-r) + 6px); display: flex; gap: 6px; align-items: center; pointer-events: none; }
.icon { width: 42px; height: 42px; flex: none; border: 0; border-radius: 50%; background: rgba(13,24,48,.72); color: #eef2f8; display: grid; place-items: center; pointer-events: auto; padding: 0; }
.icon svg { width: 22px; height: 22px; fill: currentColor; }
#btnMute { position: fixed; top: calc(var(--sa-t) + 6px); right: calc(var(--sa-r) + 6px); z-index: 6; }
#btnMute .off { display: none; } #btnMute.muted .on { display: none; } #btnMute.muted .off { display: inline; }
#board { flex: 1; min-width: 0; margin-right: 48px; display: flex; align-items: stretch; justify-content: center; gap: 4px; }
.side { flex: 1 1 0; min-width: 0; display: flex; align-items: center; gap: 6px; padding: 3px 8px; border-radius: 12px; background: rgba(13,24,48,.72); border: 2px solid transparent; }
.side.milk { justify-content: flex-start; } .side.coffee { justify-content: flex-end; }
.side.turn.milk { border-color: var(--cyan); } .side.turn.coffee { border-color: var(--amber); }
.side .score { font: 700 25px/1 Rubik, sans-serif; min-width: 16px; text-align: center; }
.side .who { min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.side.coffee .who { align-items: flex-end; }
.side .name { font-size: 12.5px; line-height: 1.1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 100%; }
.pips { display: flex; flex-wrap: nowrap; gap: 2px; }
.pip { width: 7px; height: 7px; border-radius: 50%; }
.milk .pip { background: #f0f1ec; box-shadow: 0 0 0 1px var(--cyan) inset; }
.coffee .pip { background: #3c2c28; box-shadow: 0 0 0 1.4px var(--amber) inset; }
.pip.gone { opacity: .22; }
.hammer { width: 18px; height: 18px; flex: none; fill: #ffe27a; visibility: hidden; }
.side.has .hammer { visibility: visible; }
#endNo { flex: none; align-self: center; font-weight: 700; font-size: 13px; padding: 2px 7px; border-radius: 10px; background: rgba(13,24,48,.72); white-space: nowrap; }

#status { position: fixed; top: calc(var(--sa-t) + 58px); left: 50%; transform: translateX(-50%); padding: 3px 12px; border-radius: 14px; background: rgba(13,24,48,.78); font-weight: 700; font-size: 15px; max-width: calc(100vw - 150px); text-align: center; pointer-events: none; }
#hint { position: fixed; left: 50%; bottom: calc(var(--sa-b) + 14px); transform: translateX(-50%); padding: 7px 14px; border-radius: 16px; background: rgba(251,248,238,.94); color: var(--ink); font-weight: 700; font-size: 16px; max-width: calc(100vw - 32px); text-align: center; pointer-events: none; }

#guardNote { position: fixed; bottom: 30%; left: 50%; transform: translateX(-50%); display: flex; gap: 6px; align-items: center; width: max-content; max-width: calc(100vw - 112px); padding: 4px 10px 4px 7px; border-radius: 12px; background: rgba(13,24,48,.86); border: 2px solid #ffe27a; font-size: 14px; line-height: 1.2; pointer-events: none; z-index: 3; }
#guardNote svg { width: 18px; height: 18px; flex: none; fill: #ffe27a; }
#guardNote.danger { border-color: #ff5a3c; background: #ffe9e3; color: #5c130a; font-weight: 700; }
#guardNote.danger svg { fill: #ff5a3c; }
#btnSkip { position: fixed; right: calc(var(--sa-r) + 10px); bottom: calc(var(--sa-b) + 84px); display: flex; align-items: center; gap: 6px; min-height: 44px; padding: 6px 14px; border: 2px solid #fff; border-radius: 22px; background: rgba(13,24,48,.86); color: #fff; font-weight: 700; font-size: 16px; z-index: 4; }
#btnSkip svg { width: 18px; height: 18px; fill: currentColor; }

#btnMap { position: fixed; top: calc(var(--sa-t) + 56px); right: calc(var(--sa-r) + 6px); width: 86px; height: 116px; padding: 0; border: 2px solid #3f6ea5; border-radius: 10px; background: #0d1f3a; overflow: hidden; }
#btnMap canvas { width: 100%; height: 100%; display: block; }
#btnMap.on { border-color: #fff; }

.spin { position: fixed; width: 58px; height: 58px; margin: -29px 0 0 -29px; border-radius: 50%; border: 2.5px solid rgba(255,255,255,.34); background: rgba(13,24,48,.62); color: rgba(255,255,255,.6); padding: 8px; display: grid; place-items: center; }
.spin svg { width: 100%; height: 100%; }
.spin.on { background: #fff; color: var(--ink); border-color: #fff; }

#sweepBar { position: fixed; left: 50%; bottom: calc(var(--sa-b) + 58px); width: min(66vw, 300px); height: 14px; transform: translateX(-50%); border-radius: 8px; background: rgba(13,24,48,.72); padding: 3px; pointer-events: none; }
#sweepFill { height: 100%; width: 0; border-radius: 5px; background: var(--cyan); }
#sweepFill.hot { background: #fff; }

#bubble { position: fixed; left: calc(var(--sa-l) + 8px); bottom: calc(var(--sa-b) + 10px); display: flex; gap: 8px; align-items: center; max-width: min(78vw, 360px); pointer-events: none; }
#bubble canvas { width: 46px; height: 46px; flex: none; }
#bubble p { margin: 0; padding: 7px 11px; border-radius: 14px 14px 14px 2px; background: var(--paper); color: var(--ink); font-size: 15px; }

#fxLayer { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.pop { position: absolute; transform: translate(-50%, -50%); font: 400 44px/1 Yellowtail, Rubik, cursive; color: #fff; text-shadow: 0 3px 0 rgba(13,24,48,.8); animation: pop .8s ease-out forwards; white-space: nowrap; }
.pop.big { font-size: 66px; }
.pop.shh { font-size: 36px; color: #ffe27a; }
@keyframes pop { 0% { opacity: 0; transform: translate(-50%, -30%) scale(.5); } 18% { opacity: 1; transform: translate(-50%, -50%) scale(1.1); } 70% { opacity: 1; transform: translate(-50%, -62%) scale(1); } 100% { opacity: 0; transform: translate(-50%, -80%) scale(1); } }
.reduced .pop { animation-name: popCalm; }
@keyframes popCalm { 0%, 75% { opacity: 1; transform: translate(-50%, -50%); } 100% { opacity: 0; transform: translate(-50%, -50%); } }

/* ---- the fridge is the menu ---- */
#menu { position: fixed; inset: 0; display: flex; justify-content: center; align-items: flex-start; padding: calc(var(--sa-t) + 8px) 12px 0; overflow-y: auto; pointer-events: none; }
.door { position: relative; pointer-events: auto; width: min(100%, 470px); padding: 18px 28px 16px 18px; border-radius: 20px 20px 10px 10px; background: linear-gradient(100deg, var(--enamel2), var(--enamel) 28%, #b4d3cc 58%, var(--enamel) 80%, var(--enamel2)); box-shadow: 0 16px 34px rgba(0,0,0,.5), inset 0 2px 0 rgba(255,255,255,.4), inset 0 -3px 0 rgba(0,0,0,.2); color: var(--ink); display: flex; flex-direction: column; gap: 9px; }
.handle { position: absolute; right: 8px; top: 24%; height: 26%; width: 11px; border-radius: 6px; background: linear-gradient(90deg, #eef3f5, #8c98a4 60%, #d8dfe4); box-shadow: 1px 2px 3px rgba(0,0,0,.4); }
.badge { text-align: center; }
#logo { margin: 0; font: 400 clamp(54px, 15vw, 72px)/1.05 Yellowtail, Rubik, cursive; background: linear-gradient(180deg, #ffffff 6%, #a6b3c4 44%, #1d2a40 54%, #1d2a40 60%, #c8d4e0 92%); -webkit-background-clip: text; background-clip: text; color: transparent; filter: drop-shadow(0 2px 0 rgba(20,30,40,.55)); padding: 0 .1em .08em; }
#tagline { margin: 0; font-weight: 700; font-size: 15.5px; color: #17332f; }
.notes { display: flex; flex-direction: column; gap: 10px; margin-top: 2px; }
.note { position: relative; display: flex; flex-direction: column; text-align: left; gap: 1px; padding: 11px 14px 10px; border: 0; background: var(--paper); color: var(--ink); box-shadow: 0 3px 7px rgba(10,30,30,.35); }
.note:hover { box-shadow: 0 5px 12px rgba(10,30,30,.45); }
.note::before { content: ""; position: absolute; top: -6px; left: 50%; width: 15px; height: 15px; margin-left: -7px; border-radius: 50%; background: radial-gradient(circle at 35% 30%, #ff8a7a, var(--tomato) 62%, #8e2a22); box-shadow: 0 2px 2px rgba(0,0,0,.4); }
.note .t { font-weight: 700; font-size: 20px; line-height: 1.15; }
.note .s { font-size: 14.5px; opacity: .8; }
.note.first { transform: rotate(-.8deg); }
.note.first .t { font-size: 25px; }
.note.lined { transform: rotate(.6deg); background: linear-gradient(90deg, #fbf8ee 0 8px, #e8a0a0 8px 9.5px, #fbf8ee 9.5px); }
.note.lined::before { background: radial-gradient(circle at 35% 30%, #8fd8ff, #3687c4 62%, #1f4f76); }
.note.sticky { transform: rotate(-.5deg); background: var(--sticky); }
.note.sticky::before { background: radial-gradient(circle at 35% 30%, #cfe9a0, #6aa53b 62%, #3b6a1c); }
.note.plain { background: #e8f0ec; }
.magnets { display: flex; gap: 6px; justify-content: center; }
.mag { border: 0; border-radius: 16px; padding: 5px 13px; background: rgba(23,51,47,.2); color: #122; font-weight: 700; font-size: 14.5px; min-height: 34px; }
.mag.on { background: #17332f; color: #fff; }
#menuLinks { display: flex; flex-wrap: wrap; gap: 2px 14px; justify-content: center; margin: 0; }
.link { background: none; border: 0; padding: 7px 2px; font-weight: 700; font-size: 15px; color: #123; text-decoration: underline; text-underline-offset: 3px; }
#stats, #byline { margin: 0; font-size: 13px; text-align: center; color: #17332f; }
#stats:empty { display: none; }

/* ---- paper on the fridge: every panel ---- */
#panel { position: fixed; inset: 0; display: grid; place-items: center; padding: 12px; background: rgba(13,20,40,.56); z-index: 8; overflow-y: auto; }
.card { position: relative; width: min(100%, 460px); max-height: calc(100dvh - 24px); overflow-y: auto; padding: 22px 18px 16px; background: var(--paper); color: var(--ink); box-shadow: 0 14px 34px rgba(0,0,0,.5); user-select: text; -webkit-user-select: text; }
.card h2 { margin: 0 0 8px; font: 400 36px/1.1 Yellowtail, Rubik, cursive; color: #233f73; }
#pBody p { margin: 6px 0; font-size: 16px; }
#pBody .big { font-weight: 700; font-size: 30px; }
#pBody .big2 { font-weight: 700; font-size: 18px; }
#pBtns { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
.btn { flex: 1 1 auto; min-height: 46px; padding: 8px 14px; border-radius: 10px; border: 2px solid #233f73; background: #fff; color: #233f73; font-weight: 700; font-size: 16px; }
.btn.go { background: #233f73; color: #fff; }
#pToast { margin: 8px 0 0; font-size: 14px; min-height: 18px; word-break: break-word; }
#pToast:empty { display: none; }

table.ends { border-collapse: collapse; margin: 6px 0; font-weight: 700; }
table.ends td, table.ends th { padding: 3px 9px; text-align: center; border: 1px solid #c8cdd6; }
table.ends .lab { text-align: left; font-weight: 400; }
table.ends .tot { background: #233f73; color: #fff; }

.rung { display: flex; gap: 10px; align-items: center; width: 100%; padding: 7px 8px; margin-bottom: 6px; text-align: left; border: 2px solid #c8cdd6; border-radius: 10px; background: #fff; color: var(--ink); }
.rung:disabled { opacity: .5; cursor: default; }
.rung.next { border-color: #233f73; }
.rung canvas { width: 44px; height: 44px; flex: none; }
.rung b { display: block; font-size: 16px; }
.rung span { font-size: 13.5px; }
.rung .tick { margin-left: auto; font-weight: 700; color: #2b7a48; }

.cosGroup { margin: 8px 0 12px; }
.cosGroup h3 { margin: 0 0 5px; font-size: 16px; }
.cos { display: flex; align-items: center; gap: 8px; width: 100%; padding: 6px 8px; margin-bottom: 4px; text-align: left; border: 2px solid #c8cdd6; border-radius: 9px; background: #fff; color: var(--ink); min-height: 42px; }
.cos.on { border-color: #233f73; background: #e8eefa; }
.cos:disabled { opacity: .75; cursor: default; background: #f1f0ea; }
.cos b { font-size: 15px; } .cos span { font-size: 13px; margin-left: auto; text-align: right; }

/* ---- other shapes ---- */
@media (orientation: landscape) {
  #hud { right: auto; width: min(36vw, 300px); align-items: flex-start; }
  #board { flex-direction: column; margin-right: 0; gap: 3px; }
  .side { flex: none; padding: 2px 7px; }
  .side.coffee { flex-direction: row-reverse; justify-content: flex-end; } .side.coffee .who { align-items: flex-start; }
  #endNo { align-self: flex-start; font-size: 12px; }
  #status { top: auto; bottom: calc(var(--sa-b) + 58px); left: calc(var(--sa-l) + 6px); transform: none; max-width: min(36vw, 300px); text-align: left; font-size: 14px; }
  #hint { left: calc(var(--sa-l) + 6px); bottom: calc(var(--sa-b) + 8px); transform: none; font-size: 14px; max-width: min(36vw, 300px); text-align: left; }
  #sweepBar { bottom: calc(var(--sa-b) + 8px); left: auto; right: calc(var(--sa-r) + 170px); width: 18vw; transform: none; }
  #bubble { bottom: auto; top: calc(var(--sa-t) + 150px); }
  #guardNote { bottom: calc(var(--sa-b) + 96px); left: calc(var(--sa-l) + 6px); transform: none; max-width: min(36vw, 300px); }
}
@media (orientation: landscape) and (max-height: 520px) {
  /* The floor runs left to right on short, wide screens, so the scores go back in a row along the top. */
  #hud { right: calc(var(--sa-r) + 6px); width: auto; align-items: center; }
  #board { flex-direction: row; margin-right: 48px; gap: 4px; }
  .side { flex: 1 1 0; }
  .side.coffee { flex-direction: row; justify-content: flex-end; } .side.coffee .who { align-items: flex-end; }
  #endNo { align-self: center; }
  #status { top: calc(var(--sa-t) + 52px); bottom: auto; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 230px); text-align: center; }
  #guardNote { bottom: calc(var(--sa-b) + 6px); left: calc(var(--sa-l) + 6px); transform: none; max-width: min(62vw, 520px); font-size: 13px; }
  #hint { left: auto; right: calc(var(--sa-r) + 8px); bottom: calc(var(--sa-b) + 6px); transform: none; font-size: 14px; max-width: 34vw; text-align: center; }
  #sweepBar { bottom: calc(var(--sa-b) + 10px); left: 50%; right: auto; width: 30vw; transform: translateX(-50%); }
  #bubble { top: calc(var(--sa-t) + 52px); bottom: auto; }
  #btnSkip { bottom: calc(var(--sa-b) + 48px); min-height: 40px; }
  #menu { padding: 4px 8px; align-items: center; }
  .door { width: min(100%, 760px); min-height: 0; padding: 8px 26px 8px 12px; gap: 5px; border-radius: 14px; }
  #logo { font-size: 38px; } #tagline { font-size: 13px; }
  .badge { display: flex; gap: 12px; align-items: baseline; justify-content: center; }
  .notes { flex-direction: row; gap: 8px; }
  .note { flex: 1 1 0; padding: 9px 9px 7px; min-width: 0; }
  .note .t, .note.first .t { font-size: 17px; } .note .s { font-size: 12.5px; }
  .magnets { position: absolute; left: 12px; bottom: 6px; } .mag { padding: 3px 9px; min-height: 28px; font-size: 13px; }
  #menuLinks { margin-left: 232px; justify-content: flex-start; } .link { padding: 3px 2px; font-size: 13.5px; } #stats { display: none; } #byline { font-size: 11.5px; margin-left: 232px; text-align: left; }
  #btnMap { top: calc(var(--sa-t) + 52px); right: calc(var(--sa-r) + 6px); bottom: auto; height: 62px; width: 96px; }
  .card { padding: 14px 16px 12px; width: min(100%, 560px); } .card h2 { font-size: 28px; }
  .spin { width: 50px; height: 50px; margin: -25px 0 0 -25px; }
}
@media (min-width: 900px) and (min-height: 521px) {
  #btnMap { width: 170px; height: 220px; right: calc(var(--sa-r) + 14px); top: calc(var(--sa-t) + 60px); }
  #menu { padding-top: 14px; }
}
/* ---- online ---- */
.online .side .name { white-space: normal; font-size: 11.5px; line-height: 1.05; }
.note.net { gap: 4px; }
.netBtns { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 4px; }
.netBtns .btn { min-height: 42px; padding: 6px 10px; font-size: 15px; border-color: #17332f; color: #17332f; }
.net .link { align-self: flex-start; padding: 4px 0 0; font-size: 13.5px; }
#onMsg { position: fixed; top: calc(var(--sa-t) + 54px); left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100vw - 196px); padding: 3px 10px; border-radius: 12px; background: #fbf8ee; color: var(--ink); font-weight: 700; font-size: 14px; line-height: 1.2; text-align: center; pointer-events: none; z-index: 3; }
#onMsg.mine { background: var(--sticky); }
#onMsg .clock { display: block; font-weight: 400; font-size: 13px; }
#onMsg .clock.low { color: #b3261e; font-weight: 700; }
#onMsg.bot { left: calc(var(--sa-l) + 6px); transform: none; max-width: calc(100vw - 112px); text-align: left; font-size: 13px; }
.online #status { top: auto; bottom: calc(var(--sa-b) + 60px); width: max-content; max-width: calc(100vw - 32px); }
.online #btnSkip { bottom: calc(var(--sa-b) + 104px); }
#onBar { position: fixed; top: calc(var(--sa-t) + 54px); left: calc(var(--sa-l) + 6px); display: flex; flex-direction: column; gap: 5px; width: 82px; z-index: 3; }
#onBar.sweeping { opacity: .45; pointer-events: none; } /* rubbing the screen must never press Block */
.pill { min-height: 40px; padding: 3px 6px; border: 1.5px solid rgba(255,255,255,.5); border-radius: 12px; background: rgba(13,24,48,.82); color: #fff; font-weight: 700; font-size: 12.5px; line-height: 1.1; }
.pill.on { background: #fff; color: var(--ink); }
#onToast { position: fixed; top: 34%; left: 50%; transform: translateX(-50%); padding: 7px 14px; border-radius: 14px; background: var(--paper); color: var(--ink); font-weight: 700; font-size: 17px; pointer-events: none; z-index: 4; }
.spinner { width: 34px; height: 34px; margin: 8px auto; border-radius: 50%; border: 4px solid #c8cdd6; border-top-color: #233f73; animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
.reduced .spinner { animation-duration: 6s; }
#pBody .roomCode { margin: 8px 0; font: 700 38px/1.1 Rubik, "Noto Sans", system-ui, sans-serif; letter-spacing: .12em; text-align: center; color: #233f73; word-break: break-all; }
.codeRow { display: flex; gap: 8px; margin: 8px 0; }
.codeRow input { flex: 1 1 0; min-width: 0; min-height: 46px; padding: 6px 10px; border: 2px solid #233f73; border-radius: 10px; background: #fff; color: var(--ink); font: 700 20px/1 Rubik, system-ui, sans-serif; letter-spacing: .1em; text-transform: uppercase; }
.codeRow .btn { flex: none; }
.reactGrid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; }
.small { font-size: 14px !important; color: #3b4356; }
#pBody .privacy { font-size: 14.5px; line-height: 1.35; }
@media (orientation: landscape) {
  #onMsg { top: auto; bottom: calc(var(--sa-b) + 96px); left: calc(var(--sa-l) + 6px); transform: none; max-width: min(36vw, 300px); text-align: left; }
  #onMsg.bot { max-width: min(36vw, 300px); }
  .online #status { bottom: calc(var(--sa-b) + 58px); left: calc(var(--sa-l) + 6px); width: auto; max-width: min(36vw, 300px); }
  #onBar { top: calc(var(--sa-t) + 104px); flex-direction: row; flex-wrap: wrap; width: min(36vw, 300px); }
  #onBar .pill { flex: 1 1 40%; min-height: 34px; }
  #onToast { left: 60%; }
}
@media (orientation: landscape) and (max-height: 520px) {
  #onMsg { top: calc(var(--sa-t) + 50px); bottom: auto; left: 50%; transform: translateX(-50%); max-width: calc(100vw - 420px); text-align: center; font-size: 13px; }
  #onMsg.bot { left: calc(var(--sa-l) + 6px); transform: none; max-width: calc(100vw - 130px); text-align: left; }
  .online #status { top: auto; bottom: calc(var(--sa-b) + 30px); left: 50%; transform: translateX(-50%); width: max-content; max-width: 40vw; font-size: 13px; }
  .online #btnSkip { bottom: calc(var(--sa-b) + 48px); }
  #onBar { top: calc(var(--sa-t) + 50px); width: 170px; gap: 3px; }
  #onBar .pill { flex: 1 1 40%; min-height: 30px; font-size: 11.5px; padding: 1px 4px; }
  .note.net { flex: 1.5 1 0; }
  .netBtns { margin-top: 1px; gap: 3px; } .netBtns .btn { min-height: 34px; font-size: 12.5px; padding: 2px 5px; }
  .net .link { padding: 1px 0 0; font-size: 11.5px; }
}
.reduced * { scroll-behavior: auto !important; }
