/* Start screen, music button, play-again button and the "turn sideways" hint. */

:root {
  --rounded-font: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
  --brick-shadow: #a63d2a;
}

[hidden] {
  display: none !important;
}

button {
  font-family: var(--rounded-font);
  -webkit-appearance: none;
  appearance: none;
  border: 0;
  padding: 0;
  cursor: pointer;
}

/* ---------- Start screen ---------- */

.start-screen {
  position: fixed;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 5vh;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  background: linear-gradient(
    to bottom,
    rgba(126, 200, 240, 0.78),
    rgba(190, 228, 250, 0.6) 60%,
    rgba(255, 244, 214, 0.55)
  );
}

.start-title {
  margin: 0;
  font-family: var(--rounded-font);
  font-size: clamp(48px, 11vw, 120px);
  font-weight: 900;
  line-height: 1;
  letter-spacing: 0.02em;
  text-align: center;
  color: #fffdf5;
  -webkit-text-stroke: 3px #d4543a;
  paint-order: stroke fill;
  text-shadow: 0 6px 0 var(--brick-shadow), 0 12px 18px rgba(166, 61, 42, 0.35);
  animation: title-wobble 3.2s ease-in-out infinite;
}

.start-choices {
  display: flex;
  gap: clamp(28px, 8vw, 90px);
  align-items: flex-end;
}

.choice-tile {
  position: relative;
  width: clamp(180px, 26vw, 260px);
  height: clamp(180px, 26vw, 260px);
  margin-top: 14px;
  border-radius: 28px;
  border-bottom: 14px solid var(--tile-dark);
  background: var(--tile-color);
  box-shadow: 0 10px 18px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: tile-bounce 2.4s ease-in-out infinite;
  transition: transform 0.08s ease-out, border-bottom-width 0.08s ease-out;
}

.choice-tile-easy {
  --tile-color: #5fd068;
  --tile-dark: #2f8f3d;
  --tile-light: #8ee897;
}

.choice-tile-hard {
  --tile-color: #ff7a59;
  --tile-dark: #c2452a;
  --tile-light: #ffa58c;
  animation-delay: -1.2s;
}

/* Two rows of studs on the top edge give the brick look. */
.choice-tile::before {
  content: "";
  position: absolute;
  top: -14px;
  left: 14%;
  width: 72%;
  height: 18px;
  background: radial-gradient(ellipse at 50% 55%, var(--tile-light) 0 58%, var(--tile-dark) 62% 70%, transparent 74%)
    0 0 / 50% 100% repeat-x;
  pointer-events: none;
}

.choice-tile svg {
  width: 78%;
  height: 78%;
  pointer-events: none;
}

.choice-tile:active {
  animation: none;
  transform: scale(1.06, 0.88);
  border-bottom-width: 6px;
}

.choice-tile.is-wobbling {
  animation: tile-wobble 0.25s ease-in-out;
}

@keyframes title-wobble {
  0%, 100% { transform: rotate(-1.5deg) scale(1); }
  50% { transform: rotate(1.5deg) scale(1.03); }
}

@keyframes tile-bounce {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-14px); }
}

@keyframes tile-wobble {
  0% { transform: rotate(0); }
  25% { transform: rotate(-8deg) scale(1.05); }
  50% { transform: rotate(8deg) scale(1.05); }
  75% { transform: rotate(-4deg); }
  100% { transform: rotate(0); }
}

/* ---------- Music button ---------- */

.music-button {
  position: fixed;
  z-index: 20;
  top: calc(env(safe-area-inset-top) + 16px);
  right: calc(env(safe-area-inset-right) + 16px);
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #4c8dff;
  border-bottom: 6px solid #2a5bc2;
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.25);
  display: flex;
  align-items: center;
  justify-content: center;
}

.music-button svg {
  width: 44px;
  height: 44px;
  pointer-events: none;
}

.music-button .music-icon-off {
  display: none;
}

.music-button.is-off {
  background: #9aa3b5;
  border-bottom-color: #6c7487;
}

.music-button.is-off .music-icon-on {
  display: none;
}

.music-button.is-off .music-icon-off {
  display: block;
}

.music-button:active {
  transform: scale(0.92);
}

/* ---------- Play again button ---------- */

.play-again-button {
  position: fixed;
  z-index: 20;
  left: 0;
  right: 0;
  bottom: calc(env(safe-area-inset-bottom) + 6vh);
  margin: 0 auto;
  width: 150px;
  height: 150px;
  border-radius: 50%;
  background: #2fbf5b;
  border-bottom: 12px solid #1b8a3d;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
  display: flex;
  align-items: center;
  justify-content: center;
  animation: pop-in 0.7s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

.play-again-button svg {
  width: 80%;
  height: 80%;
  pointer-events: none;
}

.play-again-button:active {
  animation: none;
  transform: scale(1.05, 0.9);
  border-bottom-width: 5px;
}

@keyframes pop-in {
  0% { transform: scale(0); }
  60% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* ---------- Rotate hint (portrait only) ---------- */

.rotate-hint {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 100;
  align-items: center;
  justify-content: center;
  background: #7ec8f0;
}

.rotate-hint svg {
  width: min(70vw, 70vh);
  height: min(70vw, 70vh);
}

.rotate-hint-tablet {
  transform-origin: 100px 90px;
  animation: tablet-turn 2.6s ease-in-out infinite;
}

@keyframes tablet-turn {
  0%, 20% { transform: rotate(0); }
  60%, 85% { transform: rotate(90deg); }
  100% { transform: rotate(0); }
}

@media (orientation: portrait) {
  .rotate-hint {
    display: flex;
  }
}

/* ---------- Calmer motion ---------- */

@media (prefers-reduced-motion: reduce) {
  .start-title,
  .choice-tile,
  .rotate-hint-tablet {
    animation: none;
  }

  .play-again-button {
    animation: none;
  }
}
