:root {
  --bg-dark: #193b66;
  --bg-mid: #2f6ba6;
  --bg-light: #d9efff;
  --accent: #f5b300;
  --text-light: #f8fbff;
  --text-dark: #102033;
  --ok: #1f9d60;
  --bad: #c23a4d;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  background: linear-gradient(180deg, var(--bg-dark), #0f2540);
  color: var(--text-light);
  min-height: 100vh;
}

.game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  margin: 0;
}

.game__header {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  z-index: 4;
  padding: 0.75rem 1rem;
  background: #0a132277;
}

.game__title {
  margin: 0;
  color: var(--accent);
}

.hud {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
}

.hud__item {
  margin: 0;
  padding: 0.4rem 0.7rem;
  border-radius: 0.5rem;
  background: #ffffff18;
}

.playfield {
  position: relative;
  height: 100vh;
  margin-top: 0;
  border: none;
  border-radius: 0;
  overflow: hidden;
  background: linear-gradient(180deg, var(--bg-mid), var(--bg-light));
}

.playfield__bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.35;
}

.playfield__bg--hidden {
  display: none;
}

.fall-zone {
  position: absolute;
  inset: 0;
}

.book {
  position: absolute;
  left: calc(50% - 5.5rem);
  bottom: 1rem;
  width: 14rem;
  height: 7.5rem;
  border: 0.22rem solid #0f2442;
  border-radius: 0.8rem;
  background: linear-gradient(180deg, #fefefe, #dfecff);
  color: var(--text-dark);
  font-weight: 700;
  padding: 0.2rem;
  display: grid;
  place-items: center;
  gap: 0.1rem;
  touch-action: none;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.25);
  grid-template-rows: 1fr auto;
}

.book__image {
  width: 8.4rem;
  height: auto;
  object-fit: contain;
}

.book__topic {
  font-size: 0.9rem;
  color: #0f2442;
  background: rgba(255, 255, 255, 0.85);
  border: 0.12rem solid rgba(15, 36, 66, 0.35);
  border-radius: 0.55rem;
  padding: 0.2rem 0.45rem;
  text-shadow: none;
  width: 13.6rem;
  max-width: calc(100% - 0.6rem);
  justify-self: center;
  text-align: center;
  transform: translateY(-0.05rem);
  line-height: 1.05;
  white-space: normal;
  overflow-wrap: anywhere;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
  overflow: hidden;
}

.falling-word {
  position: absolute;
  min-width: 10rem;
  max-width: 20rem;
  padding: 0.65rem 1rem;
  background: #fff;
  color: var(--text-dark);
  border-radius: 0.6rem;
  text-align: center;
  white-space: pre-line;
  line-height: 1.15;
  box-shadow: 0 0.25rem 0.75rem #00000033;
  font-weight: 700;
  font-size: 1.2rem;
  transition: transform 0.25s linear, opacity 0.25s linear;
}

