:root {
  color-scheme: dark;
  --bg: #070b19;
  --ink: #fff8ea;
  --muted: rgba(255, 248, 234, 0.68);
  --panel: rgba(9, 13, 31, 0.74);
  --panel-edge: rgba(255, 255, 255, 0.13);
  --accent: #ffca4b;
  --accent-2: #ff426d;
  --accent-3: #40e0d0;
  --tile: #f43f5e;
  --tile-hi: #ff788f;
  --board: rgba(5, 8, 23, 0.88);
  --cell: rgba(255, 255, 255, 0.075);
  --shadow: 0 24px 80px rgba(0, 0, 0, 0.48);
  font-family: Inter, ui-rounded, "SF Pro Rounded", system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body[data-theme="jamaica"] {
  --accent: #f9d616;
  --accent-2: #34c759;
  --accent-3: #f7a21b;
  --tile: #16a34a;
  --tile-hi: #55da7f;
}

body[data-theme="barbados"] {
  --accent: #ffc726;
  --accent-2: #3aa7ff;
  --accent-3: #70e1f5;
  --tile: #2589e8;
  --tile-hi: #66b8ff;
}

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; overscroll-behavior: none; }

body {
  min-height: 100dvh;
  color: var(--ink);
  background: var(--bg);
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

button, input { font: inherit; }
button { color: inherit; }

.scene {
  position: fixed;
  inset: 0;
  z-index: -2;
  background-image: linear-gradient(180deg, rgba(7, 9, 25, 0.16), rgba(7, 9, 25, 0.76)), url("./assets/caribbean-sunset.webp");
  background-size: cover;
  background-position: center;
  filter: saturate(0.94);
  transform: scale(1.025);
}

.scene::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% 42%, transparent 0 24%, rgba(2, 5, 17, 0.32) 74%), linear-gradient(90deg, rgba(5, 8, 24, 0.4), transparent 28% 72%, rgba(5, 8, 24, 0.4));
}

.game-shell {
  width: min(1320px, 100%);
  min-height: 100dvh;
  margin: 0 auto;
  padding: max(18px, env(safe-area-inset-top)) clamp(14px, 3vw, 36px) max(18px, env(safe-area-inset-bottom));
  display: flex;
  flex-direction: column;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 58px;
}

.brand-lockup { display: flex; align-items: center; gap: 12px; }
.brand-mark {
  width: 42px; height: 42px; display: grid; place-items: center;
  color: #25160a; background: linear-gradient(145deg, #fff3a1, var(--accent));
  border-radius: 13px; box-shadow: 0 6px 22px color-mix(in srgb, var(--accent) 32%, transparent);
  font-size: 1.35rem; transform: rotate(-6deg);
}

h1 { font-size: clamp(1rem, 2vw, 1.35rem); line-height: 1.1; margin: 0; letter-spacing: -0.035em; }
.brand-lockup p { margin: 4px 0 0; color: var(--muted); font-size: 0.76rem; letter-spacing: 0.03em; }
.top-actions { display: flex; gap: 9px; }
.icon-button {
  width: 44px; height: 44px; border: 1px solid var(--panel-edge); border-radius: 14px;
  background: rgba(7, 11, 27, 0.68); backdrop-filter: blur(18px); cursor: pointer;
  display: grid; place-items: center; font-size: 1.05rem; transition: transform .18s ease, background .18s ease;
}
.icon-button:hover { background: rgba(255,255,255,.12); transform: translateY(-1px); }
.icon-button:active { transform: scale(.94); }

.play-layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(156px, .72fr) minmax(390px, 600px) minmax(190px, .92fr);
  align-items: center;
  justify-content: center;
  gap: clamp(16px, 2.5vw, 32px);
  padding: 12px 0 4px;
}

.glass-panel {
  background: linear-gradient(145deg, rgba(18, 23, 49, .77), rgba(5, 8, 24, .68));
  border: 1px solid var(--panel-edge); border-radius: 25px; backdrop-filter: blur(24px);
  box-shadow: var(--shadow); padding: 22px;
}

.score-panel { align-self: center; }
.score-block { padding-bottom: 18px; margin-bottom: 8px; border-bottom: 1px solid rgba(255,255,255,.1); }
.eyebrow { display: block; color: var(--muted); text-transform: uppercase; font-size: .69rem; line-height: 1.2; letter-spacing: .14em; font-weight: 800; }
.score-block strong { display: block; font-size: clamp(2.2rem, 5vw, 4.2rem); letter-spacing: -.07em; line-height: .98; margin-top: 7px; font-variant-numeric: tabular-nums; }
.score-row { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 11px 0; color: var(--muted); font-size: .86rem; }
.score-row strong { color: var(--ink); font-size: 1rem; font-variant-numeric: tabular-nums; }
.combo-card { margin-top: 11px; border-radius: 16px; padding: 13px 15px; display: flex; align-items: center; justify-content: space-between; background: color-mix(in srgb, var(--accent) 13%, transparent); border: 1px solid color-mix(in srgb, var(--accent) 33%, transparent); }
.combo-card span { color: var(--muted); font-size: .82rem; }
.combo-card strong { color: var(--accent); font-size: 1.25rem; }
.combo-card.hot { animation: bounce .38s ease; }

.game-stage { width: 100%; max-width: 600px; justify-self: center; }
.fever-wrap { margin-bottom: 10px; }
.fever-copy { display: flex; justify-content: space-between; align-items: center; margin-bottom: 7px; padding: 0 4px; font-size: .8rem; font-weight: 750; }
.fever-copy b { color: var(--accent); margin-right: 4px; }
.fever-copy strong { color: var(--accent); font-variant-numeric: tabular-nums; }
.meter { height: 12px; position: relative; overflow: hidden; border-radius: 999px; background: rgba(0,0,0,.46); border: 1px solid rgba(255,255,255,.14); box-shadow: inset 0 2px 5px rgba(0,0,0,.5); }
.meter-fill { width: 0%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, var(--accent-2), var(--accent), var(--accent-3)); box-shadow: 0 0 16px color-mix(in srgb, var(--accent) 65%, transparent); transition: width .4s cubic-bezier(.2,.8,.2,1); }
.meter-shine { position: absolute; inset: 1px 0 auto; height: 2px; background: rgba(255,255,255,.42); opacity: .55; }

.board-frame { position: relative; }
.board {
  width: 100%; aspect-ratio: 1;
  display: grid; grid-template-columns: repeat(8, 1fr); grid-template-rows: repeat(8, 1fr);
  gap: clamp(4px, .75vw, 7px); padding: clamp(9px, 1.65vw, 15px);
  border-radius: clamp(22px, 4vw, 34px);
  background: linear-gradient(145deg, rgba(28,34,65,.94), var(--board));
  border: 1px solid rgba(255,255,255,.16);
  box-shadow: 0 28px 80px rgba(0,0,0,.52), inset 0 1px 0 rgba(255,255,255,.16), inset 0 -6px 18px rgba(0,0,0,.35);
  touch-action: none; user-select: none;
}

