:root { --deep: #0B3D5C; --shallow: #1E7FA8; --sand: #E8D5A3; --mud: #7A5C3E; --foam: #F2F2F2; --machine: #FF6B35;
  --font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif, "Noto Color Emoji"; }
* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
html, body { margin: 0; height: 100%; overflow: hidden; background: #0b2233; font-family: var(--font); color: var(--foam); user-select: none; -webkit-user-select: none; }
canvas#c { position: fixed; inset: 0; width: 100%; height: 100%; touch-action: none; display: block; }
button { font-family: var(--font); cursor: pointer; }

#hud { position: fixed; top: 0; left: 0; right: 0; padding: calc(env(safe-area-inset-top) + 8px) 12px 6px; pointer-events: none;
  background: linear-gradient(rgba(11,61,92,.85), rgba(11,61,92,0)); }
#hud .row1 { display: flex; justify-content: space-between; align-items: baseline; gap: 8px; max-width: 560px; margin: 0 auto; }
#stage { font-weight: 800; font-size: 18px; letter-spacing: .02em; text-shadow: 0 1px 4px rgba(0,0,0,.4); }
#money { font-weight: 800; font-size: 22px; color: #ffd98a; text-shadow: 0 1px 4px rgba(0,0,0,.45); font-variant-numeric: tabular-nums; }
.gauge { position: relative; height: 20px; border-radius: 10px; background: rgba(232,213,163,.35); overflow: hidden; max-width: 560px; margin: 6px auto 0; border: 1px solid rgba(242,242,242,.35); }
#gaugeFill { position: absolute; left: 0; top: 0; bottom: 0; width: 100%; background: linear-gradient(90deg, var(--shallow), var(--deep)); transition: width .25s linear; }
#gaugeText { position: absolute; inset: 0; font-size: 12px; font-weight: 700; display: flex; align-items: center; justify-content: center; text-shadow: 0 1px 3px rgba(0,0,0,.6); font-variant-numeric: tabular-nums; }
#hud .row2 { display: flex; justify-content: space-between; font-size: 13px; max-width: 560px; margin: 4px auto 0; min-height: 18px; text-shadow: 0 1px 3px rgba(0,0,0,.6); }
#pressure { color: #ffcf9e; font-weight: 700; }
#pressure:not(:empty)::before { content: '⚠️ '; }
#mark { position: fixed; left: 12px; bottom: calc(env(safe-area-inset-bottom) + 76px); opacity: .85; transition: opacity .8s; pointer-events: auto; }
#mark.gone { opacity: 0; pointer-events: none; }

#bar { position: fixed; left: 0; right: 0; bottom: 0; display: flex; gap: 8px; justify-content: center; padding: 8px 12px calc(env(safe-area-inset-bottom) + 10px);
  background: linear-gradient(rgba(11,34,51,0), rgba(11,34,51,.8)); }
#bar button { border: 0; border-radius: 14px; min-height: 52px; color: #fff; font-weight: 800; font-size: 16px; box-shadow: 0 3px 0 rgba(0,0,0,.25); position: relative; }
#bar .big { flex: 1; max-width: 200px; background: var(--machine); }
#bar #museumBtn { background: #2f6f9f; }
#bar .sq { width: 52px; background: rgba(242,242,242,.2); font-size: 20px; }
#bar small { font-weight: 600; opacity: .85; margin-left: 4px; }
#shopDot { position: absolute; top: 6px; right: 10px; width: 12px; height: 12px; border-radius: 50%; background: #ffe066; box-shadow: 0 0 0 2px #fff; animation: pulse 1s infinite alternate; }
@keyframes pulse { from { transform: scale(.8); } to { transform: scale(1.15); } }

