/* ============ game shell ============ */
.game-body {
  overflow: hidden;
  height: 100dvh;
}

.screen {
  position: fixed;
  inset: 0;
  display: none;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.screen.is-active { display: block; }

/* ============ start screen ============ */
.start-wrap {
  width: min(880px, 100% - 32px);
  margin: 0 auto;
  padding: 26px 0 60px;
}

.back-link {
  display: inline-block;
  color: var(--muted);
  font-size: 14px;
  padding: 8px 0;
}

.back-link:hover { color: var(--text); }

.start-head { text-align: center; margin: 12px 0 26px; }

.logo-big {
  font-size: 54px;
  line-height: 1;
  filter: drop-shadow(0 12px 30px rgba(247, 178, 103, 0.4));
  animation: floaty 5s ease-in-out infinite;
}

@keyframes floaty {
  0%, 100% { transform: translateY(0) rotate(-3deg); }
  50% { transform: translateY(-8px) rotate(3deg); }
}

.game-title {
  font-size: clamp(34px, 7vw, 56px);
  margin: 12px 0 10px;
  letter-spacing: -1.4px;
  background: linear-gradient(100deg, var(--accent), #ffe0b8 45%, var(--accent-2));
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.game-sub {
  color: var(--muted);
  max-width: 56ch;
  margin: 0 auto;
  font-size: 15.5px;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 12px;
  margin: 26px 0 22px;
}

.mode-card {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 18px 16px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--text);
  cursor: pointer;
  text-align: left;
  font: inherit;
  transition: 0.18s ease;
  backdrop-filter: blur(10px);
}

.mode-card:hover { transform: translateY(-3px); border-color: var(--line-strong); }

.mode-card.is-selected {
  border-color: rgba(247, 178, 103, 0.55);
  background: linear-gradient(150deg, rgba(247, 178, 103, 0.18), rgba(20, 27, 41, 0.7));
  box-shadow: 0 18px 40px rgba(247, 178, 103, 0.18);
}

.mode-ico { font-size: 26px; }
.mode-name { font-weight: 700; font-size: 17px; }
.mode-time { color: var(--accent); font-size: 13.5px; font-weight: 650; }
.mode-note { color: var(--muted); font-size: 12.5px; }
.mode-count {
  position: absolute;
  top: 14px;
  right: 14px;
  font-size: 11.5px;
  color: var(--muted);
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  padding: 2px 8px;
}

.start-form {
  display: grid;
  grid-template-columns: 1fr auto;
  gap: 14px;
  align-items: end;
}

.field { display: grid; gap: 8px; }
.field > span { font-size: 13px; color: var(--muted); }

.field input {
  width: 100%;
  padding: 15px 18px;
  border-radius: 999px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 16px;
  outline: none;
  transition: 0.16s ease;
}

.field input:focus {
  border-color: rgba(247, 178, 103, 0.6);
  box-shadow: 0 0 0 4px rgba(247, 178, 103, 0.14);
}

.btn-play { white-space: nowrap; padding: 15px 30px; }
.btn-play[disabled] { opacity: 0.55; cursor: not-allowed; }

.start-hint {
  color: var(--muted);
  font-size: 13.5px;
  margin: 14px 0 0;
  min-height: 20px;
}

.start-hint.warn { color: var(--accent); }

.mini-board, .over-board {
  margin-top: 34px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px 20px 20px;
  backdrop-filter: blur(12px);
}

.mini-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.mini-list { display: grid; gap: 7px; }

.mini-row {
  display: grid;
  grid-template-columns: 30px 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 9px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid var(--line);
  font-size: 14.5px;
}

.mini-row.me { border-color: rgba(247, 178, 103, 0.5); background: rgba(247, 178, 103, 0.12); }
.mini-row .rank { color: var(--muted); text-align: center; font-weight: 700; }
.mini-row .who { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mini-row .pts { font-variant-numeric: tabular-nums; font-weight: 700; }
.mini-empty { color: var(--muted); font-size: 14px; padding: 6px 2px; }

/* ============ play screen ============ */
#screenPlay {
  display: none;
  grid-template-rows: auto 1fr auto;
  height: 100dvh;
}

#screenPlay.is-active { display: grid; }

.hud {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px max(12px, env(safe-area-inset-left)) 10px max(12px, env(safe-area-inset-right));
  background: linear-gradient(180deg, rgba(7, 10, 15, 0.96), rgba(7, 10, 15, 0.55));
  border-bottom: 1px solid var(--line);
  position: relative;
  z-index: 20;
}

.hud-block { display: grid; gap: 1px; min-width: 58px; }
.hud-block.right { margin-left: auto; text-align: right; }
.hud-label { font-size: 10.5px; letter-spacing: 0.8px; text-transform: uppercase; color: var(--muted); }
.hud-value { font-size: 20px; font-weight: 750; font-variant-numeric: tabular-nums; }

.icon-btn {
  width: 40px;
  height: 40px;
  flex: none;
  border-radius: 12px;
  border: 1px solid var(--line-strong);
  background: rgba(255, 255, 255, 0.05);
  color: var(--text);
  font-size: 17px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: 0.15s ease;
}

.icon-btn:hover { background: rgba(255, 255, 255, 0.1); }
.icon-btn.sm { width: 38px; height: 38px; font-size: 18px; }

.timer { position: relative; width: 50px; height: 50px; flex: none; margin: 0 auto; }
.timer-svg { width: 100%; height: 100%; transform: rotate(-90deg); }
.timer-bg { fill: none; stroke: rgba(255, 255, 255, 0.1); stroke-width: 4; }
.timer-fg {
  fill: none;
  stroke: var(--good);
  stroke-width: 4;
  stroke-linecap: round;
  stroke-dasharray: 119.4;
  stroke-dashoffset: 0;
  transition: stroke-dashoffset 0.25s linear, stroke 0.3s ease;
}
.timer-text {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  font-size: 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}
.timer.warn .timer-fg { stroke: var(--accent); }
.timer.danger .timer-fg { stroke: var(--bad); }
.timer.danger { animation: pulse 1s ease-in-out infinite; }

@keyframes pulse { 50% { transform: scale(1.06); } }

.lives { display: flex; gap: 5px; justify-content: flex-end; }
.life {
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 30%, #ffd9a8, var(--accent));
  box-shadow: 0 0 12px rgba(247, 178, 103, 0.5);
  transition: 0.25s ease;
}
.life.lost { background: rgba(255, 255, 255, 0.12); box-shadow: none; transform: scale(0.75); }

.hud-round {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12.5px;
  color: var(--muted);
  white-space: nowrap;
}

.viewport {
  position: relative;
  overflow: hidden;
  background:
    radial-gradient(700px 400px at 50% 0%, rgba(125, 211, 252, 0.07), transparent 60%),
    #05070b;
  touch-action: none;
  cursor: grab;
  user-select: none;
}

.viewport.dragging { cursor: grabbing; }

.stage {
  position: absolute;
  top: 0;
  left: 0;
  transform-origin: 0 0;
  will-change: transform;
}

.stage img {
  display: block;
  pointer-events: none;
  -webkit-user-drag: none;
}

.markers { position: absolute; inset: 0; pointer-events: none; z-index: 6; }

.marker {
  position: absolute;
  transform: translate(-50%, -50%);
  border-radius: 50%;
  pointer-events: none;
}

.marker.miss {
  width: 34px;
  height: 34px;
  border: 3px solid var(--bad);
  animation: missPop 0.65s cubic-bezier(0.22, 1, 0.36, 1) forwards;
}

.marker.miss::before,
.marker.miss::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 16px;
  height: 3px;
  border-radius: 2px;
  background: var(--bad);
}
.marker.miss::before { transform: translate(-50%, -50%) rotate(45deg); }
.marker.miss::after { transform: translate(-50%, -50%) rotate(-45deg); }

@keyframes missPop {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.6); }
  25% { opacity: 1; transform: translate(-50%, -50%) scale(1.12); }
  70% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.03); }
}

