:root {
  color-scheme: light;
  --ink: #18202b;
  --muted: #647184;
  --paper: #f8fbff;
  --panel: #ffffff;
  --sky: #78d9ff;
  --mint: #67d9a3;
  --lemon: #ffd45a;
  --coral: #ff7670;
  --violet: #7d6bff;
  --line: #d9e2ec;
  --shadow: 0 24px 60px rgba(24, 32, 43, 0.16);
}

/*
  Beginner note:
  CSS controls how the HTML looks. Class names such as .game-card or .cup
  connect these styles to the matching elements in index.html.
*/
* {
  box-sizing: border-box;
}

html,
body {
  min-height: 100%;
}

body {
  margin: 0;
  color: var(--ink);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    linear-gradient(120deg, rgba(120, 217, 255, 0.28), rgba(103, 217, 163, 0.2)),
    radial-gradient(circle at 15% 15%, rgba(255, 212, 90, 0.5), transparent 24rem),
    radial-gradient(circle at 85% 10%, rgba(255, 118, 112, 0.35), transparent 18rem),
    var(--paper);
}

button {
  font: inherit;
}

.game-shell {
  min-height: 100vh;
  width: min(1080px, calc(100vw - 28px));
  margin: 0 auto;
  display: grid;
  place-items: center;
  padding: 28px 0;
}

.game-card {
  width: 100%;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.88);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.hero {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: start;
  padding: 24px;
  background:
    linear-gradient(90deg, rgba(255, 212, 90, 0.58), rgba(120, 217, 255, 0.42)),
    var(--panel);
  border-bottom: 2px solid var(--ink);
}

.eyebrow {
  margin: 0 0 8px;
  color: #334256;
  font-size: 0.76rem;
  font-weight: 900;
  letter-spacing: 0.11em;
  text-transform: uppercase;
}

h1,
h2,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0;
  font-size: clamp(2.2rem, 8vw, 5.9rem);
  line-height: 0.9;
  letter-spacing: 0;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(1.4rem, 4vw, 2.25rem);
  line-height: 1.05;
  letter-spacing: 0;
}

.score-panel {
  min-width: 116px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 12px 14px;
  text-align: center;
}

.score-panel span,
.hud span {
  display: block;
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.score-panel strong {
  display: block;
  margin-top: 3px;
  font-size: 2rem;
  line-height: 1;
}

.setup-panel,
.play-panel {
  padding: 24px;
}

.setup-panel p {
  max-width: 680px;
  color: var(--muted);
  line-height: 1.55;
}

.instructions-panel {
  margin-bottom: 20px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(255, 212, 90, 0.34), rgba(103, 217, 163, 0.22)), white;
  padding: 16px;
}

.instructions-panel h2 {
  margin-bottom: 10px;
  font-size: 1.45rem;
}

.instructions-panel ul {
  margin: 0;
  padding-left: 20px;
  color: #2c3848;
  line-height: 1.55;
}

.instructions-panel li + li {
  margin-top: 5px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px;
  margin-top: 18px;
}

.mode-button {
  min-height: 158px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--panel);
  color: var(--ink);
  text-align: left;
  padding: 18px;
  cursor: pointer;
  box-shadow: 0 10px 0 rgba(24, 32, 43, 0.08);
  transition: transform 160ms ease, box-shadow 160ms ease, background 160ms ease;
}

.mode-button:hover,
.mode-button:focus-visible {
  transform: translateY(-3px);
  box-shadow: 0 13px 0 rgba(24, 32, 43, 0.1);
  background: #f7fdff;
}

.mode-icon {
  display: grid;
  width: 58px;
  height: 58px;
  margin-bottom: 14px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: var(--lemon);
  font-weight: 900;
}

.mode-button strong,
.mode-button small {
  display: block;
}

.mode-button strong {
  font-size: 1.1rem;
}

.mode-button small {
  margin-top: 5px;
  color: var(--muted);
}

