/* iPad landscape–first: big touch targets, minimal chrome */

:root {
  --sky: #7ec8ff;
  --sky-deep: #4aa3ff;
  --sun: #ffe566;
  --grass: #5ad67a;
  --grass-dark: #2fb85c;
  --wheel-ring: #ff9f43;
  --wheel-hub: #fff8e7;
  --shadow: rgba(0, 60, 120, 0.22);
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100dvh;
  height: 100%;
  overflow: hidden;
  font-family: "Nunito", system-ui, sans-serif;
  background: linear-gradient(180deg, var(--sky) 0%, var(--sky-deep) 55%, var(--grass) 55%, var(--grass-dark) 100%);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
  user-select: none;
  padding: env(safe-area-inset-top, 0) env(safe-area-inset-right, 0)
    env(safe-area-inset-bottom, 0) env(safe-area-inset-left, 0);
}

#app {
  width: 100%;
  max-width: 100vw;
  min-height: 100dvh;
  max-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
  padding: min(1.5vh, 12px) min(2vw, 16px);
  box-sizing: border-box;
  overflow: hidden;
}

/* Fills viewport under #app padding; sizes the wheel from real space below the hint */
.wheel-stage {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: min(1.2vh, 10px);
  padding: min(2vmin, 20px) min(1vw, 8px) 0;
  box-sizing: border-box;
}

.hint {
  flex: 0 0 auto;
  font-size: clamp(1.1rem, 3.2vw, 1.65rem);
  font-weight: 800;
  color: #fff;
  text-shadow: 0 2px 0 rgba(0, 0, 0, 0.12);
  letter-spacing: 0.02em;
  margin: 0;
  text-align: center;
  width: 100%;
}

.wheel-wrap {
  position: relative;
  flex: 0 1 auto;
  margin: 0 auto;
  aspect-ratio: 1;
  height: auto;
  /* Avoid cqw/cqmin here: with container-type on the parent, cq units can resolve to 0 and collapse the wheel */
  width: min(96vw, 92vmin, calc(100svh - 6.5rem));
  max-width: 100%;
  max-height: min(92vmin, calc(100svh - 6.5rem));
}

#wheel {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  cursor: pointer;
  touch-action: manipulation;
  box-shadow: 0 12px 28px var(--shadow);
}

.wheel-wrap.is-spinning #wheel {
  cursor: wait;
  pointer-events: none;
}

.pointer {
  position: absolute;
  top: -2%;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: clamp(14px, 3.5vw, 22px) solid transparent;
  border-right: clamp(14px, 3.5vw, 22px) solid transparent;
  border-top: clamp(28px, 7vw, 44px) solid #ff5a7a;
  filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.2));
  z-index: 2;
  pointer-events: none;
}

#player-screen {
  position: relative;
  display: none;
  width: 100%;
  max-width: min(92vw, 1200px);
  align-self: center;
  flex: 1 1 auto;
  min-height: 0;
  max-height: 88vh;
  flex-direction: column;
  align-items: stretch;
  justify-content: center;
}

/* Hidden on wheel; on video, fixed so it isn’t under the YouTube iframe compositor layer (iPad Safari) */
.close-video {
  display: none;
  position: fixed;
  top: max(10px, env(safe-area-inset-top, 0px));
  right: max(10px, env(safe-area-inset-right, 0px));
  z-index: 99999;
  width: clamp(56px, 11vmin, 80px);
  height: clamp(56px, 11vmin, 80px);
  margin: 0;
  padding: 0;
  border-radius: 50%;
  border: 5px solid #fff;
  background: #ff5a7a;
  color: #fff;
  font-family: inherit;
  font-weight: 800;
  font-size: clamp(2rem, 6vmin, 2.75rem);
  line-height: 1;
  cursor: pointer;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.25);
  align-items: center;
  justify-content: center;
  pointer-events: auto;
  /* Promote above cross-origin iframe */
  transform: translateZ(0);
  -webkit-transform: translateZ(0);
}

#app.mode-video .close-video {
  display: flex;
}

.close-video:active {
  transform: scale(0.94) translateZ(0);
}

#app.mode-video #player-screen {
  display: flex;
}

#app.mode-video .wheel-stage {
  display: none;
}

#player {
  position: relative;
  z-index: 0;
  isolation: isolate;
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  border-radius: clamp(12px, 2vw, 24px);
  overflow: hidden;
  border: 6px solid #fff;
  box-shadow: 0 16px 40px var(--shadow);
  background: #000;
}

#player iframe {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
}

.loading {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(74, 163, 255, 0.35);
  color: #fff;
  font-weight: 800;
  font-size: clamp(1.2rem, 4vw, 2rem);
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

.loading[hidden] {
  display: none;
}

/* Settings: fixed so wheel taps don’t hit it; outside #app */
.settings-cog {
  position: fixed;
  right: max(12px, env(safe-area-inset-right, 0px));
  bottom: max(12px, env(safe-area-inset-bottom, 0px));
  z-index: 8;
  width: clamp(48px, 10vmin, 60px);
  height: clamp(48px, 10vmin, 60px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #fff;
  color: #4aa3ff;
  font-size: clamp(1.35rem, 4vmin, 1.65rem);
  line-height: 1;
  text-decoration: none;
  box-shadow: 0 6px 18px var(--shadow);
  border: 3px solid rgba(255, 255, 255, 0.95);
  touch-action: manipulation;
}

.settings-cog:active {
  transform: scale(0.94);
}