.marker.hit {
  border: 3px solid var(--good);
  animation: hitRing 1.5s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  box-shadow: 0 0 40px rgba(52, 211, 153, 0.5), inset 0 0 30px rgba(52, 211, 153, 0.25);
}

@keyframes hitRing {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(0.3); }
  30% { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -50%) scale(1.25); }
}

.float-points {
  position: absolute;
  transform: translate(-50%, -50%);
  font-weight: 800;
  font-size: 24px;
  color: var(--good);
  text-shadow: 0 6px 24px rgba(0, 0, 0, 0.6);
  animation: floatUp 1.4s cubic-bezier(0.22, 1, 0.36, 1) forwards;
  pointer-events: none;
}

@keyframes floatUp {
  0% { opacity: 0; transform: translate(-50%, -20%) scale(0.8); }
  25% { opacity: 1; transform: translate(-50%, -60%) scale(1.05); }
  100% { opacity: 0; transform: translate(-50%, -190%) scale(1); }
}

.zoom-bar {
  position: absolute;
  right: max(12px, env(safe-area-inset-right));
  bottom: max(14px, env(safe-area-inset-bottom));
  display: grid;
  gap: 8px;
  z-index: 8;
}

.toast {
  position: absolute;
  left: 50%;
  top: 16px;
  transform: translate(-50%, -20px);
  padding: 11px 20px;
  border-radius: 999px;
  background: rgba(12, 17, 27, 0.92);
  border: 1px solid var(--line-strong);
  font-size: 14.5px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  z-index: 12;
  backdrop-filter: blur(8px);
  white-space: nowrap;
}

