:root {
  color-scheme: light;
  --ink: #294d4b;
  --muted: #58726d;
  --paper: #fff9e9;
  --line: #b4bda3;
  --teal: #19675f;
  --focus-blue: #327b9a;
  --focus-halo: 0 0 0 2px var(--focus-blue), 0 0 5px 4px rgb(119 197 226 / 42%);
  --page: #d8e9dd;
  --round: ui-rounded, "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  color: var(--ink);
  font: 15px/1.5 var(--round);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
html, body { margin: 0; height: 100%; overflow: hidden; overscroll-behavior: none; }
body { background: var(--page); -webkit-tap-highlight-color: transparent; }
button, input, select, summary { font: inherit; color: inherit; }
button, summary { cursor: pointer; touch-action: manipulation; }
button { min-height: 44px; border: 0; }
button:active:not(:disabled) { transform: translateY(2px); }
h1, h2, p, figure { margin: 0; }
.app-shell {
  position: relative; isolation: isolate; display: flex; flex-direction: column;
  width: 100%; height: 100vh; height: 100dvh; margin: auto; overflow: hidden;
  padding: max(10px, env(safe-area-inset-top)) max(0px, env(safe-area-inset-right)) max(8px, env(safe-area-inset-bottom)) max(0px, env(safe-area-inset-left));
  background: linear-gradient(#76d9e2, #a7e7ee 42%, #b8eced 76%, #8edce2);
  user-select: none; -webkit-user-select: none;
}
.pool-scenery { position: absolute; inset: 0; overflow: hidden; pointer-events: none; background: #afebdb; }
.pool-painting { position: absolute; inset: 0; width: 100%; height: 100%; }
.pool-scenery img { position: absolute; display: block; height: auto; }
.palm-left { left: 0; top: 0; width: clamp(78px, 17vw, 112px); }
.palm-right { right: 0; top: 0; width: clamp(72px, 15vw, 112px); }
.sailboat { left: 62%; bottom: calc(100% - var(--horizon, 66px) - 4px); width: clamp(14px, 2.6vw, 26px); }
.swim-ring { right: 0; top: calc(var(--rim, 78px) - 2px); width: clamp(40px, 8vw, 68px); }
.game-header, .hud, .play-dock { z-index: 2; pointer-events: none; }
.game-header button, .play-dock button { pointer-events: auto; }
.game-header, .hud, .play-dock { display: flex; align-items: center; justify-content: space-between; flex: 0 0 auto; }
.game-header { padding: 3px 17px 0; }
.game-header h1 { line-height: 0; }
.game-header h1 img { display: block; width: clamp(146px, 47vw, 198px); height: auto; }
@media (max-height: 640px) { .game-header h1 img { width: 140px; } }
.menu-pill, .next-piece, .score-block {
  background: rgba(255, 249, 227, .94);
  border: 1.5px solid #ad9e7b;
  box-shadow: 0 2px 0 #99835966, inset 0 1px 0 #fffdf1;
}
.menu-pill { display: inline-flex; align-items: center; justify-content: center; gap: 8px; border-radius: 24px; min-width: 76px; padding-inline: 12px; font-size: 14px; font-weight: 750; }
.pause-icon { width: 12px; height: 14px; border-inline: 4px solid currentColor; border-radius: 2px; }
.hud { padding: 10px 17px 0; align-items: flex-start; }
.score-block { min-width: 82px; padding: 5px 13px 7px; border-radius: 10px 10px 16px 10px; }
.score-block span, .next-piece span { display: block; color: #5d6a53; font-size: 11px; font-weight: 750; }
.score-block strong {
  display: block; color: #21594f; font: 850 clamp(23px, 6.4vw, 32px)/1 ui-rounded, "Avenir Next", system-ui, sans-serif;
  letter-spacing: -.05em; font-variant-numeric: tabular-nums;
}
.next-piece { display: flex; align-items: center; gap: 6px; padding: 3px 4px 3px 13px; border-radius: 11px 24px 24px 11px; }
.next-piece div { min-width: 35px; }
.next-piece strong { display: block; font-size: 13px; line-height: 1.2; }
.next-piece img { width: 42px; height: 42px; object-fit: contain; }
.playfield { flex: 1 1 auto; min-height: 0; min-width: 0; }
#game { position: absolute; inset: 0; z-index: 1; width: 100%; height: 100%; display: block; touch-action: none; -webkit-touch-callout: none; outline: none; }
.game-toast {
  position: absolute; z-index: 3; left: 50%; bottom: 11%; transform: translateX(-50%);
  width: max-content; max-width: 83%; padding: 8px 15px; border-radius: 14px; pointer-events: none;
  color: #fffae7; background: #245751ed; text-align: center; white-space: pre-line; font-size: 13px; font-weight: 650;
}
.play-dock { padding: 0 18px 2px 12px; gap: 9px; }
.lulu-hint { display: flex; gap: 5px; align-items: center; min-width: 0; }
.lulu-hint img { width: 47px; height: 47px; object-fit: contain; filter: drop-shadow(0 2px 1px #22463855); }
.lulu-hint span {
  position: relative; padding: 7px 11px; color: #3c5d51; background: #fffbe9f2; border: 1px solid #a7ae8f;
  border-radius: 14px 14px 14px 3px; font-size: 12px; font-weight: 650; line-height: 1.4;
}
.hammer {
  position: relative; display: grid; place-content: center; flex-shrink: 0; width: 64px; height: 64px; margin-bottom: 4px;
  background: #ffe8ac; border: 2px solid #a7774d; border-radius: 22px;
  box-shadow: inset 0 3px 0 #fff7d6, inset 0 -4px 0 #efbd79, 0 3px 0 #81684e;
}
.hammer svg { margin-top: -5px; }
.hammer span {
  position: absolute; left: 50%; bottom: 0; transform: translateX(-50%);
  padding: 0 8px; color: #fff9e7; background: #78513d; border: 1px solid #fff4cf; border-radius: 8px;
  font-size: 11px; font-weight: 800; white-space: nowrap;
}
.hammer[data-ready="true"] { background: #ffcf77; border-color: #a55a39; }
.hammer[data-ready="true"] span { background: #a54832; }
.hammer[aria-pressed="true"] { background: #dff1fa; border-color: var(--focus-blue); }
.hammer:disabled { opacity: .6; }

dialog, .asset-loader-card {
  color: var(--ink); background: var(--paper); border: 2px solid #b8ae8d; border-radius: 25px; box-shadow: 0 6px 0 #45594c40;
}
dialog {
  width: min(400px, calc(100% - 28px)); max-height: calc(100vh - 32px); max-height: calc(100dvh - 32px - env(safe-area-inset-top) - env(safe-area-inset-bottom));
  padding: 21px; overflow: auto; overscroll-behavior: contain;
  margin: auto auto max(14px, env(safe-area-inset-bottom)); user-select: text; -webkit-user-select: text;
}
dialog::backdrop { background: rgba(25, 65, 63, .43); }
dialog[open] { animation: sheet-in .18s ease-out; }
@keyframes sheet-in { from { opacity: 0; translate: 0 12px; } to { opacity: 1; translate: 0 0; } }
dialog h2, .asset-loader h2 { font-size: 24px; line-height: 1.3; letter-spacing: -.04em; }
dialog p { margin-block: 8px; color: var(--muted); font-size: 14px; }
.sheet-head, .leaderboard-header, .leaderboard-profile-summary, .leaderboard-footer {
  display: flex; align-items: center; justify-content: space-between; gap: 9px;
}
.close, .leaderboard-close { flex-shrink: 0; width: 44px; background: #f3ebd5; border-radius: 50%; font: 25px/1 system-ui; }
.menu-list { margin: 9px 0 14px; }
.menu-list > a { text-decoration: none; color: inherit; }
.menu-list > a, .menu-list > button, .menu-list summary {
  display: flex; align-items: center; justify-content: space-between; width: 100%; min-height: 48px;
  padding: 8px 3px; text-align: left; border-bottom: 1px solid #dedbc3; background: transparent; font-weight: 700;
}
.menu-list span, .menu-list summary::after { color: #739086; font: 23px/1 system-ui; }
.menu-list summary { list-style: none; }
.menu-list summary::-webkit-details-marker { display: none; }
.menu-list summary::after { content: "+"; }
.menu-list details[open] summary::after { content: "−"; }
.menu-list details p { font-size: 13px; }
.menu-list details a { display: inline-block; margin-block: 3px 10px; color: var(--teal); font-size: 12px; }
.primary-button, .secondary-button {
  display: block; width: 100%; min-height: 46px; border-radius: 14px; padding: 9px 12px; margin-top: 9px;
  font-weight: 750; text-align: center;
}
.primary-button { color: #fffbed; background: var(--teal); box-shadow: 0 2px 0 #164c46; }
.secondary-button, .text-button { background: #f0e9d5; }
.text-button { padding: 5px 12px; border-radius: 12px; font-size: 13px; }
.celebration { text-align: center; }
.celebration > img { display: block; object-fit: contain; margin: 2px auto 6px; }
.tier { display: inline-block; padding: 3px 10px; color: #80583a; background: #ffebae; border-radius: 10px; font-weight: 700; }
.result-stats { padding: 9px; color: var(--muted); font-size: 12px; }
.result-stats strong { display: block; font: 800 36px/1.2 ui-rounded, system-ui; color: var(--teal); }
.leaderboard-profile-summary, .leaderboard-row { border-bottom: 1px solid #dfdcc5; padding: 7px 0; }
.leaderboard-profile-copy { flex: 1; display: grid; }
.leaderboard-profile-copy span, .leaderboard-footer span, .leaderboard-note { color: var(--muted); font-size: 12px; }
.leaderboard-avatar, .leaderboard-row img { width: 36px; height: 36px; object-fit: contain; }
.leaderboard-list { list-style: none; margin: 0; padding: 0; }
.leaderboard-row { display: grid; grid-template-columns: 24px 32px 1fr auto; gap: 8px; align-items: center; }
.leaderboard-rank { font-size: 12px; color: var(--muted); }
.leaderboard-name { overflow-wrap: anywhere; }
.leaderboard-footer { margin-top: 9px; }
.leaderboard-profile-form { display: grid; gap: 5px; margin: 10px 0; }
.leaderboard-profile-form label { font-size: 13px; font-weight: 700; }
.leaderboard-profile-form input, .leaderboard-profile-form select { min-width: 0; min-height: 44px; padding: 5px 9px; font-size: 16px; border: 1px solid var(--line); border-radius: 10px; background: #fffdf6; }
.leaderboard-avatar-picker, .leaderboard-profile-actions { display: flex; align-items: center; gap: 8px; }
.leaderboard-avatar-picker select { flex: 1; }
.leaderboard-profile-actions .primary-button { margin: 0; flex: 1; }
.asset-loader { position: absolute; inset: 0; z-index: 5; display: grid; place-items: center; background: #e6f2decc; }
.asset-loader-card { width: min(78%, 295px); padding: 19px; text-align: center; }
.asset-loader-character { width: 90px; height: 90px; object-fit: contain; }
.asset-loading-message, .asset-loading-count { font-size: 13px; margin-top: 6px; color: var(--muted); }
.asset-progress-track { height: 8px; background: #e2ddc6; margin-top: 12px; border-radius: 5px; overflow: hidden; }
.asset-progress { display: block; height: 100%; background: #559986; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip-path: inset(50%); white-space: nowrap; }
@media (max-height: 650px) {
  .hud { padding-top: 4px; }
  .hammer { width: 56px; height: 53px; border-radius: 17px; }
  .hammer svg { width: 35px; height: 35px; }
  .game-header { padding-top: 0; }
}
@media (min-width: 620px) and (orientation: portrait) {
  .app-shell { display: grid; grid-template-rows: auto minmax(0, 1fr) auto; }
  .game-header, .hud { grid-area: 1 / 1; }
  .hud { justify-self: center; align-self: center; gap: 12px; padding: 0; }
  .playfield { grid-row: 2; }
}
@media (orientation: landscape) {
  .app-shell { --rail: clamp(95px, 20vw, 190px); display: grid;
    grid-template-columns: var(--rail) minmax(0, 1fr) var(--rail); grid-template-rows: auto 1fr auto; }
  .game-header, .play-dock { display: contents; }
  .game-header h1, .menu-pill, .lulu-hint, .hammer { position: relative; z-index: 2; align-self: center; justify-self: center; }
  .game-header h1 { grid-area: 1 / 1; }
  .game-header h1 img { width: calc(var(--rail) - 12px); }
  .menu-pill { grid-area: 1 / 3; }
  .hud { grid-area: 2 / 1; flex-direction: column; align-self: start; align-items: center; gap: 10px; }
  .playfield { grid-area: 1 / 2 / 4 / 3; }
  .lulu-hint { grid-area: 3 / 1; pointer-events: none; }
  .lulu-hint img { display: none; }
  .hammer { grid-area: 3 / 3; }
}
@media (prefers-reduced-motion: reduce) { dialog[open] { animation: none; } }

/* The focused control replaces its directional raised shadow with an even halo. */
:is(button, a[href], summary, input, select):focus-visible,
.app-shell:has(#game:focus-visible) .lulu-hint span {
  outline: none;
  box-shadow: var(--focus-halo);
}
@media (forced-colors: active) {
  :is(button, a[href], summary, input, select):focus-visible,
  .app-shell:has(#game:focus-visible) .lulu-hint span {
    outline: 2px solid Highlight;
    outline-offset: 2px;
  }
}
