/* Tide Match. Harbor palette from ui.css; only transform/opacity are animated. */


.tm {
  width: min(1180px, 100%);
  margin: 0 auto;
  padding: 0.9rem clamp(0.6rem, 3vw, 1.5rem) 2.5rem;
}

/* ------------------------------------------------------------------ map view */
.tm-mapview { display: grid; gap: 1rem; align-items: start; }
@media (min-width: 900px) {
  .tm-mapview { grid-template-columns: minmax(280px, 340px) 1fr; gap: 2rem; }
  .tm-card { position: sticky; top: 5.2rem; }
}
.tm-card {
  background: var(--sail); border-radius: var(--r-panel); box-shadow: var(--shadow-float);
  padding: 1.2rem 1.25rem 1.35rem; display: grid; gap: 0.85rem;
  border-top: 6px solid var(--lamp);
}
.tm-card__title { font-size: var(--step-3); font-weight: 700; color: var(--harbor); }
.tm-card__sub { margin: 0.2rem 0 0; color: var(--ink-soft); }
.tm-lives { display: flex; align-items: center; gap: 0.75rem; flex-wrap: wrap; padding: 0.6rem 0.75rem; background: #EAF2F9; border-radius: 16px; }
.tm-lives__hearts { display: flex; gap: 2px; }
.tm-lives__hearts i { width: 28px; height: 28px; display: block; }
.tm-lives__hearts i:not(.on) { filter: grayscale(1); opacity: 0.35; }
.tm-lives__hearts svg { width: 100%; height: 100%; display: block; }
.tm-lives__text { margin: 0; display: grid; line-height: 1.25; }
.tm-lives__text span { color: var(--ink-soft); font-size: var(--step--1); font-variant-numeric: tabular-nums; }
.tm-stars { margin: 0; display: flex; align-items: center; gap: 0.5rem; }
.tm-stars__icon svg { width: 26px; height: 26px; display: block; }
.tm-play { width: 100%; font-size: var(--step-2); min-height: 60px; }

.tm-maphost { width: min(100%, 470px); margin: 0 auto; }
@media (min-width: 900px) { .tm-maphost { width: min(100%, 470px, calc((100dvh - 120px) * 400 / 660)); } }
.m-map {
  position: relative; aspect-ratio: 400 / 660; border-radius: 30px; overflow: hidden;
  box-shadow: 0 0 0 6px rgba(245, 250, 255, 0.55), 0 24px 40px -18px rgba(4, 18, 30, 0.75);
}
.m-scene { position: absolute; inset: 0; width: 100%; height: 100%; }
.m-wave { animation: m-drift 5s ease-in-out infinite alternate; }
@keyframes m-drift { to { transform: translateX(10px); } }
.m-beacon { transform-origin: 0 1px; transform-box: fill-box; animation: m-beacon 2.4s ease-in-out infinite; }
@keyframes m-beacon { 50% { opacity: 0.25; transform: scale(1.25); } }
.m-boat { animation: m-bob 3.2s ease-in-out infinite; }
@keyframes m-bob { 50% { transform: translate(320px, 404px) rotate(-3deg); } }
.m-nodes { list-style: none; margin: 0; padding: 0; position: absolute; inset: 0; }
.m-node { position: absolute; transform: translate(-50%, -50%); }
.m-node--current { z-index: 2; }
.m-buoy {
  --size: clamp(50px, 13vw, 64px);
  position: relative; display: block;
  width: var(--size); height: var(--size); padding: 0; border: 0; border-radius: 50%; cursor: pointer;
  background: transparent;
}
.m-buoy__float { position: absolute; inset: 0; transition: transform var(--dur) var(--ease-bounce); }
.m-buoy:hover .m-buoy__float { transform: translateY(-3px) scale(1.05); }
.m-buoy:active .m-buoy__float { transform: translateY(3px); }
.m-buoy__body {
  position: absolute; inset: 0; border-radius: 50%;
  background: conic-gradient(from 22.5deg, var(--buoy) 0 12.5%, #fff 0 25%, var(--buoy) 0 37.5%, #fff 0 50%, var(--buoy) 0 62.5%, #fff 0 75%, var(--buoy) 0 87.5%, #fff 0);
  box-shadow: 0 6px 0 var(--buoy-deep), 0 12px 18px -4px rgba(4, 18, 30, 0.6), inset 0 -4px 6px rgba(0, 0, 0, 0.15);
}
.m-buoy:focus-visible { box-shadow: var(--focus); }
.m-buoy__num {
  position: absolute; inset: 18%; border-radius: 50%; display: grid; place-items: center;
  background: radial-gradient(circle at 40% 35%, #fff, #E4EEF6); color: var(--harbor);
  font-family: var(--font-display); font-weight: 700; font-size: calc(var(--size) * 0.36);
  box-shadow: inset 0 -3px 0 rgba(14, 47, 72, 0.15);
}
.m-buoy--done .m-buoy__body { background: conic-gradient(from 22.5deg, var(--glass-deep) 0 12.5%, #fff 0 25%, var(--glass-deep) 0 37.5%, #fff 0 50%, var(--glass-deep) 0 62.5%, #fff 0 75%, var(--glass-deep) 0 87.5%, #fff 0); box-shadow: 0 6px 0 #1C6A5A, 0 12px 18px -4px rgba(4, 18, 30, 0.6); }
.m-buoy--locked { cursor: default; }
.m-buoy--locked .m-buoy__body { background: radial-gradient(circle at 40% 35%, #D9E2EA, #91A3B2); box-shadow: 0 5px 0 #66788A, 0 10px 14px -4px rgba(4, 18, 30, 0.5); }
.m-buoy--locked:hover .m-buoy__float { transform: none; }
.m-buoy--locked .m-buoy__num { background: radial-gradient(circle at 40% 35%, #EEF3F7, #C4D0DA); }
.m-buoy--current .m-buoy__float { animation: m-float 2.2s ease-in-out infinite; }
.m-buoy__ring {
  position: absolute; inset: -14px; border-radius: 50%; pointer-events: none; opacity: 0;
  background: radial-gradient(circle, rgba(247, 177, 60, 0.75) 40%, rgba(247, 177, 60, 0) 70%);
}
.m-buoy--current .m-buoy__ring { opacity: 1; animation: m-halo 1.8s ease-in-out infinite; }
@keyframes m-float { 50% { transform: translateY(-5px); } }
@keyframes m-halo { 50% { transform: scale(1.18); opacity: 0.55; } }
.m-buoy__stars { position: absolute; left: 50%; bottom: -15px; transform: translateX(-50%); display: flex; gap: 1px; }
.m-buoy__stars i { width: 19px; height: 19px; display: block; }
.m-buoy__stars i:nth-child(2) { transform: translateY(4px); }
.m-buoy__stars i:not(.on) { filter: grayscale(1) brightness(0.55); opacity: 0.75; }
.m-buoy__stars svg { width: 100%; height: 100%; display: block; }
.m-flag {
  position: absolute; left: 50%; bottom: calc(100% + 8px); transform: translateX(-50%);
  background: var(--lamp); color: var(--harbor); font-family: var(--font-display); font-weight: 700;
  font-size: 0.85rem; padding: 0.05rem 0.6rem; border-radius: var(--r-pill); white-space: nowrap;
  box-shadow: 0 3px 0 var(--lamp-deep); pointer-events: none;
}
.m-flag::after { content: ''; position: absolute; left: 50%; top: 100%; margin-left: -6px; border: 6px solid transparent; border-top-color: var(--lamp); }

/* ----------------------------------------------------------------- game view */
.tm-game {
  display: grid; gap: 0.75rem; justify-items: center;
  grid-template-areas: "hud" "board" "bar";
}
.hud {
  grid-area: hud; width: min(100%, 640px);
  display: grid; gap: 0.6rem 0.9rem; grid-template-columns: auto 1fr; align-items: center;
  background: var(--sail); border-radius: var(--r-panel); box-shadow: var(--shadow-float);
  padding: 0.7rem 0.9rem;
  border-bottom: 5px solid #C9D9E6;
}
.hud__top { display: flex; flex-direction: column; align-items: center; gap: 0.35rem; grid-row: span 2; }
.hud__level { font-size: var(--step-0); font-weight: 600; color: var(--ink-soft); white-space: nowrap; }
.hud__label { display: block; font-family: var(--font-display); font-weight: 600; font-size: 0.8rem; text-transform: uppercase; letter-spacing: 0.06em; color: var(--ink-soft); line-height: 1.1; }
.hud__moves {
  width: 82px; height: 82px; border-radius: 50%; display: grid; place-content: center; text-align: center;
  background: radial-gradient(circle at 40% 30%, #FFE3A6, var(--lamp) 60%, #E59A22);
  box-shadow: inset 0 -5px 0 rgba(158, 94, 10, 0.35), 0 6px 14px -6px rgba(14, 47, 72, 0.6);
}
.hud__moves .hud__label { color: var(--harbor); font-size: 0.72rem; }
.hud__num { font-family: var(--font-display); font-weight: 700; font-size: 2.1rem; line-height: 1; color: var(--harbor); font-variant-numeric: tabular-nums; }
.hud__moves.is-tick { animation: tm-tick 360ms var(--ease-bounce); }
.hud__moves.is-low { background: radial-gradient(circle at 40% 30%, #C9473D, var(--buoy-deep) 65%); box-shadow: inset 0 -5px 0 rgba(0, 0, 0, 0.25), 0 0 0 0 rgba(217, 68, 58, 0.6); animation: tm-low 1s ease-in-out infinite; }
.hud__moves.is-low .hud__label, .hud__moves.is-low .hud__num { color: var(--sail); }
@keyframes tm-tick { 40% { transform: scale(1.14); } }
@keyframes tm-low { 50% { transform: scale(1.09); } }

.hud__goals { min-width: 0; }
.goals { list-style: none; margin: 0.25rem 0 0; padding: 0; display: flex; flex-wrap: wrap; gap: 0.35rem 0.75rem; }
.goal { display: flex; align-items: center; gap: 0.3rem; }
.goal__icon { position: relative; width: 42px; height: 42px; display: block; flex: none; }
.goal__icon svg { width: 100%; height: 100%; display: block; }
.goal__icon.is-catch { animation: tm-catch 260ms var(--ease-bounce); }
@keyframes tm-catch { 50% { transform: scale(1.25); } }
.goal__num { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; font-variant-numeric: tabular-nums; color: var(--harbor); }
.goal.is-bump .goal__num { animation: bump 380ms var(--ease-bounce); display: inline-block; }
.goal.is-done .goal__num { color: var(--glass-deep); color: #1F6B5C; }
.goal.is-done .goal__icon::after {
  content: ''; position: absolute; right: -4px; bottom: -2px; width: 20px; height: 20px; border-radius: 50%;
  background: #1F6B5C url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 20 20'%3E%3Cpath d='M5 10.5l3.2 3L15 6.5' stroke='%23fff' stroke-width='2.6' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E") center / 100% no-repeat;
  box-shadow: 0 0 0 2px var(--sail);
  animation: pop 320ms var(--ease-bounce);
}
.hud__score { min-width: 0; }
.hud__scoreline { margin: 0 0 0.3rem; display: flex; align-items: baseline; gap: 0.5rem; }
.hud__scorenum { font-family: var(--font-display); font-size: var(--step-1); font-variant-numeric: tabular-nums; }
.meter { position: relative; height: 12px; border-radius: var(--r-pill); background: #D5E2EC; box-shadow: inset 0 2px 3px rgba(14, 47, 72, 0.18); margin-right: 12px; }
.meter__fill {
  position: absolute; inset: 0; border-radius: inherit; transform-origin: left center; transform: scaleX(0);
  background: linear-gradient(180deg, #FFD87A, var(--lamp) 55%, #E0931C);
  transition: transform 450ms cubic-bezier(0.2, 0.8, 0.3, 1);
}
.meter__star {
  position: absolute; top: 50%; width: 24px; height: 24px; transform: translate(-50%, -50%);
  background: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 2.5l4.1 8.6 9.4 1.2-6.9 6.5 1.8 9.3L16 23.6l-8.4 4.5 1.8-9.3-6.9-6.5 9.4-1.2z' fill='%23B9C8D4' stroke='%237E93A4' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E") center / contain no-repeat;
}
.meter__star.on {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 32 32'%3E%3Cpath d='M16 2.5l4.1 8.6 9.4 1.2-6.9 6.5 1.8 9.3L16 23.6l-8.4 4.5 1.8-9.3-6.9-6.5 9.4-1.2z' fill='%23FFC93C' stroke='%23B5650A' stroke-width='1.6' stroke-linejoin='round'/%3E%3C/svg%3E");
  animation: tm-staron 420ms var(--ease-bounce);
}
@keyframes tm-staron { 0% { transform: translate(-50%, -50%) scale(0.4); } 60% { transform: translate(-50%, -50%) scale(1.45); } }

/* Wooden pier frame around the board. */
.pier {
  grid-area: board; position: relative; width: min(100%, 640px);
  padding: clamp(8px, 2.2vw, 16px);
  border-radius: 26px;
  background:
    radial-gradient(circle at 14px 14px, #5C3A1C 3px, #C9A06A 4px, transparent 5px),
    radial-gradient(circle at calc(100% - 14px) 14px, #5C3A1C 3px, #C9A06A 4px, transparent 5px),
    radial-gradient(circle at 14px calc(100% - 14px), #5C3A1C 3px, #C9A06A 4px, transparent 5px),
    radial-gradient(circle at calc(100% - 14px) calc(100% - 14px), #5C3A1C 3px, #C9A06A 4px, transparent 5px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18), rgba(0, 0, 0, 0.12)),
    repeating-linear-gradient(90deg, #B07A44 0 52px, #9A6535 52px 54px, #A8713E 54px 106px, #8E5A2E 106px 108px);
  box-shadow: inset 0 3px 0 rgba(255, 236, 200, 0.4), inset 0 -5px 0 rgba(60, 30, 8, 0.4), 0 22px 36px -16px rgba(4, 18, 30, 0.85);
}
.pier__rope { position: absolute; inset: 4px; border-radius: 22px; border: 2px dashed rgba(240, 220, 180, 0.55); pointer-events: none; }

.board {
  position: relative; width: 100%; margin: 0 auto;
  aspect-ratio: var(--w, 8) / var(--h, 8);
  border-radius: 16px; overflow: hidden;
  --tm-board-base: radial-gradient(ellipse at 50% 0%, #2C7AA6, #17537A 55%, #0F3D5C);
  background-image: var(--tm-board-bg, none), var(--tm-board-base); background-size: cover; background-position: center;
  box-shadow: inset 0 4px 16px rgba(2, 14, 26, 0.55), 0 0 0 3px #6B421E;
  touch-action: none; user-select: none; -webkit-user-select: none;
}
.board.is-quake { animation: tm-quake 380ms ease-out; }
@keyframes tm-quake { 20% { transform: translate(-5px, 3px); } 40% { transform: translate(5px, -3px); } 60% { transform: translate(-3px, -2px); } 80% { transform: translate(2px, 2px); } }
.b-sand, .b-sprites, .b-fx, .b-cells { position: absolute; inset: 0; }
.b-fx { z-index: 3; pointer-events: none; }
.b-cells { z-index: 4; }
.b-sandcell, .b-cell, .b-sprite {
  position: absolute; left: 0; top: 0;
  width: calc(100% / var(--w)); height: calc(100% / var(--h));
  transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%));
}
.b-sandcell::before, .b-sandcell::after { content: ''; position: absolute; inset: 3%; border-radius: 22%; }
.b-sandcell::before { background: rgba(245, 250, 255, 0.07); }
.b-sandcell--alt::before { background: rgba(245, 250, 255, 0.13); }
.b-sandcell::after {
  opacity: 0;
  background:
    radial-gradient(circle at 22% 30%, #B98146 1.5px, transparent 2.5px),
    radial-gradient(circle at 70% 22%, #C48D52 1.5px, transparent 2.5px),
    radial-gradient(circle at 52% 62%, #B98146 1.5px, transparent 2.5px),
    radial-gradient(circle at 28% 78%, #C48D52 1.5px, transparent 2.5px),
    radial-gradient(circle at 80% 72%, #B98146 1.5px, transparent 2.5px),
    linear-gradient(160deg, #F7E0B0, #E6BD7D 60%, #D6A762);
  box-shadow: inset 0 -3px 0 rgba(120, 72, 28, 0.35), inset 0 2px 0 rgba(255, 246, 220, 0.6);
}
.b-sandcell.is-sand::after { opacity: 1; }
.b-sandcell.sand-gone::after { animation: tm-sandgone 520ms ease-out forwards; }
@keyframes tm-sandgone { 0% { opacity: 1; transform: scale(1); } 40% { opacity: 0.9; transform: scale(1.12); } 100% { opacity: 0; transform: scale(0.5); } }

.b-sprite { transition: transform 190ms cubic-bezier(0.3, 0.7, 0.4, 1); z-index: 1; will-change: transform; }
.b-sprite.no-trans { transition: none; }
.b-sprite.is-falling { transition: transform var(--fall, 300ms) cubic-bezier(0.5, 0.05, 0.62, 1.28) var(--delay, 0ms); }
.b-sprite.is-shuffling { transition: transform 500ms cubic-bezier(0.6, -0.3, 0.3, 1.3); }
.b-sprite.is-selected { z-index: 2; }
.b-art { position: absolute; inset: 5%; transform-origin: 50% 85%; }
.b-art > svg { width: 100%; height: 100%; display: block; position: relative; }
.b-sprite.is-selected .b-art { animation: tm-sel 900ms ease-in-out infinite; }
@keyframes tm-sel { 0%, 100% { transform: scale(1.1); } 50% { transform: scale(1.18) translateY(-3%); } }
.b-sprite.is-popping { z-index: 2; }
.b-sprite.is-popping .b-art { animation: tm-pop 300ms ease-in forwards; }
@keyframes tm-pop { 0% { transform: scale(1); } 35% { transform: scale(1.32); opacity: 1; } 100% { transform: scale(0.1); opacity: 0; } }
.b-art.is-born { animation: tm-born 420ms var(--ease-bounce); }
@keyframes tm-born { 0% { transform: scale(0.2); opacity: 0; } 60% { transform: scale(1.35); opacity: 1; } }
.b-art.is-land { animation: tm-land 300ms ease-out; }
@keyframes tm-land { 0% { transform: scale(1.12, 0.84); } 55% { transform: scale(0.96, 1.06); } 100% { transform: none; } }
.b-art.is-shake { animation: tm-shake 300ms ease-in-out; }
@keyframes tm-shake { 25% { transform: translateX(-7%) rotate(-6deg); } 75% { transform: translateX(7%) rotate(6deg); } }
.b-art.is-hint-h { animation: tm-hint-h 1.4s ease-in-out infinite; }
.b-art.is-hint-v { animation: tm-hint-v 1.4s ease-in-out infinite; }
@keyframes tm-hint-h { 0%, 60%, 100% { transform: none; } 15%, 45% { transform: translateX(calc(var(--hs, 1) * 9%)) rotate(calc(var(--hs, 1) * 4deg)); } 30% { transform: translateX(calc(var(--hs, 1) * 3%)); } }
@keyframes tm-hint-v { 0%, 60%, 100% { transform: none; } 15%, 45% { transform: translateY(calc(var(--hs, 1) * 9%)) scale(1.05); } 30% { transform: translateY(calc(var(--hs, 1) * 3%)); } }

/* Specials. */
.fx-stripe { position: absolute; inset: 0; pointer-events: none; }
.fx-stripe i {
  position: absolute; border-radius: 99px;
  background: linear-gradient(var(--sd, 180deg), #FFF6CF, #FFFFFF 50%, #FFE48A);
  box-shadow: 0 0 6px 2px rgba(255, 255, 255, 0.95), 0 0 14px 5px rgba(247, 177, 60, 0.8);
  animation: tm-glow 1.1s ease-in-out infinite alternate;
}
.fx-stripe--h i { left: 4%; right: 4%; height: 10%; }
.fx-stripe--h i:first-child { top: 33%; }
.fx-stripe--h i:last-child { top: 57%; animation-delay: 0.3s; }
.fx-stripe--v i { top: 4%; bottom: 4%; width: 10%; --sd: 90deg; }
.fx-stripe--v i:first-child { left: 33%; }
.fx-stripe--v i:last-child { left: 57%; animation-delay: 0.3s; }
.fx-stripe::before, .fx-stripe::after {
  content: ''; position: absolute; width: 20%; height: 20%; background: #FFFFFF;
  filter: drop-shadow(0 0 3px rgba(247, 177, 60, 1));
  animation: tm-glow 0.8s ease-in-out infinite alternate;
}
.fx-stripe--h::before { left: -6%; top: 40%; clip-path: polygon(0 50%, 100% 0, 100% 100%); }
.fx-stripe--h::after { right: -6%; top: 40%; clip-path: polygon(100% 50%, 0 0, 0 100%); }
.fx-stripe--v::before { top: -6%; left: 40%; clip-path: polygon(50% 0, 100% 100%, 0 100%); }
.fx-stripe--v::after { bottom: -6%; left: 40%; clip-path: polygon(50% 100%, 100% 0, 0 0); }
@keyframes tm-glow { from { opacity: 0.55; } to { opacity: 1; } }
.fx-ring {
  position: absolute; inset: -3%; border-radius: 50%; pointer-events: none;
  border: 3px solid #FFE48A;
  box-shadow: 0 0 10px 3px rgba(247, 177, 60, 0.9), inset 0 0 10px 3px rgba(247, 177, 60, 0.75);
  background: radial-gradient(circle, rgba(255, 228, 138, 0.45), rgba(255, 228, 138, 0) 70%);
  animation: tm-ring 1.2s ease-in-out infinite;
}
.b-art--sp3 > svg { transform: scale(0.86); }
@keyframes tm-ring { 50% { transform: scale(1.08); opacity: 0.75; } }
.b-art--sp4 > svg { animation: tm-spin 5s linear infinite; }
@keyframes tm-spin { to { transform: rotate(360deg); } }
.fx-sparkle { position: absolute; inset: 0; pointer-events: none; }
.fx-sparkle::before, .fx-sparkle::after {
  content: ''; position: absolute; width: 22%; height: 22%;
  background: radial-gradient(circle, #fff 18%, rgba(255, 255, 255, 0) 60%);
  animation: tm-twinkle 1.6s ease-in-out infinite;
}
.fx-sparkle::before { left: 8%; top: 10%; }
.fx-sparkle::after { right: 6%; bottom: 18%; animation-delay: 0.8s; }
@keyframes tm-twinkle { 0%, 100% { transform: scale(0.3); opacity: 0; } 50% { transform: scale(1.3); opacity: 1; } }

/* Input layer. */
.b-cell {
  border: 0; padding: 0; margin: 0; background: transparent; border-radius: 22%; cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.b-cell:hover { background: rgba(245, 250, 255, 0.1); }
.b-cell:focus-visible { box-shadow: inset 0 0 0 3px #FFFFFF, inset 0 0 0 6px var(--lamp); background: rgba(245, 250, 255, 0.12); }
.b-cell.is-selected { box-shadow: inset 0 0 0 3px var(--lamp), 0 0 16px 2px rgba(247, 177, 60, 0.75); background: rgba(255, 228, 138, 0.2); }
.board.is-hammer .b-cell { cursor: crosshair; }
.board.is-hammer .b-cell:hover, .board.is-hammer .b-cell:focus-visible { box-shadow: inset 0 0 0 3px var(--buoy), inset 0 0 0 6px #FFFFFF; background: rgba(217, 68, 58, 0.22); }
.board.is-hammer { box-shadow: inset 0 4px 16px rgba(2, 14, 26, 0.55), 0 0 0 3px var(--buoy); }

/* Effects. */
.b-spark { position: absolute; width: 9px; height: 9px; margin: -4.5px 0 0 -4.5px; border-radius: 50%; box-shadow: 0 0 6px rgba(255, 255, 255, 0.8); animation: tm-spark 600ms cubic-bezier(0.2, 0.8, 0.4, 1) forwards; }
@keyframes tm-spark { to { transform: translate(var(--dx), var(--dy)) scale(0.1); opacity: 0; } }
.b-floater {
  position: absolute; transform: translate(-50%, -50%); white-space: nowrap;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.1rem, 3.4vw, 1.6rem); color: #FFF8E1;
  text-shadow: 0 2px 0 #8A5208, 0 -1px 0 #8A5208, 2px 0 0 #8A5208, -2px 0 0 #8A5208, 0 4px 10px rgba(0, 0, 0, 0.5);
  animation: tm-float 1s ease-out forwards;
}
.b-floater--combo { color: #FFE48A; font-size: clamp(1.3rem, 4vw, 1.9rem); }
@keyframes tm-float { 0% { transform: translate(-50%, -30%) scale(0.5); opacity: 0; } 20% { transform: translate(-50%, -60%) scale(1.15); opacity: 1; } 70% { opacity: 1; } 100% { transform: translate(-50%, -160%) scale(1); opacity: 0; } }
.b-banner {
  position: absolute; left: 50%; top: 46%; transform: translate(-50%, -50%); white-space: nowrap;
  font-family: var(--font-display); font-weight: 700; font-size: clamp(1.8rem, 7vw, 3rem); color: #FFF8E1;
  text-shadow: 0 3px 0 var(--harbor), 0 -2px 0 var(--harbor), 3px 0 0 var(--harbor), -3px 0 0 var(--harbor), 0 8px 18px rgba(0, 0, 0, 0.55);
  animation: tm-banner 1.3s var(--ease-bounce) forwards;
}
.b-banner--combo { color: #FFE48A; top: 30%; }
.b-banner--win { color: #FFE48A; font-size: clamp(2rem, 8vw, 3.4rem); }
.b-banner--lose { color: #FFD3CF; }
.b-banner--info { font-size: clamp(1.2rem, 5vw, 2rem); }
.b-banner--intro { color: #FFF8E1; }
@keyframes tm-banner { 0% { transform: translate(-50%, -50%) scale(0.3); opacity: 0; } 25% { transform: translate(-50%, -50%) scale(1.12); opacity: 1; } 35% { transform: translate(-50%, -50%) scale(1); } 80% { opacity: 1; transform: translate(-50%, -50%) scale(1); } 100% { transform: translate(-50%, -90%) scale(1); opacity: 0; } }
.b-beam { position: absolute; pointer-events: none; animation: tm-beam 540ms ease-out forwards; }
.b-beam--h {
  left: 0; width: 100%; top: calc(var(--r) * 100% / var(--h)); height: calc(100% / var(--h));
  background: linear-gradient(180deg, rgba(255, 255, 255, 0) 15%, rgba(255, 244, 200, 0.95) 42%, #fff 50%, rgba(255, 244, 200, 0.95) 58%, rgba(255, 255, 255, 0) 85%);
  animation-name: tm-beam-h;
}
.b-beam--v {
  top: 0; height: 100%; left: calc(var(--c) * 100% / var(--w)); width: calc(100% / var(--w));
  background: linear-gradient(90deg, rgba(255, 255, 255, 0) 15%, rgba(255, 244, 200, 0.95) 42%, #fff 50%, rgba(255, 244, 200, 0.95) 58%, rgba(255, 255, 255, 0) 85%);
  animation-name: tm-beam-v;
}
@keyframes tm-beam-h { 0% { transform: scaleX(0); opacity: 1; } 45% { transform: scaleX(1); opacity: 1; } 100% { transform: scaleX(1) scaleY(0.2); opacity: 0; } }
@keyframes tm-beam-v { 0% { transform: scaleY(0); opacity: 1; } 45% { transform: scaleY(1); opacity: 1; } 100% { transform: scaleY(1) scaleX(0.2); opacity: 0; } }
.b-blast {
  position: absolute; width: calc(320% / var(--w)); aspect-ratio: 1; border-radius: 50%; pointer-events: none;
  background: radial-gradient(circle, #FFFBEA 0 18%, rgba(255, 214, 120, 0.9) 35%, rgba(247, 177, 60, 0.5) 55%, rgba(247, 177, 60, 0) 70%);
  animation: tm-blast 600ms ease-out forwards;
}
@keyframes tm-blast { 0% { transform: translate(-50%, -50%) scale(0.2); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1.3); opacity: 0; } }
.b-nova {
  position: absolute; width: 140%; aspect-ratio: 1; border-radius: 50%; pointer-events: none;
  background: conic-gradient(rgba(255, 107, 107, 0.7), rgba(255, 177, 60, 0.7), rgba(255, 228, 92, 0.7), rgba(95, 214, 138, 0.7), rgba(79, 168, 240, 0.7), rgba(160, 102, 224, 0.7), rgba(255, 107, 107, 0.7));
  -webkit-mask: radial-gradient(circle, #000 0 30%, transparent 62%);
  mask: radial-gradient(circle, #000 0 30%, transparent 62%);
  animation: tm-nova 880ms ease-out forwards;
}
@keyframes tm-nova { 0% { transform: translate(-50%, -50%) scale(0.05) rotate(0); opacity: 1; } 100% { transform: translate(-50%, -50%) scale(1) rotate(200deg); opacity: 0; } }
.b-hammer { position: absolute; width: calc(150% / var(--w)); aspect-ratio: 1; pointer-events: none; transform-origin: 80% 90%; animation: tm-hammer 420ms cubic-bezier(0.6, -0.4, 0.7, 1) forwards; }
.b-hammer svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 4px 4px rgba(0, 0, 0, 0.4)); }
@keyframes tm-hammer { 0% { transform: translate(-30%, -80%) rotate(40deg); opacity: 0; } 30% { opacity: 1; transform: translate(-30%, -80%) rotate(55deg); } 75% { transform: translate(-40%, -60%) rotate(-25deg); } 100% { transform: translate(-40%, -60%) rotate(-15deg); opacity: 1; } }

.fly { position: fixed; z-index: 60; pointer-events: none; transition: transform 520ms cubic-bezier(0.55, -0.25, 0.6, 1), opacity 520ms ease-in; }
.fly svg { width: 100%; height: 100%; display: block; }

/* Bottom bar. */
.bar {
  grid-area: bar; width: min(100%, 640px);
  display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; justify-content: center;
  padding: 0.6rem 0.7rem; border-radius: var(--r-panel);
  background: rgba(14, 47, 72, 0.88); box-shadow: var(--shadow-float);
}
.bar__btn {
  display: inline-flex; flex-direction: column; align-items: center; justify-content: center; gap: 0.1rem;
  min-width: 68px; min-height: 60px; padding: 0.35rem 0.7rem; border: 0; border-radius: 16px; cursor: pointer;
  background: var(--sail); color: var(--harbor); font-family: var(--font-display); font-weight: 600; font-size: 0.95rem; line-height: 1.1;
  box-shadow: 0 4px 0 #B9CBDB; transition: transform var(--dur) var(--ease-bounce);
}
.bar__btn:hover { transform: translateY(-2px); }
.bar__btn:active { transform: translateY(3px); box-shadow: 0 1px 0 #B9CBDB; }
.bar__btn:focus-visible { box-shadow: 0 4px 0 #B9CBDB, var(--focus); }
.bar__icon { width: 30px; height: 30px; display: block; }
.bar__icon svg { width: 100%; height: 100%; display: block; }
.bar__btn--booster { position: relative; min-width: 92px; background: linear-gradient(180deg, #FFF6DF, #FFE3A6); box-shadow: 0 4px 0 var(--lamp-deep); }
.bar__btn--booster .bar__icon { width: 36px; height: 36px; }
.bar__btn--booster[aria-pressed="true"] { background: var(--lamp); box-shadow: 0 4px 0 var(--lamp-deep), 0 0 0 3px var(--sail), 0 0 18px 4px rgba(247, 177, 60, 0.85); animation: tm-low 900ms ease-in-out infinite; }
.bar__btn--booster[aria-pressed="true"] .bar__icon { animation: tm-wobble 600ms ease-in-out infinite; }
@keyframes tm-wobble { 50% { transform: rotate(-14deg); } }
.bar__price {
  position: absolute; top: -10px; right: -8px; display: inline-flex; align-items: center; gap: 2px;
  padding: 0 0.45rem 0 0.2rem; border-radius: var(--r-pill); background: var(--harbor); color: var(--sail);
  font-size: 0.8rem; font-weight: 700; line-height: 1.6;
}
.bar__price svg { width: 15px; height: 15px; }
.bar__btn--booster.is-poor .bar__price { background: var(--buoy-deep); }
.bar__coins { margin: 0; color: var(--sail); font-size: var(--step--1); flex: 1 1 10rem; max-width: 15rem; line-height: 1.35; }
.bar__coins strong { color: #FFE3A6; }
#sound[aria-pressed="false"] .bar__icon { opacity: 0.55; }

/* Desktop: HUD + bar beside the board. */
@media (min-width: 980px) {
  .tm-game {
    grid-template-columns: 290px minmax(0, 1fr); grid-template-rows: auto 1fr;
    grid-template-areas: "hud board" "bar board"; align-items: start; gap: 1rem 1.5rem; justify-items: stretch;
  }
  .hud { width: 100%; grid-template-columns: 1fr; text-align: left; padding: 1rem 1.1rem; gap: 0.9rem; }
  .hud__top { flex-direction: row; justify-content: space-between; grid-row: auto; }
  .hud__level { font-size: var(--step-2); color: var(--harbor); }
  .hud__moves { width: 96px; height: 96px; }
  .hud__num { font-size: 2.5rem; }
  .goals { flex-direction: column; gap: 0.4rem; }
  .goal__icon { width: 48px; height: 48px; }
  .bar { width: 100%; }
  .pier { justify-self: center; width: min(100%, 680px, calc((100dvh - 150px) * var(--w, 8) / var(--h, 8) + 32px)); }
}

/* Dialogs. */
.tm-modal .modal__body { text-align: center; }
.tm-modal .modal__actions { justify-content: center; }
.lv-intro { display: grid; justify-items: center; gap: 0.4rem; }
.lv-stars { display: flex; gap: 0.3rem; }
.lv-stars i { width: 40px; height: 40px; display: block; }
.lv-stars i:nth-child(2) { transform: translateY(-8px); }
.lv-stars i:not(.on) { filter: grayscale(1); opacity: 0.35; }
.lv-stars svg, .lv-hearts svg { width: 100%; height: 100%; display: block; }
.lv-hearts { width: 64px; height: 64px; margin: 0 auto 0.5rem; animation: tm-low 1.4s ease-in-out infinite; }
.lv-sub { margin: 0; color: var(--ink-soft); font-weight: 600; }
.lv-goals { list-style: none; margin: 0.4rem 0; padding: 0; display: grid; gap: 0.35rem; justify-items: start; text-align: left; }
.lv-goals li { display: flex; align-items: center; gap: 0.6rem; font-weight: 700; }
.lv-goal-icon { width: 40px; height: 40px; display: block; flex: none; }
.lv-goal-icon svg { width: 100%; height: 100%; display: block; }
.lv-note { font-size: var(--step--1); margin: 0.3rem 0 0; }
.tm-modal ul.lv-goals { justify-content: center; margin-inline: auto; }

.tm-result .modal__title { font-size: var(--step-3); }
.tm-result.is-won .modal__body { background: radial-gradient(ellipse at 50% 0%, #FFF0CC, rgba(255, 240, 204, 0) 70%); border-radius: var(--r-panel) var(--r-panel) 0 0; }
.res-stars { display: flex; justify-content: center; align-items: flex-end; gap: 0.25rem; margin: 0.3rem 0 0.6rem; }
.res-star { width: 72px; height: 72px; display: block; }
.res-star:nth-child(2) { width: 92px; height: 92px; margin-bottom: 14px; }
.res-star svg { width: 100%; height: 100%; display: block; filter: drop-shadow(0 4px 6px rgba(181, 101, 10, 0.4)); }
.res-star:not(.on) { filter: grayscale(1); opacity: 0.28; }
.res-star.on { animation: tm-starin 620ms var(--ease-bounce) both; }
.res-stars--lost .res-star { opacity: 0.22; }
@keyframes tm-starin { 0% { transform: scale(0) rotate(-120deg); opacity: 0; } 60% { transform: scale(1.3) rotate(10deg); opacity: 1; } 100% { transform: scale(1) rotate(0); } }
.res-score { font-size: var(--step-1); margin: 0 auto 0.6rem; }
.res-score strong { font-family: var(--font-display); }
.res-rewards { list-style: none; margin: 0 0 0.8rem; padding: 0; display: flex; justify-content: center; gap: 0.6rem; flex-wrap: wrap; }
.res-rewards li { display: inline-flex; align-items: center; gap: 0.4rem; padding: 0.35rem 0.9rem 0.35rem 0.45rem; border-radius: var(--r-pill); background: #E7EFF6; font-weight: 700; }
.res-rewards li svg { width: 30px; height: 30px; }
.res-rewards strong { font-family: var(--font-display); font-size: var(--step-1); font-variant-numeric: tabular-nums; }
.res-note { font-size: var(--step--1); margin-inline: auto; }
.res-extra { display: flex; flex-wrap: wrap; gap: 0.6rem; justify-content: center; }
.res-restore { text-decoration: none; }
.tm-result p { margin-inline: auto; }

/* ------------------------------------------------------------ round 2: chapters */
.m-journey { display: grid; gap: 1.4rem; }
.m-chapter { isolation: isolate; }
.m-chapter__head {
  position: absolute; left: 12px; top: 12px; z-index: 3; max-width: calc(100% - 24px);
  padding: 0.35rem 0.85rem 0.4rem; border-radius: 16px;
  background: rgba(14, 47, 72, 0.86); color: var(--sail); box-shadow: 0 6px 14px -6px rgba(4, 18, 30, 0.7);
}
.m-chapter__title { margin: 0; font-size: var(--step-1); line-height: 1.15; color: var(--sail); }
.m-chapter__num { display: block; font-size: 0.72rem; letter-spacing: 0.08em; text-transform: uppercase; color: #FFE3A6; }
.m-chapter__meta { margin: 0.1rem 0 0; font-size: var(--step--1); color: #DCE8F2; }
.m-chapter.is-locked .m-scene { filter: saturate(0.45) brightness(0.78); }
.m-gull { animation: m-gull 3.6s ease-in-out infinite alternate; transform-box: fill-box; }
@keyframes m-gull { to { transform: translate(14px, -6px) scaleY(0.7); } }
.m-boat2 { animation: m-bob2 3.8s ease-in-out infinite; }
@keyframes m-bob2 { 50% { transform: translate(150px, 524px) rotate(2deg); } }
.m-star { animation: tm-twinkle 2.4s ease-in-out infinite; transform-box: fill-box; transform-origin: center; }
.m-star:nth-child(2n) { animation-delay: 1.1s; }
.m-beam { transform-origin: 0 -64px; animation: m-sweep 6s ease-in-out infinite alternate; }
@keyframes m-sweep { from { transform: rotate(-8deg); opacity: 0.5; } to { transform: rotate(16deg); opacity: 1; } }
.m-foam { animation: m-foam 2.6s ease-in-out infinite; }
@keyframes m-foam { 50% { opacity: 0.2; } }

/* ------------------------------------------------------------ round 2: blockers */
.b-blocks { position: absolute; inset: 0; z-index: 2; pointer-events: none; }
.b-block {
  position: absolute; left: 0; top: 0;
  width: calc(100% / var(--w)); height: calc(100% / var(--h));
  transform: translate(calc(var(--c) * 100%), calc(var(--r) * 100%));
}
.b-block > svg { position: absolute; inset: 3%; width: 94%; height: 94%; display: block; }
.b-rock > svg { animation: tm-born 360ms var(--ease-bounce); }
.b-rock.is-crack > svg { animation: tm-crack 380ms ease-out; }
@keyframes tm-crack { 20% { transform: translateX(-6%) rotate(-5deg) scale(1.08); } 50% { transform: translateX(5%) rotate(4deg); } }
.b-block.is-gone > svg { animation: tm-rockgone 400ms ease-in forwards; }
@keyframes tm-rockgone { 30% { transform: scale(1.2); opacity: 1; } 100% { transform: scale(0.2) rotate(30deg); opacity: 0; } }
.b-net > svg { inset: 0; width: 100%; height: 100%; opacity: 0.95; }
.b-net.is-gone > svg { animation: tm-netgone 400ms ease-in forwards; }
@keyframes tm-netgone { 40% { transform: scale(1.18); opacity: 1; } 100% { transform: scale(1.5); opacity: 0; } }
.b-sandcell.is-hole::before {
  inset: 0; border-radius: 0;
  background: repeating-linear-gradient(90deg, #A8713E 0 46%, #8E5A2E 46% 50%, #B07A44 50% 96%, #8E5A2E 96% 100%);
  box-shadow: inset 0 0 0 1px rgba(60, 30, 8, 0.4);
}
.b-cell--hole { cursor: default; }
.b-cell--hole:hover { background: transparent; }
.b-sprite.is-docked { z-index: 3; }
.b-sprite.is-docked .b-art { animation: tm-dock 500ms cubic-bezier(0.5, 0, 0.75, 0) forwards; }
@keyframes tm-dock { 30% { transform: translateY(-12%) scale(1.25); } 100% { transform: translateY(80%) scale(0.4); opacity: 0; } }
.b-art.is-charge { animation: tm-charge 260ms ease-in-out; }
@keyframes tm-charge { 50% { transform: scale(1.35) rotate(12deg); } }

/* Special + special combos: bigger, brighter versions of the single effects. */
.b-beam--mega { filter: drop-shadow(0 0 8px rgba(255, 228, 138, 0.95)); animation-duration: 680ms; }
.b-blast--mega { width: calc(560% / var(--w)); animation-duration: 780ms; }
.b-nova--mega { width: 230%; animation-duration: 1050ms; }
.b-flash { position: absolute; inset: 0; background: radial-gradient(circle, rgba(255, 250, 230, 0.75), rgba(255, 250, 230, 0) 70%); animation: tm-flash 560ms ease-out forwards; }
@keyframes tm-flash { 0% { opacity: 0; } 25% { opacity: 1; } 100% { opacity: 0; } }
.b-banner--mega { font-size: clamp(2rem, 8vw, 3.2rem); top: 26%; }

/* ------------------------------------------------------------ round 2: Tide Rush */
.tm-game.is-rush .hud__moves { background: radial-gradient(circle at 40% 30%, #C9F5EC, var(--glass) 60%, #3AA894); box-shadow: inset 0 -5px 0 rgba(20, 90, 76, 0.35), 0 6px 14px -6px rgba(14, 47, 72, 0.6); }
.tm-game.is-rush .hud__num { font-size: 1.7rem; }
.tm-game.is-rush .hud__moves.is-low { background: radial-gradient(circle at 40% 30%, #C9473D, var(--buoy-deep) 65%); }
.hud__moves.is-paused .hud__num { opacity: 0.7; }

/* ------------------------------------------------------------ round 2: level intro */
.lv-chapter { margin: 0; font-family: var(--font-display); font-weight: 600; color: var(--ink-soft); display: flex; gap: 0.5rem; align-items: center; justify-content: center; flex-wrap: wrap; }
.lv-rush { background: #1F6B5C; color: var(--sail); border-radius: var(--r-pill); padding: 0 0.6rem; font-size: 0.85rem; }
.lv-boosts { width: 100%; margin-top: 0.3rem; padding: 0.6rem 0.6rem 0.4rem; border-radius: 18px; background: #EEF4F9; }
.lv-boosts__title { margin: 0 0 0.4rem; font-weight: 700; color: var(--harbor); }
.lv-boosts__list { list-style: none; margin: 0; padding: 0; display: flex; gap: 0.6rem; justify-content: center; flex-wrap: wrap; }
.lv-boost {
  display: grid; justify-items: center; gap: 0.1rem; min-width: 104px; min-height: 44px; padding: 0.45rem 0.6rem 0.4rem;
  border: 2px solid #C9D9E6; border-radius: 16px; background: var(--sail); color: var(--harbor); cursor: pointer;
  font: inherit; font-weight: 700; box-shadow: 0 3px 0 #C9D9E6; transition: transform var(--dur) var(--ease-bounce);
}
.lv-boost:hover { transform: translateY(-2px); }
.lv-boost:focus-visible { box-shadow: var(--focus); }
.lv-boost[aria-pressed="true"] { border-color: var(--lamp-deep); background: #FFF1CC; box-shadow: 0 3px 0 var(--lamp-deep), 0 0 0 3px rgba(247, 177, 60, 0.45); }
.lv-boost[aria-disabled="true"] { opacity: 0.6; cursor: not-allowed; }
.lv-boost__art { position: relative; width: 44px; height: 44px; display: block; }
.lv-boost__art svg { width: 100%; height: 100%; display: block; position: relative; }
.lv-boost__price { display: inline-flex; align-items: center; gap: 0.2rem; font-size: 0.85rem; }
.lv-boost__price svg { width: 16px; height: 16px; }
.lv-boosts__note { margin: 0.45rem 0 0; font-size: var(--step--1); }

/* ------------------------------------------------------------ round 2: result flow */
.tm-result.is-won .modal__actions { flex-direction: column; align-items: stretch; }
.tm-result.is-won .modal__actions .btn:first-child { font-size: var(--step-2); min-height: 60px; animation: tm-nudge 1.6s ease-in-out 1.2s infinite; }
@keyframes tm-nudge { 0%, 70%, 100% { transform: none; } 80% { transform: scale(1.04); } 90% { transform: scale(0.99); } }

/* Pack piece art: a painted token, clipped round so every skin sits like the built-in pieces. */
.tm-piece { width: 100%; height: 100%; display: block; object-fit: cover; clip-path: circle(43% at 50% 50%); pointer-events: none; user-select: none; }
