:root {
  color-scheme: dark;
  --bg: #0b4148; --bg-deep: #083239; --card: #0b7c86; --chip: #0c666d; --line: #2a8a92;
  --white: #ffffff; --mist: #cfe6e8; --sun: #fdb913; --sun-hot: #ffc93c; --ink: #0a3a42;
  --font: "Nunito", ui-rounded, system-ui, -apple-system, "Segoe UI", sans-serif;
}
* { box-sizing: border-box }
[hidden] { display: none !important }
html { background: var(--bg); overflow-x: clip; scroll-behavior: auto }
body {
  margin: 0; min-height: 100vh; overflow-x: clip;
  background: radial-gradient(120% 90% at 50% 0, #0e4c54 0, var(--bg) 55%, var(--bg-deep) 100%) no-repeat, var(--bg);
  color: var(--white); font: 600 16px/1.4 var(--font);
  padding-left: max(16px, env(safe-area-inset-left, 0px));
  padding-right: max(16px, env(safe-area-inset-right, 0px));
  padding-block: 0 36px;
}
.wrap { max-width: 1444px; margin-inline: auto }
button { font-family: inherit; color: inherit }
svg { fill: currentColor }
h1, h2 { margin: 0; font-weight: 900; line-height: 1.08; text-wrap: balance }
p { margin: 0 }
:focus-visible { outline: 3px solid var(--sun); outline-offset: 2px }

/* Header */
.top { display: flex; align-items: center; gap: 56px; padding-block: 18px 12px }
.logo { display: flex; align-items: center; gap: 6px; background: none; border: 0; padding: 0; cursor: pointer; font-size: 38px; font-weight: 800; letter-spacing: -.01em; line-height: 1 }
.logo img { display: block; height: 46px; width: auto }
.right { margin-left: auto; display: flex; align-items: center; gap: 20px }
.langmenu { position: relative; z-index: 9700 }
.langbtn { display: flex; align-items: center; gap: 6px; min-height: 40px; padding: 6px 10px 6px 12px; border: 2px solid var(--line); border-radius: 22px; background: none; color: var(--white); font: 800 16px var(--font); cursor: pointer }
.langbtn:hover, .langbtn[aria-expanded="true"] { background: var(--chip) }
.langbtn .globe { width: 20px; height: 20px }
.langbtn .chev { width: 14px; height: 14px; transition: rotate .15s }
.langbtn[aria-expanded="true"] .chev { rotate: 180deg }
.langlist { position: absolute; right: 0; top: calc(100% + 8px); width: max-content; min-width: 210px; max-width: calc(100vw - 32px); margin: 0; padding: 6px; list-style: none; border-radius: 16px; background: #f6efe3; box-shadow: 0 12px 32px rgba(0,20,25,.45) }
.langlist button { display: flex; align-items: center; gap: 4px; width: 100%; min-height: 44px; padding: 8px 12px; border: 0; border-radius: 10px; background: none; color: var(--ink); font: 700 16px var(--font); text-align: left; cursor: pointer }
.langlist .other { color: #4a676c; font-weight: 600 }
.langlist button:hover, .langlist button:focus-visible { background: rgba(11,65,72,.1); outline: none }
.langlist button:focus-visible { box-shadow: inset 0 0 0 2px var(--ink) }
.langlist button[aria-checked="true"] { background: var(--sun) }
.langlist .tick { flex: none; width: 18px; height: 18px; margin-left: auto; padding-left: 12px; box-sizing: content-box }
.iconbtn { width: 40px; height: 40px; display: grid; place-items: center; background: none; border: 0; border-radius: 50%; cursor: pointer; color: var(--mist) }
.iconbtn svg { width: 22px; height: 22px }
.iconbtn:hover { background: var(--chip) }
.iconbtn.off { opacity: .45 }
.avatar { width: 46px; height: 46px; border-radius: 50%; background: var(--white); color: var(--ink); display: grid; place-items: center }
.avatar svg { width: 26px; height: 26px }

/* Home */
#home { display: grid; gap: 16px }
#home h1 { font-size: clamp(34px, 4vw, 61px); display: flex; align-items: flex-start; letter-spacing: -.01em; text-wrap: initial }
.marks { color: var(--sun); flex: none }
#home h1 .marks { width: .72em; height: .72em; margin-left: .06em; transform: rotate(-4deg) }
.bento { display: grid; grid-template-columns: minmax(0, 1.195fr) minmax(0, 1fr); grid-template-rows: minmax(258px, auto) minmax(210px, auto); gap: 15px }
.card { position: relative; border-radius: 22px; overflow: hidden; min-width: 0 }
.card h2 { font-size: 34px }
.daily { grid-row: 1 / 3; background: var(--bg-deep); scroll-margin-top: 12px }
.daily img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover }
.seams { position: absolute; inset: 0; width: 100%; height: 100%; pointer-events: none }
.daily::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,.26) 0, rgba(0,0,0,0) 22%, rgba(0,0,0,0) 68%, rgba(0,0,0,.5) 100%); pointer-events: none }
.kicker { position: absolute; z-index: 1; left: 24px; top: 18px; font-size: 30px; font-weight: 800; text-shadow: 0 2px 8px rgba(0,0,0,.45) }
.daily .info { position: absolute; z-index: 1; left: 26px; bottom: 20px; right: 292px; text-shadow: 0 2px 8px rgba(0,0,0,.5) }
.daily .info h2 { font-size: 26px; font-weight: 800 }
.daily .info p { font-size: 18px }
.playnow { position: absolute; z-index: 1; right: 16px; bottom: 16px; display: flex; align-items: center; justify-content: center; gap: 14px; min-width: 260px; height: 58px; padding-inline: 28px; border: 0; border-radius: 30px; background: var(--sun); color: var(--ink); font-size: 24px; font-weight: 800; cursor: pointer; box-shadow: 0 4px 14px rgba(0,0,0,.28) }
.playnow svg { width: 26px; height: 26px }
.playnow:hover { background: var(--sun-hot) }
.photo { background: var(--card); display: flex; justify-content: space-between }
.photo.over { outline: 3px solid var(--sun); outline-offset: -3px }
.card .copy { position: relative; z-index: 2; padding: 32px 0 22px 33px; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; min-width: 0 }
.photo .copy { flex: 0 1 300px }
.photo .copy h2 { display: flex; align-items: flex-start }
.photo .copy h2 .marks { width: 40px; height: 40px; margin-left: -20px }
.photo .copy p { font-size: 19px; line-height: 1.22; color: #eaf6f7 }
.stack { display: flex; flex-direction: column; gap: 12px; align-items: flex-start; min-width: 0 }
.pill { display: inline-flex; align-items: center; gap: 12px; min-height: 48px; padding: 8px 32px 8px 24px; border: 0; border-radius: 26px; background: var(--white); color: var(--ink); font-size: 18px; font-weight: 800; cursor: pointer; box-shadow: 0 2px 6px rgba(0,0,0,.12); text-align: left; line-height: 1.1 }
.pill svg { width: 28px; height: 28px; flex: none }
.pill:hover { background: #fff5d6 }
.links { display: flex; flex-wrap: wrap; gap: 4px 14px }
.links button { background: none; border: 0; padding: 0; cursor: pointer; font-size: 14px; font-weight: 700; text-decoration: underline; text-underline-offset: 2px }
small { font-size: 13px; color: var(--mist) }
.promo { position: absolute; right: 14px; top: 50%; translate: 0 -50%; width: min(100% - 330px, 310px); max-height: calc(100% - 12px); object-fit: contain; pointer-events: none }
.challenge .promo { width: min(100% - 370px, 262px) }
.challenge { background: var(--sun); color: var(--ink); grid-column: 2 }
.challenge .copy { padding-top: 26px; gap: 8px }
.challenge .copy h2 { font-size: 37px; max-width: 340px }
.challenge .copy p { font-size: 19px; line-height: 1.2; max-width: 275px; color: #123f46 }
.challenge .pill { margin-top: 8px; min-height: 48px }

#gallery { display: grid; gap: 16px; scroll-margin-top: 12px; margin-top: -6px }
.filters { display: flex; flex-wrap: wrap; gap: 12px }
.filters button { min-height: 38px; padding: 6px 26px; border: 0; border-radius: 20px; background: var(--chip); color: var(--white); font-size: 16px; font-weight: 800; cursor: pointer }
.filters button:hover { background: #0e7b83 }
.filters button[aria-pressed="true"] { background: var(--sun); color: var(--ink) }
.shelves { display: grid; gap: 14px }
.shelf { font-size: 32px; padding-top: 6px }
.grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 17px }
.grid.portraits .tile { height: auto; aspect-ratio: 4 / 5 }
.tile { position: relative; display: block; height: 282px; width: 100%; padding: 0; border: 0; border-radius: 20px; overflow: hidden; background: var(--bg-deep); cursor: pointer; text-align: left }
.art { position: absolute; inset: 0; transition: transform .25s }
.tile img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover }
.tile:hover .art { transform: scale(1.04) }
.tile::after { content: ""; position: absolute; inset: 0; background: linear-gradient(180deg, rgba(0,0,0,0) 56%, rgba(0,0,0,.72) 100%) }
.cap { position: absolute; z-index: 1; left: 20px; right: 16px; bottom: 16px; display: grid; text-shadow: 0 2px 6px rgba(0,0,0,.55) }
.cap b { font-size: 25px; font-weight: 800; line-height: 1.15 }
.cap small { font-size: 18px; color: var(--white) }
.credits { color: var(--mist); font-size: 14px; padding-top: 8px }
.credits summary { cursor: pointer; font-weight: 700 }
.credits ul { columns: 2; padding-left: 18px; margin: 10px 0 0 }
.credits a { color: var(--white) }

/* Difficulty */
#crop { display: grid; gap: 18px; justify-items: center; text-align: center; padding-top: 4px }
.back { justify-self: start; background: none; border: 0; padding: 6px 0; cursor: pointer; font-size: 17px; font-weight: 800 }
.flowhead { display: grid; gap: 4px }
.flowhead h2 { font-size: clamp(32px, 5vw, 46px) }
.flowhead p { color: var(--mist); font-size: 18px }
.cropbox { display: grid; gap: 18px; width: min(100%, 460px) }
#cropc { width: 100%; aspect-ratio: 1; border-radius: 18px; touch-action: none; cursor: grab; display: block; background: var(--bg-deep) }
.field { display: grid; gap: 6px; text-align: left }
.field label, .field .lab { font-weight: 700; font-size: 14px; color: var(--mist) }
#zoom { width: 100%; accent-color: var(--sun) }
.seg { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px }
#modes { grid-template-columns: repeat(2, minmax(0, 1fr)) }
.sizes { display: grid; gap: 18px }
.seg button { font-size: 15px; font-weight: 800; padding: 10px 4px; border-radius: 14px; border: 2px solid var(--line); background: none; cursor: pointer; min-height: 48px }
.seg b { display: block; font-weight: 800 }
.seg small { display: block; font-weight: 600; font-size: 12px; color: inherit; opacity: .85; font-variant-numeric: tabular-nums }
.seg button[aria-pressed="true"] { background: var(--white); border-color: var(--white); color: var(--ink) }
.btn { font-size: 16px; font-weight: 800; line-height: 1; border-radius: 24px; padding: 15px 24px; cursor: pointer; border: 2px solid var(--line); background: transparent; min-height: 48px }
.btn:hover { background: var(--chip) }
.btn.main { background: var(--sun); border-color: var(--sun); color: var(--ink) }
.btn.main:hover { background: var(--sun-hot) }
.btn.small { padding: 8px 14px; min-height: 40px; font-size: 14px; border-radius: 20px }
.btn:disabled { opacity: .5; cursor: default }
.cropbox > .btn { width: 100%; font-size: 18px }
.flowsaved { display: flex; gap: 14px; align-items: center; text-align: left; padding: 12px; border-radius: 16px; background: var(--card) }
.flowsaved img { width: 96px; height: 96px; object-fit: cover; border: 4px solid var(--white); flex: none }
.flowsaved .pill { min-height: 42px; padding: 6px 18px 6px 14px; font-size: 15px }
.flowsaved .pill svg { width: 20px; height: 20px }

/* Challenges */
.chscreen { display: grid; gap: 18px; justify-items: center; text-align: center; padding-top: 4px }
.chscreen.wide { text-align: left; justify-items: start }
.chscreen.wide .shelves { width: 100% }
.chscreen .stack { align-items: stretch; text-align: left }
.fullw { width: 100% }
.legal { max-width: 720px; margin-inline: auto; display: grid; gap: 12px }
.legal h3 { margin: 16px 0 0; font-size: 21px; font-weight: 900 }
.legal p { line-height: 1.5 }
.legal a { color: var(--sun) }
#footer { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px 24px; margin-top: 36px; padding-block: 18px; background: var(--bg-deep); box-shadow: 0 0 0 100vmax var(--bg-deep); clip-path: inset(0 -100vmax); color: var(--mist); font-size: 15px; font-weight: 700 }
#footer button, .textlink { background: none; border: 0; padding: 0; cursor: pointer; color: inherit; font: inherit; text-decoration: underline }
#footer button { text-decoration: none }
#footer button:hover, #footer #cookieSettings { color: var(--white); text-decoration: underline }
#cookieDialog { width: min(100% - 32px, 440px); max-height: calc(100dvh - 32px); padding: 26px; border: 2px solid var(--line); border-radius: 22px; background: var(--bg-deep); color: var(--white); box-shadow: 0 16px 48px rgba(0,20,25,.6) }
#cookieDialog::backdrop { background: rgba(3,20,24,.7) }
#cookieDialog form { display: grid; gap: 16px }
#cookieDialog h2 { font-size: 30px }
#cookieDialog p { color: var(--mist); font-size: 15px; line-height: 1.45 }
#cookieDialog .textlink { justify-self: start; text-align: left; color: var(--sun); font-size: 15px; font-weight: 700 }
#cookieDialog .row { display: flex; flex-wrap: wrap; gap: 10px }
#cookieDialog .row .btn { flex: 1 1 auto; white-space: nowrap }
.cookiepart { display: grid; gap: 8px; padding-top: 16px; border-top: 1px solid var(--line) }
.cookiehead { display: flex; align-items: center; justify-content: space-between; gap: 12px; font-size: 17px }
.cookiehead.start { justify-content: flex-start; cursor: pointer }
.cookiehead small { color: var(--mist); font-size: 14px; font-weight: 700 }
.cookiehead input { width: 22px; height: 22px; accent-color: var(--sun); cursor: pointer }
.tile .cap b, .tile .cap small { overflow-wrap: anywhere; hyphens: auto }
#cookieBanner { position: fixed; z-index: 30; left: 50%; bottom: 16px; translate: -50% 0; width: min(100% - 32px, 620px); display: grid; gap: 12px; padding: 16px 18px; border: 2px solid var(--line); border-radius: 18px; background: var(--bg-deep); box-shadow: 0 8px 28px rgba(0,20,25,.5); font-size: 15px; line-height: 1.4 }
#cookieBanner .row { display: flex; flex-wrap: wrap; justify-content: flex-end; gap: 8px }
#demoTag { display: flex; flex-wrap: wrap; align-items: center; justify-content: center; gap: 4px 10px; margin: 0 0 14px; color: var(--mist); font-size: 14px; font-weight: 700; text-align: center }
#demoTag b { padding: 3px 12px; border-radius: 12px; background: var(--chip); color: var(--white); font-weight: 800 }
.textin { width: 100%; min-width: 0; min-height: 48px; padding: 10px 14px; border-radius: 14px; border: 2px solid var(--line); background: var(--bg-deep); color: var(--white); font: 700 16px var(--font) }
.textin:focus { border-color: var(--sun); outline: none }
.chbest { color: var(--sun); font-weight: 800; font-size: 17px }
.ranks { list-style: none; margin: 0; padding: 0; display: grid; gap: 8px; text-align: left }
.ranks li { display: grid; grid-template-columns: 34px minmax(0, 1fr) auto; align-items: center; gap: 12px; padding: 12px 16px; border-radius: 16px; background: var(--chip) }
.ranks li.winner { background: var(--sun); color: var(--ink) }
.ranks li.you { box-shadow: inset 0 0 0 3px var(--white) }
.ranks b { font-weight: 800; overflow-wrap: anywhere }
.ranks small { color: inherit; font-weight: 700; opacity: .8 }
.ranks .place { font-weight: 900; font-size: 20px }
.ranks .time { font-weight: 900; font-size: 22px; font-variant-numeric: tabular-nums }

/* Playing */
.hud { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 8px 16px; padding-bottom: 12px }
.hud > div { display: flex; align-items: center; gap: 12px; min-width: 0 }
#clock { font-size: 36px; font-weight: 900; line-height: 1; color: var(--sun); font-variant-numeric: tabular-nums; min-width: 3ch }
#beat { font-size: 14px; color: var(--mist) }
.status { font-size: 14px; font-weight: 800; letter-spacing: .04em; text-transform: uppercase; color: var(--mist) }
.stagewrap { position: relative }
#stage { position: relative; width: 100%; touch-action: none; user-select: none; -webkit-user-select: none }
#board { position: absolute; background: var(--bg-deep); outline: 2px solid var(--line) }
#stage canvas { position: absolute; left: 0; top: 0; pointer-events: none; filter: drop-shadow(0 3px 4px rgba(0,20,25,.6)); will-change: transform }
#stage canvas.locked { filter: none; will-change: auto }
#stage.many canvas { filter: none }
#stage canvas.pop { animation: pop .28s ease-out }
@keyframes pop { 50% { filter: brightness(1.35) } }
#slide { position: absolute; overflow: hidden; background: var(--bg-deep); outline: 2px solid var(--line); touch-action: manipulation }
#slide button { position: absolute; left: 0; top: 0; padding: 0; border: 0; cursor: pointer; background: none; box-shadow: inset 0 0 0 1px rgba(255,255,255,.28); transition: transform .12s ease-out }
#slide canvas { position: static; display: block; width: 100%; height: 100%; filter: none; will-change: auto }
#slide.solved button { box-shadow: none; cursor: default }
.ref { position: relative; display: flex }
.refthumb { width: 96px; height: 96px; padding: 0; border: 2px solid var(--line); border-radius: 12px; overflow: hidden; background: var(--bg-deep); cursor: zoom-in }
.refthumb:hover, .refthumb:focus-visible { border-color: var(--sun) }
.refthumb canvas { display: block; width: 100%; height: 100% }
.refmin { display: none }
#refOverlay { position: fixed; inset: 0; z-index: 9800; display: grid; place-items: center; padding: 16px; background: rgba(3,20,24,.85); cursor: zoom-out }
#refBig { width: min(100%, 86vh, 760px); height: auto; aspect-ratio: 1; border: 2px solid var(--line); border-radius: 18px; box-shadow: 0 16px 48px rgba(0,0,0,.5) }
@media (max-width: 760px) {
  .ref { position: fixed; right: 12px; bottom: 12px; z-index: 9600; touch-action: none }
  .ref[data-corner^="t"] { top: var(--ref-top, 12px); bottom: auto }
  .ref[data-corner$="l"] { left: 12px; right: auto }
  .ref.dragging { right: auto; bottom: auto }
  .ref.dragging .refthumb { cursor: grabbing; border-color: var(--sun) }
  #refToggle.hider { display: none }
  .refthumb { width: 88px; height: 88px; box-shadow: 0 6px 20px rgba(0,20,25,.6) }
  .refmin { display: grid; place-items: center; position: absolute; top: -10px; right: -10px; width: 30px; height: 30px; padding: 0; border: 0; border-radius: 50%; background: var(--sun); color: var(--ink); font: 900 18px var(--font); cursor: pointer }
}
#peek { z-index: 9000; filter: none; box-shadow: 0 8px 30px rgba(0,20,25,.7) }
#pausedCover { position: absolute; inset: 0; min-height: 320px; z-index: 9500; display: grid; place-content: center; justify-items: center; gap: 12px; text-align: center; border-radius: 18px; background: var(--bg-deep) }
#pausedCover h2 { font-size: 44px }
#pausedTime { font-size: 30px; font-weight: 900; color: var(--sun); font-variant-numeric: tabular-nums }

/* Results */
#done { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 32px; align-items: center; padding-top: 8px }
#done > div { display: grid; gap: 18px; min-width: 0 }
#finalImg { width: 100%; max-width: 460px; aspect-ratio: 1; justify-self: center; box-shadow: 0 0 0 9px var(--white) }
#total { font-size: clamp(56px, 10vw, 84px); font-weight: 900; line-height: 1; color: var(--sun); font-variant-numeric: tabular-nums }
.stats { display: flex; flex-wrap: wrap; gap: 12px 32px; margin: 0 }
.stats dt { color: var(--mist); font-size: 14px }
.stats dd { margin: 0; font-size: 22px; font-weight: 800; font-variant-numeric: tabular-nums }
#verdict { font-weight: 800; font-size: 18px; color: var(--sun) }
.row { display: flex; flex-wrap: wrap; gap: 12px; align-items: center }

#toast { position: fixed; left: 50%; bottom: calc(24px + env(safe-area-inset-bottom, 0px)); transform: translateX(-50%); z-index: 9900; padding: 12px 22px; border-radius: 24px; background: var(--white); color: var(--ink); font-weight: 800; box-shadow: 0 6px 18px rgba(0,0,0,.35); max-width: calc(100vw - 32px) }
#confetti { position: fixed; inset: 0; width: 100%; height: 100%; pointer-events: none; z-index: 9800 }

@media (max-width: 1240px) {
  .card .copy { padding-left: 24px }
  .promo { width: min(100% - 290px, 240px) }
  .challenge .promo { width: min(100% - 310px, 200px) }

  .photo .copy h2 .marks { display: none }
  .card h2 { font-size: 30px }
  .challenge .copy h2 { font-size: 31px }
  .grid, .grid.portraits { grid-template-columns: repeat(3, minmax(0, 1fr)) }
}
@media (max-width: 980px) {
  .promo { width: min(100% - 330px, 300px) }
  .challenge .promo { width: min(100% - 370px, 262px) }
  .top { gap: 24px }
  .bento { grid-template-columns: minmax(0, 1fr); grid-template-rows: auto }
  .daily { grid-row: auto; aspect-ratio: 16 / 10 }
  .photo { min-height: 250px }
  .challenge { grid-column: auto; min-height: 210px }
  .grid, .grid.portraits { grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 12px }
  .tile { height: auto; aspect-ratio: 1 / .85 }
}
@media (max-width: 620px) {
  .top { gap: 10px }
  .logo { font-size: 30px }
  #footer { justify-content: center; text-align: center }
  .logo { flex: 0 1 190px; min-width: 0 }
  .logo img { width: 100%; height: auto }
  .right { gap: 6px; flex: none }
  .avatar { width: 40px; height: 40px }
  .card h2, .challenge .copy h2 { font-size: 26px }
  .daily { aspect-ratio: 1 / 1 }
  .kicker { font-size: 24px; left: 18px; top: 14px }
  .daily .info { left: 18px; right: 18px; bottom: 82px }
  .playnow { left: 16px; right: 16px; min-width: 0; height: 54px; font-size: 21px }
  .photo { min-height: 290px }
  .photo { flex-direction: column }
  .photo .copy { flex: 0 0 auto; padding-right: 24px; padding-bottom: 8px }
  .photo .copy h2 { max-width: 240px }
  .challenge .copy { padding-right: 24px; padding-bottom: 8px }
  .promo, .challenge .promo { position: static; translate: none; display: block; width: min(100% - 32px, 300px); max-height: none; margin: 4px auto 14px }
  .challenge .copy p { max-width: none }
  .cap { left: 12px; right: 10px; bottom: 10px }
  .cap b { font-size: 18px }
  .cap small { font-size: 13px }
  .credits ul { columns: 1 }
  #done { grid-template-columns: minmax(0, 1fr) }
  #clock { font-size: 28px }
}
@media (prefers-reduced-motion: reduce) {
  .art, #slide button { transition: none }
  #stage canvas.pop { animation: none }
}