.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.good { border-color: rgba(52, 211, 153, 0.5); color: #bbf7d0; }
.toast.bad { border-color: rgba(251, 113, 133, 0.5); color: #fecdd3; }

.loader {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  background: rgba(5, 7, 11, 0.6);
  opacity: 0;
  pointer-events: none;
  transition: 0.2s ease;
  z-index: 10;
}

.loader.show { opacity: 1; }

.spinner {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 3px solid rgba(255, 255, 255, 0.15);
  border-top-color: var(--accent);
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.playbar {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 10px max(14px, env(safe-area-inset-left)) calc(10px + env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-right));
  border-top: 1px solid var(--line);
  background: rgba(7, 10, 15, 0.9);
  font-size: 12.5px;
  color: var(--muted);
}

.playbar-hint { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ============ game over ============ */
.over-wrap {
  width: min(720px, 100% - 32px);
  margin: 0 auto;
  padding: 40px 0 60px;
}

.over-card {
  text-align: center;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 24px;
  padding: 34px 26px 30px;
  backdrop-filter: blur(14px);
  box-shadow: var(--shadow);
}

.over-emoji { font-size: 52px; }
.over-card h2 { margin: 10px 0 6px; font-size: clamp(22px, 4vw, 30px); letter-spacing: -0.6px; }
.over-sub { color: var(--muted); margin: 0 0 22px; }

.over-stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 24px; }
.over-stats .metric b { font-size: 26px; }

.cta-row.center { justify-content: center; }

/* ============ small screens ============ */
@media (max-width: 620px) {
  .start-form { grid-template-columns: 1fr; }
  .hud { gap: 8px; padding: 8px 10px; }
  .hud-value { font-size: 17px; }
  .timer { width: 44px; height: 44px; }
  .hud-round { display: none; }
  .over-stats { grid-template-columns: 1fr 1fr; }
  .playbar-hint:first-child { display: none; }
  .zoom-bar { bottom: max(10px, env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .logo-big, .timer.danger { animation: none; }
}
