* { box-sizing: border-box; }

:root {
  color-scheme: light;
  --panel: rgba(255,255,255,.94);
  --line: #d9e6f2;
  --text: #183047;
  --muted: #60778d;
  --accent: #087fbc;
  --accent-2: #dff5ff;
}

html, body {
  margin: 0;
  min-height: 100%;
  background:
    radial-gradient(circle at 10% 8%, #ffffff 0, #eefaff 32rem, transparent 46rem),
    radial-gradient(circle at 92% 88%, #fff7dc 0, #f7fbff 31rem, transparent 49rem),
    linear-gradient(135deg, #f9fdff 0%, #eaf8ff 48%, #fffdf3 100%);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--text);
}

body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 28px;
}

.app { width: min(1120px, 100%); }

.topbar {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 24px;
  margin-bottom: 14px;
}

.eyebrow {
  margin: 0 0 6px;
  color: var(--accent);
  font-size: .72rem;
  font-weight: 850;
  letter-spacing: .16em;
}

h1 {
  margin: 0;
  font-size: clamp(2rem, 5vw, 4rem);
  line-height: .95;
  letter-spacing: -.05em;
  color: #17344d;
}

.scorebox {
  min-width: 105px;
  padding: 10px 16px;
  border: 1px solid var(--line);
  border-radius: 14px;
  background: #ffffff;
  text-align: center;
  box-shadow: 0 8px 24px rgba(37, 103, 145, .10);
}
.scorebox span { display: block; color: var(--muted); font-size: .76rem; }
.scorebox strong { display: block; margin-top: 2px; font-size: 1.8rem; color: #15354e; }

.game-shell {
  overflow: hidden;
  border: 1px solid #d4e5f0;
  border-radius: 24px;
  background: #ffffff;
  box-shadow: 0 24px 65px rgba(43, 105, 143, .14);
}

.photo-stage {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 10;
  overflow: hidden;
  background: #eef8fd;
  outline: none;
  cursor: crosshair;
  user-select: none;
  touch-action: manipulation;
}

.photo-stage::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: linear-gradient(110deg, rgba(255,255,255,.12), transparent 30%, rgba(255,255,255,.06) 58%, transparent 78%);
}

#photo {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scale(1.001);
}

#glassCanvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.start-overlay {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(238, 249, 255, .22);
  transition: opacity 260ms ease, visibility 260ms ease;
}
.start-overlay.hidden { opacity: 0; visibility: hidden; pointer-events: none; }