.cell {
  position: relative; min-width: 0; min-height: 0; border: 0; border-radius: clamp(6px, 1.2vw, 11px);
  background: var(--cell); box-shadow: inset 0 2px 5px rgba(0,0,0,.38), 0 1px 0 rgba(255,255,255,.035);
  padding: 0; cursor: pointer; transition: transform .14s ease, background .14s ease, box-shadow .14s ease;
}
.cell::after {
  content: ""; position: absolute; inset: 0; border-radius: inherit; opacity: 0;
  background: linear-gradient(145deg, rgba(255,255,255,.55), transparent 45%);
}
.cell.filled {
  background: linear-gradient(145deg, var(--piece-a, var(--tile-hi)), var(--piece-b, var(--tile)) 58%, color-mix(in srgb, var(--piece-b, var(--tile)) 70%, #190b22));
  box-shadow: inset 0 2px 2px rgba(255,255,255,.38), inset 0 -4px 6px rgba(0,0,0,.22), 0 5px 9px rgba(0,0,0,.28);
  animation: place .25s cubic-bezier(.2,1.7,.35,1);
}
.cell.filled::after { opacity: .44; }
.cell.special.filled { outline: 2px solid var(--accent); outline-offset: -3px; }
.cell.special.filled::before { content: "✦"; position: absolute; inset: 0; display: grid; place-items: center; font-size: clamp(.55rem, 1.7vw, 1rem); color: #fff6bb; text-shadow: 0 1px 7px rgba(255,226,112,.9); z-index: 1; }
.cell.treasure.filled::before { content: attr(data-icon); position: absolute; inset: 0; display: grid; place-items: center; z-index: 2; font-size: clamp(.62rem, 2.1vw, 1.18rem); line-height: 1; filter: drop-shadow(0 2px 2px rgba(0,0,0,.32)); }
.cell.ghost-valid { background: color-mix(in srgb, var(--accent-3) 60%, transparent); box-shadow: inset 0 0 0 2px color-mix(in srgb, var(--accent-3) 65%, white); transform: scale(.92); }
.cell.ghost-invalid { background: rgba(255,75,91,.3); box-shadow: inset 0 0 0 2px rgba(255,100,110,.65); }
.cell.clearing { animation: clear .42s ease both; z-index: 3; }
.cell:focus-visible { outline: 3px solid white; outline-offset: -2px; }

.rush-badge {
  position: absolute; z-index: 10; top: -16px; left: 50%; transform: translateX(-50%);
  padding: 8px 16px; border-radius: 999px; white-space: nowrap; font-size: .78rem; font-weight: 950; letter-spacing: .08em;
  color: #261400; background: linear-gradient(90deg, var(--accent), #fff5a2, var(--accent));
  box-shadow: 0 5px 30px color-mix(in srgb, var(--accent) 60%, transparent); animation: badgeIn .45s cubic-bezier(.2,1.5,.3,1);
}
.rush-badge[hidden] { display: none; }
.callout {
  position: absolute; z-index: 11; pointer-events: none; top: 45%; left: 50%;
  transform: translate(-50%, -50%) scale(.8); opacity: 0;
  font-size: clamp(1.55rem, 6vw, 3.2rem); font-weight: 1000; letter-spacing: -.05em; white-space: nowrap;
  color: white; text-shadow: 0 4px 0 rgba(22,10,32,.45), 0 0 24px var(--accent-2);
}
.callout.show { animation: callout 1.15s ease both; }

.tray-heading { display: flex; align-items: center; justify-content: space-between; padding: 12px 6px 7px; color: var(--muted); font-size: .76rem; }
.tray-heading > span:first-child { color: var(--ink); font-weight: 780; font-size: .84rem; }
.piece-tray { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; }
.piece-slot {
  position: relative;
  min-height: 104px; border: 1px solid rgba(255,255,255,.12); border-radius: 20px;
  background: linear-gradient(160deg, rgba(28,33,62,.72), rgba(8,11,29,.68));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.08), 0 8px 26px rgba(0,0,0,.22);
  display: grid; place-items: center; padding: 10px 10px 27px; cursor: grab; touch-action: none;
  transition: transform .2s ease, border-color .2s ease, background .2s ease, opacity .2s ease;
}
.piece-slot:hover { transform: translateY(-2px); border-color: rgba(255,255,255,.26); }
.piece-slot.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 13%, rgba(8,11,29,.72)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--accent) 24%, transparent), 0 14px 34px rgba(0,0,0,.3); transform: translateY(-4px); }
.piece-slot.used { opacity: .18; pointer-events: none; transform: scale(.9); }
.mini-grid { --unit: clamp(13px, 3vw, 22px); position: relative; }
.mini-block { position: absolute; width: var(--unit); height: var(--unit); border-radius: calc(var(--unit) * .28); background: linear-gradient(145deg, var(--piece-a, var(--tile-hi)), var(--piece-b, var(--tile))); box-shadow: inset 0 2px 2px rgba(255,255,255,.44), inset 0 -3px 4px rgba(0,0,0,.22), 0 3px 5px rgba(0,0,0,.28); }
.mini-block.treasure-block::after { content: attr(data-icon); position: absolute; inset: 0; display: grid; place-items: center; font-size: calc(var(--unit) * .68); line-height: 1; filter: drop-shadow(0 1px 1px rgba(0,0,0,.3)); }
.piece-treasure { position: absolute; left: 6px; right: 6px; bottom: 7px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: center; color: var(--muted); font-size: .62rem; font-weight: 760; letter-spacing: .01em; pointer-events: none; }

.journey-panel { display: flex; flex-direction: column; gap: 18px; }
.journey-title strong { display: block; margin-top: 6px; font-size: 1rem; }
.mini-meter { height: 6px; border-radius: 99px; background: rgba(255,255,255,.09); overflow: hidden; }
.mini-meter span { display: block; width: 0; height: 100%; background: var(--accent); transition: width .35s ease; }
.collectible-card { display: flex; align-items: center; gap: 12px; border: 1px solid rgba(255,255,255,.1); border-radius: 17px; padding: 12px; background: rgba(255,255,255,.055); }
.food-emoji { display: grid; place-items: center; flex: 0 0 50px; height: 50px; border-radius: 14px; background: linear-gradient(145deg, rgba(255,255,255,.18), rgba(255,255,255,.04)); font-size: 1.8rem; }
.collectible-card strong, .collectible-card small { display: block; }
.collectible-card strong { font-size: .86rem; margin-top: 4px; }
.collectible-card small { color: var(--muted); margin-top: 3px; font-size: .68rem; }
.treasure-shelf { min-height: 39px; display: flex; gap: 7px; align-items: center; }
.treasure-token { width: 35px; height: 35px; display: grid; place-items: center; border-radius: 11px; background: rgba(255,255,255,.075); border: 1px solid rgba(255,255,255,.1); font-size: 1.05rem; }
.treasure-empty { color: var(--muted); font-size: .7rem; line-height: 1.35; }
.goal-list { font-size: .78rem; color: var(--muted); }
.goal-list p { color: var(--ink); font-weight: 750; margin: 0 0 10px; }
.goal-list div { display: flex; gap: 8px; padding: 6px 0; }
.check { color: rgba(255,255,255,.4); font-size: 1rem; line-height: .8; }
.check.done { color: var(--accent); }

