/* THROW ANYTHING - mobile-first portrait layout */

:root {
  --bg: #0b1016;
  --ink: #f2f6fa;
  --ink-dim: rgba(242, 246, 250, 0.62);
  --accent: #ffcb45;
  --accent-ink: #1a1205;
  --panel: rgba(12, 18, 26, 0.86);
  --panel-line: rgba(255, 255, 255, 0.12);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; }

/* Any author rule that sets `display` beats the browser's own [hidden] rule,
   which has already caught three elements here. One rule, once. */
[hidden] { display: none !important; }

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--ink);
  font-family: "Trebuchet MS", "Segoe UI", -apple-system, BlinkMacSystemFont, "Malgun Gothic",
    "Apple SD Gothic Neo", sans-serif;
  -webkit-text-size-adjust: 100%;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#app {
  position: fixed;
  inset: 0;
  display: block;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}

#game-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  touch-action: none;
}

/* ---------- HUD ---------- */

.hud {
  position: absolute;
  top: calc(var(--safe-top) + 10px);
  left: 0;
  right: 0;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  padding: 0 18px;
  pointer-events: none;
  text-shadow: 0 2px 6px rgba(0, 0, 0, 0.45);
}

.hud-cell { display: flex; flex-direction: column; gap: 2px; min-width: 64px; }
.hud-cell--center { align-items: center; }
.hud-cell--right { align-items: flex-end; }

.hud-label {
  font-size: 10px;
  letter-spacing: 0.18em;
  color: var(--ink-dim);
  font-weight: 700;
}

.hud-value {
  font-size: 30px;
  line-height: 1;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  letter-spacing: 0.01em;
}

.hud-value--sm { font-size: 20px; padding-top: 6px; }

/* Combo badge under the score */
.hud-combo {
  margin-top: 5px;
  align-self: flex-start;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(255, 203, 69, 0.18);
  border: 1px solid rgba(255, 203, 69, 0.55);
  color: var(--accent);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  white-space: nowrap;
}

.hud-combo[hidden] { display: none; }

/* Wind gauge under the level number */
.hud-wind {
  margin-top: 5px;
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 9px;
  border-radius: 999px;
  background: rgba(8, 12, 18, 0.5);
  border: 1px solid var(--panel-line);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.06em;
  color: #9ddcff;
  white-space: nowrap;
}

.hud-wind[hidden] { display: none; }
.hud-wind[data-tier="3"] { color: #ffb37a; }

/* ---------- Bottom hint ---------- */

.hint {
  position: absolute;
  left: 50%;
  bottom: calc(var(--safe-bottom) + 18px);
  transform: translateX(-50%);
  max-width: 88vw;
  padding: 9px 16px;
  border-radius: 999px;
  background: rgba(8, 12, 18, 0.5);
  border: 1px solid var(--panel-line);
  font-size: 13px;
  line-height: 1.35;
  text-align: center;
  color: var(--ink-dim);
  pointer-events: none;
  opacity: 1;
  transition: opacity 220ms ease;
}

.hint[data-hidden="true"] { opacity: 0; }

/* ---------- First-run coaching ---------- */

.coach {
  position: absolute;
  left: 50%;
  /* Above the play area: it must never cover the object or the target. */
  top: 42%;
  transform: translate(-50%, -50%);
  width: min(320px, 86vw);
  pointer-events: none;
  animation: fade-in 260ms ease both;
}


.coach-card {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 15px 17px 13px;
  border-radius: 18px;
  background: rgba(10, 15, 22, 0.86);
  border: 1px solid var(--panel-line);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.45);
}

.coach-step {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 14px;
  line-height: 1.3;
  color: var(--ink);
}

.coach-step b {
  flex: 0 0 auto;
  width: 21px;
  height: 21px;
  display: grid;
  place-items: center;
  border-radius: 50%;
  background: var(--accent);
  color: var(--accent-ink);
  font-size: 12px;
  font-weight: 800;
}

