/* Gamerall: оригінал hakimsaqib/Ball-sorting-Game (MIT, див. LICENSE.txt). Зміни позначено коментарями «Gamerall». */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Franklin Gothic Medium", "Arial Narrow", Arial, sans-serif;
}
/* Gamerall: у рамці сторінка прозора й показувала темний фон плеєра, тож чорний текст зливався з ним; додано білий фон і колонку на всю висоту */
body {
  background: #fff;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
h1 {
  text-align: center;
  margin: 4px;
}
/* Gamerall: рядок стану й кнопка «Новая игра» */
.bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 4px 12px 8px;
}
.status {
  font-size: 15px;
}
.status.win {
  font-weight: bold;
  color: #0a7a2f;
}
.restart {
  flex: none;
  padding: 8px 16px;
  font-size: 15px;
  cursor: pointer;
}
/* Gamerall: лічильник ходів */
.moves {
  flex: none;
  font-size: 15px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
/* Gamerall: стандартні правила (2026-11-19) — вісім колб у два ряди по чотири; колби однакової висоти й не ростуть */
.container {
  position: relative;
  background: linear-gradient(45deg, #2f9df6, #68dbdb, #aae113);
  width: 100%;
  flex: 1 1 auto;
  padding: 18px 10px;
  display: grid;
  grid-template-columns: repeat(4, auto);
  justify-content: center;
  align-content: start;
  gap: 20px 24px;
}
/* Gamerall: колба — кнопка на чотири кульки; кульки складаються знизу вгору */
.room {
  --ball: 56px;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  gap: 4px;
  width: calc(var(--ball) + 20px);
  height: calc(4 * var(--ball) + 3 * 4px + 20px);
  padding: 10px;
  border: none;
  border-radius: 15px;
  background: linear-gradient(45deg, #2f9df6, #a71178, #c618e9);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  transition: transform 0.15s ease-out;
}
@media (hover: hover) {
  .room:hover {
    transform: scale(0.97);
  }
}
.room:focus-visible {
  outline: 3px solid #10233d;
  outline-offset: 3px;
}
/* Gamerall: зібрана колба (чотири кульки одного кольору) — золота рамка */
.room.room--done {
  box-shadow: 0 0 0 3px #ffd54a, 0 0 16px rgba(255, 213, 74, 0.8);
}
.room[aria-pressed="true"] {
  box-shadow: 0 0 0 3px #fff;
}
.circle {
  flex: none;
  width: var(--ball);
  height: var(--ball);
  border-radius: 50%;
  background-color: white;
  transition: translate 0.15s ease-out;
}
/* Gamerall: взята верхня кулька піднімається над колбою */
.circle.lifted {
  translate: 0 -14px;
  outline: 3px solid #fff;
}
/* Gamerall: екран перемоги поверх поля */
.victory {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(16, 35, 61, 0.55);
}
.victory[hidden] {
  display: none;
}
.victory__card {
  display: grid;
  justify-items: center;
  gap: 12px;
  padding: 28px 32px;
  border-radius: 18px;
  background: #fff;
  box-shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  text-align: center;
}
.victory__title {
  font-size: 34px;
  font-weight: bold;
  color: #0a7a2f;
}
.victory__text {
  font-size: 17px;
}
.victory__again {
  padding: 10px 22px;
  font-size: 17px;
  cursor: pointer;
}
@media (prefers-reduced-motion: no-preference) {
  .victory:not([hidden]) {
    animation: victory-in 0.2s ease-out;
  }
  @keyframes victory-in {
    from {
      opacity: 0;
    }
    to {
      opacity: 1;
    }
  }
}
@media (prefers-reduced-motion: reduce) {
  .room,
  .circle {
    transition: none;
  }
}