.score-history {
  display: grid;
  grid-template-columns: minmax(0, 0.78fr) minmax(240px, 1fr);
  gap: 12px;
  align-items: stretch;
  margin-bottom: 14px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: linear-gradient(90deg, rgba(255, 212, 90, 0.32), rgba(120, 217, 255, 0.24)), white;
  padding: 14px;
}

.score-history h2 {
  margin-bottom: 6px;
  font-size: 1.45rem;
}

.history-label {
  margin-bottom: 6px;
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.player-name {
  margin: 0;
  font-weight: 900;
}

.best-streak {
  margin: 8px 0 0;
  color: #2c3848;
  font-weight: 900;
}

.score-history-list {
  margin: 0;
  padding: 0;
  display: grid;
  gap: 6px;
  list-style: none;
}

.score-history-list li {
  min-height: 34px;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.82);
  padding: 7px 10px;
  font-size: 0.92rem;
}

.score-history-list .empty-score {
  justify-content: center;
  color: var(--muted);
  font-weight: 800;
}

.score-history-list span {
  min-width: 0;
}

.score-history-list small {
  display: block;
  margin-top: 2px;
  color: var(--muted);
  font-weight: 800;
}

.score-history-list strong {
  font-size: 1rem;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 10px;
}

.hud div {
  min-height: 68px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 12px;
}

.hud strong {
  display: block;
  margin-top: 4px;
  font-size: 1.55rem;
  line-height: 1;
}

.message-text {
  min-height: 32px;
  margin: 18px 0 12px;
  color: #2c3848;
  font-size: 1.05rem;
  font-weight: 800;
  line-height: 1.35;
}

.timer-track {
  width: 100%;
  height: 14px;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 999px;
  background: white;
}

.timer-bar {
  display: block;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, var(--mint), var(--lemon), var(--coral));
  transform: scaleX(0);
  transform-origin: left center;
}

.table {
  position: relative;
  width: min(760px, 100%);
  height: 300px;
  margin: 26px auto 18px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.3), transparent 42%),
    repeating-linear-gradient(90deg, rgba(255, 255, 255, 0.12) 0 18px, transparent 18px 36px),
    #2e8d7a;
  box-shadow: inset 0 -18px 0 rgba(24, 32, 43, 0.14);
  overflow: hidden;
}

.table::after {
  content: "";
  position: absolute;
  left: 4%;
  right: 4%;
  bottom: 32px;
  height: 18px;
  border-radius: 999px;
  background: rgba(24, 32, 43, 0.2);
}

.cup-slot {
  position: absolute;
  left: calc(50% - 72px);
  bottom: 42px;
  z-index: 1;
  width: 144px;
  height: 188px;
  border: 0;
  background: transparent;
  cursor: default;
  transition: transform 420ms cubic-bezier(0.34, 1.56, 0.64, 1);
}

.cup-slot.is-guessable {
  cursor: pointer;
}

.cup-slot.is-guessable:hover .cup,
.cup-slot:focus-visible .cup {
  transform: translateY(-10px) rotate(-1deg);
}

.cup-slot:disabled {
  pointer-events: none;
}

.cup {
  position: absolute;
  left: 16px;
  bottom: 24px;
  width: 112px;
  height: 132px;
  border: 3px solid var(--ink);
  border-radius: 24px 24px 36px 36px;
  background: linear-gradient(135deg, #ff9e99, var(--coral));
  box-shadow: inset -13px -10px 0 rgba(24, 32, 43, 0.09), 0 12px 0 rgba(24, 32, 43, 0.12);
  transform-origin: center bottom;
  transition: transform 180ms ease;
}

.cup::before,
.cup::after {
  content: "";
  position: absolute;
  top: 48px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--ink);
}

.cup::before {
  left: 30px;
}

.cup::after {
  right: 30px;
}

