:root { --ink: #1b1b2f; --sun: #FFC52E; --red: #E8402A; --sat: env(safe-area-inset-top, 0px); --sab: env(safe-area-inset-bottom, 0px); --sal: env(safe-area-inset-left, 0px); --sar: env(safe-area-inset-right, 0px); }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #2f86d6; overscroll-behavior: none; }
body { position: fixed; inset: 0; font-family: "Trebuchet MS", "Segoe UI", system-ui, sans-serif; color: #fff; user-select: none; -webkit-user-select: none; -webkit-touch-callout: none; touch-action: none; }
#cv { position: absolute; left: 0; top: 0; display: block; touch-action: none; }
.sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }

#score { position: absolute; top: calc(var(--sat) + 8px); left: 0; right: 0; text-align: center; font-weight: 900; font-size: clamp(44px, 10vmin, 84px); line-height: 1; letter-spacing: .01em; color: #fff; text-shadow: 0 3px 0 rgba(27, 27, 47, .45), 0 0 18px rgba(255, 210, 80, .55); pointer-events: none; opacity: 0; transition: opacity .25s; font-variant-numeric: tabular-nums; }
html[data-mode="play"] #score { opacity: 1; }

#hud-btns { position: absolute; top: calc(var(--sat) + 8px); right: calc(var(--sar) + 10px); display: flex; gap: 8px; z-index: 5; opacity: .85; }
html[data-mode="play"] #hud-btns { opacity: .35; }
.ibtn { min-width: 46px; height: 46px; padding: 0 10px; border: 3px solid var(--ink); border-radius: 14px; background: rgba(255, 255, 255, .92); color: var(--ink); font: 900 16px "Trebuchet MS", system-ui, sans-serif; display: flex; align-items: center; justify-content: center; cursor: pointer; touch-action: manipulation; }
.ibtn:focus-visible, #btn-replay:focus-visible { outline: 4px solid var(--sun); outline-offset: 2px; }
.ibtn svg { display: block; }

#word { position: absolute; left: 0; right: 0; top: 78%; text-align: center; font-weight: 900; font-size: clamp(34px, 8.5vmin, 66px); letter-spacing: .03em; color: #fff; text-shadow: 0 3px 0 rgba(27, 27, 47, .55), 0 0 22px rgba(0, 0, 0, .25); pointer-events: none; animation: breathe 1.4s ease-in-out infinite; }
html:not([data-mode="ready"]) #word { display: none; }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.07); } }

#hint { position: absolute; left: 50%; top: 62%; width: clamp(64px, 14vmin, 110px); height: clamp(80px, 17vmin, 135px); margin-left: calc(clamp(64px, 14vmin, 110px) / -2); pointer-events: none; display: none; filter: drop-shadow(0 4px 6px rgba(0, 0, 0, .35)); }
html[data-mode="ready"][data-first="1"] #hint { display: block; }
#hint .hand { transform-origin: 52px 40px; animation: tap 1.3s ease-in-out infinite; }
#hint .ripple { transform-origin: 52px 40px; animation: rip 1.3s ease-out infinite; }
@keyframes tap { 0%, 100% { transform: translateY(0) scale(1); } 40% { transform: translateY(10px) scale(.93); } 60% { transform: translateY(10px) scale(.93); } }
@keyframes rip { 0%, 35% { opacity: 0; transform: scale(.5); } 50% { opacity: .95; transform: scale(1); } 100% { opacity: 0; transform: scale(2.4); } }

#over { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; background: radial-gradient(ellipse at center, rgba(20, 16, 40, .62), rgba(20, 16, 40, .35) 70%); z-index: 4; animation: fadein .35s ease-out; padding: calc(var(--sat) + 10px) 16px calc(var(--sab) + 10px); }
#over[hidden] { display: none; }
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }
#ovScore { font-weight: 900; font-size: clamp(76px, 20vmin, 150px); line-height: 1; color: #fff; text-shadow: 0 5px 0 rgba(27, 27, 47, .5), 0 0 30px rgba(255, 210, 80, .6); font-variant-numeric: tabular-nums; animation: pop .5s cubic-bezier(.2, 1.6, .4, 1); }
@keyframes pop { from { transform: scale(.4); opacity: 0; } to { transform: scale(1); opacity: 1; } }
#ovNew { min-height: 1.2em; font-weight: 900; font-size: clamp(20px, 5vmin, 30px); color: var(--sun); text-shadow: 0 2px 0 rgba(27, 27, 47, .6); letter-spacing: .04em; text-transform: uppercase; }
#ovBest { display: flex; align-items: center; gap: 10px; font-weight: 900; font-size: clamp(26px, 6vmin, 40px); text-shadow: 0 2px 0 rgba(27, 27, 47, .55); }
#btn-replay { width: clamp(84px, 18vmin, 112px); height: clamp(84px, 18vmin, 112px); margin-top: 8px; border-radius: 50%; border: 5px solid var(--ink); background: var(--sun); display: flex; align-items: center; justify-content: center; cursor: pointer; box-shadow: 0 6px 0 rgba(27, 27, 47, .55); animation: breathe 1.4s ease-in-out infinite; touch-action: manipulation; }
#btn-replay svg { width: 55%; height: 55%; }

@media (max-height: 460px) { #over { flex-direction: row; flex-wrap: wrap; gap: 6px 22px; } #ovScore { font-size: clamp(54px, 15vmin, 96px); } #ovNew { width: 100%; text-align: center; order: -1; min-height: 0; } #word { top: 76%; } #hint { top: 40%; } }
html[data-rm="1"] #word, html[data-rm="1"] #btn-replay, html[data-rm="1"] #hint .hand { animation: none; }
@media (prefers-reduced-motion: reduce) { #word, #btn-replay { animation: none; } #hint .hand { animation-duration: 2.4s; } }