.overlay {
  position: fixed; inset: 0; z-index: 50; display: grid; place-items: center; overflow-y: auto;
  padding: max(20px, env(safe-area-inset-top)) 16px max(20px, env(safe-area-inset-bottom));
  background: rgba(3, 5, 16, .72); backdrop-filter: blur(18px);
}
.overlay[hidden] { display: none; }
.start-overlay { background: radial-gradient(circle at 50% 28%, rgba(255,87,93,.18), transparent 36%), rgba(3,5,16,.57); }
.start-card, .modal-card {
  width: min(570px, 100%); border: 1px solid rgba(255,255,255,.16); border-radius: 30px;
  background: linear-gradient(150deg, rgba(25,29,61,.95), rgba(5,8,24,.94)); box-shadow: 0 34px 120px rgba(0,0,0,.68);
  padding: clamp(24px, 5vw, 42px); text-align: center;
}
.start-card { position: relative; overflow: hidden; }
.start-card::before { content: ""; position: absolute; width: 260px; height: 260px; top: -160px; left: -80px; border-radius: 50%; background: var(--accent-2); filter: blur(60px); opacity: .22; }
.start-spark { width: 52px; height: 52px; margin: 0 auto 12px; display: grid; place-items: center; border-radius: 17px; background: linear-gradient(145deg, #fff3a1, var(--accent)); color: #2b1600; font-size: 1.5rem; box-shadow: 0 8px 32px color-mix(in srgb, var(--accent) 40%, transparent); transform: rotate(-7deg); }
.kicker { color: var(--accent); text-transform: uppercase; letter-spacing: .16em; font-weight: 850; font-size: .68rem; margin: 0 0 9px; }
.start-card h2 { margin: 0; font-size: clamp(2.35rem, 9vw, 4.4rem); line-height: .87; letter-spacing: -.075em; text-wrap: balance; }
.start-card h2 span { color: var(--accent); }
.start-copy { color: var(--muted); font-size: .98rem; line-height: 1.5; margin: 20px auto 22px; max-width: 410px; }
.island-ribbon { display: flex; justify-content: center; gap: 5px; margin: -8px 0 16px; }
.island-ribbon span { width: 31px; height: 31px; display: grid; place-items: center; border-radius: 10px; background: rgba(255,255,255,.07); border: 1px solid rgba(255,255,255,.1); font-size: 1rem; transform: rotate(var(--tilt, -3deg)); }
.island-ribbon span:nth-child(even) { --tilt: 4deg; }
.island-picker { border: 0; padding: 0; margin: 0; text-align: left; }
.island-picker legend { width: 100%; color: var(--muted); font-size: .72rem; text-transform: uppercase; letter-spacing: .13em; font-weight: 800; margin-bottom: 9px; }
.island-options { display: grid; grid-template-columns: repeat(3, 1fr); gap: 9px; }
.island-option { position: relative; display: grid; place-items: center; gap: 3px; text-align: center; padding: 12px 7px; border: 1px solid rgba(255,255,255,.11); border-radius: 16px; background: rgba(255,255,255,.045); cursor: pointer; transition: .18s ease; }
.island-option input { position: absolute; opacity: 0; }
.island-option.selected { border-color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); box-shadow: inset 0 0 0 1px color-mix(in srgb, var(--accent) 22%, transparent); }
.island-option:focus-within { outline: 2px solid white; outline-offset: 2px; }
.flag-dot { font-size: 1.55rem; }
.island-option b { font-size: .73rem; line-height: 1.1; }
.island-option small { color: var(--muted); font-size: .63rem; }
.primary-button { width: 100%; min-height: 54px; margin-top: 18px; border: 0; border-radius: 17px; background: linear-gradient(100deg, var(--accent-2), var(--accent)); color: #211006; font-weight: 900; cursor: pointer; box-shadow: 0 10px 30px color-mix(in srgb, var(--accent-2) 30%, transparent); transition: transform .18s ease, filter .18s ease; }
.primary-button span { margin-left: 7px; font-size: 1.25em; }
.primary-button:hover { filter: brightness(1.08); transform: translateY(-1px); }
.primary-button:active { transform: scale(.98); }
.start-note { margin: 11px 0 0; color: rgba(255,255,255,.45); font-size: .68rem; }

.small-card { width: min(390px, 100%); }
.modal-icon { width: 56px; height: 56px; margin: 0 auto; display: grid; place-items: center; border-radius: 18px; background: color-mix(in srgb, var(--accent) 18%, transparent); color: var(--accent); font-size: 1.4rem; }
.modal-card h2 { margin: 14px 0 7px; font-size: 1.9rem; letter-spacing: -.045em; }
.modal-card > p { color: var(--muted); margin: 0; }
.text-button { border: 0; background: transparent; color: var(--muted); padding: 14px; cursor: pointer; font-weight: 720; }
.text-button:hover { color: var(--ink); }
.settings-card { width: min(460px, 100%); max-height: calc(100dvh - 28px); overflow-y: auto; text-align: left; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 18px; }
.modal-head h2 { margin: 4px 0 0; }
.setting-row { display: flex; align-items: center; justify-content: space-between; gap: 16px; padding: 15px 0; border-top: 1px solid rgba(255,255,255,.09); cursor: pointer; }
.setting-row span b, .setting-row span small { display: block; }
.setting-row span b { font-size: .9rem; }
.setting-row span small { color: var(--muted); font-size: .72rem; margin-top: 3px; }
.setting-row input { position: absolute; opacity: 0; }
.setting-row i { position: relative; width: 48px; height: 28px; flex: 0 0 48px; border-radius: 99px; background: rgba(255,255,255,.15); transition: .2s ease; }
.setting-row i::after { content: ""; position: absolute; width: 22px; height: 22px; left: 3px; top: 3px; border-radius: 50%; background: white; box-shadow: 0 2px 7px rgba(0,0,0,.3); transition: .2s ease; }
.setting-row input:checked + i { background: var(--accent-2); }
.setting-row input:checked + i::after { transform: translateX(20px); }
.setting-row input:focus-visible + i { outline: 2px solid white; outline-offset: 3px; }

.result-card { width: min(430px, 100%); }
.result-score { margin: 18px 0; padding: 19px; border-radius: 19px; background: linear-gradient(135deg, color-mix(in srgb, var(--accent) 18%, transparent), color-mix(in srgb, var(--accent-2) 10%, transparent)); border: 1px solid color-mix(in srgb, var(--accent) 25%, transparent); }
.result-score span { display: block; color: var(--muted); font-size: .76rem; text-transform: uppercase; letter-spacing: .13em; }
.result-score strong { display: block; font-size: 3.4rem; letter-spacing: -.07em; line-height: 1; margin-top: 5px; }
.result-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.result-grid div { padding: 12px 5px; border-radius: 14px; background: rgba(255,255,255,.055); }
.result-grid span, .result-grid strong { display: block; }
.result-grid span { color: var(--muted); font-size: .65rem; }
.result-grid strong { margin-top: 4px; }

.confetti-layer { position: fixed; inset: 0; z-index: 40; pointer-events: none; overflow: hidden; }
.confetti { position: absolute; top: -20px; width: 10px; height: 18px; border-radius: 3px; animation: confettiFall var(--fall, 2.4s) linear forwards; transform: rotate(var(--rot)); }

body.rush .board { border-color: color-mix(in srgb, var(--accent) 55%, white); box-shadow: 0 28px 90px rgba(0,0,0,.58), 0 0 34px color-mix(in srgb, var(--accent) 35%, transparent), inset 0 1px 0 rgba(255,255,255,.2); }
body.rush .scene { animation: rushGlow 2s ease-in-out infinite alternate; }

@keyframes place { from { transform: scale(.25) rotate(-8deg); opacity: .4; } to { transform: scale(1); opacity: 1; } }
@keyframes clear { 0% { transform: scale(1); filter: brightness(1); } 45% { transform: scale(1.16); filter: brightness(2.2); } 100% { transform: scale(.12) rotate(12deg); opacity: 0; } }
@keyframes bounce { 50% { transform: scale(1.08); } }
@keyframes badgeIn { from { transform: translateX(-50%) scale(.5); opacity: 0; } }
@keyframes callout { 0% { opacity: 0; transform: translate(-50%,-50%) scale(.55) rotate(-4deg); } 22% { opacity: 1; transform: translate(-50%,-50%) scale(1.08) rotate(1deg); } 70% { opacity: 1; transform: translate(-50%,-50%) scale(1); } 100% { opacity: 0; transform: translate(-50%,-75%) scale(.9); } }
@keyframes confettiFall { to { transform: translate3d(var(--drift), 110vh, 0) rotate(calc(var(--rot) + 900deg)); opacity: .1; } }
@keyframes rushGlow { from { filter: saturate(.95) brightness(1); } to { filter: saturate(1.28) brightness(1.08); } }

@media (max-width: 960px) {
  .play-layout { grid-template-columns: minmax(0, 1fr); max-width: 640px; width: 100%; margin: 0 auto; padding-top: 8px; }
  .score-panel, .journey-panel { display: none; }
  .topbar { max-width: 640px; width: 100%; margin: 0 auto; }
  .game-stage { max-width: min(600px, 78vh); }
}

@media (max-width: 620px) {
  .game-shell { padding-left: 10px; padding-right: 10px; }
  .brand-mark { width: 37px; height: 37px; border-radius: 12px; }
  h1 { font-size: .96rem; }
  .brand-lockup p { max-width: 210px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  .icon-button { width: 40px; height: 40px; border-radius: 13px; }
  .top-actions { gap: 6px; }
  .game-stage { max-width: min(100%, calc(100dvh - 212px)); }
  .board { gap: 4px; padding: 9px; border-radius: 23px; }
  .piece-slot { min-height: 91px; border-radius: 16px; padding: 7px 7px 24px; }
  .mini-grid { --unit: clamp(12px, 4.4vw, 18px); }
  .tray-heading { padding-top: 9px; }
  .tray-heading #tipText { font-size: .67rem; }
  .island-options { grid-template-columns: 1fr; }
  .island-option { grid-template-columns: 36px 1fr; grid-template-rows: auto auto; text-align: left; place-items: center start; padding: 9px 12px; }
  .island-option .flag-dot { grid-row: 1 / 3; }
  .start-card { padding: 24px 20px; }
  .start-card h2 { font-size: clamp(2.4rem, 13vw, 3.55rem); }
  .start-copy { margin: 14px auto 16px; font-size: .88rem; }
  .island-ribbon { margin-bottom: 12px; }
}

@media (max-height: 730px) and (max-width: 960px) {
  .game-shell { padding-top: 8px; padding-bottom: 7px; }
  .topbar { min-height: 44px; }
  .brand-mark { width: 34px; height: 34px; }
  .game-stage { max-width: min(500px, calc(100dvh - 168px)); }
  .piece-slot { min-height: 72px; }
  .tray-heading { padding: 6px 5px 4px; }
  .fever-wrap { margin-bottom: 6px; }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; scroll-behavior: auto !important; transition-duration: .01ms !important; }
}

body.reduce-motion *, body.reduce-motion *::before, body.reduce-motion *::after { animation-duration: .01ms !important; animation-iteration-count: 1 !important; transition-duration: .01ms !important; }

/* V2 — glass-toy redesign, compact laptop layout, regional journey map */
html, body { height: 100%; }
body { overflow: hidden; }

.game-shell {
  height: 100dvh;
  min-height: 0;
  padding: max(9px, env(safe-area-inset-top)) clamp(12px, 2.2vw, 30px) max(9px, env(safe-area-inset-bottom));
  overflow: hidden;
}

.topbar { flex: 0 0 52px; min-height: 52px; }
.play-layout {
  min-height: 0;
  padding: 3px 0 0;
  grid-template-columns: minmax(145px, 180px) minmax(360px, 470px) minmax(205px, 240px);
  gap: clamp(12px, 1.8vw, 25px);
}
.game-stage {
  width: min(470px, 50vw, calc(100dvh - 208px));
  min-width: 0;
  max-width: none;
}
.score-panel, .journey-panel { max-height: calc(100dvh - 86px); overflow: auto; scrollbar-width: none; }
.score-panel::-webkit-scrollbar, .journey-panel::-webkit-scrollbar { display: none; }

.glass-panel,
.piece-slot,
.unlock-banner,
.start-card,
.modal-card {
  background:
    linear-gradient(145deg, rgba(255,255,255,.15), rgba(255,255,255,.025) 34%, rgba(3,8,25,.72) 70%),
    rgba(10,16,38,.58);
  border: 1px solid rgba(255,255,255,.22);
  box-shadow: 0 18px 55px rgba(0,0,0,.4), inset 0 1px 0 rgba(255,255,255,.28), inset 0 -1px 0 rgba(0,0,0,.35);
  backdrop-filter: blur(28px) saturate(1.25);
  -webkit-backdrop-filter: blur(28px) saturate(1.25);
}

.game-controls { align-items: center; }
.control-button {
  height: 40px;
  padding: 0 13px;
  border-radius: 12px;
  border: 1px solid rgba(255,255,255,.16);
  background: linear-gradient(180deg, rgba(255,255,255,.16), rgba(255,255,255,.045));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22), 0 5px 15px rgba(0,0,0,.2);
  font-size: .73rem;
  font-weight: 850;
  cursor: pointer;
  transition: transform .16s ease, filter .16s ease, opacity .16s ease;
}
.control-button span { margin-right: 5px; }
.control-button:hover { transform: translateY(-1px); filter: brightness(1.15); }
.control-button:active { transform: translateY(1px) scale(.97); }
.control-button:disabled { opacity: .35; cursor: not-allowed; transform: none; }
.start-control { color: #082117; border-color: rgba(117,255,190,.5); background: linear-gradient(180deg, #72f1b8, #32bb7b); }
.pause-control { color: #2b2104; border-color: rgba(255,226,110,.5); background: linear-gradient(180deg, #ffe777, #eeb93d); }
.stop-control { color: #fff; border-color: rgba(255,105,120,.48); background: linear-gradient(180deg, #f45f73, #bc3049); }
.stop-modal-icon { color: #ff8595; background: rgba(255,76,99,.16); }
.danger-text { color: #ff94a2; }

.fever-wrap { margin-bottom: 6px; }
.unlock-banner {
  min-height: 44px;
  margin: 0 0 7px;
  border-radius: 15px;
  padding: 6px 8px;
  display: grid;
  grid-template-columns: 34px 1fr auto;
  align-items: center;
  gap: 8px;
}
.unlock-flag { width: 34px; height: 31px; border-radius: 9px; display: grid; place-items: center; background: rgba(255,255,255,.11); font-size: 1.25rem; box-shadow: inset 0 1px 0 rgba(255,255,255,.2); }
.unlock-banner div { min-width: 0; }
.unlock-banner strong, .unlock-banner small { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.unlock-banner strong { font-size: .73rem; }
.unlock-banner small { color: var(--muted); margin-top: 2px; font-size: .62rem; }
.unlock-banner button { border: 1px solid color-mix(in srgb, var(--accent) 45%, transparent); color: var(--accent); background: color-mix(in srgb, var(--accent) 12%, transparent); border-radius: 10px; padding: 7px 9px; font-size: .66rem; font-weight: 850; cursor: pointer; }

.board-frame { isolation: isolate; filter: drop-shadow(0 25px 35px rgba(0,0,0,.38)); }
.board {
  position: relative;
  gap: clamp(4px, .62vw, 6px);
  padding: clamp(9px, 1.2vw, 13px);
  border: 1px solid rgba(255,255,255,.3);
  background:
    radial-gradient(circle at 22% 10%, rgba(255,255,255,.18), transparent 33%),
    linear-gradient(145deg, rgba(41,52,92,.86), rgba(7,12,33,.9));
  box-shadow:
    0 28px 70px rgba(0,0,0,.48),
    inset 0 2px 0 rgba(255,255,255,.32),
    inset 0 -10px 24px rgba(0,0,0,.38),
    inset 0 0 30px rgba(84,169,255,.06);
  transform: perspective(1200px) rotateX(.8deg);
}
.board::before {
  content: "";
  position: absolute;
  z-index: -1;
  inset: 7px;
  border-radius: inherit;
  background: linear-gradient(110deg, transparent 12%, rgba(255,255,255,.08) 25%, transparent 42%);
  pointer-events: none;
}
.cell {
  overflow: visible;
  border: 1px solid rgba(255,255,255,.055);
  background: linear-gradient(150deg, rgba(255,255,255,.105), rgba(255,255,255,.018));
  box-shadow: inset 0 2px 4px rgba(0,0,0,.32), inset 0 1px 0 rgba(255,255,255,.08), 0 1px 0 rgba(255,255,255,.03);
}
.cell.filled {
  border-color: rgba(255,255,255,.3);
  background:
    linear-gradient(145deg, rgba(255,255,255,.52), transparent 28%),
    linear-gradient(155deg, color-mix(in srgb, var(--piece-a, var(--tile-hi)) 76%, transparent), color-mix(in srgb, var(--piece-b, var(--tile)) 76%, rgba(7,11,30,.45)));
  box-shadow:
    inset 0 2px 2px rgba(255,255,255,.55),
    inset 3px 0 7px rgba(255,255,255,.13),
    inset 0 -5px 8px rgba(0,0,0,.31),
    0 6px 10px rgba(0,0,0,.31),
    0 0 12px color-mix(in srgb, var(--piece-a, var(--accent)) 18%, transparent);
  backdrop-filter: blur(5px);
}
.cell.filled::after { opacity: .72; background: linear-gradient(145deg, rgba(255,255,255,.72), transparent 38%); }
.cell.treasure.filled::before { content: none; }
.cell.treasure { z-index: 6; }
.board-treasure {
  position: absolute;
  z-index: 8;
  width: 135%;
  height: 135%;
  left: -17%;
  top: -24%;
  object-fit: contain;
  pointer-events: none;
  filter: drop-shadow(0 4px 3px rgba(0,0,0,.42)) drop-shadow(0 0 6px rgba(255,255,255,.2));
  transform: translateZ(20px);
}
.board-flag { position: absolute; z-index: 8; inset: -10%; display: grid; place-items: center; font-size: clamp(1rem, 3vw, 2rem); filter: drop-shadow(0 4px 3px rgba(0,0,0,.42)); pointer-events: none; }
.cell.treasure::after { opacity: .45; }

.effects-layer { position: absolute; z-index: 18; inset: 0; pointer-events: none; overflow: visible; }
.board-particle { position: absolute; left: 50%; top: 50%; width: var(--size, 10px); height: var(--size, 10px); border-radius: 50% 20% 50% 20%; background: var(--color); box-shadow: 0 0 10px var(--color); animation: boardBurst .75s cubic-bezier(.1,.65,.25,1) forwards; }
.shockwave { position: absolute; left: 50%; top: 50%; width: 40px; height: 40px; margin: -20px; border: 4px solid var(--accent); border-radius: 50%; box-shadow: 0 0 24px var(--accent); animation: shockwave .7s ease-out forwards; }
.score-pop { position: absolute; left: 50%; top: 43%; transform: translate(-50%,-50%); font-size: clamp(1.4rem,5vw,2.8rem); font-weight: 1000; color: #fff; text-shadow: 0 3px 0 rgba(0,0,0,.3), 0 0 18px var(--accent); animation: scorePop .95s ease-out forwards; white-space: nowrap; }
body.screen-shake .board-frame { animation: screenShake .34s ease; }

.tray-heading { padding: 7px 5px 5px; }
.piece-tray { gap: 8px; }
.piece-slot {
  min-height: 96px;
  padding: 5px 7px 23px;
  overflow: hidden;
  border-radius: 18px;
}
.piece-slot::before { content: ""; position: absolute; inset: 0; background: radial-gradient(circle at 50% 20%, color-mix(in srgb, var(--piece-a, var(--accent)) 20%, transparent), transparent 58%); pointer-events: none; }
.piece-slot.selected { transform: translateY(-4px) scale(1.015); }
.piece-visual { position: relative; width: 100%; height: 66px; display: grid; place-items: center; pointer-events: none; }
.piece-art { position: absolute; z-index: 3; width: 74px; height: 74px; object-fit: contain; filter: drop-shadow(0 7px 5px rgba(0,0,0,.42)); }
.piece-flag { position: absolute; z-index: 3; font-size: 3rem; line-height: 1; filter: drop-shadow(0 7px 5px rgba(0,0,0,.42)); }
.piece-slot .mini-grid { --unit: 11px; z-index: 1; opacity: .46; filter: blur(.1px); }
.piece-slot .mini-block { border: 1px solid rgba(255,255,255,.38); background: linear-gradient(145deg, rgba(255,255,255,.5), color-mix(in srgb, var(--piece-b, var(--tile)) 62%, transparent)); }
.mini-block.treasure-block::after { content: none; }
.piece-treasure { z-index: 5; color: rgba(255,255,255,.88); font-size: .65rem; text-shadow: 0 1px 3px rgba(0,0,0,.8); }

.food-emoji { overflow: hidden; padding: 3px; }
.latest-art { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 4px 3px rgba(0,0,0,.35)); }
.treasure-token { overflow: hidden; padding: 2px; }
.treasure-token img { width: 100%; height: 100%; object-fit: contain; filter: drop-shadow(0 2px 2px rgba(0,0,0,.3)); }
.treasure-token .piece-flag { font-size: 1.45rem; }
.next-island-card { border-radius: 15px; padding: 11px 12px; background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 12%, transparent), rgba(255,255,255,.035)); border: 1px solid color-mix(in srgb, var(--accent) 26%, transparent); }
.next-island-card strong, .next-island-card small { display: block; }
.next-island-card strong { margin-top: 4px; font-size: .86rem; }
.next-island-card small { margin-top: 3px; color: var(--muted); font-size: .66rem; line-height: 1.3; }

.journey-start-card { width: min(980px, 100%); padding: clamp(18px, 3vw, 30px); }
.journey-start-card .start-spark { width: 43px; height: 43px; margin-bottom: 8px; }
.journey-start-card h2 { font-size: clamp(2.2rem, 6vh, 3.7rem); line-height: .88; }
.journey-start-card .start-copy { max-width: 620px; margin: 13px auto 15px; font-size: .88rem; }
.journey-map-head { display: flex; align-items: end; justify-content: space-between; gap: 20px; text-align: left; margin: 0 2px 8px; }
.journey-map-head strong { display: block; margin-top: 4px; font-size: .82rem; }
.map-legend { color: var(--muted); font-size: .68rem; white-space: nowrap; }
.map-legend i { display: inline-block; width: 7px; height: 7px; margin-right: 5px; border-radius: 50%; background: var(--accent); box-shadow: 0 0 10px var(--accent); }
.destination-map { display: grid; grid-template-columns: repeat(8, minmax(0,1fr)); gap: 7px; }
.destination-card {
  min-width: 0;
  min-height: 82px;
  position: relative;
  border: 1px solid rgba(255,255,255,.13);
  border-radius: 15px;
  padding: 8px 5px 7px;
  display: grid;
  place-items: center;
  gap: 2px;
  color: var(--ink);
  background: linear-gradient(155deg, rgba(255,255,255,.12), rgba(255,255,255,.025));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.13), 0 5px 14px rgba(0,0,0,.2);
  cursor: pointer;
  transition: .18s ease;
}
.destination-card:hover:not(:disabled) { transform: translateY(-2px); border-color: rgba(255,255,255,.32); }
.destination-card.selected { border-color: var(--card-accent, var(--accent)); box-shadow: 0 0 0 2px color-mix(in srgb, var(--card-accent, var(--accent)) 28%, transparent), inset 0 1px 0 rgba(255,255,255,.23), 0 7px 20px rgba(0,0,0,.3); background: linear-gradient(155deg, color-mix(in srgb, var(--card-accent, var(--accent)) 22%, transparent), rgba(255,255,255,.03)); }
.destination-card.locked { opacity: .52; cursor: not-allowed; filter: saturate(.55); }
.destination-flag { font-size: 1.55rem; line-height: 1; }
.destination-card b { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .62rem; }
.destination-card small { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; color: var(--muted); font-size: .54rem; }
.destination-lock { position: absolute; right: 5px; top: 5px; font-size: .58rem; }
.journey-start-card .primary-button { max-width: 370px; min-height: 49px; margin-top: 13px; }

@keyframes boardBurst { to { transform: translate(var(--dx), var(--dy)) rotate(480deg) scale(.2); opacity: 0; } }
@keyframes shockwave { to { width: 125%; height: 125%; margin: -62.5%; opacity: 0; border-width: 1px; } }
@keyframes scorePop { 0% { opacity: 0; transform: translate(-50%,-25%) scale(.5); } 22% { opacity: 1; transform: translate(-50%,-50%) scale(1.12); } 100% { opacity: 0; transform: translate(-50%,-130%) scale(.88); } }
@keyframes screenShake { 20% { transform: translate(-4px,2px) rotate(-.4deg); } 40% { transform: translate(4px,-2px) rotate(.4deg); } 65% { transform: translate(-2px,-1px); } }

@media (min-height: 900px) and (min-width: 1100px) {
  .play-layout { grid-template-columns: minmax(155px, 190px) minmax(400px, 540px) minmax(215px, 255px); }
  .game-stage { width: min(540px, 50vw, calc(100dvh - 220px)); }
  .piece-slot { min-height: 106px; }
}

@media (max-width: 1050px) {
  .play-layout { grid-template-columns: minmax(0,1fr); }
  .score-panel, .journey-panel { display: none; }
  .game-stage { width: min(470px, calc(100vw - 24px), calc(100dvh - 208px)); max-width: none; }
  .topbar { max-width: 620px; }
}

@media (max-width: 760px) {
  .destination-map { grid-template-columns: repeat(4, minmax(0,1fr)); }
  .journey-map-head { align-items: start; }
  .map-legend { white-space: normal; text-align: right; max-width: 140px; }
}

@media (max-width: 620px) {
  .game-shell { padding: max(7px, env(safe-area-inset-top)) 8px max(6px, env(safe-area-inset-bottom)); }
  .topbar { min-height: 45px; flex-basis: 45px; }
  .brand-mark { display: none; }
  .brand-lockup { gap: 0; }
  .brand-lockup p { max-width: 155px; font-size: .61rem; }
  .game-controls { gap: 4px; }
  .control-button { width: 35px; height: 35px; padding: 0; font-size: 0; }
  .control-button span { margin: 0; font-size: .8rem; }
  .icon-button { width: 35px; height: 35px; }
  .game-stage { width: min(calc(100vw - 16px), calc(100dvh - 194px)); }
  .unlock-banner { min-height: 39px; padding: 4px 6px; margin-bottom: 5px; }
  .unlock-flag { width: 30px; height: 29px; }
  .board { border-radius: 22px; }
  .piece-slot { min-height: 82px; padding-bottom: 21px; }
  .piece-visual { height: 55px; }
  .piece-art { width: 61px; height: 61px; }
  .piece-flag { font-size: 2.5rem; }
  .piece-slot .mini-grid { --unit: 9px; }
  .destination-map { grid-template-columns: repeat(2, minmax(0,1fr)); max-height: 285px; overflow-y: auto; padding: 2px; }
  .destination-card { min-height: 66px; grid-template-columns: 35px 1fr; grid-template-rows: auto auto; text-align: left; place-items: center start; padding: 7px 9px; }
  .destination-flag { grid-row: 1 / 3; }
  .destination-card b { font-size: .67rem; }
  .journey-map-head { display: block; }
  .map-legend { display: block; margin-top: 4px; text-align: left; max-width: none; }
  .journey-start-card .start-copy { font-size: .8rem; }
}

@media (max-height: 700px) and (min-width: 800px) {
  .game-stage { width: min(440px, 48vw, calc(100dvh - 185px)); }
  .piece-slot { min-height: 79px; }
  .piece-visual { height: 53px; }
  .piece-art { width: 58px; height: 58px; }
  .unlock-banner { min-height: 38px; }
  .tray-heading { padding-top: 4px; }
}

/* V3 — laptop-first board, always-visible pieces, and in-game coaching */
.play-layout {
  grid-template-columns: minmax(140px, 170px) minmax(650px, 760px) minmax(200px, 230px);
  gap: clamp(10px, 1.3vw, 20px);
}

.game-stage {
  --board-size: min(520px, calc(100dvh - 145px), calc(100vw - 710px));
  width: calc(var(--board-size) + 226px);
}

.play-surface {
  display: grid;
  grid-template-columns: var(--board-size) 214px;
  gap: 12px;
  align-items: stretch;
}

.board-frame {
  width: var(--board-size);
  align-self: start;
}

.piece-dock {
  min-width: 0;
  min-height: 0;
  padding: 9px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 22px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  background:
    linear-gradient(150deg, rgba(255,255,255,.14), rgba(255,255,255,.025) 34%, rgba(3,8,25,.76) 74%),
    rgba(10,16,38,.62);
  box-shadow: 0 20px 50px rgba(0,0,0,.38), inset 0 1px 0 rgba(255,255,255,.22);
  backdrop-filter: blur(26px) saturate(1.22);
  -webkit-backdrop-filter: blur(26px) saturate(1.22);
}

.coach-card {
  position: relative;
  overflow: hidden;
  flex: 0 0 auto;
  min-height: 86px;
  padding: 10px 11px;
  border: 1px solid color-mix(in srgb, var(--accent) 38%, rgba(255,255,255,.12));
  border-radius: 15px;
  background: linear-gradient(145deg, color-mix(in srgb, var(--accent) 17%, transparent), rgba(255,255,255,.035));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.18), 0 8px 20px rgba(0,0,0,.18);
}
.coach-card::after {
  content: "";
  position: absolute;
  width: 72px;
  height: 72px;
  right: -26px;
  top: -31px;
  border-radius: 50%;
  background: var(--accent);
  opacity: .13;
  filter: blur(2px);
}
.coach-step { display: block; color: var(--accent); font-size: .58rem; font-weight: 950; letter-spacing: .12em; }
.coach-card strong { display: block; margin-top: 4px; font-size: .9rem; line-height: 1.08; }
.coach-card p { margin: 5px 0 0; color: rgba(255,255,255,.76); font-size: .66rem; line-height: 1.3; }

.rules-strip {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 4px;
}
.rules-strip div {
  min-width: 0;
  padding: 5px 2px;
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 10px;
  display: grid;
  place-items: center;
  gap: 2px;
  color: rgba(255,255,255,.5);
  background: rgba(255,255,255,.035);
  font-size: .56rem;
  font-weight: 800;
  transition: .2s ease;
}
.rules-strip b { width: 18px; height: 18px; display: grid; place-items: center; border-radius: 50%; background: rgba(255,255,255,.1); font-size: .58rem; }
.rules-strip div.active { color: #fff; border-color: color-mix(in srgb, var(--accent) 52%, transparent); background: color-mix(in srgb, var(--accent) 14%, transparent); }
.rules-strip div.active b { color: #18202a; background: var(--accent); box-shadow: 0 0 13px color-mix(in srgb, var(--accent) 55%, transparent); }
.rules-strip div.done { color: rgba(255,255,255,.72); }
.rules-strip div.done b { color: #092218; background: #55dba1; }

.piece-dock .tray-heading { flex: 0 0 auto; padding: 2px 2px 0; }
.piece-dock .tray-heading > span:first-child { font-size: .72rem; }
.piece-dock .tray-heading #tipText { max-width: 100px; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; text-align: right; color: var(--accent); font-size: .57rem; }
.piece-dock .piece-tray {
  min-height: 0;
  flex: 1 1 auto;
  display: grid;
  grid-template-columns: 1fr;
  grid-template-rows: repeat(3, minmax(0,1fr));
  gap: 6px;
}
.piece-dock .piece-slot {
  min-height: 0;
  padding: 4px 6px 19px;
  border-radius: 14px;
  overflow: hidden;
}
.piece-dock .piece-slot:hover { transform: translateX(-2px); }
.piece-dock .piece-slot.selected { transform: translateX(-4px) scale(1.015); }
.piece-dock .piece-visual {
  height: 100%;
  min-height: 52px;
  grid-template-columns: minmax(66px, 1fr) minmax(44px, .72fr);
  gap: 3px;
}
.piece-dock .piece-art,
.piece-dock .piece-flag {
  position: relative;
  grid-column: 1;
  grid-row: 1;
  place-self: center;
}
.piece-dock .piece-art { width: 82px; height: 82px; }
.piece-dock .piece-flag { font-size: 3.25rem; }
.piece-dock .piece-slot .mini-grid {
  grid-column: 2;
  grid-row: 1;
  place-self: center;
  --unit: 13px;
  z-index: 3;
  opacity: 1;
  filter: none;
}
.piece-dock .piece-slot .mini-block {
  border-color: rgba(255,255,255,.68);
  background: linear-gradient(145deg, rgba(255,255,255,.75), var(--piece-a, var(--tile-hi)) 33%, var(--piece-b, var(--tile)));
  box-shadow: inset 0 2px 2px rgba(255,255,255,.62), inset 0 -3px 4px rgba(0,0,0,.28), 0 3px 7px rgba(0,0,0,.38);
}
.piece-dock .piece-treasure { bottom: 4px; color: #fff; font-size: .61rem; }
.game-rule-note {
  flex: 0 0 auto;
  margin: 0;
  padding: 6px 7px 2px;
  color: rgba(255,255,255,.65);
  font-size: .57rem;
  line-height: 1.3;
}
.game-rule-note strong { color: var(--accent); }

.cell {
  border-color: rgba(255,255,255,.035);
  background: linear-gradient(150deg, rgba(255,255,255,.065), rgba(0,0,0,.16));
}
.cell.filled {
  border-color: rgba(255,255,255,.58);
  filter: saturate(1.25) brightness(1.07);
  box-shadow:
    inset 0 2px 2px rgba(255,255,255,.72),
    inset 3px 0 7px rgba(255,255,255,.2),
    inset 0 -6px 8px rgba(0,0,0,.35),
    0 6px 11px rgba(0,0,0,.42),
    0 0 15px color-mix(in srgb, var(--piece-a, var(--accent)) 30%, transparent);
}
.cell.ghost-valid {
  background: color-mix(in srgb, var(--accent-3) 76%, transparent);
  box-shadow: inset 0 0 0 3px #fff, 0 0 17px color-mix(in srgb, var(--accent-3) 72%, transparent);
  transform: scale(.9);
}

@media (max-width: 1279px) {
  .play-layout { grid-template-columns: minmax(0,1fr); }
  .score-panel, .journey-panel { display: none; }
  .game-stage {
    --board-size: min(540px, calc(100dvh - 145px), calc(100vw - 260px));
    width: calc(var(--board-size) + 226px);
  }
  .topbar { max-width: 766px; }
}

@media (max-width: 760px) {
  body { overflow-y: auto; }
  .game-shell { height: auto; min-height: 100dvh; overflow: visible; }
  .play-layout { display: block; }
  .game-stage { width: min(100%, 560px); margin: 0 auto; }
  .play-surface { display: flex; flex-direction: column; gap: 8px; }
  .board-frame { width: min(100%, 58dvh); margin: 0 auto; }
  .piece-dock { width: 100%; padding: 7px; border-radius: 18px; gap: 5px; }
  .coach-card { min-height: 0; padding: 8px 10px; display: grid; grid-template-columns: auto 1fr; column-gap: 8px; align-items: center; }
  .coach-step { grid-row: 1 / 3; max-width: 43px; line-height: 1.25; }
  .coach-card strong { margin: 0; font-size: .82rem; }
  .coach-card p { margin: 2px 0 0; font-size: .61rem; }
  .rules-strip { display: none; }
  .piece-dock .piece-tray { grid-template-columns: repeat(3, minmax(0,1fr)); grid-template-rows: 1fr; min-height: 84px; }
  .piece-dock .piece-slot { min-height: 84px; padding: 3px 3px 18px; }
  .piece-dock .piece-visual { min-height: 57px; display: grid; grid-template-columns: 1fr; }
  .piece-dock .piece-art,
  .piece-dock .piece-flag,
  .piece-dock .piece-slot .mini-grid { grid-column: 1; grid-row: 1; }
  .piece-dock .piece-art { width: 62px; height: 62px; transform: translateX(-12px); }
  .piece-dock .piece-flag { font-size: 2.55rem; transform: translateX(-12px); }
  .piece-dock .piece-slot .mini-grid { --unit: 9px; transform: translateX(24px); }
  .game-rule-note { padding: 2px 5px; font-size: .55rem; }
}

@media (max-width: 620px) {
  .board-frame { width: min(100%, 52dvh); }
  .fever-wrap { margin-bottom: 4px; }
  .piece-dock .tray-heading { display: none; }
}

@media (max-height: 700px) and (min-width: 761px) {
  .game-stage {
    --board-size: min(470px, calc(100dvh - 190px), calc(100vw - 260px));
  }
  .fever-wrap { margin-bottom: 4px; }
  .unlock-banner { min-height: 37px; margin-bottom: 5px; }
  .coach-card { min-height: 75px; padding: 8px 9px; }
  .coach-card p { font-size: .61rem; }
  .piece-dock .piece-art { width: 70px; height: 70px; }
  .piece-dock .piece-flag { font-size: 2.8rem; }
  .game-rule-note { font-size: .53rem; padding-top: 3px; }
}

/* V4 — full laptop viewport fit and progressive island picker */
.game-stage {
  --board-size: min(500px, calc(100dvh - 190px), calc(100vw - 710px));
}

.island-carousel {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) 52px;
  align-items: stretch;
  gap: 10px;
}

.island-nav {
  min-height: 104px;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 17px;
  color: #fff;
  background: linear-gradient(160deg, rgba(255,255,255,.16), rgba(8,12,31,.74));
  box-shadow: inset 0 1px 0 rgba(255,255,255,.24), 0 10px 25px rgba(0,0,0,.28);
  font-size: 2rem;
  font-weight: 800;
  cursor: pointer;
  transition: transform .18s ease, border-color .18s ease, opacity .18s ease;
}
.island-nav:hover:not(:disabled) { transform: translateY(-2px); border-color: var(--accent); }
.island-nav:active:not(:disabled) { transform: scale(.96); }
.island-nav:disabled { opacity: .3; cursor: not-allowed; }

.journey-start-card { width: min(680px, 100%); max-height: calc(100dvh - 24px); overflow-y: auto; }
.journey-start-card .destination-map { display: block; }
.destination-featured {
  min-height: 104px;
  padding: 13px 18px;
  grid-template-columns: 78px minmax(0, 1fr);
  place-items: center start;
  gap: 14px;
  text-align: left;
  cursor: default;
}
.destination-featured:hover { transform: none; }
.destination-featured .destination-flag {
  width: 68px;
  height: 68px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(255,255,255,.1);
  box-shadow: inset 0 1px 0 rgba(255,255,255,.22);
  font-size: 2.7rem;
}
.destination-copy { min-width: 0; display: block; }
.destination-featured b { display: block; font-size: 1rem; white-space: normal; }
.destination-featured small { display: block; margin-top: 6px; font-size: .76rem; line-height: 1.35; white-space: normal; }
.island-picker-hint { margin: 8px 0 0; color: var(--muted); font-size: .72rem; line-height: 1.35; text-align: center; }

@media (max-width: 1279px) {
  .game-stage {
    --board-size: min(500px, calc(100dvh - 190px), calc(100vw - 260px));
  }
}

@media (min-height: 850px) and (min-width: 1280px) {
  .game-stage {
    --board-size: min(520px, calc(100dvh - 190px), calc(100vw - 710px));
  }
}

@media (max-width: 760px) {
  .journey-start-card { width: min(560px, 100%); }
  .island-carousel { grid-template-columns: 42px minmax(0,1fr) 42px; gap: 6px; }
  .island-nav { min-height: 88px; border-radius: 14px; font-size: 1.65rem; }
  .destination-featured { min-height: 88px; padding: 9px; grid-template-columns: 52px minmax(0,1fr); gap: 9px; }
  .destination-featured .destination-flag { width: 50px; height: 50px; border-radius: 13px; font-size: 2rem; }
  .destination-featured b { font-size: .82rem; }
  .destination-featured small { margin-top: 3px; font-size: .66rem; }
}

@media (max-height: 700px) and (min-width: 761px) {
  .game-shell { padding-top: max(6px, env(safe-area-inset-top)); padding-bottom: max(6px, env(safe-area-inset-bottom)); }
  .topbar { flex-basis: 46px; min-height: 46px; }
  .brand-mark { width: 40px; height: 40px; }
  .control-button { height: 36px; }
  .icon-button { width: 38px; height: 38px; }
  .game-stage { --board-size: min(470px, calc(100dvh - 190px), calc(100vw - 260px)); }
  .fever-copy { margin-bottom: 4px; }
  .meter { height: 9px; }
  .unlock-banner { min-height: 36px; padding-block: 3px; }
  .piece-dock { padding: 7px; gap: 4px; overflow: hidden; }
  .coach-card { min-height: 66px; padding: 7px 9px; }
  .coach-card strong { font-size: .82rem; }
  .coach-card p { margin-top: 3px; font-size: .58rem; line-height: 1.22; }
  .rules-strip div { padding: 3px 2px; }
  .piece-dock .piece-visual { min-height: 43px; }
  .piece-dock .piece-art { width: 61px; height: 61px; }
  .piece-dock .piece-flag { font-size: 2.5rem; }
  .piece-dock .piece-slot .mini-grid { --unit: 11px; }
  .game-rule-note { display: none; }
  .journey-start-card { padding: 16px 22px; }
  .journey-start-card .start-spark { display: none; }
  .journey-start-card h2 { font-size: clamp(2rem, 7vh, 2.75rem); }
  .journey-start-card .start-copy { margin: 8px auto 10px; }
  .island-picker-hint { margin-top: 6px; }
  .journey-start-card .primary-button { margin-top: 9px; }
}

/* V5 — every block keeps its collectible identity */
.cell.filled {
  overflow: hidden;
  background:
    linear-gradient(145deg, rgba(255,255,255,.68), transparent 25%),
    linear-gradient(155deg, var(--piece-a, var(--tile-hi)), var(--piece-b, var(--tile)) 74%);
}
.cell.treasure::after { opacity: .2; }
.board-treasure {
  width: 86%;
  height: 86%;
  left: 7%;
  top: 7%;
  object-fit: contain;
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.5)) drop-shadow(0 0 4px rgba(255,255,255,.22));
}
.board-flag {
  inset: 0;
  font-size: clamp(.82rem, 1.65vw, 1.3rem);
  filter: drop-shadow(0 3px 2px rgba(0,0,0,.48));
}
.cell.special.filled::before {
  inset: auto 2px 2px auto;
  width: 15px;
  height: 15px;
  z-index: 10;
  border-radius: 50%;
  background: rgba(8,12,30,.78);
  font-size: .58rem;
}

.mini-block {
  overflow: hidden;
  display: grid;
  place-items: center;
}
.mini-treasure-art {
  position: absolute;
  z-index: 3;
  inset: 9%;
  width: 82%;
  height: 82%;
  object-fit: contain;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.55));
}
.mini-treasure-flag {
  position: absolute;
  z-index: 3;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: calc(var(--unit) * .62);
  line-height: 1;
  filter: drop-shadow(0 1px 1px rgba(0,0,0,.45));
}
.piece-dock .piece-slot .mini-block {
  background: linear-gradient(145deg, rgba(255,255,255,.82), var(--piece-a, var(--tile-hi)) 38%, var(--piece-b, var(--tile)));
}

.ghost-treasure-art {
  position: absolute;
  z-index: 9;
  inset: 10%;
  width: 80%;
  height: 80%;
  object-fit: contain;
  opacity: .82;
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.4));
}
.ghost-treasure-flag {
  position: absolute;
  z-index: 9;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: .86;
  font-size: clamp(.82rem, 1.65vw, 1.3rem);
  pointer-events: none;
  filter: drop-shadow(0 2px 2px rgba(0,0,0,.4));
}
.unlock-flag-art {
  width: 100%;
  height: 100%;
  border-radius: 6px;
  object-fit: cover;
  box-shadow: 0 2px 5px rgba(0,0,0,.35);
}
.destination-flag-art {
  display: block;
  width: 54px;
  height: auto;
  max-height: 40px;
  object-fit: contain;
  border-radius: 5px;
  box-shadow: 0 4px 9px rgba(0,0,0,.35);
}
@media (max-width: 760px) {
  .destination-flag-art { width: 42px; max-height: 31px; }
}

