/* Quicksand: SIL Open Font License 1.1 */
@font-face { font-family: Quicksand; src: url(quicksand.ttf); font-weight: 700; font-display: swap; }
:root { --ink: #3b2a1a; --cream: #fffdf3; --sun: #ffd93b; --orange: #ff8a2a; --blue: #2f9fe0; --pink: #ff6f91; --green: #5ecb5a;
  --text: var(--ink); --panel: #fff; --veil: #ffffffd9; --on-bright: #3b2a1a; }
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { min-height: 100%; background: linear-gradient(#7fd3f7, #c9f0ff 70%, #e6fbff) fixed; }
body { margin: 0; min-height: 100vh; color: var(--text); font: 700 15px Quicksand, ui-rounded, system-ui, sans-serif; }

/* sky and sea behind everything */
#scenery { position: fixed; inset: 0; z-index: -1; overflow: hidden; pointer-events: none; }
.sea { position: absolute; bottom: 0; left: 0; width: 200%; height: 190px; }
.sea path { animation: roll 14s linear infinite; }
.w1 { fill: #8fdcf2; animation-duration: 19s !important; }
.w2 { fill: #4fc0e8; animation-direction: reverse !important; }
.w3 { fill: #2f9fe0; animation-duration: 9s !important; }
@keyframes roll { to { transform: translateX(-1200px); } }
.sun { position: absolute; top: -60px; right: -50px; width: 190px; height: 190px; border-radius: 50%; background: var(--sun);
  box-shadow: 0 0 0 18px #ffe98a88, 0 0 0 40px #fff3b755; animation: breathe 5s ease-in-out infinite; }
@keyframes breathe { 50% { transform: scale(1.08); } }
.cloud { position: absolute; width: 130px; height: 40px; border-radius: 40px; background: #fff; opacity: .85; animation: drift 70s linear infinite; }
.cloud::before, .cloud::after { content: ''; position: absolute; border-radius: 50%; background: #fff; }
.cloud::before { width: 62px; height: 62px; left: 20px; top: -28px; }
.cloud::after { width: 46px; height: 46px; left: 66px; top: -18px; }
.c1 { top: 12%; animation-delay: -10s; }
.c2 { top: 40%; scale: .7; animation-duration: 95s; animation-delay: -60s; }
.c3 { top: 66%; scale: .5; animation-duration: 120s; animation-delay: -30s; }
@keyframes drift { from { translate: -220px 0; } to { translate: 110vw 0; } }

/* bouncy bits */
input, button { font: inherit; color: inherit; border-radius: 999px; border: 3px solid var(--ink); background: var(--panel); padding: .45em 1em; }
input:focus-visible, button:focus-visible, summary:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }
button { cursor: pointer; box-shadow: 0 4px 0 var(--ink); transition: transform .12s cubic-bezier(.3, 2.5, .6, 1), box-shadow .12s; }
button:hover:not(:disabled) { transform: translateY(-2px) rotate(-1.5deg) scale(1.04); box-shadow: 0 6px 0 var(--ink); }
button:active:not(:disabled) { transform: translateY(4px) scale(.97); box-shadow: 0 0 0 var(--ink); }
button:disabled { opacity: .45; cursor: default; }
.go { background: var(--green); } .hot { background: var(--pink); } .big { background: var(--sun); }
.go, .hot, .big { color: var(--on-bright); }
.card { background: var(--cream); border: 4px solid var(--ink); border-radius: 26px; box-shadow: 0 7px 0 #3b2a1a33; }

.theme { flex: none; }
#login .theme { justify-self: center; font-size: 13px; border-width: 2px; box-shadow: 0 3px 0 var(--ink); }
header .theme { padding: .3em .6em; }

.blob { margin: 0; display: inline-grid; justify-items: center; line-height: 1.05; padding: .55em 1.2em .65em; background: var(--sun);
  border: 4px solid var(--ink); border-radius: 48% 52% 46% 54% / 58% 55% 45% 42%; animation: jelly 6s ease-in-out infinite; }
.blob span:first-child { color: var(--orange); font-size: 1.25em; }
.blob span:last-child { color: var(--blue); }
.blob span { -webkit-text-stroke: 5px #fff; paint-order: stroke fill; }
.blob.small { font-size: 15px; }
@keyframes jelly { 0%, 100% { border-radius: 48% 52% 46% 54% / 58% 55% 45% 42%; rotate: -3deg; }
  50% { border-radius: 55% 45% 52% 48% / 46% 44% 56% 54%; rotate: 2deg; } }

#login { width: min(360px, calc(100% - 32px)); margin: 11vh auto 0; display: grid; gap: .9em; padding: 1.4em; animation: pop .5s cubic-bezier(.3, 1.8, .6, 1); }
#login .blob { justify-self: center; font-size: 25px; margin: -2.4em 0 .2em; }
#error { color: #c8321f; margin: 0; text-align: center; min-height: 1.2em; }
@keyframes pop { from { transform: scale(.5); opacity: 0; } }

main { display: grid; grid-template-columns: minmax(0, 1fr) 330px; gap: 14px; height: 100vh; padding: 12px; }
#stage { overflow: auto; padding: 0 4px; text-align: center; }
header { display: flex; align-items: center; justify-content: center; gap: 14px; flex-wrap: wrap; margin-bottom: 10px; }
.bubble { position: relative; background: var(--panel); border: 3px solid var(--ink); border-radius: 22px; padding: .5em 1.2em; font-size: 17px; }
.bubble::after { content: ''; position: absolute; left: -9px; top: 50%; width: 13px; height: 13px; background: var(--panel); border-left: 3px solid var(--ink); border-bottom: 3px solid var(--ink); translate: 0 -50%; rotate: 45deg; }
.bubble.bounce { animation: pop .4s cubic-bezier(.3, 2.2, .6, 1); }
.meter { position: relative; display: inline-block; flex: none; width: 150px; height: 32px; background: var(--panel); border: 3px solid var(--ink); border-radius: 999px; overflow: hidden; }
.meter i { position: absolute; inset: 0 auto 0 0; background: var(--sun); transition: width 1s linear; }
.meter i.low { background: #ffb3a0; }
.meter b { position: relative; display: block; line-height: 26px; text-align: center; }
.meter.draining i { background: repeating-linear-gradient(-45deg, var(--orange) 0 10px, var(--sun) 10px 20px); }
.meter.double i { background: repeating-linear-gradient(-45deg, #ff4d4d 0 10px, var(--orange) 10px 20px); }
.meter.small { width: 74px; height: 22px; border-width: 2px; font-size: 12px; }
.meter.small b { line-height: 18px; }
#economy { margin: -4px 0 8px; font-size: 13px; opacity: .75; }
#pinned { margin: 12px auto 0; max-width: 640px; color: var(--on-bright); background: var(--sun); border: 3px solid var(--ink); border-radius: 16px; padding: .4em 1em; overflow-wrap: anywhere; animation: pop .4s cubic-bezier(.3, 2, .6, 1); }

#screen { position: relative; width: 100%; max-width: calc((100vh - 325px) * 16 / 9); min-width: min(100%, 480px); margin: auto; border: 6px solid var(--panel); border-radius: 24px;
  outline: 4px solid var(--ink); overflow: hidden; background: #123; touch-action: none; user-select: none; }
#screen.mine { border-color: var(--sun); animation: glow 1.6s ease-in-out infinite; }
@keyframes glow { 50% { box-shadow: 0 0 0 10px #ffd93baa; } }
#video { display: block; width: 100%; aspect-ratio: 16 / 9; }
#cursors, #pops { position: absolute; inset: 0; pointer-events: none; overflow: hidden; }
.cursor { position: absolute; transition: left 60ms linear, top 60ms linear; white-space: nowrap; font-size: 12px; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.cursor::before { content: ''; display: block; width: 15px; height: 15px; background: var(--c); clip-path: polygon(0 0, 100% 45%, 55% 55%, 45% 100%); filter: drop-shadow(0 0 1px #000); }
.pop { position: absolute; bottom: 8%; background: var(--panel); border: 3px solid var(--c); border-radius: 999px; padding: .3em .8em; white-space: nowrap; animation: rise 1.8s ease-out forwards; }
@keyframes rise { from { transform: translateY(20px) scale(.3); opacity: 0; } 20% { transform: translateY(0) scale(1.2); opacity: 1; } to { transform: translateY(-140px) rotate(8deg); opacity: 0; } }

#bar, #hostbar, #pad { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-top: 14px; }
#padlabel { margin: 14px 0 -6px; min-height: 1.3em; }
#pad { margin-top: 12px; gap: 8px; }
#pad button { min-width: 2.9em; height: 2.9em; padding: 0 .7em; user-select: none; touch-action: none; }
#pad.poking button:not(:disabled) { background: #ffd5df; }
.help { margin: 14px auto 8px; max-width: 640px; background: var(--veil); border-radius: 18px; padding: .5em 1em; }
.help summary { cursor: pointer; }
.help p { text-align: left; margin: .6em 0; }

aside { display: flex; flex-direction: column; gap: 16px; min-height: 0; }
aside .card { padding: 10px 14px 14px; }
.talk { flex: 1; display: flex; flex-direction: column; min-height: 220px; overflow-y: auto; }
h2 { margin: 0 0 8px; font-size: 16px; color: var(--blue); }
ul, ol { list-style: none; margin: 0; padding: 0; }
#users { max-height: 30vh; overflow-y: auto; }
#users li { display: flex; gap: 8px; align-items: center; padding: 4px 2px; }
.face { flex: none; display: grid; place-items: center; width: 32px; height: 32px; border-radius: 46% 46% 50% 50%; background: var(--c); border: 3px solid var(--ink); font-style: normal; }
#users li.playing .face { animation: hop .7s ease-in-out infinite alternate; }
@keyframes hop { to { translate: 0 -5px; rotate: 8deg; } }
#users li > span { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: left; }
#users button { padding: 0 .55em; border-width: 2px; box-shadow: 0 2px 0 var(--ink); }
#chat { flex: 1; min-height: 110px; overflow-y: auto; overflow-wrap: anywhere; display: flex; flex-direction: column; gap: 7px; padding: 2px; }
#chat li { align-self: flex-start; max-width: 100%; background: var(--panel); border: 2px solid var(--c, var(--ink)); border-radius: 4px 16px 16px 16px; padding: .35em .75em; animation: pop .3s cubic-bezier(.3, 2, .6, 1); }
#chat li b { display: block; font-size: 12px; color: var(--blue); }
#chat .notice { align-self: center; text-align: center; color: var(--on-bright); background: var(--sun); border-radius: 999px; font-size: 13px; }
#say { display: flex; gap: 8px; margin-top: 10px; }
#text { flex: 1; min-width: 0; }
#say button { padding-inline: .8em; }

/* messages bought with energy */
.said i { font-style: normal; white-space: pre-wrap; }
#chat li.big .said { font-size: 26px; line-height: 1.15; }
#chat li.wavy .said i { display: inline-block; animation: wave 1s ease-in-out infinite alternate; }
@keyframes wave { from { translate: 0 -3px; } to { translate: 0 3px; } }
#chat li.rainbow .said i { animation: hue 2.4s linear infinite; color: hsl(0 85% 45%); }
@keyframes hue { to { filter: hue-rotate(360deg); } }
#chat li.shake .said { display: inline-block; animation: shake .25s linear infinite; }
@keyframes shake { 25% { translate: -2px 1px; } 75% { translate: 2px -1px; } }
#chat li.pin { background: var(--sun); color: var(--on-bright); }
#chat li.pin b { color: var(--on-bright); }

/* toy box */
#toys { margin-top: 10px; border-top: 3px dashed #3b2a1a44; padding-top: 10px; max-height: 42vh; overflow-y: auto; flex: none; }
#toys nav { display: flex; gap: 5px; flex-wrap: wrap; }
#toys nav button, .chip { border-width: 2px; box-shadow: 0 3px 0 var(--ink); padding: .25em .7em; font-size: 13px; }
#toys nav button.on, .chip.on { background: var(--blue); color: #fff; }
#toys p { margin: .6em 0 0; font-size: 13px; }
.chips { display: flex; flex-wrap: wrap; gap: 7px; margin: 10px 0 8px; }
.chip small { opacity: .75; }
#emoji .chip span { font-size: 20px; }
#toys label { display: flex; align-items: center; gap: 7px; font-size: 13px; margin-top: 8px; }
#toys input[type=checkbox] { width: 16px; height: 16px; flex: none; accent-color: var(--blue); }
#toys input[type=range] { flex: 1; min-width: 0; padding: 0; border: 0; accent-color: var(--blue); }
#toys select { font: inherit; border: 2px solid var(--ink); border-radius: 999px; padding: .15em .6em; background: var(--panel); color: inherit; }
.mineonly { margin-top: 10px; border-top: 2px solid #3b2a1a22; }

/* things landing on the picture */
.thrown, .drop { position: absolute; font-size: 54px; line-height: 1; text-align: center; }
.thrown small { display: block; font-size: 12px; color: #fff; text-shadow: 0 0 3px #000, 0 0 3px #000; }
.thrown { animation: fling 3s cubic-bezier(.2, 1.4, .5, 1) forwards; }
@keyframes fling { from { translate: var(--from) 180px; rotate: -540deg; scale: .4; } 25% { translate: 0 0; rotate: 0deg; scale: 1.5; } 35% { scale: 1; } 80% { opacity: 1; } to { translate: 0 40px; opacity: 0; } }
.drop { top: -70px; font-size: 34px; animation: fall 2.4s linear forwards; }
@keyframes fall { to { translate: 0 min(800px, 100vh); rotate: 220deg; } }
#screen[data-fx=disco] #video { animation: hue 4s linear infinite; }
#screen[data-fx=wobble] #video { animation: wobble 1.4s ease-in-out infinite; }
@keyframes wobble { 25% { transform: skew(7deg, 2deg) scale(.95); } 75% { transform: skew(-7deg, -2deg) scale(.95); } }
#screen[data-fx=tiny] #video { transform: scale(.4); }
#screen[data-fx=flip] #video { transform: rotate(180deg); }
#video { transition: transform .6s cubic-bezier(.3, 1.6, .6, 1); }

@media (max-width: 860px) { main { grid-template-columns: minmax(0, 1fr); height: auto; padding: 8px; } #screen { max-width: 100%; min-width: 0; } #chat { max-height: 40vh; } .blob.small, .bubble::after { display: none; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } .pop, .thrown, .drop { animation: none !important; } .drop { display: none; } }

/* night on the island */
html[data-theme=dark] { --ink: #080b1c; --text: #f2eeff; --panel: #333c6b; --veil: #252c52e6; --cream: #242a4c; --blue: #6cc4ff;
  color-scheme: dark; background: linear-gradient(#0d1230, #232c5e 70%, #34407a) fixed; }
[data-theme=dark] .sun { background: #f4f0cd; box-shadow: 0 0 0 16px #f4f0cd22, 0 0 0 38px #f4f0cd11; }
[data-theme=dark] .sun::after { content: ''; position: absolute; left: 34px; bottom: 44px; width: 30px; height: 30px; border-radius: 50%; background: #d9d4a8; box-shadow: 38px 22px 0 -7px #d9d4a8; }
[data-theme=dark] .cloud { opacity: .13; }
[data-theme=dark] .w1 { fill: #27407f; } [data-theme=dark] .w2 { fill: #1c3068; } [data-theme=dark] .w3 { fill: #132250; }
[data-theme=dark] .go { background: #4fb64b; } [data-theme=dark] .hot { background: #f2688a; } [data-theme=dark] .big { background: #f0c730; }
[data-theme=dark] #pad.poking button:not(:disabled) { background: #7a3558; }
[data-theme=dark] .meter i { background: #9a6d0c; }
[data-theme=dark] .meter i.low { background: #8c3a34; }
[data-theme=dark] .meter.draining i { background: repeating-linear-gradient(-45deg, #a8540f 0 10px, #9a6d0c 10px 20px); }
[data-theme=dark] .meter.double i { background: repeating-linear-gradient(-45deg, #a52a2a 0 10px, #a8540f 10px 20px); }
[data-theme=dark] .meter b { text-shadow: 0 0 3px #000; }
[data-theme=dark] #chat li.rainbow .said i { color: hsl(0 100% 72%); }
[data-theme=dark] #chat .notice, [data-theme=dark] #chat li.pin, [data-theme=dark] #pinned { background: #f0c730; }
[data-theme=dark] #toys, [data-theme=dark] .mineonly { border-top-color: #ffffff2b; }
[data-theme=dark] #error { color: #ff9d8a; }
[data-theme=dark] #toys nav button.on, [data-theme=dark] .chip.on { color: #081030; }

/* clips */
#clipbar { display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: center; margin-top: 12px; }
#clipbar[hidden], #chat[hidden], #shelf[hidden] { display: none; }
select#cliplen { width: auto; }
#clipsbtn { float: right; }
#clipsbtn.on { background: var(--blue); color: #fff; }
#shelf { flex: 1; min-height: 110px; overflow-y: auto; display: flex; flex-direction: column; gap: 10px; }
#shelf b { display: block; font-size: 12px; color: var(--blue); }
.clipcard { display: flex; flex-direction: column; gap: 4px; align-items: center; padding: 6px; margin-top: 4px; width: 100%; max-width: 230px; border-radius: 14px; font-size: 13px; }
.clipcard img { width: 100%; aspect-ratio: 16 / 9; object-fit: cover; border-radius: 8px; background: #123; }
#player { width: min(920px, 94vw); max-height: 94vh; color: var(--text); background: var(--panel); }
#player::backdrop { background: #0b1230cc; }
#player video { display: block; width: 100%; max-height: 66vh; border-radius: 14px; background: #000; }
#player p { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; margin: 12px 0 0; }
a.button { display: inline-block; text-decoration: none; padding: .45em 1.1em; border: 3px solid var(--ink); border-radius: 999px; box-shadow: 0 4px 0 var(--ink); font-weight: bold; }
[data-theme=dark] #clipsbtn.on { color: #081030; }
select#cliplen { font: inherit; color: inherit; border-radius: 999px; border: 3px solid var(--ink); background: var(--panel); padding: .45em .8em; }
