/* Triple7 — wet glassy fruit under a sunny sky. */
:root {
  --sky-hi: #8fdcff;
  --sky-lo: #34a8e8;
  --sky-deep: #2287c9;
  --sun-core: #fff8d6;
  --sun-glow: #ffe066;
  --deep: #0b4d79;
  --glass: rgba(255, 255, 255, 0.16);
  --glass-edge: rgba(255, 255, 255, 0.45);
  --juice: #ff5a4e;
  --sun: #ffc93c;
  --gem: #3ec6ff;
  --leaf: #37c05e;
  --ink: #07344f;
  --radius: 18px;
  --focus: #1b6ef3;
  font-size: 16px;
}

* { box-sizing: border-box; -webkit-tap-highlight-color: transparent; }
/* Phase 23: one visible focus ring everywhere, keyboard-only (mouse/touch
   clicks never show it) via the browser's own :focus-visible heuristic. */
:focus-visible {
  outline: 3px solid var(--focus);
  outline-offset: 2px;
  border-radius: 4px;
}
html, body { margin: 0; padding: 0; min-height: 100%; }
html {
  /* Lock the page at 100% zoom, always — belt and suspenders with the
     viewport meta's maximum-scale/user-scalable (iOS Safari has, at times,
     ignored user-scalable=no for accessibility reasons, but honors
     touch-action reliably). "pan-x pan-y" keeps normal scrolling/dragging
     working but drops both the double-tap-zoom and pinch-zoom gestures —
     "manipulation" would still allow pinch-zoom, which isn't what we want. */
  touch-action: pan-x pan-y;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}
body {
  font-family: "Trebuchet MS", "Segoe UI", Verdana, sans-serif;
  color: var(--ink);
  background: linear-gradient(180deg, var(--sky-hi) 0%, var(--sky-lo) 55%, var(--sky-deep) 100%);
  background-attachment: fixed;
  touch-action: pan-x pan-y;
  overscroll-behavior: none;
  overflow-x: hidden;
}

/* ── Sky ─────────────────────────────────────────────────────── */
#sky { position: fixed; inset: 0; z-index: -1; overflow: hidden; }
#sky .sun {
  position: absolute; top: -70px; right: -70px; width: 260px; height: 260px;
  border-radius: 50%;
  background: radial-gradient(circle at 40% 40%, var(--sun-core) 0%, var(--sun-glow) 45%, rgba(255, 201, 60, 0.0) 72%);
  animation: sunpulse 6s ease-in-out infinite;
}
@keyframes sunpulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.06); } }
.cloud {
  position: absolute; height: 46px; border-radius: 999px;
  background: rgba(255, 255, 255, 0.75);
  box-shadow: 24px -14px 0 6px rgba(255,255,255,0.65), 54px 2px 0 2px rgba(255,255,255,0.7);
  animation: drift linear infinite;
}
.c1 { top: 12%; width: 110px; animation-duration: 70s; }
.c2 { top: 30%; width: 80px; animation-duration: 95s; animation-delay: -40s; }
.c3 { top: 52%; width: 130px; animation-duration: 120s; animation-delay: -70s; opacity: 0.6; }
@keyframes drift { from { left: -180px; } to { left: 105%; } }
body.reduced-motion .cloud, body.reduced-motion #sky .sun { animation: none; }

/* ── Header / HUD ────────────────────────────────────────────── */
/* Header + game nav pinned together at the top, above scrolling panel
   content, with a translucent sky wash so it reads as one solid bar. */
#fixedhead {
  position: sticky; top: 0; z-index: 40;
  background: linear-gradient(180deg, rgba(34, 135, 201, 0.92), rgba(52, 168, 232, 0.75));
  backdrop-filter: blur(6px);
  box-shadow: 0 4px 14px rgba(7, 52, 79, 0.18);
}
/* Two internal rows: identity+actions on top, currencies on their own full-
   width row below — splitting them out is what actually keeps the pills
   comfortably horizontal instead of squeezed to near-nothing alongside the
   logo and three icon buttons on a narrow phone. */