.hint { position: fixed; left: 50%; bottom: 120px; transform: translateX(-50%); width: min(320px, 84vw); text-align: center; pointer-events: none; transition: opacity .6s; }
.hint p { margin: 0; padding: 10px 14px; border-radius: 14px; background: rgba(11,61,92,.82); font-weight: 700; font-size: 15px; line-height: 1.3; }
.hint .finger { width: 34px; height: 34px; margin: 0 auto 8px; border-radius: 50%; background: rgba(242,242,242,.9); box-shadow: 0 0 0 6px rgba(242,242,242,.25); animation: swipe 1.8s ease-in-out infinite; }
@keyframes swipe { 0% { transform: translateY(-30px); opacity: 0; } 15% { opacity: 1; } 55% { transform: translateY(30px); } 70% { transform: translateY(30px); } 82% { transform: translateY(-50px); opacity: 1; } 100% { transform: translateY(-50px); opacity: 0; } }
.hint.gone { opacity: 0; }
body.touch .mouse-only, body:not(.touch) .touch-only { display: none; }

#flick { position: fixed; left: 50%; top: 34%; transform: translateX(-50%); font-weight: 800; font-size: 20px; pointer-events: none; text-shadow: 0 2px 6px rgba(0,0,0,.5); opacity: 0; white-space: nowrap; }
#flick.show { animation: floatUp 1.1s ease-out; }
@keyframes floatUp { 0% { opacity: 0; transform: translate(-50%, 10px) scale(.9); } 15% { opacity: 1; transform: translate(-50%, 0) scale(1.05); } 100% { opacity: 0; transform: translate(-50%, -40px); } }

#toasts { position: fixed; top: calc(env(safe-area-inset-top) + 92px); left: 50%; transform: translateX(-50%); width: min(360px, 92vw); display: flex; flex-direction: column; gap: 6px; pointer-events: none; z-index: 5; }
.toast { padding: 9px 12px; border-radius: 12px; background: rgba(11,61,92,.9); font-size: 14px; font-weight: 600; animation: toastIn .3s ease-out; box-shadow: 0 4px 12px rgba(0,0,0,.25); }
@keyframes toastIn { from { opacity: 0; transform: translateY(-8px); } }

#labels { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
#labels .lab { position: absolute; transform: translate(-50%, -100%); pointer-events: auto; border: 0; border-radius: 22px; min-width: 44px; min-height: 44px; padding: 6px 12px; font-weight: 800; font-size: 15px; color: #3a2400;
  background: #ffe066; box-shadow: 0 3px 0 #b8901a, 0 0 18px rgba(255,224,102,.7); animation: bob 1.1s ease-in-out infinite alternate; white-space: nowrap; }
#labels .lab.find { width: 48px; height: 48px; padding: 0; border-radius: 50%; font-size: 22px; }
#labels .lab.unclog { background: #ff8a5c; color: #fff; box-shadow: 0 3px 0 #a33d14, 0 0 18px rgba(255,107,53,.8); }
#labels .lab.chip { background: rgba(242,242,242,.0); box-shadow: none; animation: none; min-width: 44px; min-height: 44px; padding: 0; }
#labels .lab.slot { width: 52px; height: 52px; border-radius: 50%; padding: 0; background: rgba(255,107,53,.35); border: 3px solid #ff6b35; box-shadow: 0 0 20px rgba(255,107,53,.9); color: #fff; font-size: 22px; transform: translate(-50%, -50%); animation: pulse .7s infinite alternate; }
#labels .lab:focus-visible, #sheet button:focus-visible { outline: 3px solid #fff; outline-offset: 2px; }
@keyframes bob { from { margin-top: 0; } to { margin-top: -6px; } }

#placeBar { position: fixed; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 80px); transform: translateX(-50%); display: flex; align-items: center; gap: 10px; padding: 8px 8px 8px 14px; border-radius: 16px; background: rgba(11,61,92,.92); font-weight: 700; white-space: nowrap; }
#placeBar button { border: 0; border-radius: 12px; min-height: 44px; padding: 0 14px; background: rgba(242,242,242,.2); color: #fff; font-weight: 700; }

