:root {
  color-scheme: dark;
  --bg: #0d1017;
  --bg-soft: #151a24;
  --panel: #1b2230;
  --ink: #eef1f7;
  --muted: #9aa3b4;
  --line: #2a3344;
  --accent: #6ea8fe;

  --board: #1f3a8a;
  --board-edge: #16307a;
  --slot: #0d1017;

  --red: #ef4756;
  --red-edge: #c5303e;
  --yellow: #f5c451;
  --yellow-edge: #d6a02f;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: grid;
  place-items: start center;
  padding: 1.1rem 1rem 1.4rem;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background:
    radial-gradient(1200px 600px at 50% -10%, #182033 0%, transparent 60%),
    var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}

.app {
  width: 100%;
  max-width: 30rem;
  display: flex;
  flex-direction: column;
  gap: 1.05rem;
  align-items: center;
}

.masthead { text-align: center; }

h1 {
  margin: 0;
  font-size: clamp(1.5rem, 5vw, 2.1rem);
  letter-spacing: -0.02em;
  text-wrap: balance;
}

.tagline {
  margin: 0.3rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.controls {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.control-group {
  display: inline-flex;
  padding: 0.25rem;
  gap: 0.25rem;
  background: var(--bg-soft);
  border: 1px solid var(--line);
  border-radius: 0.75rem;
}

.seg {
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.9rem;
  padding: 0.5rem 0.85rem;
  border-radius: 0.55rem;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
  white-space: nowrap;
}

.seg:hover { color: var(--ink); }

.seg.is-active {
  background: var(--panel);
  color: var(--ink);
  box-shadow: 0 1px 0 rgba(255, 255, 255, 0.04) inset;
}

.difficulty { transition: opacity 0.2s ease; }
.difficulty.is-hidden {
  opacity: 0;
  pointer-events: none;
  position: absolute;
}

.level-hint {
  margin: -0.5rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  text-align: center;
  text-wrap: balance;
}

.status {
  margin: 0;
  min-height: 1.5rem;
  font-size: 1.05rem;
  font-weight: 500;
  text-align: center;
  text-wrap: balance;
}

.status .dot {
  display: inline-block;
  width: 0.7rem;
  height: 0.7rem;
  border-radius: 50%;
  margin-right: 0.1rem;
  vertical-align: -0.02em;
  box-shadow: 0 0 0 2px rgba(0, 0, 0, 0.25) inset;
}
.status .dot.red { background: var(--red); }
.status .dot.yellow { background: var(--yellow); }

.board-wrap {
  width: 100%;
  display: grid;
  place-items: center;
}

.board {
  --gap: clamp(0.4rem, 2.2vw, 0.7rem);
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: var(--gap);
  width: 100%;
  /* Stay full size when there is room (tall screens / 100% zoom); only when the
     viewport is short (e.g. browser zoom) shrink just enough to avoid scrolling. */
  max-width: min(100%, calc((100svh - 11rem) * 7 / 6));
  margin-inline: auto;
  padding: var(--gap);
  background: linear-gradient(180deg, var(--board) 0%, var(--board-edge) 100%);
  border-radius: 1rem;
  box-shadow:
    0 1px 0 rgba(255, 255, 255, 0.08) inset,
    0 18px 40px -18px rgba(8, 12, 24, 0.9);
  touch-action: manipulation;
}

.cell {
  position: relative;
  aspect-ratio: 1 / 1;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 30%, #0b0e15 0%, var(--slot) 70%);
  box-shadow: 0 2px 3px rgba(0, 0, 0, 0.45) inset;
  overflow: hidden;
}

.disc {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  transform: translateY(-650%);
  animation: drop 0.32s cubic-bezier(0.34, 0.8, 0.4, 1) forwards;
}

.disc.red {
  background: radial-gradient(circle at 34% 30%, #ff6b78 0%, var(--red) 55%, var(--red-edge) 100%);
}
.disc.yellow {
  background: radial-gradient(circle at 34% 30%, #ffe08a 0%, var(--yellow) 55%, var(--yellow-edge) 100%);
}

@keyframes drop {
  0% { transform: translateY(-650%); }
  70% { transform: translateY(0); }
  82% { transform: translateY(-7%); }
  100% { transform: translateY(0); }
}

/* Column hover affordance (pointer devices only) */
.board.playable .col-hot .cell {
  background: radial-gradient(circle at 32% 30%, #11161f 0%, #11203f 75%);
}

.cell.win .disc {
  animation: drop 0.32s cubic-bezier(0.34, 0.8, 0.4, 1) forwards, pulse 1.1s ease-in-out 0.32s infinite;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.85), 0 0 18px 2px rgba(255, 255, 255, 0.4);
}

@keyframes pulse {
  0%, 100% { filter: brightness(1); }
  50% { filter: brightness(1.35); }
}

.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 0.75rem; }

.hidden { display: none; }

.btn {
  appearance: none;
  font: inherit;
  font-weight: 500;
  padding: 0.6rem 1.3rem;
  border-radius: 0.7rem;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  cursor: pointer;
  transition: border-color 0.15s ease, transform 0.05s ease;
}
.btn:hover { border-color: var(--accent); }
.btn:active { transform: translateY(1px); }

@media (hover: none) {
  .board.playable .col-hot .cell { background: radial-gradient(circle at 32% 30%, #0b0e15 0%, var(--slot) 70%); }
}

/* Short viewports (e.g. browser zoom): trim the chrome further so the board still
   fits above the fold at its full size. */
@media (max-height: 760px) {
  body { padding-top: 0.45rem; padding-bottom: 0.4rem; }
  .app { gap: 0.38rem; }
  .tagline { display: none; }
  h1 { font-size: clamp(1.3rem, 4.5vw, 1.7rem); }
  .status { min-height: 0; }
  .level-hint { margin-top: -0.3rem; }
}