#topbar {
  display: flex; flex-direction: column; gap: 6px;
  padding: 10px 14px 4px;
  max-width: 860px; margin: 0 auto;
}
.headtop { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.headbtns { display: flex; gap: 8px; flex: none; }
.logo {
  margin: 0; font-size: 1.7rem; letter-spacing: 1px; color: #fff;
  text-shadow: 0 2px 0 rgba(7, 52, 79, 0.35), 0 6px 14px rgba(7, 52, 79, 0.25);
  display: flex; align-items: center; gap: 6px;
}
.logo .seven { color: var(--sun); font-size: 2rem; }
.logo .logomark {
  width: 44px; height: 44px;
  filter: drop-shadow(0 3px 5px rgba(7, 52, 79, 0.4));
}
/* Always horizontal, never wraps to a second line (the resource values are
   core HUD info, not something that should jump around vertically). On a
   screen too narrow to fit all three at comfortable width, the row scrolls
   horizontally instead — a hidden scrollbar so it doesn't look like a
   broken layout. */
#hud {
  display: flex; gap: 6px; min-width: 0;
  justify-content: center; flex-wrap: nowrap;
  overflow-x: auto; scrollbar-width: none;
}
#hud::-webkit-scrollbar { display: none; }
.pill {
  display: flex; align-items: center; gap: 6px; flex: none;
  background: var(--glass); border: 1px solid var(--glass-edge);
  backdrop-filter: blur(6px);
  border-radius: 999px; padding: 5px 12px 5px 8px;
  color: #fff; text-shadow: 0 1px 2px rgba(7,52,79,0.5);
  min-width: 74px; justify-content: flex-start;
  transition: transform 0.15s ease;
}
.pill.bump { transform: scale(1.12); }
.pill .cur-ic { width: 19px; height: 19px; flex: none;
  filter: drop-shadow(0 1px 2px rgba(7,52,79,0.45)); }
.pill b { font-size: 1.02rem; }
.pill small { opacity: 0.85; font-size: 0.68rem; }
.iconbtn {
  background: var(--glass); border: 1px solid var(--glass-edge); color: #fff;
  width: 40px; height: 40px; border-radius: 50%; font-size: 1.2rem; cursor: pointer;
}
.iconbtn:hover { background: rgba(255,255,255,0.3); }
.iconbtn img { width: 24px; height: 24px; vertical-align: middle; }
#btn-daily {
  position: fixed; right: 14px; top: 50%; transform: translateY(-50%);
  z-index: 50; width: 48px; height: 48px; padding: 0;
}
#btn-daily.hidden { display: none; }
.dailybtn {
  background: linear-gradient(180deg, #ffe28a, var(--sun) 55%, #f0a500);
  border-color: #fff; animation: dailypulse 2.4s ease-in-out infinite;
}
@keyframes dailypulse { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.08); } }
body.reduced-motion .dailybtn { animation: none; }

/* ── Tabs ────────────────────────────────────────────────────── */
/* Just the 3 games + the shop-menu toggle now — Grove/Charms/Shop moved
   into the dropdown below so this row stays a tidy 4 items, never 6. */