.cup-face {
  position: absolute;
  left: 42px;
  top: 68px;
  width: 28px;
  height: 14px;
  border-bottom: 4px solid var(--ink);
  border-radius: 0 0 999px 999px;
}

.cup-rim {
  position: absolute;
  left: -9px;
  right: -9px;
  bottom: -13px;
  height: 30px;
  border: 3px solid var(--ink);
  border-radius: 999px;
  background: #ffbeb9;
}

.spark {
  position: absolute;
  left: 51px;
  bottom: 18px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--lemon);
  box-shadow: 0 0 22px rgba(255, 212, 90, 0.9), 0 0 42px rgba(255, 212, 90, 0.55);
  opacity: 0;
  transform: scale(0.4);
  transition: opacity 180ms ease, transform 180ms ease;
}

.spark::before,
.spark::after {
  content: "";
  position: absolute;
  inset: 8px 19px;
  border-radius: 999px;
  background: white;
}

.spark::after {
  transform: rotate(90deg);
}

.cup-slot.has-spark .spark {
  opacity: 1;
  transform: scale(1);
  animation: sparkPulse 620ms ease-in-out infinite alternate;
}

.cup-slot.has-spark .cup {
  transform: translateY(-32px) rotate(1deg);
}

.cup-slot.is-correct .cup {
  animation: happyCup 520ms ease-in-out 2;
}

.cup-slot.is-wrong .cup {
  animation: wrongCup 280ms ease-in-out 2;
}

.cup-number {
  position: absolute;
  left: 50%;
  bottom: 0;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 50%;
  background: white;
  font-weight: 900;
  opacity: 0;
  transform: translateX(-50%) translateY(8px) scale(0.86);
  transition: opacity 160ms ease, transform 160ms ease;
}

.cup-slot.show-position-label .cup-number {
  opacity: 1;
  transform: translateX(-50%) translateY(0) scale(1);
}

.actions {
  display: flex;
  gap: 10px;
  justify-content: center;
  flex-wrap: wrap;
}

.primary-button,
.secondary-button {
  min-height: 46px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  padding: 0 18px;
  font-weight: 900;
  cursor: pointer;
}

.primary-button {
  background: var(--ink);
  color: white;
}

.secondary-button {
  background: white;
  color: var(--ink);
}

.primary-button:disabled,
.secondary-button:disabled {
  cursor: wait;
  opacity: 0.58;
}

.is-hidden {
  display: none;
}

@keyframes sparkPulse {
  from {
    filter: brightness(1);
    transform: scale(0.92);
  }
  to {
    filter: brightness(1.16);
    transform: scale(1.08);
  }
}

@keyframes happyCup {
  0%, 100% {
    transform: translateY(-32px) rotate(1deg);
  }
  50% {
    transform: translateY(-44px) rotate(-3deg);
  }
}

@keyframes wrongCup {
  0%, 100% {
    transform: translateX(0);
  }
  33% {
    transform: translateX(-7px);
  }
  66% {
    transform: translateX(7px);
  }
}

@media (max-width: 760px) {
  .game-shell {
    width: min(100vw - 18px, 560px);
    align-items: start;
    padding: 12px 0 20px;
  }

  .hero,
  .setup-panel,
  .play-panel {
    padding: 16px;
  }

  .hero {
    flex-direction: column;
  }

  .score-panel {
    width: 100%;
  }

  .mode-grid,
  .score-history,
  .hud {
    grid-template-columns: 1fr;
  }

  .table {
    height: 260px;
  }

  .cup-slot {
    left: calc(50% - 52px);
    width: 104px;
    height: 160px;
  }

  .cup {
    left: 10px;
    width: 84px;
    height: 108px;
  }

  .cup::before {
    left: 22px;
  }

  .cup::after {
    right: 22px;
  }

  .cup-face {
    left: 31px;
    width: 22px;
  }

  .spark {
    left: 34px;
  }
}
