/* BOUNCE SORT -- css/style.css
 *
 * Palette lives here AND in BS.COLORS (js/game.js). Edit both together.
 * Bright and toy-like: dark navy ground, ivory pegs, candy balls.
 */

:root {
  --bs-ground:    #0f1730;
  --bs-ground-lo: #0a1024;
  --bs-grid:      #1b2547;
  --bs-ivory:     #f4efe2;
  --bs-ivory-lo:  #c9c0ad;
  --bs-text:      #eaf0ff;
  --bs-muted:     #8fa0c8;
  --bs-danger:    #ff3b3b;
  --bs-accent:    #ffd93d;

  --bs-coral: #ff6b6b;
  --bs-sun:   #ffd93d;
  --bs-mint:  #6bcb77;
  --bs-sky:   #4d96ff;

  --bs-font: ui-rounded, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
             "Helvetica Neue", Arial, "Noto Sans", sans-serif;

  --bs-safe-b: env(safe-area-inset-bottom, 0px);
  --bs-safe-t: env(safe-area-inset-top, 0px);

  color-scheme: dark;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  overflow: hidden;
  overscroll-behavior: none;
  background: var(--bs-ground-lo);
  color: var(--bs-text);
  font-family: var(--bs-font);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}

body {
  position: fixed;
  inset: 0;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#stage {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
  cursor: pointer;
}

/* ------------------------------------------------------------------ *
 * In-game pause button. Sits over the top-centre of the board, between
 * the canvas score (left) and the lives pips (right). Only during play.
 * ------------------------------------------------------------------ */
.pause-btn {
  position: absolute;
  top: calc(6px + var(--bs-safe-t));
  left: 50%;
  transform: translateX(-50%);
  z-index: 3;
  width: 46px;
  height: 46px;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  appearance: none;
  border: 0;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.16);
  color: var(--bs-muted);
  font-family: inherit;
  font-size: 15px;
  line-height: 1;
  letter-spacing: 0.06em;
  cursor: pointer;
  touch-action: manipulation;
}
.pause-btn:active { background: rgba(255, 255, 255, 0.14); }
.pause-btn:focus-visible { outline: 3px solid var(--bs-accent); outline-offset: 3px; }
.pause-btn[hidden] { display: none; }

/* ------------------------------------------------------------------ *
 * Overlay screens
 * ------------------------------------------------------------------ */
.ui {
  position: absolute;
  inset: 0;
  display: flex;
  pointer-events: none;
  z-index: 2;
}
.ui.is-open { pointer-events: auto; }
.ui[hidden] { display: none; }

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: calc(24px + var(--bs-safe-t)) 20px calc(22px + var(--bs-safe-b));
  background: radial-gradient(120% 85% at 50% 22%, rgba(15, 23, 48, 0.86) 0%, rgba(10, 16, 36, 0.97) 62%, rgba(10, 16, 36, 0.99) 100%);
  text-align: center;
  animation: fade 0.18s ease-out;
}
.screen[hidden] { display: none; }

@keyframes fade { from { opacity: 0; } to { opacity: 1; } }

.screen-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 420px;
}

/* everything actionable sits in the bottom third, thumb country */
.screen-bottom {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 10px;
  width: 100%;
  max-width: 340px;
  flex: 0 0 auto;
}

/* ------------------------------------------------------------------ *
 * Wordmark
 * ------------------------------------------------------------------ */
