@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600;700&family=Space+Grotesk:wght@400;500;600;700&display=swap');

:root { color-scheme: dark; --ink: #e9faf6; --lagoon: #69dfcd; --coral: #ffad87; --muted: #bdd7d9; --page: #073642; }
* { box-sizing: border-box; }
body { margin: 0; isolation: isolate; background: radial-gradient(ellipse at 85% 5%, #125e6c 0%, transparent 55%), linear-gradient(160deg, #073e4b, #052a38); background-attachment: fixed; color: var(--ink); font-family: 'DM Sans', sans-serif; font-size: 16px; -webkit-font-smoothing: antialiased; }
/* Slow decorative motion stays behind the game and never receives input. */
.ocean-ambience { position: fixed; inset: 0; z-index: 0; pointer-events: none; overflow: hidden; contain: strict; }
.ocean-wave { position: absolute; left: -30%; width: 160%; height: 65%; fill: #72dbcd; animation: ocean-swell 36s ease-in-out infinite alternate; }
.ocean-wave--far { bottom: 3%; opacity: .035; animation-duration: 44s; animation-delay: -17s; }
.ocean-wave--near { bottom: -24%; opacity: .045; animation-direction: alternate-reverse; animation-delay: -8s; }
.ocean-bubble { position: absolute; bottom: -24px; left: var(--left); width: var(--size); height: var(--size); border: 1px solid #a4ebdf; border-radius: 50%; background: radial-gradient(circle at 30% 25%, #d1fff540, transparent 55%); opacity: 0; animation: bubble-rise var(--duration) linear var(--delay) infinite; }
@keyframes ocean-swell { from { transform: translate3d(-3%, 1%, 0); } to { transform: translate3d(3%, -2%, 0); } }
@keyframes bubble-rise {
  0% { transform: translate3d(0, 0, 0); opacity: 0; }
  12% { opacity: .16; }
  80% { opacity: .16; }
  100% { transform: translate3d(var(--drift), calc(-100dvh - 48px), 0); opacity: 0; }
}
html.is-play-view .ocean-ambience { opacity: .45; }
button, a { -webkit-tap-highlight-color: transparent; }
button { font: inherit; cursor: pointer; }
button:focus-visible, a:focus-visible { outline: 3px solid #ffac84; outline-offset: 5px; }
.page-shell { position: relative; z-index: 1; max-width: 1192px; margin: 0 auto; padding: 0 48px; }
.site-header { height: 112px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid #27616b; gap: 24px; }
.wordmark { display: flex; align-items: center; white-space: nowrap; flex-shrink: 0; color: var(--ink); text-decoration: none; font-family: 'Space Grotesk', sans-serif; font-size: 30px; font-weight: 700; letter-spacing: -1.4px; }
.brand-dot { color: var(--lagoon); }
.brand-icon { display: flex; width: 35px; height: 31px; position: relative; margin-right: 12px; }
.brand-icon i { position: absolute; top: 3px; left: 2px; width: 16px; height: 25px; border-radius: 4px; background: var(--lagoon); transform: rotate(-13deg); }
.brand-icon i + i { left: 19px; background: #ff967d; transform: rotate(13deg); }
.header-note { font-size: 14px; color: var(--muted); }
.help-button { display: flex; align-items: center; gap: 9px; background: none; border: 0; color: var(--ink); font-size: 14px; font-weight: 600; padding: 12px 0 12px 12px; }
.help-icon { display: inline-grid; place-items: center; width: 21px; height: 21px; border: 1.5px solid #98bbc0; border-radius: 50%; font-size: 12px; }
.header-actions { display: flex; align-items: center; gap: 20px; flex-shrink: 0; }
.fullscreen-button { display: flex; align-items: center; justify-content: center; gap: 9px; min-width: 44px; min-height: 44px; padding: 10px 13px; border: 1px solid #316974; border-radius: 10px; color: var(--lagoon); background: #114f5c; font-size: 14px; font-weight: 600; }
.fullscreen-button:hover, .fullscreen-button[aria-pressed="true"] { background: #155967; border-color: #69dfcd; }
.fullscreen-button:disabled { cursor: wait; }
.fullscreen-button svg { width: 19px; height: 19px; flex-shrink: 0; }
.screen-reader-only { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
.game-layout { display: grid; grid-template-columns: 1fr 1.48fr; gap: 90px; align-items: center; padding: 52px 0 44px; }
.game-info { padding: 12px 0 0; }
.edition { display: flex; align-items: center; gap: 9px; font-size: 12px; font-weight: 700; letter-spacing: 1.6px; color: var(--lagoon); }
.edition > span { font-size: 23px; line-height: 1; }
h1 { margin: 24px 0 20px; font-family: 'Space Grotesk', sans-serif; font-size: clamp(48px, 5.2vw, 68px); line-height: 1.02; font-weight: 600; letter-spacing: -3.6px; }
h1 > span { color: var(--coral); }
.intro { line-height: 1.7; color: #bdd7d9; margin: 0 0 29px; }
.duration-controls { border: 0; padding: 0; margin: 0 0 18px; min-width: 0; }
.duration-controls legend { padding: 0; margin-bottom: 9px; font-size: 12px; font-weight: 700; letter-spacing: 1.4px; color: #a7c9cc; }
.duration-options { display: flex; gap: 8px; }
.duration-options label { position: relative; flex: 1; cursor: pointer; }
.duration-options input { position: absolute; opacity: 0; width: 1px; height: 1px; }
.duration-options span { display: block; text-align: center; padding: 11px 12px; background: #0e4957; color: #d1e9e7; border: 1px solid #316974; border-radius: 10px; font-size: 14px; font-weight: 600; }
.duration-options input:checked + span { color: var(--lagoon); border-color: var(--lagoon); background: #155967; box-shadow: inset 0 0 0 1px var(--lagoon); }
.duration-options input:focus-visible + span { outline: 3px solid #ffac84; outline-offset: 3px; }
#duration-note { font-size: 12px; color: #bdd7d9; margin: 8px 0 0; }
#time-stat.is-urgent { border-color: #ef9d8c; background: #693c3d; }
#time-stat.is-urgent strong, #time-stat.is-urgent .stat-label { color: #ffd3bd; }
.stats { display: flex; gap: 12px; margin-bottom: 18px; }
.stat { background: #0d4956; border: 1px solid #286672; border-radius: 14px; padding: 15px 20px 13px; flex: 1; }
.stat-label { display: block; color: #a7c9cc; font-size: 12px; letter-spacing: 1.4px; font-weight: 700; margin-bottom: 4px; }
.stat strong { font-family: 'Space Grotesk', sans-serif; font-size: 33px; line-height: 1.25; font-weight: 500; font-variant-numeric: tabular-nums; }
.new-game { width: 100%; display: flex; align-items: center; justify-content: center; gap: 11px; padding: 16px 20px; color: #123e47; background: var(--coral); border: 1px solid var(--coral); border-radius: 12px; font-weight: 600; transition: background .15s, transform .15s; }
.new-game:hover { background: #ffbe9c; border-color: #ffbe9c; }
.new-game:active { transform: translateY(2px); }
.new-game svg { width: 20px; height: 20px; }
.restart-note { font-size: 12px; color: #bdd7d9; text-align: center; margin: 11px 0 16px; }
.history-button { display: flex; align-items: center; justify-content: center; gap: 10px; width: 100%; min-height: 44px; padding: 12px 16px; margin-bottom: 28px; background: transparent; border: 1px solid #337280; border-radius: 12px; color: var(--ink); font-size: 14px; font-weight: 500; }
.history-button:hover { background: #155967; border-color: var(--lagoon); }
.history-button svg { width: 19px; height: 19px; }
.history-button > span { margin-left: auto; color: var(--lagoon); }
.set-label { border-top: 1px solid #27616b; padding-top: 22px; display: flex; align-items: center; gap: 13px; font-size: 14px; line-height: 1.65; }
.set-label b { font-size: 12px; font-weight: 400; color: #bdd7d9; }
.mini-shapes { font-size: 23px; white-space: nowrap; color: var(--lagoon); letter-spacing: -3px; }
.play-area { min-width: 0; }
.play-toolbar { display: none; }
.board-topline { display: flex; align-items: center; justify-content: space-between; margin: 0 4px 15px; color: #b1d6d4; font-size: 12px; font-weight: 700; letter-spacing: 1.5px; }
.board-size { letter-spacing: 1px; border: 1px solid #326b78; border-radius: 6px; padding: 4px 9px; background: #125464; }
.board-wrap { border-radius: 24px; padding: 17px; background: #15515b; border: 1px solid #367981; box-shadow: 0 6px 0 #0b303f, 0 20px 44px -24px #001c2699; }
.board { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 5px; }
.tile { position: relative; display: block; width: 100%; aspect-ratio: 1122 / 1402; padding: 0; border: 0; border-radius: 13px; background: transparent; perspective: 800px; }
.tile-inner { width: 100%; height: 100%; position: relative; display: block; transform-style: preserve-3d; transition: transform .38s cubic-bezier(.2,.7,.2,1); }
.tile.is-revealed .tile-inner { transform: rotateY(180deg); }
.tile-back, .tile-front { position: absolute; inset: 0; display: flex; align-items: center; justify-content: center; border-radius: 13px; backface-visibility: hidden; -webkit-backface-visibility: hidden; overflow: hidden; }
.tile-back { background-color: #148a98; background-image: url('assets/maldives-reef-user.png'); background-size: var(--reef-size, 400% 400%); background-position: var(--reef-x) var(--reef-y); background-repeat: no-repeat; box-shadow: inset 0 0 0 1px #e5fff318, 0 2px 0 #033947; transition: filter .15s; }
.tile:hover:not(.is-revealed) .tile-back { filter: brightness(1.14); }
.tile-back, .tile-front { border-radius: 6px; }
.tile-front { transform: rotateY(180deg); background: var(--tile-bg, white); border: 1px solid #f2fcf455; box-shadow: 0 4px 0 #034959; }
.tile-fallback { padding: 8px; color: #074653; text-align: center; font-size: clamp(11px, 2vw, 20px); font-weight: 600; }
.tile-front img { display: block; width: 100%; height: 100%; object-fit: contain; }
.match-check { position: absolute; bottom: 5px; right: 5px; background: #fff; color: #074653; width: 19px; height: 19px; border-radius: 50%; display: none; place-items: center; box-shadow: 0 1px 3px #0001; }
.match-check svg { width: 11px; height: 11px; }
.is-matched .match-check { display: grid; }
.is-matched { cursor: default; }
.is-matched .tile-front { box-shadow: 0 2px 0 #034959; }
.board-bottomline { display: flex; align-items: center; justify-content: space-between; gap: 12px; margin: 27px 4px 0; }
.pair-count { display: flex; align-items: baseline; gap: 7px; }
.pair-count strong { color: var(--lagoon); font-size: 22px; font-family: 'Space Grotesk', sans-serif; }
.pair-count > span { color: #bad2d2; font-size: 14px; }
.progress { display: flex; gap: 6px; }
.progress i { width: 14px; height: 6px; border-radius: 6px; background: #2a6170; transition: background .2s; }
.progress i.filled { background: var(--lagoon); }
.game-message { min-height: 23px; text-align: center; color: #bdd7d9; font-size: 13px; margin: 23px 0 0; }
footer { display: flex; justify-content: space-between; gap: 20px; border-top: 1px solid #27616b; padding: 24px 0 30px; font-size: 12px; color: #bdd7d9; }
footer > span:last-child { display: flex; align-items: center; gap: 9px; }
.footer-links { display: flex; align-items: center; flex-wrap: wrap; justify-content: center; gap: 22px; }
.footer-links a { color: #bdd7d9; text-decoration: none; text-underline-offset: 4px; }
.footer-links a:hover { color: var(--coral); text-decoration: underline; }
.footer-star { color: var(--lagoon); font-size: 19px; line-height: 1; }
dialog { color: var(--ink); background: #0d4652; border: 1px solid #337280; border-radius: 24px; padding: 42px; width: min(480px, calc(100% - 32px)); max-height: calc(100dvh - 32px); box-shadow: 0 30px 90px #00111c80; }
dialog::backdrop { background: #001e29bb; backdrop-filter: blur(5px); }
.dialog-close { position: absolute; top: 11px; right: 12px; width: 38px; height: 38px; border-radius: 50%; background: transparent; border: 0; font-size: 27px; color: #b8d9d9; }
.dialog-close:hover { background: #185b66; }
.dialog-eyebrow { display: block; font-size: 11px; letter-spacing: 1.2px; color: var(--lagoon); font-weight: 700; }
h2 { font-family: 'Space Grotesk', sans-serif; font-size: 34px; line-height: 1.1; letter-spacing: -1.5px; font-weight: 600; margin: 16px 0 22px; }
.rules-list { padding-left: 23px; margin: 0 0 28px; }
.rules-list li { padding-left: 6px; margin: 18px 0; }
.rules-list li::marker { color: var(--lagoon); font-weight: 700; }
.rules-list b { display: block; font-size: 16px; margin-bottom: 5px; }
.rules-list span, .win-copy { font-size: 14px; line-height: 1.7; color: #b4cecf; }
#win-dialog, #timeout-dialog { text-align: center; }
.timeout-symbol { background: #ffb193 !important; color: #78452c; }
.timeout-symbol svg { width: 54px; height: 54px; }
.win-symbol { display: grid; place-items: center; width: 86px; height: 86px; background: var(--coral); color: #125460; border-radius: 50%; font-size: 70px; margin: 0 auto 24px; }
.win-stats { display: flex; justify-content: center; gap: 60px; padding: 13px 0 25px; }
.win-stats strong { display: block; font-family: 'Space Grotesk', sans-serif; font-size: 31px; }
.win-stats span { font-size: 13px; color: var(--muted); }
.result-save-note { margin: -5px 0 20px; color: var(--muted); font-size: 12px; line-height: 1.6; }
#history-dialog { width: min(650px, calc(100% - 32px)); }
#history-dialog [hidden] { display: none; }
#history-dialog h2 { margin-bottom: 12px; }
.history-description, .history-storage-note, .history-running { font-size: 13px; line-height: 1.65; color: var(--muted); }
.history-storage-note:empty { display: none; }
.history-storage-note, .history-running { padding: 10px 14px; background: #173e48; border: 1px solid #50727a; border-radius: 9px; color: #ffcea8; }
.history-summary { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin: 24px 0; }
.history-summary > div { background: #083b47; border: 1px solid #286672; padding: 15px 10px; border-radius: 12px; text-align: center; }
.history-summary strong { display: block; color: var(--lagoon); font: 500 28px 'Space Grotesk', sans-serif; }
.history-summary span { display: block; margin-top: 4px; font-size: 11px; color: var(--muted); }
.history-empty { text-align: center; padding: 28px 10px 32px; border-block: 1px solid #337280; margin-top: 24px; }
.history-empty > span { color: var(--lagoon); font-size: 40px; }
.history-empty h3 { margin: 8px 0; font: 500 22px 'Space Grotesk', sans-serif; }
.history-empty p { font-size: 13px; color: var(--muted); margin-bottom: 0; }
.history-list { padding: 0; margin: 0; list-style: none; }
.history-round { padding: 17px 0; border-bottom: 1px solid #337280; }
.history-round-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; margin-bottom: 10px; }
.history-result { color: var(--lagoon); font-size: 14px; font-weight: 700; }
.history-result.is-timeout { color: var(--coral); }
.history-round time { font-size: 11px; line-height: 1.5; color: var(--muted); text-align: right; }
.history-round-details { display: flex; flex-wrap: wrap; gap: 5px 16px; color: var(--muted); font-size: 12px; line-height: 1.6; font-variant-numeric: tabular-nums; }
.history-round-details span:first-child { color: var(--ink); }
.history-actions { display: flex; align-items: center; gap: 20px; margin-top: 20px; }
.history-actions p { color: var(--muted); font-size: 11px; line-height: 1.6; margin: 0; }
.history-clear, .history-cancel { border: 1px solid #588089; background: transparent; color: var(--coral); padding: 10px 13px; min-height: 44px; border-radius: 9px; font-size: 12px; white-space: nowrap; }
.history-clear:hover { background: #563e3e; border-color: var(--coral); }
.history-cancel { color: var(--ink); }
.history-cancel:hover { background: #155967; }
.history-confirm { margin-top: 20px; padding: 15px; border: 1px solid #bb8a72; border-radius: 12px; }
.history-confirm p { font-size: 13px; line-height: 1.6; margin-top: 0; }
.history-confirm > div { display: flex; flex-wrap: wrap; gap: 10px; }
.noscript { position: fixed; bottom: 0; background: #0d4652; padding: 20px; width: 100%; text-align: center; }
@media (min-width: 1500px) { .game-layout { padding-top: 78px; padding-bottom: 66px; } .site-header { height: 128px; } }
@media (max-width: 1000px) { .page-shell { padding: 0 32px; } .game-layout { gap: 45px; } .board { gap: 5px; } .board-wrap { padding: 13px; } h1 { font-size: 54px; } .stat { padding: 14px; } .set-label { gap: 9px; } .mini-shapes { font-size: 19px; } }
@media (max-width: 760px) { .page-shell { max-width: 540px; padding: 0 22px; } .site-header { height: 86px; } .wordmark { font-size: 27px; } .header-note { display: none; } .help-button { font-size: 13px; } .game-layout { grid-template-columns: 1fr; gap: 29px; padding: 29px 0 31px; } .game-info { display: grid; grid-template-columns: 1fr 1fr; align-items: end; gap: 0 20px; padding: 0; } .edition { grid-column: 1 / -1; font-size: 10px; letter-spacing: 1.3px; } .edition > span { font-size: 18px; } h1 { font-size: 43px; letter-spacing: -2.3px; margin: 17px 0 14px; } .intro { grid-column: 1; font-size: 14px; line-height: 1.6; margin: 0; } .stats { grid-row: 2; grid-column: 2; align-self: center; gap: 9px; margin: 10px 0 0; } .stat { padding: 12px 10px; border-radius: 10px; } .stat-label { font-size: 10px; letter-spacing: 1px; } .stat strong { font-size: 24px; } .game-info .new-game { grid-column: 2; grid-row: 3; padding: 13px 9px; font-size: 13px; align-self: center; border-radius: 9px; gap: 8px; } .game-info .new-game svg { width: 17px; height: 17px; } .restart-note, .set-label { display: none; } .board-topline { font-size: 10px; margin-bottom: 12px; } .board-wrap { border-radius: 20px; padding: 14px; } .board { gap: 4px; } .tile, .tile-front, .tile-back { border-radius: 5px; } .board-bottomline { margin-top: 24px; } .game-message { font-size: 12px; margin-top: 18px; } footer { font-size: 11px; padding: 20px 0; } footer > span:first-child { display: none; } footer > span:last-child { margin: auto; } }
@media (max-width: 370px) { .page-shell { padding: 0 14px; } .game-info { gap: 0 10px; } h1 { font-size: 39px; } .intro { font-size: 13px; } .board { gap: 4px; } .board-wrap { padding: 11px; } .stat { padding: 10px 8px; } .stat strong { font-size: 21px; } .progress { gap: 4px; } .progress i { width: 11px; } dialog { padding: 34px 24px; } }
@media (max-width: 1000px) { .header-note { display: none; } }
@media (max-width: 760px) {
  .history-button { grid-column: 1 / -1; grid-row: 5; margin: 14px 0 0; }
  .duration-controls { grid-column: 1 / -1; grid-row: 4; margin: 20px 0 0; }
  .duration-controls legend { font-size: 10px; }
  .duration-options span { padding: 10px 12px; }
  .site-header { gap: 12px; }
  .header-actions { gap: 10px; }
  #fullscreen-label { display: none; }
  .fullscreen-button { padding: 10px; }
}
@media (max-width: 480px) { .help-label { display: none; } .help-button { justify-content: center; width: 36px; min-height: 44px; padding: 8px; } }
@media (max-width: 480px) { #history-dialog { padding: 36px 20px 24px; } .history-summary { gap: 6px; } .history-actions { align-items: flex-start; flex-direction: column; gap: 12px; } }
@media (max-width: 760px) { .footer-links { margin-inline: auto; } }
/* Focused play is independent of browser fullscreen. Only Back restores the menu. */
html.is-play-view { background: var(--page); --focus-board-width: calc((100dvh - 132px - env(safe-area-inset-top) - env(safe-area-inset-bottom)) * 1122 / 1402); }
html.is-play-view .page-shell { max-width: none; min-height: 100dvh; display: grid; place-items: center; padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left)); }
html.is-play-view .site-header,
html.is-play-view .game-info,
html.is-play-view footer,
html.is-play-view .board-topline,
html.is-play-view .board-bottomline { display: none; }
html.is-play-view .game-layout { display: block; width: 100%; margin: 0; padding: 0; }
html.is-play-view .play-area { display: flex; flex-direction: column; align-items: center; gap: 14px; width: 100%; }
html.is-play-view .board-wrap { width: min(100%, max(128px, var(--focus-board-width))); padding: 10px; border-radius: 19px; }
html.is-play-view .play-toolbar { display: flex; align-items: center; justify-content: space-between; gap: 16px; width: min(100%, max(340px, var(--focus-board-width))); min-height: 66px; padding: 9px 15px; border: 1px solid #337280; border-radius: 14px; background: #0d4652; }
.back-button { display: inline-flex; align-items: center; gap: 9px; min-height: 44px; padding: 9px 6px; border: 0; background: none; color: var(--ink); font-weight: 600; font-size: 16px; border-radius: 7px; }
.back-button:hover { color: var(--coral); background: #185b66; }
.back-button:disabled { cursor: wait; opacity: .65; }
.back-button svg { width: 20px; height: 20px; }
.play-stats { display: flex; align-items: center; gap: clamp(16px, 4vw, 44px); }
.play-stat { text-align: center; font-variant-numeric: tabular-nums; }
.play-stat > span { display: block; font-size: 11px; font-weight: 600; letter-spacing: .9px; color: #bdd7d9; }
.play-stat strong { display: block; margin-top: 3px; font-family: 'Space Grotesk', sans-serif; font-size: 23px; font-weight: 500; line-height: 1.15; }
.play-total { font-size: 16px; color: #bdd7d9; }
.play-stat.is-urgent > span, .play-stat.is-urgent strong { color: #ffad87; }
html.is-play-view .game-message { position: absolute; width: 1px; height: 1px; min-height: 0; padding: 0; margin: -1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; border: 0; }
@media (orientation: landscape) {
  html.is-play-view .page-shell { display: block; height: 100dvh; min-height: 0; padding: max(8px, env(safe-area-inset-top)) max(8px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(8px, env(safe-area-inset-left)); }
  html.is-play-view .game-layout { height: 100%; }
  html.is-play-view .play-area { height: 100%; gap: 8px; }
  html.is-play-view .play-toolbar { width: 100%; flex: 0 0 auto; min-height: 52px; padding: 3px 12px; border-radius: 10px; }
  html.is-play-view .board-wrap { width: 100%; flex: 1 1 0; min-height: 0; padding: 6px; border-radius: 12px; box-shadow: none; }
  html.is-play-view .board { --reef-fit: cover; height: 100%; grid-template-rows: repeat(4, minmax(0, 1fr)); gap: 4px; }
  html.is-play-view .tile { height: 100%; min-height: 0; aspect-ratio: auto; }
  html.is-play-view .play-stat > span { font-size: 10px; }
  html.is-play-view .play-stat strong { font-size: 21px; margin-top: 1px; }
}
@media (max-width: 380px) {
  html.is-play-view .play-toolbar { gap: 8px; padding: 8px 10px; }
  .play-stats { gap: 12px; }
  .play-stat > span { font-size: 10px; letter-spacing: .5px; }
  .play-stat strong { font-size: 21px; }
  .back-button { gap: 6px; font-size: 14px; }
}
@media (prefers-reduced-motion: reduce) {
  .ocean-ambience { display: none; }
  *, *::before, *::after { transition: none !important; animation: none !important; }
}
