@font-face { font-family: "Modak"; src: url(fonts/modak-latin-400-normal.woff2) format("woff2"); font-weight: 400; font-display: swap; }
@font-face { font-family: "Overpass"; src: url(fonts/overpass-latin-500-normal.woff2) format("woff2"); font-weight: 500; font-display: swap; }
@font-face { font-family: "Overpass"; src: url(fonts/overpass-latin-800-normal.woff2) format("woff2"); font-weight: 800; font-display: swap; }

:root {
  --ink: #06323f;
  --deep: #0b5c70;
  --water: #29bccb;
  --foam: #eef9f7;
  --noodle: #ff3d8b;
  --noodle-dark: #c41a62;
  --duck: #ffd23c;
  --frog: #57c941;
  --whistle: #e8262d;
  --hud-h: 54px;
  --ctl-h: 138px;
  --side-w: 260px;
  --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(--deep); color: var(--foam); font: 500 16px/1.35 Overpass, "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 #fff; outline-offset: 2px; box-shadow: 0 0 0 6px var(--ink); }

/* A button is a little inflatable: fat, soft, a highlight along the top, and it gives when pressed. */
.btn { display: block; width: 100%; border: 0; border-radius: 22px; padding: 12px 18px; background: var(--foam); color: var(--ink); font-weight: 800; box-shadow: inset 0 3px 0 rgba(255,255,255,.75), inset 0 -5px 0 rgba(6,50,63,.18), 0 3px 0 rgba(6,50,63,.35); transition: transform .08s; }
.btn:active { transform: translateY(2px) scale(.985); }
.btn.primary { background: var(--noodle); color: #fff; box-shadow: inset 0 3px 0 rgba(255,255,255,.4), inset 0 -5px 0 rgba(120,0,60,.35), 0 3px 0 rgba(6,50,63,.35); }
.btn.warm { background: var(--duck); color: var(--ink); box-shadow: inset 0 3px 0 rgba(255,255,255,.6), inset 0 -5px 0 rgba(160,100,0,.3), 0 3px 0 rgba(6,50,63,.35); }
.btn.plain { background: var(--deep); color: var(--foam); box-shadow: inset 0 0 0 2px rgba(255,255,255,.5); }
.btn.big { padding: 11px 18px 12px; text-align: left; }
.btn .t { display: block; font-size: 1.22rem; line-height: 1.15; }
.btn .s { display: block; font-weight: 500; font-size: .86rem; line-height: 1.2; margin-top: 2px; opacity: .85; }
.icon { width: 42px; height: 42px; display: grid; place-items: center; padding: 8px; border: 0; border-radius: 50%; background: var(--foam); color: var(--ink); box-shadow: inset 0 -3px 0 rgba(6,50,63,.18); flex: none; }
.icon svg { width: 100%; height: 100%; fill: currentColor; display: block; }
#btnMute { position: fixed; z-index: 30; top: calc(6px + var(--sa-t)); right: calc(6px + var(--sa-r)); }
#btnMute .off { display: none; } #btnMute.muted .off { display: inline; } #btnMute.muted .on { display: none; }
.link { background: none; border: 0; padding: 6px 4px; font-weight: 800; color: #fff; text-decoration: underline; text-underline-offset: 3px; min-height: 36px; }

/* ---- during play ---- */
#hud { position: fixed; z-index: 20; top: 0; left: 0; right: 0; height: calc(var(--hud-h) + var(--sa-t)); padding: calc(6px + var(--sa-t)) calc(54px + var(--sa-r)) 6px calc(6px + var(--sa-l)); display: flex; align-items: center; gap: 8px; background: var(--ink); }
#sides { flex: 1; display: flex; gap: 6px; min-width: 0; }
.side { flex: 1 1 50%; min-width: 0; display: grid; grid-template-columns: 30px minmax(0, 1fr); grid-template-rows: auto auto; column-gap: 6px; align-items: center; padding: 3px 9px 3px 4px; border-radius: 20px; opacity: .55; }
.side.on { opacity: 1; background: rgba(255,255,255,.14); box-shadow: inset 0 0 0 2px #fff; }
.sideIcon { width: 30px; height: 30px; grid-row: 1 / 3; }
.sideName { font-weight: 800; font-size: .84rem; line-height: 1.05; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sideDots { font-weight: 800; font-size: .76rem; line-height: 1; letter-spacing: .08em; white-space: nowrap; }
#dailyHud { flex: 1; font-weight: 800; line-height: 1.15; font-size: .95rem; min-width: 0; }
#dailyHud small { display: block; font-weight: 500; font-size: .8rem; opacity: .85; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

#ctl { position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; height: calc(var(--ctl-h) + var(--sa-b)); padding: 8px calc(10px + var(--sa-r)) calc(8px + var(--sa-b)) calc(10px + var(--sa-l)); background: var(--ink); display: grid; grid-template-columns: 50px 1fr; grid-template-rows: 50px 1fr; gap: 8px; touch-action: none; }
#ctl.idle #fine, #ctl.idle #power, #ctl.idle #spinBox { opacity: .35; pointer-events: none; }
#spinBox { grid-row: 1 / 3; display: flex; flex-direction: column; gap: 4px; justify-content: stretch; }
.spin { flex: 1; min-height: 0; padding: 3px; display: grid; place-items: center; border: 0; border-radius: 14px; background: rgba(255,255,255,.1); color: var(--foam); }
.spin svg { height: 100%; max-height: 30px; width: auto; display: block; }
.spin circle { fill: #fff; } .spin .dot { fill: var(--noodle); }
.spin.on { background: var(--noodle); } .spin.on .dot { fill: var(--ink); }
#fine { grid-column: 2; position: relative; border-radius: 16px; touch-action: none; cursor: ew-resize; display: grid; place-items: center; font-weight: 800; font-size: .9rem; color: var(--ink);
  background-color: var(--foam); background-image: repeating-linear-gradient(90deg, rgba(6,50,63,.0) 0 9px, rgba(6,50,63,.45) 9px 11px); box-shadow: inset 12px 0 10px -6px rgba(6,50,63,.6), inset -12px 0 10px -6px rgba(6,50,63,.6); }
#fineLabel { background: var(--foam); padding: 1px 10px; border-radius: 10px; pointer-events: none; }
#fine.grab { background-color: #fff; }
#power { grid-column: 2; position: relative; border-radius: 26px; background: #0d4a5c; touch-action: none; cursor: grab; overflow: hidden; display: grid; place-items: center; box-shadow: inset 0 3px 8px rgba(0,0,0,.35); min-height: 44px; }
#powerFill { position: absolute; inset: 0 auto 0 0; width: 0; background: linear-gradient(90deg, #ffd23c, #ff7a18 55%, var(--whistle)); opacity: .95; }
#powerThumb { position: absolute; top: 4px; bottom: 4px; left: 4px; width: 64px; border-radius: 22px; background: repeating-linear-gradient(90deg, var(--noodle) 0 8px, #ff5fa1 8px 11px); box-shadow: inset 0 3px 0 rgba(255,255,255,.4), inset 0 -4px 0 var(--noodle-dark), 0 2px 5px rgba(0,0,0,.4); }
#powerLabel { position: relative; font-weight: 800; font-size: .92rem; pointer-events: none; padding-left: 66px; padding-right: 8px; line-height: 1.1; text-align: center; }
#power.hot #powerLabel { color: #fff; text-shadow: 0 1px 2px rgba(0,0,0,.6); justify-self: start; padding-left: 14px; }
#btnHere { grid-column: 2; grid-row: 1 / 3; background: var(--noodle); color: #fff; font-size: 1.2rem; box-shadow: inset 0 3px 0 rgba(255,255,255,.4), inset 0 -5px 0 rgba(120,0,60,.35); }
#ctl.placing #fine, #ctl.placing #power, #ctl.placing #spinBox { display: none; }
#ctl.placing { grid-template-columns: 1fr; }
#ctl.placing #btnHere { grid-column: 1; }

/* The lifeguard talks from a speech bubble, top of the pool */
#bubble { position: fixed; z-index: 25; left: calc(10px + var(--sa-l)); right: calc(10px + var(--sa-r)); top: calc(var(--hud-h) + var(--sa-t) + 8px); display: flex; align-items: center; gap: 8px; padding: 6px 12px 6px 6px; background: #fff; color: var(--ink); border-radius: 26px; font-weight: 800; font-size: .96rem; line-height: 1.2; box-shadow: 0 3px 0 rgba(6,50,63,.35); pointer-events: none; animation: pop .16s ease-out; max-width: 520px; margin: 0 auto; }
#bubbleFace { width: 42px; height: 42px; flex: none; }
#bubble p { margin: 0; }
#status { position: fixed; z-index: 15; pointer-events: none; font-weight: 800; color: #fff; background: var(--ink); text-align: center; left: 50%; transform: translateX(-50%); width: max-content; max-width: calc(100% - 20px); bottom: calc(var(--ctl-h) + var(--sa-b) + 4px); font-size: .88rem; padding: 2px 12px; border-radius: 12px; line-height: 1.25; }
@keyframes pop { from { transform: scale(.93); opacity: .3; } to { transform: none; opacity: 1; } }

/* ---- online: who, whose turn, how long, and the buttons that must always be in reach ---- */
.btn.online { background: var(--water); color: var(--ink); box-shadow: inset 0 3px 0 rgba(255,255,255,.5), inset 0 -5px 0 rgba(6,50,63,.25), 0 3px 0 rgba(6,50,63,.35); }
#onBar { position: fixed; z-index: 19; left: 0; right: 0; top: calc(var(--hud-h) + var(--sa-t)); padding: 0 calc(8px + var(--sa-r)) 6px calc(8px + var(--sa-l)); background: var(--ink); }
#onTop { display: flex; align-items: center; gap: 8px; min-height: 2.3em; font-size: .86rem; line-height: 1.15; }
#onMsg { flex: 1; min-width: 0; margin: 0; font-weight: 800; color: #fff; }
#onClock { flex: none; font-weight: 800; color: var(--foam); }
#onClock.low { color: var(--duck); }
#onBtns { display: flex; gap: 6px; }
.pill { flex: 1 1 0; min-width: 0; min-height: 36px; padding: 3px 4px; border: 0; border-radius: 12px; background: var(--deep); color: var(--foam); font-weight: 800; font-size: .76rem; line-height: 1.05; box-shadow: inset 0 0 0 1px rgba(255,255,255,.4); }
.pill.warn { background: var(--foam); color: var(--ink); }
.pill[disabled] { opacity: .5; }
#onEmotes { position: absolute; left: 0; right: 0; top: 100%; display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; padding: 0 calc(8px + var(--sa-r)) 8px calc(8px + var(--sa-l)); background: var(--ink); border-radius: 0 0 14px 14px; }
#onEmotes[hidden] { display: none; }
body.online #bubble { top: calc(var(--hud-h) + var(--sa-t) + var(--on-h, 0px) + 8px); }
body.online.land #bubble { top: calc(var(--on-h, 0px) + 8px + var(--sa-t)); }
body.land #onBar { top: 0; right: calc(var(--side-w) + var(--sa-r)); padding-top: calc(4px + var(--sa-t)); }
body.land #onTop { min-height: 1.3em; }
.onCode { margin: 6px 0 4px; text-align: center; font-weight: 800; font-size: 2.3rem; letter-spacing: .1em; line-height: 1.1; color: var(--deep); -webkit-user-select: text; user-select: text; }
.onJoin { display: flex; gap: 8px; align-items: stretch; margin: 6px 0; }
.onJoin input { flex: 1; min-width: 0; font: 800 1.1rem Overpass, system-ui, sans-serif; text-transform: uppercase; letter-spacing: .08em; padding: 8px 10px; border: 2px solid var(--deep); border-radius: 14px; color: var(--ink); background: #fff; -webkit-user-select: text; user-select: text; }
.onJoin .btn { flex: none; width: auto; }
#pBody .link.onLink { color: var(--deep); padding-left: 0; }
.spinner { width: 38px; height: 38px; margin: 8px auto; border-radius: 50%; border: 5px solid rgba(11,92,112,.25); border-top-color: var(--deep); animation: spin .9s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }
body.reduced .spinner { animation: none; }

/* Wide screens: the pool lies on its side and everything you touch sits in one column to the right */
body.land #hud { z-index: 22; left: auto; right: 0; width: calc(var(--side-w) + var(--sa-r)); padding: calc(6px + var(--sa-t)) calc(54px + var(--sa-r)) 6px 6px; height: auto; background: none; align-items: flex-start; flex-wrap: wrap; padding-right: calc(6px + var(--sa-r)); }
body.land #sides, body.land #dailyHud { flex: 1 0 100%; order: 2; }
body.land #dailyHud small { white-space: normal; }
body.land .side { padding-right: 5px; }
body.land #ctl { left: auto; right: 0; top: 0; width: calc(var(--side-w) + var(--sa-r)); height: auto; grid-template-rows: 1fr 54px 72px; }
body.land #spinBox { grid-row: 2 / 4; }
body.land #fine { grid-row: 2; }
body.land #power { grid-row: 3; }
body.land #btnHere { grid-row: 2 / 4; }
body.land #bubble { left: calc(10px + var(--sa-l)); right: calc(var(--side-w) + 10px + var(--sa-r)); top: calc(8px + var(--sa-t)); }
body.land #status { z-index: 21; left: auto; right: calc(8px + var(--sa-r)); transform: none; width: calc(var(--side-w) - 16px); max-width: none; bottom: calc(150px + var(--sa-b)); background: none; font-size: .95rem; }

/* ---- menu ---- */
#menu { position: fixed; inset: 0; z-index: 10; display: flex; flex-direction: column; justify-content: space-between; padding: calc(8px + var(--sa-t)) calc(14px + var(--sa-r)) calc(10px + var(--sa-b)) calc(14px + var(--sa-l)); overflow: auto; touch-action: pan-y; }
.menu-head { text-align: center; padding-top: 6px; }
#logo { margin: 0; font: 400 clamp(68px, 23vw, 118px)/.84 Modak, Overpass, system-ui, sans-serif; color: var(--noodle); -webkit-text-stroke: 3px #fff; paint-order: stroke fill; letter-spacing: .005em; text-shadow: 0 5px 0 rgba(6,50,63,.55); }
#tagline { margin: 6px auto 0; display: inline-block; padding: 3px 12px; font-weight: 800; font-size: 1.04rem; color: #fff; background: var(--ink); border-radius: 12px; }
.menu-actions { width: 100%; max-width: 460px; margin: 0 auto; display: flex; flex-direction: column; gap: 8px; }
#menuFoot { background: var(--ink); border-radius: 18px; padding: 3px 10px 7px; }
#menuLinks { margin: 0; display: flex; flex-wrap: wrap; gap: 0 14px; justify-content: center; }
#stats, #byline { margin: 0; text-align: center; font-size: .84rem; line-height: 1.25; color: #fff; }
#stats:empty { display: none; }
#byline { font-size: .74rem; opacity: .85; }
body.land #menu { flex-direction: row; align-items: center; gap: 20px; justify-content: center; }
body.land .menu-head { flex: 1 1 45%; min-width: 0; }
body.land #logo { font-size: min(10.5vw, 27vh); }
body.land .menu-actions { flex: 1 1 50%; max-height: 100%; }

/* ---- panels ---- */
#panel { position: fixed; inset: 0; z-index: 40; display: flex; align-items: center; justify-content: center; padding: calc(10px + var(--sa-t)) calc(10px + var(--sa-r)) calc(10px + var(--sa-b)) calc(10px + var(--sa-l)); background: rgba(6,50,63,.55); overflow: auto; }
.card { width: 100%; max-width: 480px; max-height: 100%; overflow: auto; background: var(--foam); color: var(--ink); border-radius: 26px; padding: 16px 18px; box-shadow: 0 6px 0 rgba(6,50,63,.5); -webkit-user-select: text; user-select: text; touch-action: pan-y; }
#pTitle { margin: 0 0 8px; font: 400 clamp(32px, 9vw, 46px)/1 Modak, Overpass, system-ui, sans-serif; color: var(--noodle); letter-spacing: .005em; }
#pBody p { margin: 0 0 8px; }
#pBody .lead { font-weight: 800; font-size: 1.1rem; }
#pBody .good { font-weight: 800; color: #0a7a55; }
#pBody .mute { opacity: .8; font-size: .92rem; }
#pBtns { display: flex; flex-direction: column; gap: 8px; margin-top: 10px; }
#pToast { margin: 6px 0 0; min-height: 1.3em; font-size: .9rem; font-weight: 800; }
#pBody textarea { width: 100%; height: 88px; font: inherit; border: 2px solid var(--deep); border-radius: 10px; padding: 8px; -webkit-user-select: text; user-select: text; }

.row { display: flex; align-items: center; gap: 10px; padding: 8px; margin: 0 0 6px; border-radius: 16px; background: #fff; width: 100%; border: 0; text-align: left; color: var(--ink); box-shadow: inset 0 -3px 0 rgba(6,50,63,.12); }
.row[disabled] { opacity: .55; cursor: default; }
.row canvas { flex: none; }
.row .txt { min-width: 0; flex: 1; }
.row b { display: block; font-weight: 800; line-height: 1.15; }
.row small { display: block; line-height: 1.2; font-size: .84rem; opacity: .85; margin-top: 1px; }
.row.sel { box-shadow: inset 0 0 0 3px var(--noodle); }
.row .tag { flex: none; font-weight: 800; font-size: .78rem; padding: 2px 8px; border-radius: 10px; background: var(--water); color: var(--ink); }
.poolPick { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; margin-bottom: 8px; }
.poolPick .row { margin: 0; padding: 6px; }
.toggle { display: flex; align-items: center; gap: 10px; }
#pBody h3 { margin: 10px 0 5px; font-size: 1rem; font-weight: 800; }
.howList { padding: 0; margin: 0 0 8px; list-style: none; }
.howList li { margin-bottom: 8px; }
.result { display: flex; align-items: baseline; gap: 10px; margin-bottom: 4px; }
.result .num { font: 400 58px/1 Modak, Overpass, system-ui, sans-serif; color: var(--ink); }

body.reduced * { animation: none !important; transition: none !important; }

/* Short phones and landscape phones: squeeze controls, never the pool */
@media (max-height: 700px) and (orientation: portrait) {
  :root { --ctl-h: 116px; --hud-h: 48px; }
  #ctl { grid-template-rows: 42px 1fr; }
  #logo { font-size: clamp(56px, 18vw, 80px); }
  .btn.big { padding: 8px 14px 9px; }
  .btn .t { font-size: 1.08rem; } .btn .s { font-size: .8rem; }
}
@media (max-height: 460px) {
  :root { --side-w: 210px; }
  body.land #ctl { grid-template-rows: 1fr 44px 56px; grid-template-columns: 34px 1fr; padding: 6px 8px 6px 8px; gap: 6px; }
  body.land #status { bottom: 116px; font-size: .84rem; }
  body.land #hud { padding-top: 4px; padding-bottom: 4px; }
  .sideIcon { width: 24px; height: 24px; }
  .side { padding: 1px 8px 1px 3px; }
  .icon { width: 38px; height: 38px; padding: 7px; }
  #powerThumb { width: 46px; } #powerLabel { padding-left: 48px; font-size: .8rem; }
  #fine { font-size: .8rem; }
  .menu-actions { gap: 5px; }
  .btn.big { padding: 6px 12px 7px; }
  .btn .t { font-size: 1rem; } .btn .s { font-size: .76rem; }
  #stats { display: none; } #byline { font-size: .7rem; }
  #menuLinks .link { min-height: 28px; padding: 2px 4px; font-size: .86rem; }
  .card { padding: 10px 14px; border-radius: 18px; }
  #pTitle { font-size: 30px; }
}