#sheet { position: fixed; inset: 0; display: flex; align-items: flex-end; justify-content: center; background: rgba(5,20,30,.45); z-index: 10; }
#sheet[hidden], #findCard[hidden], #placeBar[hidden] { display: none; }
.sheetIn { position: relative; width: min(560px, 100%); max-height: 82vh; overflow-y: auto; background: #f6efe0; color: #22303a; border-radius: 22px 22px 0 0; padding: 18px 16px calc(env(safe-area-inset-bottom) + 18px); box-shadow: 0 -8px 30px rgba(0,0,0,.3); }
@media (min-width: 700px) and (min-height: 600px) { #sheet { align-items: center; } .sheetIn { border-radius: 22px; } }
.sheetIn h2 { margin: 0 44px 4px 0; font-size: 22px; }
.sheetIn .sub { margin: 0 0 12px; color: #5b6770; font-size: 14px; }
.close { position: absolute; top: 10px; right: 10px; width: 44px; height: 44px; border: 0; border-radius: 50%; background: rgba(0,0,0,.08); font-size: 18px; color: #22303a; }
.item { display: grid; grid-template-columns: 44px 1fr auto; gap: 10px; align-items: center; padding: 10px 0; border-top: 1px solid rgba(0,0,0,.08); }
.item .ico { font-size: 30px; text-align: center; }
.item b { font-size: 16px; }
.item .meta { font-size: 13px; color: #5b6770; line-height: 1.3; }
.item .catch { font-size: 13px; color: #a0461d; line-height: 1.3; }
.item button, .btn { border: 0; border-radius: 12px; min-height: 44px; min-width: 84px; padding: 0 14px; background: var(--machine); color: #fff; font-weight: 800; font-size: 15px; box-shadow: 0 2px 0 #b84418; }
.item button:disabled, .btn:disabled { background: #c9c2b4; box-shadow: none; color: #fff; cursor: default; }
.item.locked { opacity: .55; }
.btn.blue { background: #2f6f9f; box-shadow: 0 2px 0 #1d4a6c; }
.btn.wide { width: 100%; min-height: 52px; font-size: 17px; margin-top: 10px; }
.shelf { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.shelf .f { background: #fff; border-radius: 12px; padding: 8px 6px; text-align: center; font-size: 12px; line-height: 1.25; min-height: 96px; border: 0; color: #22303a; }
.shelf .f .i { font-size: 32px; display: block; margin-bottom: 4px; }
.shelf .f.unknown { background: rgba(0,0,0,.06); color: #9a948a; }
.shelf h3 { grid-column: 1 / -1; margin: 10px 0 0; font-size: 15px; color: #2f6f9f; }
.curator { margin: 10px 0 0; padding: 10px 12px; border-radius: 12px; background: #fff; font-size: 14px; line-height: 1.4; }
.curator::before { content: '🧐 The curator: '; font-weight: 700; }

#findCard { position: fixed; left: 50%; top: calc(env(safe-area-inset-top) + 96px); transform: translateX(-50%); width: min(360px, 92vw); z-index: 8; background: #f6efe0; color: #22303a; border-radius: 18px; padding: 12px 14px; box-shadow: 0 10px 30px rgba(0,0,0,.35); animation: cardIn .35s cubic-bezier(.2,1.4,.4,1); pointer-events: auto; }
#findCard .top { display: flex; gap: 10px; align-items: center; }
#findCard .i { font-size: 38px; }
#findCard b { font-size: 17px; display: block; }
#findCard .val { color: #1f8a4c; font-weight: 800; }
#findCard p { margin: 8px 0 0; font-size: 14px; line-height: 1.4; }
@keyframes cardIn { from { opacity: 0; transform: translate(-50%, -16px) scale(.92); } }

.vote { margin-top: 14px; padding-top: 12px; border-top: 1px solid rgba(0,0,0,.1); }
.vote p { margin: 0 0 8px; font-weight: 700; font-size: 14px; }
.vote .opts { display: flex; gap: 6px; overflow-x: auto; padding-bottom: 4px; }
.vote .opts button { flex: none; border: 0; border-radius: 20px; min-height: 40px; padding: 0 12px; background: #e3dccb; color: #22303a; font-weight: 600; font-size: 13px; }
.door { display: block; width: 100%; margin-top: 10px; border: 2px dashed #2f6f9f; border-radius: 12px; min-height: 44px; background: transparent; color: #2f6f9f; font-weight: 700; font-size: 14px; }
[data-wefav-row] { margin-top: 12px; }
[data-wefav-row] a { color: #2f6f9f; font-size: 13px; }

@media (min-width: 900px) {
  #hud { padding-left: 24px; padding-right: 24px; }
  #bar { justify-content: center; }
}

/* round 2: the title card with today's tide, personal and rare finds, the share row */
#title { position: fixed; inset: 0; z-index: 20; display: flex; align-items: center; justify-content: center; background: rgba(6,38,58,.55); backdrop-filter: blur(2px); padding: 16px; }
#title[hidden] { display: none; }
#title .tIn { width: min(380px, 100%); background: #f6efe0; color: #22303a; border-radius: 20px; padding: 18px 18px 14px; box-shadow: 0 12px 40px rgba(0,0,0,.4); }
#title h1 { margin: 0 0 6px; font-size: 32px; color: #0b3d5c; letter-spacing: -.5px; }
#title .goal { margin: 0 0 12px; font-size: 15px; line-height: 1.4; }
#title .tide { display: flex; gap: 12px; align-items: flex-start; background: #0b3d5c; color: #f2f2f2; border-radius: 14px; padding: 12px; }
#title .tide .ti { font-size: 36px; line-height: 1; }
#title .tide small { display: block; opacity: .75; font-size: 12px; }
#title .tide b { display: block; font-size: 18px; color: #ffd23f; }
#title .tide p { margin: 4px 0 0; font-size: 13px; line-height: 1.35; }
.shelf .f.mine { background: #fff4d6; box-shadow: inset 0 0 0 2px #d9a441; }
.shelf .f.sil { background: rgba(0,0,0,.05); color: #6b6358; }
.shelf .f.sil .i { filter: brightness(0) opacity(.45); }
.shelf .f.rare { background: #e3fbf5; box-shadow: inset 0 0 0 2px #2fb59a; }
.shelf .f.wide { grid-column: span 2; min-height: 0; }
#findCard.mine { background: #fff4d6; box-shadow: 0 0 0 3px #d9a441, 0 10px 30px rgba(0,0,0,.35); }
#findCard.rare { background: #e3fbf5; box-shadow: 0 0 0 3px #2fb59a, 0 10px 30px rgba(0,0,0,.35); }
.shareRow { display: flex; gap: 10px; align-items: center; margin-top: 10px; }
.shareRow img { width: 88px; height: 88px; border-radius: 10px; flex: none; cursor: zoom-in; }
.shareRow p { margin: 0 0 6px; font-size: 13px; line-height: 1.35; }
.shareRow .btn { min-height: 40px; padding: 0 16px; }
.shareRow a { font-size: 13px; color: #2f6f9f; margin-left: 8px; }
#tideChip { color: #ffd23f; font-weight: 700; white-space: nowrap; }
#labels .lab.find.mine { width: auto; border-radius: 24px; padding: 0 14px; font-size: 16px; background: #fff4d6; box-shadow: 0 0 0 3px #d9a441, 0 0 22px rgba(255,210,63,.9); }
#labels .lab.find.rare { background: #e3fbf5; box-shadow: 0 0 0 3px #2fb59a, 0 0 22px rgba(95,245,216,.9); }

/* the power spike: the first machine is a moment, later ones show the jump */
#spike { position: fixed; left: 50%; top: 40%; transform: translateX(-50%); text-align: center; pointer-events: none; opacity: 0; z-index: 4; text-shadow: 0 2px 8px rgba(0,0,0,.55); width: min(340px, 90vw); }
#spike b { display: block; font-size: 20px; }
#spike big { display: block; font-size: 30px; font-weight: 900; color: #ffd23f; }
#spike small { display: block; font-size: 14px; font-weight: 600; opacity: .9; }
#spike.first big { font-size: 52px; }
#spike.show { animation: spikeUp 2s ease-out; }
#spike.first.show { animation: spikeUp 3.6s ease-out; }
@keyframes spikeUp { 0% { opacity: 0; transform: translate(-50%, 16px) scale(.7); } 10% { opacity: 1; transform: translate(-50%, 0) scale(1.12); } 20% { transform: translate(-50%, 0) scale(1); } 80% { opacity: 1; } 100% { opacity: 0; transform: translate(-50%, -30px); } }
.rank { color: #ffd23f; font-weight: 700; margin: 4px 0 8px; }
#board:empty { display: none; }
#board { margin: 10px 0; }

/* round 4: seabed zones along the front, and the title card's peek at today's fastest */
#labels .lab.zone { transform: translate(-50%, 0); min-width: 0; max-width: 31vw; min-height: 44px; padding: 5px 9px; border-radius: 12px; font-size: 12px; line-height: 1.2; background: rgba(11,61,92,.82); color: #f2f2f2; box-shadow: 0 2px 0 rgba(0,0,0,.35); animation: none; display: flex; flex-direction: column; align-items: center; white-space: nowrap; }
#labels .lab.zone small { font-weight: 600; opacity: .8; font-size: 11px; }
#labels .lab.zone.on { background: #ffd23f; color: #3a2400; box-shadow: 0 2px 0 #a37c10, 0 0 16px rgba(255,210,63,.7); }
#title .peek { margin: 10px 2px 0; font-size: 14px; min-height: 1em; }
#title .peek:empty { display: none; }

/* round 5: the zone worth aiming at next pulses when the aimed one has nothing left to find */
#labels .lab.zone.nudge { animation: zoneNudge 1.1s ease-in-out infinite; box-shadow: 0 2px 0 rgba(0,0,0,.35), 0 0 0 2px #ffd23f; }
@keyframes zoneNudge { 0%, 100% { transform: translate(-50%, 0) scale(1); } 50% { transform: translate(-50%, -3px) scale(1.07); } }

/* the How to play panel: real HTML in the page, closed by default */
.how { position: fixed; inset: 0; z-index: 40; display: flex; align-items: flex-end; justify-content: center; background: rgba(5,20,30,.55); }
.how[hidden] { display: none; }
.howIn { position: relative; width: min(560px, 100%); max-height: 86vh; overflow-y: auto; -webkit-overflow-scrolling: touch; background: #f6efe0; color: #22303a; border-radius: 22px 22px 0 0; padding: 18px 18px calc(env(safe-area-inset-bottom) + 20px); box-shadow: 0 -8px 30px rgba(0,0,0,.3); font-size: 15px; line-height: 1.45; }
@media (min-width: 700px) and (min-height: 600px) { .how { align-items: center; } .howIn { border-radius: 22px; } }
.howIn h2 { margin: 0 48px 8px 0; font-size: 22px; color: #0b3d5c; }
.howIn h3 { margin: 14px 0 4px; font-size: 16px; color: #0b3d5c; }
.howIn p { margin: 0 0 8px; }
.howIn ul { margin: 0 0 8px; padding-left: 20px; }
.howIn li { margin-bottom: 5px; }
.howIn dt { font-weight: 800; margin-top: 8px; }
.howIn dd { margin: 2px 0 0; }
.howLink { display: block; width: 100%; min-height: 44px; margin-top: 4px; border: 0; background: none; color: #2f6f9f; font-weight: 800; font-size: 15px; text-decoration: underline; }

/* links in the How to play panel */
.how a { color: #FFD84D; }