.wordmark {
  margin: 0 0 14px;
  line-height: 0.88;
  letter-spacing: -0.02em;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.wordmark .w1,
.wordmark .w2 {
  display: block;
  font-weight: 900;
  font-size: clamp(40px, 15vw, 62px);
}
.wordmark .w1 { color: var(--bs-sun); }
.wordmark .w2 {
  color: var(--bs-sky);
  letter-spacing: 0.22em;
  text-indent: 0.22em;
  font-size: clamp(30px, 11vw, 46px);
}

.tagline {
  margin: 0 0 18px;
  color: var(--bs-muted);
  font-size: 14px;
  line-height: 1.45;
  max-width: 300px;
}
.tagline em { color: var(--bs-text); font-style: normal; font-weight: 700; }

.legend {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(2, auto);
  gap: 7px 18px;
  font-size: 12px;
  color: var(--bs-muted);
  font-weight: 600;
}
.legend li { display: flex; align-items: center; gap: 7px; }

.chip {
  width: 14px;
  height: 14px;
  flex: 0 0 14px;
  display: inline-block;
}
.chip-coral { background: var(--bs-coral); border-radius: 50%; }
.chip-sun {
  background: var(--bs-sun);
  clip-path: polygon(50% 0%, 100% 100%, 0% 100%);
}
.chip-mint { background: var(--bs-mint); border-radius: 2px; }
.chip-sky {
  background: var(--bs-sky);
  clip-path: polygon(50% 0%, 100% 50%, 50% 100%, 0% 50%);
}

/* ------------------------------------------------------------------ *
 * Buttons
 * ------------------------------------------------------------------ */
.btn {
  appearance: none;
  border: 0;
  border-radius: 14px;
  padding: 15px 18px;
  font-family: inherit;
  font-size: 16px;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  min-height: 52px;
  transition: transform 0.08s ease, filter 0.12s ease, opacity 0.12s ease;
  touch-action: manipulation;
}
.btn:active { transform: translateY(1px) scale(0.99); }
.btn:focus-visible { outline: 3px solid var(--bs-accent); outline-offset: 3px; }
.btn[hidden] { display: none; }
.btn:disabled { opacity: 0.55; cursor: default; }

.btn-primary {
  background: var(--bs-sun);
  color: #3a2c00;
  box-shadow: 0 5px 0 #c9a800;
}
.btn-primary:active { box-shadow: 0 3px 0 #c9a800; }

.btn-ghost {
  background: rgba(255, 255, 255, 0.09);
  color: var(--bs-text);
  box-shadow: inset 0 0 0 1.5px rgba(255, 255, 255, 0.18);
}

.btn-quiet {
  background: transparent;
  color: var(--bs-muted);
  font-size: 12px;
  letter-spacing: 0.14em;
  min-height: 40px;
  padding: 10px;
}
.btn-quiet.is-off { color: #5f6d92; }

/* ------------------------------------------------------------------ *
 * Meta text
 * ------------------------------------------------------------------ */
.best {
  margin: 0 0 2px;
  font-size: 12px;
  letter-spacing: 0.16em;
  color: var(--bs-muted);
  font-weight: 700;
}
.best strong { color: var(--bs-text); font-size: 15px; }

.tilt-note {
  margin: 0 0 4px;
  font-size: 12px;
  line-height: 1.4;
  color: var(--bs-muted);
}

.footnote {
  margin: 6px 0 0;
  font-size: 11px;
  letter-spacing: 0.05em;
  color: #5f6d92;
}

.over-title {
  margin: 0 0 6px;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.3em;
  text-indent: 0.3em;
  color: var(--bs-muted);
}

.final-score {
  margin: 0;
  font-size: clamp(64px, 24vw, 96px);
  font-weight: 900;
  line-height: 1;
  color: var(--bs-sun);
}

.final-meta {
  margin: 12px 0 0;
  display: flex;
  gap: 22px;
  justify-content: center;
  font-size: 11px;
  letter-spacing: 0.14em;
  color: var(--bs-muted);
  font-weight: 700;
}
.final-meta strong { color: var(--bs-text); }

.new-best {
  margin: 16px 0 0;
  padding: 6px 14px;
  border-radius: 999px;
  background: var(--bs-mint);
  color: #0e4218;
  font-size: 12px;
  font-weight: 900;
  letter-spacing: 0.18em;
}
.new-best[hidden] { display: none; }

.share-note {
  margin: 0;
  min-height: 16px;
  font-size: 12px;
  color: var(--bs-mint);
  word-break: break-word;
}

/* ------------------------------------------------------------------ *
 * Rotate nag
 * ------------------------------------------------------------------ */
.rotate {
  position: absolute;
  inset: 0;
  z-index: 5;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 24px;
  text-align: center;
  background: var(--bs-ground-lo);
  font-size: 15px;
  font-weight: 700;
  color: var(--bs-text);
}
.rotate[hidden] { display: none; }
.rotate-icon {
  margin: 0;
  font-size: 54px;
  color: var(--bs-accent);
  animation: nudge 1.6s ease-in-out infinite;
}
@keyframes nudge {
  0%, 100% { transform: rotate(0deg); }
  50% { transform: rotate(-90deg); }
}

/* Short viewports: trim the decorative half so the buttons stay reachable. */
@media (max-height: 620px) {
  .wordmark { margin-bottom: 8px; }
  .tagline { margin-bottom: 10px; font-size: 13px; }
  .legend { display: none; }
  .screen { padding-top: calc(16px + var(--bs-safe-t)); }
}

@media (prefers-reduced-motion: reduce) {
  .screen { animation: none; }
  .rotate-icon { animation: none; }
  .btn { transition: none; }
}