.start-card {
  max-width: 440px;
  padding: 26px 28px;
  border: 1px solid rgba(196, 222, 237, .95);
  border-radius: 22px;
  background: rgba(255,255,255,.91);
  text-align: center;
  backdrop-filter: blur(10px);
  box-shadow: 0 18px 48px rgba(43, 105, 143, .16);
}
.start-card h2 { margin: 16px 0 8px; font-size: clamp(1.25rem, 3vw, 2rem); color: #15354e; }
.start-card p { margin: 0; color: #536b80; }

.keycap {
  display: inline-block;
  min-width: 130px;
  padding: 12px 18px;
  border: 1px solid #b8d5e7;
  border-bottom-width: 5px;
  border-radius: 12px;
  background: linear-gradient(#ffffff, #eaf6fc);
  color: #17344d;
  font-weight: 900;
  letter-spacing: .12em;
  box-shadow: 0 7px 19px rgba(48, 112, 151, .16);
}

.flash { position: absolute; inset: 0; opacity: 0; pointer-events: none; background: white; }
.flash.go { animation: flash 145ms ease-out; }

.controls {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 16px;
  border-top: 1px solid #e0edf5;
  background: #ffffff;
}

.button {
  appearance: none;
  border: 1px solid #bcd6e6;
  border-radius: 12px;
  padding: 10px 14px;
  background: #f4fbff;
  color: #17344d;
  font: inherit;
  font-weight: 760;
  cursor: pointer;
  transition: transform 120ms ease, background 120ms ease, box-shadow 120ms ease;
}
.button:hover { background: #e8f7ff; transform: translateY(-1px); box-shadow: 0 5px 14px rgba(42, 111, 150, .12); }
.button:active { transform: translateY(1px); }
.button.primary { background: #1288c4; border-color: #1288c4; color: #ffffff; }
.button.primary:hover { background: #087bb5; }

.sound-control {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 8px;
  color: #49647a;
}

.photo-status { margin: 0; padding: 0 16px 8px; color: #61788c; font-size: .88rem; background: #ffffff; }
.photo-status.ok { color: #247a49; }
.photo-status.error { color: #b53a3a; }
.hint { margin: 0; padding: 0 16px 17px; color: var(--muted); font-size: .9rem; background: #ffffff; }
.photo-stage.dragging { box-shadow: inset 0 0 0 4px rgba(18,136,196,.58); }

@keyframes flash { 0% { opacity: .72; } 100% { opacity: 0; } }

@media (max-width: 650px) {
  body { padding: 14px; }
  .topbar { align-items: center; }
  .scorebox { min-width: 84px; }
  .photo-stage { aspect-ratio: 4 / 5; }
  .sound-control { margin-left: 0; }
}


.leaderboard {
  border-top: 1px solid #e0edf5;
  padding: 20px 16px 22px;
  background: linear-gradient(180deg, #fbfeff 0%, #f3faff 100%);
}

.leaderboard-head {
  display: flex;
  align-items: start;
  justify-content: space-between;
  gap: 18px;
}

.leaderboard h2 {
  margin: 0;
  color: #17344d;
  font-size: clamp(1.25rem, 2.6vw, 1.75rem);
  letter-spacing: -.02em;
}

.leaderboard-note {
  margin: 6px 0 0;
  color: var(--muted);
  font-size: .88rem;
}

.player-row {
  display: grid;
  grid-template-columns: auto minmax(150px, 240px) 1fr;
  align-items: center;
  gap: 10px;
  margin-top: 16px;
}

.player-row label {
  color: #36536b;
  font-size: .9rem;
  font-weight: 750;
}

.player-row input {
  width: 100%;
  border: 1px solid #bcd6e6;
  border-radius: 10px;
  padding: 9px 11px;
  background: #fff;
  color: #17344d;
  font: inherit;
  font-weight: 700;
  outline: none;
}

.player-row input:focus {
  border-color: #1288c4;
  box-shadow: 0 0 0 3px rgba(18,136,196,.12);
}

.save-status {
  min-height: 1.2em;
  color: #667e91;
  font-size: .82rem;
}

.leaderboard-list {
  margin: 16px 0 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 7px;
  counter-reset: rank;
}

.leaderboard-entry,
.leaderboard-empty {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  align-items: center;
  gap: 10px;
  min-height: 45px;
  padding: 9px 12px;
  border: 1px solid #dbe8f1;
  border-radius: 12px;
  background: #fff;
}

.leaderboard-entry { counter-increment: rank; }
.leaderboard-entry::before {
  content: "#" counter(rank);
  color: #6a8295;
  font-size: .82rem;
  font-weight: 850;
}

.leaderboard-name {
  overflow: hidden;
  color: #17344d;
  font-weight: 780;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.leaderboard-score {
  color: #087fbc;
  font-variant-numeric: tabular-nums;
  font-size: 1.05rem;
  font-weight: 900;
}

.leaderboard-entry.current {
  border-color: #87cdec;
  background: #eefaff;
  box-shadow: inset 3px 0 0 #1288c4;
}

.leaderboard-empty {
  grid-template-columns: 1fr;
  color: #6c8294;
  text-align: center;
}

.button.danger {
  border-color: #efc5c5;
  background: #fff7f7;
  color: #9b3030;
}
.button.danger:hover { background: #ffeded; }

@media (max-width: 650px) {
  .leaderboard-head { flex-direction: column; }
  .player-row { grid-template-columns: 1fr; }
  .leaderboard-head .button { width: 100%; }
}


/* Pass 10: keyboard focus and reduced-motion hardening */
.skip-link{position:fixed;left:14px;top:14px;z-index:1000;background:#fff;color:#17364f;border:2px solid #6db0dc;border-radius:8px;padding:10px 14px;font-weight:900;text-decoration:none;transform:translateY(-180%);transition:transform .15s ease}.skip-link:focus{transform:translateY(0)}
:where(a,button,input,[tabindex]):focus-visible{outline:3px solid #ffb45e;outline-offset:3px}
@media(prefers-reduced-motion:reduce){*,*::before,*::after{animation-duration:.001ms!important;animation-iteration-count:1!important;transition-duration:.001ms!important;scroll-behavior:auto!important}.flash{display:none!important}}