.coach-drag {
  position: relative;
  height: 22px;
  margin-top: 4px;
  border-radius: 999px;
  background: linear-gradient(90deg, rgba(255, 203, 69, 0.35), rgba(255, 203, 69, 0.05));
}

.coach-dot {
  position: absolute;
  top: 3px;
  left: 4px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent);
  animation: coach-pull 1.8s ease-in-out infinite;
}

@keyframes coach-pull {
  0%, 12% { transform: translateX(72%); opacity: 1; }
  55% { transform: translateX(0); opacity: 1; }
  70% { transform: translateX(0); opacity: 1; }
  78% { transform: translateX(72%); opacity: 0.25; }
  100% { transform: translateX(72%); opacity: 1; }
}

/* ---------- Result panel ---------- */

.result {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 7, 11, 0.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  animation: fade-in 180ms ease both;
}


.result-card {
  width: 100%;
  max-width: 320px;
  padding: 26px 22px 22px;
  border-radius: 22px;
  background: var(--panel);
  border: 1px solid var(--panel-line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.45);
  text-align: center;
  animation: pop-in 220ms cubic-bezier(0.22, 1.2, 0.4, 1) both;
}

.result-kicker {
  margin: 0 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.22em;
  color: var(--ink-dim);
}

.result-title {
  margin: 0 0 6px;
  font-size: 30px;
  line-height: 1.1;
  font-weight: 800;
  letter-spacing: 0.01em;
}

.result-title[data-tone="fail"] { color: #ff8f7a; }
.result-title[data-tone="success"] { color: var(--accent); }

.result-sub {
  margin: 0 0 20px;
  font-size: 14px;
  color: var(--ink-dim);
}

.btn {
  appearance: none;
  border: 0;
  width: 100%;
  min-height: 52px;
  border-radius: 14px;
  font-size: 17px;
  font-weight: 800;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: transform 90ms ease, filter 140ms ease;
}

.btn:active { transform: scale(0.975); }
.btn:focus-visible { outline: 3px solid rgba(255, 203, 69, 0.6); outline-offset: 3px; }

.btn--primary { background: var(--accent); color: var(--accent-ink); }
.btn--primary:hover { filter: brightness(1.05); }

.btn--ghost {
  background: rgba(255, 255, 255, 0.08);
  color: var(--ink);
  border: 1px solid var(--panel-line);
}
.btn--ghost:hover { background: rgba(255, 255, 255, 0.14); }

.result-actions { display: flex; flex-direction: column; gap: 10px; }
.result-actions .btn[hidden] { display: none; }

/* Sound toggle - bottom right, clear of the pull-back area on the left */
.btn-icon {
  position: absolute;
  right: 16px;
  bottom: calc(var(--safe-bottom) + 74px);
  width: 46px;
  height: 46px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--panel-line);
  border-radius: 50%;
  background: rgba(8, 12, 18, 0.55);
  color: var(--ink);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: transform 90ms ease, background 140ms ease;
}

/* Sits above the sound toggle, same column, so neither covers the play field. */
.btn-icon--home {
  bottom: calc(var(--safe-bottom) + 128px);
  text-decoration: none;
  font-size: 23px;
}

.btn-icon:active { transform: scale(0.94); }
.btn-icon:focus-visible { outline: 3px solid rgba(255, 203, 69, 0.6); outline-offset: 3px; }
.btn-icon[aria-pressed="true"] { color: var(--ink-dim); }

@keyframes fade-in { from { opacity: 0; } to { opacity: 1; } }
@keyframes pop-in {
  from { opacity: 0; transform: translateY(14px) scale(0.96); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@media (prefers-reduced-motion: reduce) {
  .result, .result-card, .coach { animation: none; }
  .coach-dot { animation: none; transform: translateX(36%); }
  .hint { transition: none; }
}

/* Landscape / desktop: keep the portrait play field centred */
@media (min-aspect-ratio: 1/1) {
  .hud { padding: 0 max(18px, calc(50vw - 27.6vh)); }
}

/* A quiet link to the privacy policy and terms, where a player can always
   reach it: the result panel opens after every throw. */