#tabs {
  display: flex; gap: 6px; justify-content: center; align-items: flex-start;
  padding: 8px 10px; max-width: 860px; margin: 0 auto;
}
.tab, .shopbtn {
  border: 1px solid var(--glass-edge);
  background: var(--glass);
  color: #fff; text-shadow: 0 1px 2px rgba(7,52,79,0.5);
  padding: 8px 16px; border-radius: 999px; font-size: 0.95rem; font-weight: 700;
  cursor: pointer; backdrop-filter: blur(6px);
  transition: background 0.15s ease, transform 0.1s ease;
}
.tab:hover, .shopbtn:hover { transform: translateY(-1px); background: rgba(255,255,255,0.28); }
.tab.active, .shopbtn[aria-expanded="true"] {
  background: linear-gradient(180deg, #fff8, #fff3);
  color: var(--deep); text-shadow: none;
  border-color: #fff;
}
/* Shop menu: one hamburger icon standing in for Grove/Charms/Shop — the
   "categories of shops" — opened as a small dropdown instead of three more
   buttons crowding the nav row. */
.shopmenu { position: relative; }
.shopbtn .hamlines { font-size: 0.85rem; line-height: 1; }
.shopmenu-panel {
  position: absolute; top: calc(100% + 8px); right: 0; z-index: 45;
  display: flex; flex-direction: column; gap: 6px;
  background: rgba(15, 82, 122, 0.94); backdrop-filter: blur(8px);
  border: 1px solid var(--glass-edge); border-radius: 14px;
  padding: 8px; min-width: 150px;
  box-shadow: 0 10px 26px rgba(7, 52, 79, 0.35);
}
.shopmenu-panel.hidden { display: none; }
.shopmenu-panel .tab {
  display: flex; align-items: center; gap: 4px; width: 100%;
  text-align: left; justify-content: flex-start;
}
.tab .lock { margin-left: 5px; }
.tab .lock.hidden { display: none; }
.tab .tabicon, .shopbtn .tabicon { width: 18px; height: 18px; vertical-align: -3px; margin-right: 1px; }
.tab .lock img { width: 13px; height: 13px; vertical-align: -1px; }

/* ── Panels ──────────────────────────────────────────────────── */
main { max-width: 860px; margin: 0 auto; padding: 6px 12px 60px; }
.panel { display: none; position: relative; }
.panel.active { display: block; }
.panel h2 { color: #fff; text-shadow: 0 2px 6px rgba(7,52,79,0.4); margin: 14px 4px 10px; }
.panel h2 small { font-weight: 400; opacity: 0.9; font-size: 0.7em; }

.gamewrap {
  background: var(--glass);
  border: 1px solid var(--glass-edge);
  border-radius: var(--radius);
  backdrop-filter: blur(6px);
  padding: 8px;
  box-shadow: 0 10px 30px rgba(7, 52, 79, 0.25);
}
.gamewrap canvas {
  display: block; width: 100%; height: min(64vh, 500px);
  border-radius: 12px; cursor: pointer;
  /* none, not pan-x/pan-y: a touch-drag on a game canvas is a swipe gesture
     for the game, never a page pan — letting the browser claim it mid-drag
     (as pan-x/pan-y would) breaks match-3 swipe by cancelling the pointer
     sequence. The page itself still can't zoom (html/body keep pan-x pan-y
     + the viewport meta), so this only tightens behavior over the canvas. */
  touch-action: none;
}
/* Taller than the other games: the slots canvas stacks the Beach Getaway
   top screen above the reel cabinet (a modern cabinet's dual display). */
.slotwrap canvas { height: min(58vh, 470px); }

/* Match-3 best-run stats, just under the board. */
.m3stats { display: flex; gap: 8px; flex-wrap: wrap; padding: 8px 4px 0; }
.combostat {
  display: flex; align-items: center; gap: 5px;
  background: var(--glass); border: 1px solid var(--glass-edge);
  backdrop-filter: blur(6px);
  border-radius: 999px; padding: 5px 12px;
  color: #fff; text-shadow: 0 1px 2px rgba(7,52,79,0.5);
  font-size: 0.8rem;
}
.combostat b { font-size: 0.95rem; color: var(--sun); }

.actionbar {
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
  padding: 12px 4px;
}
.tip { color: #eaf7ff; font-size: 0.85rem; text-shadow: 0 1px 2px rgba(7,52,79,0.5); }

.bigbtn {
  font: inherit; font-weight: 800; font-size: 1.05rem;
  color: #7a2c00;
  background: linear-gradient(180deg, #ffe28a, var(--sun) 55%, #f0a500);
  border: none; border-radius: 999px; padding: 12px 26px; cursor: pointer;
  box-shadow: 0 4px 0 #c47f00, 0 8px 18px rgba(7,52,79,0.3);
  transition: transform 0.08s ease, box-shadow 0.08s ease, filter 0.2s;
}
.bigbtn:hover { filter: brightness(1.05); }
.bigbtn:active { transform: translateY(3px); box-shadow: 0 1px 0 #c47f00; }
.bigbtn:disabled { filter: grayscale(0.7) brightness(0.85); cursor: not-allowed; transform: none; }
.minibtn {
  font: inherit; font-size: 0.85rem; font-weight: 700; color: var(--deep);
  background: rgba(255,255,255,0.85); border: none; border-radius: 999px;
  padding: 8px 16px; cursor: pointer;
}
.minibtn:hover { background: #fff; }
.ic-img { width: 1em; height: 1em; vertical-align: -0.12em; }

.lockveil {
  position: absolute; inset: 0; border-radius: var(--radius);
  background: rgba(7, 52, 79, 0.72); backdrop-filter: blur(4px);
  display: flex; flex-direction: column; align-items: center; justify-content: center; text-align: center;
  gap: 10px; color: #fff; font-size: 1.05rem; padding: 20px; z-index: 5;
}
.lockveil.hidden { display: none; }
.veilicon { width: 44px; height: 44px; filter: drop-shadow(0 3px 5px rgba(0,0,0,0.35)); }
.veilprogress {
  width: 100%; max-width: 220px; height: 10px; border-radius: 999px;
  background: rgba(255,255,255,0.2); overflow: hidden;
}
.veilprogress-bar {
  height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--sun), #fff3c4);
  transition: width 0.3s ease;
}
.h3icon { width: 26px; height: 26px; vertical-align: -6px; margin-right: 4px; }

/* ── Cards (grove, shop, achievements) ───────────────────────── */
.cardlist { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.card {
  background: linear-gradient(160deg, rgba(255,255,255,0.9), rgba(235, 249, 255, 0.82));
  border-radius: 14px; padding: 12px 14px;
  box-shadow: 0 6px 16px rgba(7, 52, 79, 0.18);
  border: 1px solid rgba(255,255,255,0.9);
}
.card h3 { margin: 0 0 4px; font-size: 1rem; }
.card p { margin: 2px 0 8px; font-size: 0.8rem; opacity: 0.85; }
.card .row { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.card .owned { font-weight: 800; color: var(--deep); }
.card button { white-space: nowrap; }
.card.done { opacity: 0.95; background: linear-gradient(160deg, #fff6d8, #ffedb0); }
.card.lockedcard { opacity: 0.55; }
.card.prestige { margin-top: 14px; background: linear-gradient(160deg, #fff0d8, #ffd8a6); }
.card.prestige.hidden { display: none; }

/* ── Charm cabinet ───────────────────────────────────────────── */
#charm-sets .setblock { margin-bottom: 16px; }
#charm-sets h3 { color: #fff; text-shadow: 0 1px 4px rgba(7,52,79,0.5); margin: 10px 4px 8px; }
#charm-sets h3 small { font-weight: 400; opacity: 0.9; }
.charmgrid { display: grid; grid-template-columns: repeat(auto-fill, minmax(96px, 1fr)); gap: 8px; }
.charm {
  background: var(--glass); border: 1px solid var(--glass-edge); border-radius: 12px;
  text-align: center; padding: 10px 6px; color: #fff; position: relative;
  backdrop-filter: blur(4px);
}
.charm .glyph { display: block; height: 34px;
  filter: drop-shadow(0 3px 3px rgba(7,52,79,0.4)); }
.charm .glyph img { width: 34px; height: 34px; }
.charm.unowned .glyph { filter: grayscale(1) brightness(0.6) opacity(0.5); }
.charm .cname { font-size: 0.62rem; display: block; margin-top: 4px; line-height: 1.15; }
.charm .lvl {
  position: absolute; top: 4px; right: 6px; font-size: 0.62rem; font-weight: 800;
  background: rgba(255,255,255,0.9); color: var(--deep); border-radius: 8px; padding: 1px 5px;
}
.charm.r4 { border-color: #ffd76a; box-shadow: 0 0 12px rgba(255, 215, 106, 0.45); }
.charm.r3 { border-color: #d9b1ff; }

/* ── Toasts ──────────────────────────────────────────────────── */
#toasts { position: fixed; right: 14px; bottom: 14px; display: flex; flex-direction: column;
  gap: 8px; z-index: 60; pointer-events: none; }
.toast {
  background: rgba(7, 52, 79, 0.92); color: #fff; border-radius: 12px;
  padding: 10px 16px; font-size: 0.9rem; max-width: 300px;
  display: flex; align-items: center; gap: 8px;
  border-left: 4px solid var(--sun);
  animation: toastin 0.25s ease, toastout 0.4s ease 3.6s forwards;
  box-shadow: 0 8px 18px rgba(0,0,0,0.3);
}
.toast img { width: 22px; height: 22px; flex: none; }
.toast.charm { border-left-color: #b06ce8; }
.toast.gold { border-left-color: var(--sun); background: rgba(122, 62, 0, 0.95); }
@keyframes toastin { from { transform: translateX(120%); } to { transform: none; } }
@keyframes toastout { to { opacity: 0; transform: translateY(8px); } }

/* ── Dialogs ─────────────────────────────────────────────────── */
dialog {
  border: none; border-radius: 18px; padding: 20px 22px; max-width: 460px; width: 92%;
  background: linear-gradient(170deg, #f4fbff, #dff2ff);
  color: var(--ink);
  box-shadow: 0 24px 60px rgba(0, 20, 40, 0.45);
}
dialog::backdrop { background: rgba(7, 30, 50, 0.55); backdrop-filter: blur(3px); }
dialog h2 { margin-top: 0; }
.setrow { margin: 10px 0; display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }
.setrow.danger { border-top: 1px dashed #d88; padding-top: 10px; }
.mini { font-size: 0.8rem; opacity: 0.85; }
.intro-steps { list-style: none; margin: 0 0 12px; padding: 0; display: flex; flex-direction: column; gap: 10px; }
.intro-steps li { display: flex; align-items: center; gap: 10px; line-height: 1.35; }
.intro-ic { width: 30px; height: 30px; flex: none; }
#save-code { width: 100%; font-family: monospace; font-size: 0.7rem; border-radius: 8px;
  border: 1px solid #9cc; padding: 8px; resize: vertical; }
#stats-list { columns: 2; }
#stats-list div { break-inside: avoid; padding: 2px 0; }
#paytable-body table { width: 100%; border-collapse: collapse; }
#paytable-body td { padding: 3px 6px; border-bottom: 1px solid rgba(7,52,79,0.15); }
#paytable-body td:last-child { text-align: right; font-weight: 700; }

@media (max-width: 620px) {
  .logo { font-size: 1.2rem; }
  .logo .logomark { width: 32px; height: 32px; }
  .pill b { font-size: 0.9rem; }
  .gamewrap canvas { height: min(58vh, 430px); }
  /* Must follow the .gamewrap rule (equal specificity): keeps the slots
     canvas tall enough for its two stacked screens on phones too. */
  .slotwrap canvas { height: min(62vh, 470px); }
  #stats-list { columns: 1; }
}
@media (max-width: 480px) {
  /* Every pixel counts at this width: drop the little income-rate text
     (still shown at rest via the pill's title tooltip) and shrink pills
     further so Juice/Suncoin/Stargem reliably stay on one line. */
  .pill { min-width: 64px; padding: 4px 9px 4px 7px; gap: 4px; }
  .pill small { display: none; }
  .tab, .shopbtn { padding: 7px 12px; font-size: 0.88rem; }
}

/* ── Debug overlay (?debug=1 or backtick, dev-only) ───────────────────── */
#debug-overlay {
  position: fixed; top: 6px; left: 6px; z-index: 9999;
  background: rgba(0,0,0,0.78); color: #7dffb0;
  font: 11px/1.5 "Courier New", monospace; padding: 8px 10px;
  border-radius: 8px; white-space: pre; pointer-events: none;
}

/* ── Plan II Phase 33: Juice Stand & Squeeze Combo ─────────────────────── */
.meterbar {
  display: inline-block; width: 84px; height: 8px; border-radius: 999px;
  background: rgba(255,255,255,0.22); overflow: hidden; vertical-align: middle;
}
.meterbar > span, .meterbar > #squeeze-bar {
  display: block; height: 100%; width: 0%; border-radius: 999px;
  background: linear-gradient(90deg, var(--sun), #fff3c4);
  transition: width 0.3s ease;
}
.squeezestat b { min-width: 2.8em; text-align: right; }
#panel-match3 .orders { margin: 4px 4px 12px; }
.orderrow {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 6px 0; border-bottom: 1px solid rgba(255,255,255,0.12);
}
.orderrow:last-child { border-bottom: none; }
.orderlabel { flex: 1 1 160px; font-size: 0.9rem; }
.orderbar { flex: 0 0 84px; }
.orderprog { min-width: 4em; text-align: right; opacity: 0.85; }
.orderpay { color: var(--sun); font-weight: 700; }
.orderreroll { padding: 4px 10px; }

/* ── Plan II Phase 34: Weather Dial & Sun Meter ─────────────────────────── */
.modebtn { opacity: 0.78; }
.modebtn.done {
  background: linear-gradient(180deg, #ffe28a, var(--sun) 70%);
  color: #7a2c00; opacity: 1; font-weight: 800;
}
#mode-dial { padding-top: 0; gap: 8px; }
.sunmeterstat b { min-width: 3.4em; text-align: right; }

/* ── Plan II Phase 36: The Sunline ──────────────────────────────────────── */
#sunline {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  padding: 2px 10px 6px; color: #fff; font-size: 0.78rem;
  text-shadow: 0 1px 2px rgba(7,52,79,0.5);
}
#sunline .sunlinebar { width: 160px; }
#sunline.resonant #sunline-bar {
  background: linear-gradient(90deg, #ffe066, #fff8d6, #ffe066);
}
#sunline.resonant b { color: var(--sun); }

/* ── Plan II Phase 37: The Charm Bracelet ───────────────────────────────── */
.braceletbar {
  background: var(--glass); border: 1px solid var(--glass-edge);
  border-radius: 12px; padding: 8px 14px; margin-bottom: 12px;
  color: #fff; text-shadow: 0 1px 2px rgba(7,52,79,0.5);
}
.charm { position: relative; }
.charm:not(.unowned) { cursor: pointer; }
.charm.equipped {
  outline: 2px solid var(--sun);
  outline-offset: -1px;
  box-shadow: 0 0 12px rgba(255, 201, 60, 0.45);
}
.charm .eqmark {
  position: absolute; top: 2px; right: 5px;
  color: var(--sun); font-size: 0.85rem;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
}

/* ── Plan II Phase 39: The Moonlit Tidepool ─────────────────────────────── */
#panel-tidepool { position: relative; }
body.night #sky {
  background: linear-gradient(180deg, #1a2247 0%, #232f63 55%, #16204a 100%);
}
body.night #sky .sun {
  background: radial-gradient(circle at 42% 38%, #fdfbf1 0%, #e8e4d0 55%, rgba(232,228,208,0) 72%);
  box-shadow: 0 0 60px rgba(232, 228, 208, 0.35);
}
body.night #sky .cloud { opacity: 0.25; }
.pill.pearl b { color: #e8ddff; }
.creatureglyph { font-size: 22px; line-height: 34px; color: #cfe8ff; }
#cast-result { margin: 6px 4px 12px; color: #fff; }
#aquarium-card { margin: 4px 4px 12px; }