.falling-word--gold {
  background: linear-gradient(180deg, #fff7bf, #ffd95e);
  border: 0.18rem solid #c99400;
  box-shadow: 0 0 1.4rem #ffe366;
  font-size: 1.4rem;
  transform: scale(1.08);
}

.falling-word--ok {
  background: rgba(31, 157, 96, 0.95);
  border: 0.12rem solid #0f6b3f;
  color: #fff;
}

.falling-word--bad {
  background: rgba(194, 58, 77, 0.95);
  border: 0.12rem solid #8f2435;
  color: #fff;
}

.lives {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.lives__heart {
  font-size: 1.1rem;
  line-height: 1;
  filter: drop-shadow(0 0.1rem 0.1rem rgba(0, 0, 0, 0.35));
}

.lives__heart--lost {
  opacity: 0.2;
  filter: grayscale(1);
}

.overlay {
  position: absolute;
  inset: 0;
  background: #0a1322cc;
  display: grid;
  place-items: center;
  z-index: 5;
}

.intro-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  z-index: 0;
}

.overlay--hidden {
  display: none;
}

.intro-start {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.8rem;
  padding: 1rem;
}

.intro-start.card {
  border: none;
  width: min(52rem, 94vw);
}

.intro-start h2 {
  margin: 0;
  font-size: 3.1rem;
  color: #0a5f95;
  text-shadow: 0 0.08rem 0.1rem #ffffffcc;
}

.intro-start p {
  margin: 0;
  font-size: 1.35rem;
  font-weight: 700;
  text-align: center;
}

.intro-start .rules {
  font-size: 1.15rem;
  line-height: 1.35;
}

.intro-start .rules li {
  white-space: nowrap;
}

.intro-start .button {
  font-size: 1.25rem;
  padding: 0.75rem 1.35rem;
}

.card {
  width: min(42rem, 90vw);
  background: #ffffff;
  color: var(--text-dark);
  border-radius: 1rem;
  padding: 1.2rem 1.4rem;
  border: 0.2rem solid var(--accent);
  position: relative;
  z-index: 1;
}

.card--small {
  width: min(22rem, 80vw);
  text-align: center;
}

.countdown {
  font-size: 3rem;
  margin: 0.5rem 0 0;
  color: var(--accent);
  font-weight: 800;
}

.rules {
  margin: 0.8rem 0 1rem;
}

.button {
  padding: 0.55rem 1rem;
  border: none;
  border-radius: 0.5rem;
  background: var(--bg-mid);
  color: #fff;
  font-size: 1rem;
  font-weight: 700;
}

.button:focus-visible,
.book:focus-visible {
  outline: 0.18rem solid var(--accent);
  outline-offset: 0.1rem;
}

.book--boost {
  width: 21rem;
}

.event-banner {
  position: absolute;
  top: 5.2rem;
  left: 50%;
  transform: translateX(-50%);
  background: #113a74ea;
  border: 0.15rem solid #f5b300;
  color: #fff;
  padding: 0.5rem 1rem;
  border-radius: 0.6rem;
  font-weight: 800;
  z-index: 4;
}

.event-banner--hidden {
  display: none;
}

.motivation-toast {
  position: absolute;
  top: 8.1rem;
  left: 50%;
  transform: translateX(-50%);
  background: #1f9d60f0;
  color: #fff;
  padding: 0.45rem 0.9rem;
  border-radius: 0.6rem;
  font-weight: 700;
  z-index: 4;
}

.motivation-toast--hidden {
  display: none;
}

.tuning {
  position: absolute;
  top: 6rem;
  right: 1rem;
  width: 14rem;
  padding: 0.8rem;
  border-radius: 0.8rem;
  border: 0.15rem solid #ffffff55;
  background: #0a1322cc;
  color: #fff;
  z-index: 4;
}

.tuning__title {
  margin: 0 0 0.5rem;
  font-weight: 800;
}

.tuning__row {
  margin: 0 0 0.5rem;
  font-size: 0.9rem;
}

.tuning__pause {
  width: 100%;
  margin: 0 0 0.6rem;
  padding: 0.45rem 0.6rem;
  border-radius: 0.5rem;
  border: 0.1rem solid #ffffff55;
  background: #0f2540;
  color: #fff;
  font-weight: 800;
}

.tuning__stages {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 0.4rem;
  margin: 0 0 0.6rem;
}

.tuning__stage-btn {
  padding: 0.35rem 0;
  border-radius: 0.5rem;
  border: 0.1rem solid #ffffff55;
  background: #0f2540;
  color: #fff;
  font-weight: 800;
}

.tuning__stage-btn:focus-visible {
  outline: 0.18rem solid var(--accent);
  outline-offset: 0.1rem;
}

.tuning__field {
  display: grid;
  grid-template-columns: 1fr 5.2rem;
  align-items: center;
  gap: 0.6rem;
  margin: 0.35rem 0;
  font-size: 0.85rem;
}

.tuning input {
  width: 100%;
  padding: 0.25rem 0.35rem;
  border-radius: 0.4rem;
  border: 0.1rem solid #ffffff55;
  background: #0f2540;
  color: #fff;
}

.tuning__close {
  position: absolute;
  top: 0.3rem;
  right: 0.3rem;
  width: 2rem;
  height: 2rem;
  border-radius: 1rem;
  border: 0.1rem solid #ffffff55;
  background: #0f2540;
  color: #fff;
  font-size: 1.2rem;
  line-height: 1;
}

@media (max-width: 900px) {
  .game__header {
    gap: 0.4rem;
    padding: 0.45rem 0.5rem;
    flex-wrap: nowrap;
  }

  .game__title {
    font-size: 0.95rem;
    white-space: nowrap;
  }

  .hud {
    gap: 0.25rem;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .hud::-webkit-scrollbar {
    display: none;
  }

  .hud__item {
    white-space: nowrap;
    font-size: 0.72rem;
    padding: 0.25rem 0.4rem;
  }

  .book {
    width: 11.5rem;
    height: 5.2rem;
    bottom: 0.55rem;
  }

  .book--boost {
    width: 14rem;
  }

  .book__image {
    width: 5.6rem;
  }

  .book__topic {
    font-size: 0.72rem;
  }

  .falling-word {
    min-width: 6.2rem;
    max-width: 10.5rem;
    font-size: 0.86rem;
    padding: 0.3rem 0.48rem;
    border-radius: 0.45rem;
  }

  .event-banner {
    top: 3.6rem;
    font-size: 0.72rem;
    padding: 0.32rem 0.55rem;
  }

  .motivation-toast {
    top: 5.2rem;
    font-size: 0.72rem;
    padding: 0.32rem 0.55rem;
  }

  .intro-start h2 {
    font-size: 1.4rem;
    white-space: nowrap;
  }
}