/* V6 — player piece controls and collision-safe previews */
.sr-only {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0, 0, 0, 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.piece-tools {
  flex: 0 0 auto;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 6px;
}
.piece-tool-button {
  min-width: 0;
  min-height: 35px;
  padding: 5px 7px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  border: 1px solid color-mix(in srgb, var(--accent) 34%, rgba(255,255,255,.14));
  border-radius: 11px;
  color: #fff;
  background: color-mix(in srgb, var(--accent) 10%, rgba(8,12,31,.74));
  font-size: .62rem;
  font-weight: 850;
  cursor: pointer;
  transition: transform .16s ease, border-color .16s ease, opacity .16s ease;
}
.piece-tool-button:hover:not(:disabled) { transform: translateY(-1px); border-color: var(--accent); }
.piece-tool-button:active:not(:disabled) { transform: scale(.97); }
.piece-tool-button:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.piece-tool-button:disabled { opacity: .42; cursor: not-allowed; }
.piece-tool-icon { color: var(--accent); font-size: 1rem; line-height: 1; }
.piece-tool-button kbd,
.piece-tool-button strong {
  min-width: 20px;
  padding: 2px 5px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 6px;
  color: var(--accent);
  background: rgba(255,255,255,.07);
  font-family: inherit;
  font-size: .57rem;
  font-weight: 850;
  line-height: 1.2;
}

.piece-dock .piece-visual {
  grid-template-columns: minmax(0,1fr) minmax(52px,.8fr);
  gap: 5px;
  overflow: hidden;
}
.piece-collectible-preview,
.piece-shape-preview {
  position: relative;
  min-width: 0;
  width: 100%;
  height: 100%;
  display: grid;
  place-items: center;
  overflow: hidden;
  pointer-events: none;
}
.piece-collectible-preview { grid-column: 1; grid-row: 1; }
.piece-shape-preview { grid-column: 2; grid-row: 1; }
.piece-dock .piece-collectible-preview .piece-art {
  position: static;
  width: min(72px, 96%);
  height: min(72px, 96%);
  transform: none;
  object-fit: contain;
}
.piece-dock .piece-collectible-preview .piece-art.flag-art {
  width: min(64px, 90%);
  height: min(45px, 74%);
  border-radius: 5px;
}
.piece-dock .piece-collectible-preview .piece-flag {
  position: static;
  transform: none;
  font-size: 2.7rem;
}
.piece-dock .piece-shape-preview .mini-grid {
  grid-column: auto;
  grid-row: auto;
  place-self: center;
  transform: none;
  opacity: 1;
  filter: none;
}
.piece-dock .piece-treasure {
  z-index: 12;
  padding-top: 5px;
  background: linear-gradient(transparent, rgba(5,8,24,.9) 45%);
  text-shadow: 0 1px 3px #000;
}

.destination-featured { overflow: hidden; }
.destination-featured .destination-flag { position: relative; z-index: 1; overflow: hidden; flex: 0 0 auto; }
.destination-featured .destination-copy { position: relative; z-index: 2; overflow: hidden; }
.destination-featured .destination-copy b,
.destination-featured .destination-copy small { overflow-wrap: anywhere; }

@media (max-width: 760px) {
  .piece-tools { gap: 5px; }
  .piece-tool-button { min-height: 38px; font-size: .64rem; }
  .piece-dock .piece-visual { grid-template-columns: minmax(0,1fr) minmax(39px,.72fr); gap: 2px; }
  .piece-dock .piece-collectible-preview .piece-art { width: min(52px, 94%); height: min(52px, 94%); transform: none; }
  .piece-dock .piece-collectible-preview .piece-art.flag-art { width: min(46px, 88%); height: min(32px, 65%); }
  .piece-dock .piece-collectible-preview .piece-flag { font-size: 2.15rem; transform: none; }
  .piece-dock .piece-shape-preview .mini-grid { --unit: 8px; transform: none; }
}

@media (max-width: 390px) {
  .piece-tool-button kbd { display: none; }
  .piece-tool-button { padding-inline: 5px; }
  .piece-dock .piece-slot { min-height: 80px; }
}

@media (max-height: 700px) and (min-width: 761px) {
  .piece-tool-button { min-height: 30px; padding-block: 3px; }
  .piece-dock .piece-collectible-preview .piece-art { width: min(56px, 92%); height: min(56px, 92%); }
  .piece-dock .piece-collectible-preview .piece-art.flag-art { height: min(36px, 72%); }
}
