* { box-sizing: border-box; }
:root {
  --ink: #1A1C2C; --plum: #5D275D; --red: #B13E53; --coral: #EF7D57; --sand: #FFCD75; --lime: #A7F070;
  --green: #38B764; --teal: #257179; --navy: #29366F; --sky: #41A6F6; --cream: #FFF8E7;
  --font: "Baloo 2", "Nunito", system-ui, "Noto Sans", sans-serif;
}
html, body {
  margin: 0; height: 100%; overflow: hidden; background: #1A1C2C; color: #fff; font-family: var(--font);
  -webkit-user-select: none; user-select: none; -webkit-tap-highlight-color: transparent;
}
#viewport { position: fixed; inset: 0; }
#stage { position: absolute; left: 0; top: 0; width: 1280px; height: 720px; transform-origin: 0 0; overflow: hidden; }
#game { position: absolute; inset: 0; width: 1280px; height: 720px; touch-action: none; display: block; }
.hidden { display: none !important; }

/* ------------------------------------------------ pixel icons */
.ico { display: inline-block; width: 26px; height: 26px; background: center / contain no-repeat; image-rendering: pixelated; vertical-align: middle; flex: none; }
.ico.crab { background-image: url(assets/crab.webp); image-rendering: auto; }
.ico.shell { background-image: url(assets/shell.webp); image-rendering: auto; }
.ico.spade { background-image: url(assets/spade.webp); image-rendering: auto; }
.ico.hat { background-image: url(assets/hat_nonla.webp); image-rendering: auto; }
.ico.dig { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath fill='%23C78A45' d='M0 6h8v2H0z'/%3E%3Cpath fill='%23FFCD75' d='M1 5h6v1H1zM2 4h4v1H2z'/%3E%3Cpath fill='%235E3A1A' d='M3 6h2v1H3z'/%3E%3C/svg%3E"); }
.ico.clock { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath fill='%231A1C2C' d='M2 0h4v1H2zM1 1h1v1H1zM6 1h1v1H6zM0 2h1v4H0zM7 2h1v4H7zM1 6h1v1H1zM6 6h1v1H6zM2 7h4v1H2z'/%3E%3Cpath fill='%23F4F4F4' d='M2 1h4v1H2zM1 2h6v4H1zM2 6h4v1H2z'/%3E%3Cpath fill='%23B13E53' d='M4 2h1v2H4zM4 4h2v1H4z'/%3E%3C/svg%3E"); }
.ico.wave { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath fill='%2341A6F6' d='M0 4h2v1H0zM2 3h2v1H2zM4 4h2v1H4zM6 3h2v1H6zM0 5h8v3H0z'/%3E%3Cpath fill='%23F4F4F4' d='M2 2h2v1H2zM6 2h2v1H6z'/%3E%3C/svg%3E"); }
.ico.lens { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath fill='%231A1C2C' d='M1 0h3v1H1zM0 1h1v3H0zM4 1h1v3H4zM1 4h3v1H1zM4 4h1v1H4zM5 5h1v1H5zM6 6h1v1H6z'/%3E%3Cpath fill='%2373EFF7' d='M1 1h3v3H1z'/%3E%3Cpath fill='%23F4F4F4' d='M1 1h1v1H1z'/%3E%3Cpath fill='%23C78A45' d='M5 6h1v1H5zM6 7h2v1H6zM7 6h1v1H7z'/%3E%3C/svg%3E"); }
.ico.heart { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath fill='%231A1C2C' d='M1 0h2v1H1zM5 0h2v1H5zM0 1h1v3H0zM3 1h2v1H3zM7 1h1v3H7zM1 4h1v1H1zM6 4h1v1H6zM2 5h1v1H2zM5 5h1v1H5zM3 6h2v1H3z'/%3E%3Cpath fill='%23FF5A7A' d='M1 1h2v1H1zM5 1h2v1H5zM1 2h6v2H1zM2 4h4v1H2zM3 5h2v1H3z'/%3E%3Cpath fill='%23F4F4F4' d='M1 1h1v1H1z'/%3E%3C/svg%3E"); }
.ico.heart.off { filter: grayscale(1) brightness(.5); opacity: .6; }
.ico.star { background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8' shape-rendering='crispEdges'%3E%3Cpath fill='%23FFCD75' d='M3 0h2v2H3zM0 2h8v2H0zM1 4h6v1H1zM1 5h2v3H1zM5 5h2v3H5zM3 5h2v1H3z'/%3E%3C/svg%3E"); }

/* ------------------------------------------------ pixel buttons & chips */
.pbtn {
  font: inherit; font-weight: 800; font-size: 21px; color: #fff; cursor: pointer; line-height: 1.1;
  padding: 10px 22px 12px; border: 4px solid var(--ink); border-radius: 6px; position: relative;
  background: #475569; box-shadow: inset 0 -5px 0 rgba(0,0,0,.28), inset 0 3px 0 rgba(255,255,255,.28), 0 4px 0 var(--ink);
  transition: transform .08s, filter .12s; display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  text-shadow: 0 2px 0 rgba(0,0,0,.35); white-space: nowrap;
}
.pbtn:hover { filter: brightness(1.12); transform: translateY(-2px); }
.pbtn:active { transform: translateY(3px); box-shadow: inset 0 -2px 0 rgba(0,0,0,.28), inset 0 3px 0 rgba(255,255,255,.28), 0 1px 0 var(--ink); }
.pbtn:disabled { filter: grayscale(1) brightness(.7); cursor: not-allowed; transform: none; }
.pbtn.green { background: #38B764; } .pbtn.blue { background: #3B7DD8; } .pbtn.gold { background: #F2A93B; color: #3a2200; text-shadow: none; }
.pbtn.purple { background: #8A4FC2; } .pbtn.dark { background: #3A4466; } .pbtn.teal { background: #257179; } .pbtn.red { background: var(--red); }
.pbtn.icon { padding: 8px 14px 10px; min-width: 56px; }
.pbtn.big { font-size: 24px; padding: 8px 30px 10px; }
.pbtn.on { background: var(--coral); }
.pbtn .badge { position: absolute; top: -12px; right: -12px; min-width: 26px; height: 26px; padding: 0 6px; border-radius: 13px; background: var(--red); border: 3px solid var(--ink); font-size: 15px; line-height: 20px; }
.chip {
  display: inline-flex; align-items: center; gap: 6px; background: rgba(26,28,44,.82); border: 3px solid var(--ink);
  border-radius: 6px; padding: 3px 12px; font-weight: 800; font-size: 22px; box-shadow: inset 0 2px 0 rgba(255,255,255,.12);
}
.chip b { color: var(--sand); min-width: 1ch; }

/* ------------------------------------------------ HUD */
#hud { position: absolute; left: 0; right: 0; top: 0; height: 74px; display: flex; align-items: center; justify-content: space-between; padding: 8px 12px; gap: 10px; pointer-events: none; }
#hud > * { pointer-events: auto; }
.hud-l, .hud-c, .hud-r { display: flex; align-items: center; gap: 10px; }
.hud-l { min-width: 0; flex: 1 1 0; }
.hud-r { flex: 1 1 0; justify-content: flex-end; }
.hud-mode { font-weight: 800; font-size: 20px; text-shadow: 0 2px 0 var(--ink), 2px 0 0 var(--ink), -2px 0 0 var(--ink), 0 -2px 0 var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 250px; }
.hearts { gap: 2px; }
.hearts .ico { width: 28px; height: 28px; }
.hearts .ico.lost { animation: heartOut .5s ease both; }
@keyframes heartOut { 0% { transform: scale(1.6) rotate(-20deg); filter: none; } 100% { transform: scale(1); } }
.chip.tide .bar { width: 110px; height: 14px; background: #10121f; border: 2px solid #000; display: block; position: relative; }
.chip.tide .bar i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--sky); display: block; transition: width .3s; }
.chip.tide.danger .bar i { background: var(--red); animation: blink .5s steps(2) infinite; }
@keyframes blink { 50% { opacity: .4; } }
.pbtn.toggle { min-width: 150px; }
.pbtn.toggle.spade { background: var(--red); }
#h-hint .ico, #h-tool .ico { width: 28px; height: 28px; }
.chip.bump { animation: bump .3s ease; }
@keyframes bump { 40% { transform: scale(1.25); } }

/* ------------------------------------------------ overlays */
.overlay { position: absolute; inset: 0; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 16px; background: rgba(26,28,44,.6); animation: fade .2s ease; }
@keyframes fade { from { opacity: 0 } to { opacity: 1 } }
@keyframes pop { from { transform: scale(.85); opacity: 0 } to { transform: scale(1); opacity: 1 } }
.loader { text-align: center; font-size: 22px; font-weight: 800; }
.loader .bar { width: 320px; height: 22px; border: 4px solid #fff; padding: 3px; margin: 0 auto 10px; }
.loader .bar i { display: block; height: 100%; width: 0; background: var(--sand); transition: width .2s; }

.modal {
  background: #2B2F4F; border: 4px solid var(--ink); border-radius: 8px; padding: 22px 30px; min-width: 440px; max-width: 920px;
  text-align: center; box-shadow: 0 0 0 4px #F7C977, 0 0 0 8px var(--ink), 0 24px 60px rgba(0,0,0,.55); animation: pop .22s ease both;
  max-height: 690px; overflow-y: auto;
}
.modal.wide { width: 900px; }
.modal h2 { margin: 0 0 6px; font-size: 38px; line-height: 1.1; color: var(--sand); text-shadow: 0 3px 0 var(--ink); }
.modal h3 { margin: 12px 0 6px; font-size: 22px; text-align: left; color: #cfd5f5; }
.sub { margin: 0 0 8px; color: #C9CFEE; font-size: 18px; line-height: 1.3; }
.sub.small { font-size: 15px; max-width: 420px; margin: 10px auto 0; }
.stack { display: flex; flex-direction: column; gap: 12px; margin-top: 10px; }
.actions { display: flex; gap: 12px; justify-content: center; margin-top: 16px; flex-wrap: wrap; }
.menu-row { display: flex; gap: 12px; flex-wrap: wrap; justify-content: center; }
.menu-row.small { margin-top: 14px; }

/* ------------------------------------------------ menu */
.overlay.menu { background: linear-gradient(90deg, rgba(26,28,44,0) 0%, rgba(26,28,44,0) 24%, rgba(26,28,44,.5) 34%, rgba(26,28,44,.72) 100%); align-items: flex-end; justify-content: flex-start; padding: 22px 26px 0 0; gap: 14px; }
.menu-head { width: 900px; display: flex; justify-content: space-between; align-items: flex-start; }
.logo { margin: 0; display: flex; flex-direction: column; line-height: .85; transform: rotate(-3deg); }
.logo span { font-weight: 800; letter-spacing: 3px; text-shadow: 4px 0 0 var(--ink), -4px 0 0 var(--ink), 0 4px 0 var(--ink), 0 -4px 0 var(--ink), 4px 4px 0 var(--ink), 6px 8px 0 rgba(0,0,0,.35); }
.logo .l1 { font-size: 64px; color: var(--sand); }
.logo .l2 { font-size: 78px; color: var(--coral); margin-left: 60px; }
.head-right { display: flex; flex-direction: column; align-items: flex-end; gap: 10px; }
.wallet-row { display: flex; gap: 10px; }
.streak b { color: #FFB36B; }
.continue { animation: glow 1.4s ease-in-out infinite; font-size: 19px; flex-direction: column; gap: 0; }
.continue small { display: block; font-size: 14px; opacity: .9; }
@keyframes glow { 50% { filter: brightness(1.2); } }
.cards { width: 900px; display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.card {
  background: rgba(43,47,79,.94); border: 4px solid var(--ink); border-radius: 8px; padding: 12px 16px 14px;
  display: flex; flex-direction: column; gap: 8px; align-items: flex-start; min-height: 168px; position: relative;
  box-shadow: inset 0 4px 0 rgba(255,255,255,.08), 0 5px 0 var(--ink); animation: pop .3s ease both;
}
.card:nth-child(2) { animation-delay: .05s } .card:nth-child(3) { animation-delay: .1s } .card:nth-child(4) { animation-delay: .15s }
.cards .card { cursor: pointer; }
.card-t { font-size: 27px; font-weight: 800; color: #fff; line-height: 1.1; }
.card.classic .card-t { color: var(--sand); } .card.daily .card-t { color: #FFB36B; } .card.trip .card-t { color: #8EC9FF; } .card.tide .card-t { color: #73EFF7; }
.card-sub { color: #C9CFEE; font-size: 17px; line-height: 1.3; flex: 1; }
.card-sub b { color: var(--sand); }
.card .pbtn { align-self: flex-end; margin-top: auto; }
.diff-row { display: flex; gap: 6px; flex-wrap: wrap; }
.tab { font: inherit; font-weight: 800; font-size: 16px; color: #C9CFEE; cursor: pointer; background: #1f2340; border: 3px solid var(--ink); border-radius: 5px; padding: 2px 12px; }
.tab.on { background: var(--sand); color: var(--ink); }
@media (pointer: coarse) { .tab { position: relative; } .tab::after { content: ''; position: absolute; inset: -10px -3px; } }

/* ------------------------------------------------ trip */
.trip-list { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 8px; }
.beach-col { display: flex; flex-direction: column; gap: 8px; }
.beach-name { font-weight: 800; font-size: 16px; color: #8EC9FF; min-height: 42px; display: flex; align-items: center; justify-content: center; line-height: 1.1; }
.stop { font: inherit; cursor: pointer; background: #3A4466; border: 3px solid var(--ink); border-radius: 6px; color: #fff; padding: 6px 4px; text-align: center; box-shadow: 0 3px 0 var(--ink); transition: transform .1s; }
.stop:hover:not(:disabled) { transform: translateY(-3px); background: #46527a; }
.stop:disabled { opacity: .45; cursor: not-allowed; }
.stop .n { font-weight: 800; font-size: 20px; }
.stop .meta { font-size: 13px; color: #C9CFEE; }
.stop .st { color: var(--sand); letter-spacing: 2px; font-size: 15px; }
.stop .st .off { color: #232845; }
.stop .sp { font-size: 12px; color: #A7F070; min-height: 15px; }

/* ------------------------------------------------ custom */
.sliders { display: grid; gap: 12px; margin: 10px 0; min-width: 380px; }
.slider { display: grid; grid-template-columns: 150px 1fr 56px; gap: 10px; align-items: center; text-align: left; font-weight: 800; }
.slider input { width: 100%; accent-color: var(--coral); }
.slider b { color: var(--sand); text-align: right; }

/* ------------------------------------------------ shop */
.shop-wallet { position: absolute; }
.modal { position: relative; }
.shop-wallet { top: 18px; right: 22px; }
.shop-grid { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; }
.hat-card { font: inherit; color: #fff; cursor: pointer; background: #3A4466; border: 3px solid var(--ink); border-radius: 6px; padding: 6px; display: flex; flex-direction: column; align-items: center; gap: 2px; box-shadow: 0 3px 0 var(--ink); }
.hat-card:hover { background: #46527a; }
.hat-card.eq { background: #2f6b4a; border-color: var(--lime); }
.hat-card img, .hat-card .none { width: 64px; height: 56px; object-fit: contain; }
.hat-card .none { font-size: 34px; line-height: 56px; opacity: .6; }
.hat-card .nm { font-weight: 800; font-size: 15px; line-height: 1.1; min-height: 34px; display: flex; align-items: center; }
.hat-card .pr { font-size: 15px; color: var(--sand); display: flex; align-items: center; gap: 3px; }
.hat-card .pr .ico { width: 18px; height: 18px; }
.hat-card.locked .pr { color: #ff9aa9; }
.shop-tools { display: grid; gap: 8px; }
.tool-row { display: grid; grid-template-columns: 44px 1fr auto; gap: 12px; align-items: center; background: rgba(255,255,255,.05); border-radius: 6px; padding: 6px 12px; text-align: left; }
.tool-row .ico { width: 40px; height: 40px; }
.tool-row .nm { font-weight: 800; font-size: 19px; }
.tool-row .ds { color: #C9CFEE; font-size: 15px; }
.tool-row .pbtn { font-size: 17px; padding: 6px 14px 8px; }

/* ------------------------------------------------ missions */
.mis-list { display: grid; gap: 8px; margin-top: 8px; }
.mis { display: grid; grid-template-columns: 1fr 190px 150px; gap: 12px; align-items: center; background: rgba(255,255,255,.05); border-radius: 6px; padding: 8px 14px; text-align: left; }
.mis .nm { font-weight: 800; font-size: 18px; }
.mis .prog { height: 14px; background: #10121f; border: 2px solid #000; position: relative; }
.mis .prog i { position: absolute; left: 0; top: 0; bottom: 0; background: var(--lime); }
.mis .pv { font-size: 14px; color: #C9CFEE; }
.mis .pbtn { font-size: 16px; padding: 6px 10px 8px; }
.mis.claimed { opacity: .5; }
.mis-stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 8px; margin-top: 14px; }
.mis-stats div { background: rgba(255,255,255,.05); border-radius: 6px; padding: 6px; }
.mis-stats b { display: block; color: var(--sand); font-size: 22px; }
.mis-stats small { color: #C9CFEE; font-size: 13px; }

/* ------------------------------------------------ settings */
.set-list { display: grid; gap: 10px; text-align: left; min-width: 380px; margin-top: 8px; }
.set-row { display: flex; justify-content: space-between; align-items: center; gap: 20px; font-size: 20px; font-weight: 800; background: rgba(255,255,255,.05); border-radius: 6px; padding: 6px 12px; cursor: pointer; }
.set-row input[type=checkbox] { width: 26px; height: 26px; accent-color: var(--green); }
.set-row select { font: inherit; font-size: 18px; background: #1f2340; color: #fff; border: 3px solid var(--ink); border-radius: 5px; padding: 2px 8px; }

/* ------------------------------------------------ howto */
.howto { text-align: left; font-size: 19px; line-height: 1.4; margin: 6px 0; padding-left: 26px; }
.howto li { margin: 5px 0; }
.howto b { color: var(--sand); }
.keys { color: #C9CFEE; font-size: 15px; }
kbd { background: #1f2340; border: 2px solid var(--ink); border-radius: 4px; padding: 0 6px; margin: 0 2px; font-family: inherit; font-weight: 800; color: #fff; }

/* ------------------------------------------------ result */
#result { background: rgba(26,28,44,.45); }
.stars { font-size: 60px; letter-spacing: 8px; line-height: 1; margin: 4px 0 8px; display: flex; justify-content: center; gap: 10px; }
.stars .ico { width: 58px; height: 58px; animation: pop .4s ease both; }
.stars .ico.off { filter: grayscale(1) brightness(.35); }
.stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin: 10px 0; }
.stats div { background: rgba(255,255,255,.06); border-radius: 6px; padding: 6px 10px; }
.stats b { display: block; font-size: 26px; color: var(--sand); }
.stats small { color: #C9CFEE; font-size: 14px; }
.reward { font-size: 32px; font-weight: 800; display: flex; align-items: center; justify-content: center; gap: 6px; }
.reward .ico { width: 38px; height: 38px; }
.reward b { color: var(--sand); }
.r-extra { font-size: 17px; color: #D6DCF7; display: grid; gap: 3px; margin-top: 6px; }
.r-extra .q { color: var(--lime); } .r-extra .goal { color: var(--sand); } .r-extra .best { color: #FFB36B; font-weight: 800; }
.win h2 { color: var(--lime); } .lose h2 { color: #FF8A9A; }

.toast {
  position: absolute; top: 84px; left: 50%; transform: translateX(-50%); z-index: 20; max-width: 760px; text-align: center;
  background: var(--sand); color: var(--ink); font-weight: 800; font-size: 21px; padding: 8px 22px; border: 4px solid var(--ink); border-radius: 6px;
  box-shadow: 0 4px 0 var(--ink); animation: pop .25s ease both; pointer-events: none;
}

.toast.side { left: auto; right: 56px; transform: none; max-width: 370px; font-size: 19px; animation-name: popSide; }
@keyframes popSide { from { opacity: 0; transform: scale(.8); } to { opacity: 1; transform: none; } }

#rotate { display: none; }
@media (orientation: portrait) and (max-width: 700px) and (pointer: coarse) {
  #rotate { display: block; position: fixed; left: 0; right: 0; bottom: 0; padding: 10px; text-align: center; background: var(--sand); color: var(--ink); font-weight: 800; z-index: 10; }
}
@media (prefers-reduced-motion: reduce) {
  .overlay, .modal, .card, .toast, .continue, .stars .ico { animation: none !important; }
}
/* shop sits to the right so the digger can model the hat */
#shop { align-items: flex-end; padding-right: 24px; }
#shop .modal.wide { width: 880px; }
