/* ============================================================================
 * LIQUID SORT 3D — STYLESHEET
 * ----------------------------------------------------------------------------
 * File    : css/style.css
 * Purpose : All UI styling: HUD buttons, overlays (menu, tube select,
 *           level select, win screen) and animations.
 *
 * SECTIONS
 *   1. Reset / base
 *   2. HUD (in-game buttons & labels)
 *   3. Overlay base
 *   4. Main menu
 *   5. Tube style selection screen
 *   6. Level selection screen
 *   7. Win screen
 * ========================================================================= */

/* ---------------------------------------------------------------------------
 * 1. RESET / BASE
 * ------------------------------------------------------------------------ */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, Arial, sans-serif;
  background: #1a1040;
}

/* The game canvas fills the whole screen. */
#game {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
}

/* ---------------------------------------------------------------------------
 * 2. HUD  (visible while playing)
 * ------------------------------------------------------------------------ */
#hud {
  position: fixed;
  inset: 0;
  pointer-events: none;   /* buttons re-enable pointer events themselves */
  display: none;
}
#hud.show { display: block; }

/* Level number pill + move counter (top-left, stacked & centered) */
.hud-left {
  position: absolute;
  top: 14px;
  left: 14px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 7px;
}

.badge {
  background: linear-gradient(160deg, #9b5cff 0%, #6d2ce8 45%, #4a00e0 100%);
  color: #fff;
  padding: 10px 26px;
  border-radius: 30px;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 1.5px;
  border: 2px solid rgba(255,255,255,.35);
  box-shadow: 0 5px 0 #35128a, 0 10px 22px rgba(0,0,0,.45),
              inset 0 3px 6px rgba(255,255,255,.4);
  text-shadow: 0 2px 3px rgba(0,0,0,.35);
}

/* Move counter — dark pill with gold border & text (reference-game style) */
.moves {
  background: linear-gradient(180deg, #2c2440 0%, #1a1430 100%);
  color: #ffd35e;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 1.2px;
  padding: 6px 18px;
  border-radius: 20px;
  border: 2px solid #e8b53a;
  box-shadow: 0 4px 10px rgba(0,0,0,.45),
              inset 0 2px 4px rgba(255,255,255,.08);
  text-shadow: 0 1px 2px rgba(0,0,0,.6);
}

/* Button groups */
.btnrow {
  position: absolute;
  top: 14px;
  right: 14px;
  display: flex;
  gap: 10px;
  pointer-events: auto;
}
.bottomrow {
  position: absolute;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 16px;
  pointer-events: auto;
}

/* Squircle-style game button (rounded square, like casual mobile games).
   Base sets shape + gloss; a color class (.teal/.pink/.orange/.blue/
   .greenbtn/.darkbtn) sets the gradient. */
.cbtn {
  position: relative;
  width: 58px;
  height: 58px;
  border-radius: 20px;
  border: none;
  cursor: pointer;
  font-size: 25px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .1s, filter .15s;
  user-select: none;
}
/* glossy highlight bubble on the upper-left */
.cbtn::before {
  content: '';
  position: absolute;
  top: 5px; left: 7px;
  width: 60%; height: 38%;
  border-radius: 50%;
  background: linear-gradient(180deg, rgba(255,255,255,.5), rgba(255,255,255,0));
  pointer-events: none;
}
.cbtn:hover  { filter: brightness(1.12); }
.cbtn:active { transform: translateY(4px) scale(.97); }
.cbtn:disabled {
  filter: grayscale(.9) brightness(.6);
  cursor: default;
}
/* audio button "off" state (music + effects muted) */
.cbtn.off { filter: grayscale(.85) brightness(.65); }

/* -- button colors (match the reference game's candy look) -- */
.cbtn.teal {
  background: linear-gradient(160deg, #4fe0d0 0%, #17b3a5 55%, #0b8177 100%);
  box-shadow: 0 5px 0 #06554e, 0 10px 18px rgba(0,0,0,.4),
              inset 0 2px 4px rgba(255,255,255,.5), inset 0 -4px 6px rgba(0,0,0,.22);
}
.cbtn.pink {
  background: linear-gradient(160deg, #ff8fc0 0%, #f5539a 55%, #cc2f77 100%);
  box-shadow: 0 5px 0 #8f1c50, 0 10px 18px rgba(0,0,0,.4),
              inset 0 2px 4px rgba(255,255,255,.5), inset 0 -4px 6px rgba(0,0,0,.22);
}
.cbtn.orange {
  background: linear-gradient(160deg, #ffc46b 0%, #f79420 55%, #cf6a08 100%);
  box-shadow: 0 5px 0 #8f4703, 0 10px 18px rgba(0,0,0,.4),
              inset 0 2px 4px rgba(255,255,255,.5), inset 0 -4px 6px rgba(0,0,0,.22);
}
.cbtn.blue {
  background: linear-gradient(160deg, #6db2ff 0%, #2f7ef2 55%, #1553c2 100%);
  box-shadow: 0 5px 0 #0c3684, 0 10px 18px rgba(0,0,0,.4),
              inset 0 2px 4px rgba(255,255,255,.5), inset 0 -4px 6px rgba(0,0,0,.22);
}
.cbtn.greenbtn {
  background: linear-gradient(160deg, #6ff09a 0%, #2cc95e 55%, #128a3c 100%);
  box-shadow: 0 5px 0 #0a5c27, 0 10px 18px rgba(0,0,0,.4),
              inset 0 2px 4px rgba(255,255,255,.5), inset 0 -4px 6px rgba(0,0,0,.22);
}
.cbtn.darkbtn {
  background: linear-gradient(160deg, #5a5a68 0%, #35353f 55%, #1c1c24 100%);
  box-shadow: 0 5px 0 #0c0c12, 0 10px 18px rgba(0,0,0,.4),
              inset 0 2px 4px rgba(255,255,255,.3), inset 0 -4px 6px rgba(0,0,0,.3);
}

/* Small yellow counter bubble on a button (undo count etc.) */
.cbtn .cnt {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ffcf3f;
  color: #5a3b00;
  font-size: 11px;
  font-weight: 900;
  border-radius: 10px;
  padding: 2px 6px;
  box-shadow: 0 2px 4px rgba(0,0,0,.3);
}

/* ---------------------------------------------------------------------------
 * 3. OVERLAY BASE  (shared by all full-screen panels)
 * ------------------------------------------------------------------------ */
.overlay {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 20;
  background: radial-gradient(ellipse at 50% 30%,
              rgba(90,40,190,.55), rgba(10,5,35,.92));
  backdrop-filter: blur(3px);
  opacity: 0;
  pointer-events: none;
  transition: opacity .4s;
}
.overlay.show {
  opacity: 1;
  pointer-events: auto;
}

/* Big green action button (PLAY / START / NEXT) */
.bigbtn {
  margin-top: 38px;
  padding: 18px 70px;
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 3px;
  color: #fff;
  border: none;
  border-radius: 50px;
  cursor: pointer;
  background: linear-gradient(145deg, #2fe07c, #0aa14e);
  box-shadow: 0 8px 0 #067636, 0 16px 30px rgba(0,0,0,.45),
              inset 0 3px 5px rgba(255,255,255,.4);
  transition: transform .1s, box-shadow .1s;
}
.bigbtn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 #067636, 0 6px 12px rgba(0,0,0,.4);
}

/* ---------------------------------------------------------------------------
 * 4. MAIN MENU
 * ------------------------------------------------------------------------ */
.title {
  font-size: min(13vw, 72px);
  font-weight: 900;
  letter-spacing: 2px;
  text-align: center;
  line-height: 1.05;
  background: linear-gradient(180deg, #8be9ff 0%, #4facfe 30%,
              #b465ff 65%, #ff5da2 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,.5));
  animation: floaty 3s ease-in-out infinite;
}
@keyframes floaty {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-10px); }
}

.subtitle {
  color: rgba(255,255,255,.8);
  font-size: 16px;
  margin-top: 8px;
  letter-spacing: 4px;
  font-weight: 600;
}

.tube-logo {
  font-size: 64px;
  margin-bottom: 6px;
  animation: wiggle 2.5s ease-in-out infinite;
}
@keyframes wiggle {
  0%, 100% { transform: rotate(-8deg); }
  50%      { transform: rotate(8deg); }
}

.lvl-indicator {
  margin-top: 22px;
  color: rgba(255,255,255,.7);
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 1px;
}

/* ---------------------------------------------------------------------------
 * 5. TUBE STYLE SELECTION SCREEN
 * ------------------------------------------------------------------------ */
.choose-title {
  font-size: min(9vw, 44px);
  font-weight: 900;
  letter-spacing: 2px;
  text-align: center;
  background: linear-gradient(180deg, #8be9ff, #4facfe, #b465ff);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 5px 12px rgba(0,0,0,.5));
}

.style-grid {
  display: flex;
  gap: 18px;
  margin-top: 34px;
  flex-wrap: wrap;
  justify-content: center;
}

.style-card {
  background: rgba(255,255,255,.06);
  border: 3px solid rgba(255,255,255,.22);
  border-radius: 22px;
  padding: 16px 12px 12px;
  cursor: pointer;
  text-align: center;
  transition: transform .15s, border-color .15s, box-shadow .15s;
}
.style-card:hover { transform: translateY(-6px); }
.style-card.sel {
  border-color: #ffd23f;
  box-shadow: 0 0 26px rgba(255,210,63,.5),
              inset 0 0 18px rgba(255,210,63,.12);
  transform: translateY(-6px) scale(1.04);
}
.style-card canvas { display: block; margin: 0 auto; }

.style-name {
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  margin-top: 10px;
  letter-spacing: 2px;
}
.style-card.sel .style-name { color: #ffd23f; }

/* ---------------------------------------------------------------------------
 * 6. LEVEL SELECTION SCREEN  (paged — 20 levels per page, no scrolling)
 * ------------------------------------------------------------------------ */
.level-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
  margin-top: 30px;
  width: min(430px, 88vw);
}

.lvbtn {
  aspect-ratio: 1;
  border: 2px solid rgba(255,255,255,.35);
  border-radius: 16px;
  font-size: 17px;
  font-weight: 900;
  color: #fff;
  cursor: pointer;
  background: linear-gradient(160deg, #a06bff 0%, #7a35f0 45%, #5314c9 100%);
  box-shadow: 0 4px 0 #37109a, 0 8px 14px rgba(0,0,0,.35),
              inset 0 2px 4px rgba(255,255,255,.4);
  transition: transform .1s, filter .15s;
  text-shadow: 0 2px 3px rgba(0,0,0,.35);
}
.lvbtn:hover { transform: scale(1.08); filter: brightness(1.1); }
.lvbtn.done {                       /* already completed */
  background: linear-gradient(160deg, #55f09a 0%, #23c96a 50%, #0a8c42 100%);
  box-shadow: 0 4px 0 #06642e, 0 8px 14px rgba(0,0,0,.35),
              inset 0 2px 4px rgba(255,255,255,.45);
}
.lvbtn.locked {                     /* not reached yet */
  background: rgba(255,255,255,.08);
  border-color: rgba(255,255,255,.12);
  color: rgba(255,255,255,.35);
  box-shadow: none;
  cursor: default;
  text-shadow: none;
}
.lvbtn.locked:hover { transform: none; filter: none; }
.lvbtn.current {                    /* next level to play */
  outline: 3px solid #ffd23f;
  box-shadow: 0 0 18px rgba(255,210,63,.65), 0 4px 0 #37109a;
}

/* pager: ◀  1 / 5  ▶ */
.pager {
  display: flex;
  align-items: center;
  gap: 22px;
  margin-top: 26px;
}
.pgbtn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid rgba(255,255,255,.4);
  cursor: pointer;
  font-size: 21px;
  color: #fff;
  background: linear-gradient(160deg, #55f09a 0%, #23c96a 50%, #0a8c42 100%);
  box-shadow: 0 5px 0 #06642e, 0 10px 18px rgba(0,0,0,.4),
              inset 0 3px 5px rgba(255,255,255,.45);
  transition: transform .1s, filter .15s;
}
.pgbtn:hover { filter: brightness(1.12); }
.pgbtn:active { transform: translateY(4px); box-shadow: 0 1px 0 #06642e; }
.pgbtn:disabled {
  filter: grayscale(.9) brightness(.55);
  cursor: default;
}
.page-label {
  color: #fff;
  font-weight: 900;
  font-size: 18px;
  letter-spacing: 2px;
  min-width: 74px;
  text-align: center;
  text-shadow: 0 2px 4px rgba(0,0,0,.5);
}

/* ---------------------------------------------------------------------------
 * 7. WIN SCREEN
 * ------------------------------------------------------------------------ */
.stars { font-size: min(14vw, 64px); margin-bottom: 6px; }
.stars span {
  display: inline-block;
  animation: pop .5s cubic-bezier(.2, 2.2, .4, 1) both;
}
.stars span:nth-child(2) { animation-delay: .15s; font-size: 1.25em; }
.stars span:nth-child(3) { animation-delay: .3s; }
@keyframes pop {
  from { transform: scale(0) rotate(-30deg); }
  to   { transform: scale(1) rotate(0); }
}

.win-title {
  font-size: min(10vw, 52px);
  font-weight: 900;
  letter-spacing: 1px;
  background: linear-gradient(180deg, #fff6a8, #ffc93c, #ff8a00);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 5px 12px rgba(0,0,0,.5));
}

.win-sub {
  color: rgba(255,255,255,.85);
  margin-top: 10px;
  font-size: 16px;
  font-weight: 600;
}
