/* Royal Coast — Maintenance + Royal Tower */

:root {
  --bg: #0a0a0a;
  --bg-elev: #121214;
  --bg-elev-2: #1a1a1d;
  --border: rgba(255, 255, 255, 0.07);
  --border-strong: rgba(255, 255, 255, 0.14);
  --fg: #faf8f3;
  --fg-mute: rgba(250, 248, 243, 0.62);
  --fg-dim: rgba(250, 248, 243, 0.4);
  --accent: #c8956c;
  --accent-2: #e0b88a;
  --accent-dim: rgba(200, 149, 108, 0.18);
  --gold: #d4b896;
  --green: #4ade80;
  --red: #f87171;
  --shadow: 0 20px 60px -20px rgba(0, 0, 0, 0.6), 0 6px 20px -8px rgba(0, 0, 0, 0.4);

  --radius: 16px;
  --radius-sm: 10px;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--fg);
  font-family:
    -apple-system, BlinkMacSystemFont, "Segoe UI", "SF Pro Display",
    "Helvetica Neue", Roboto, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  min-height: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  position: relative;
  overflow-x: hidden;
}

.ambient {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 0;
  background:
    radial-gradient(circle at 18% 10%, rgba(200, 149, 108, 0.18), transparent 45%),
    radial-gradient(circle at 82% 6%, rgba(80, 120, 200, 0.12), transparent 45%),
    radial-gradient(circle at 50% 100%, rgba(200, 149, 108, 0.08), transparent 55%);
}

/* ─── Hero ───────────────────────────────────────────────────────────────── */
.hero {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: clamp(28px, 5vw, 56px) clamp(20px, 4vw, 48px) clamp(18px, 3vw, 28px);
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 14px 6px 12px;
  border: 1px solid var(--border-strong);
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-mute);
  background: rgba(255, 255, 255, 0.02);
}

.hero-tag .dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent);
  box-shadow: 0 0 0 0 var(--accent);
  animation: pulse 1.6s ease-out infinite;
}

@keyframes pulse {
  0% { box-shadow: 0 0 0 0 rgba(200, 149, 108, 0.55); }
  70% { box-shadow: 0 0 0 12px rgba(200, 149, 108, 0); }
  100% { box-shadow: 0 0 0 0 rgba(200, 149, 108, 0); }
}

.hero-title {
  margin: 18px 0 12px;
  font-size: clamp(32px, 5vw, 56px);
  font-weight: 500;
  letter-spacing: -0.02em;
  line-height: 1.05;
  max-width: 18ch;
}

.hero-accent {
  background: linear-gradient(120deg, var(--accent) 0%, var(--accent-2) 60%, var(--gold) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

.hero-sub {
  margin: 0;
  max-width: 64ch;
  color: var(--fg-mute);
  font-size: clamp(15px, 1.6vw, 17px);
}

.hero-preview-link {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 8px 14px;
  border: 1px solid var(--accent-dim);
  border-radius: 999px;
  font-size: 13px;
  color: var(--accent-2);
  background: rgba(200, 149, 108, 0.06);
  text-decoration: none;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.hero-preview-link:hover {
  background: rgba(200, 149, 108, 0.14);
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Game-mode (открыли через /__maintenance-test?game=1 из /crm/tools) ─────
   Скрываем hero и status-row — оставляем только саму игру + лидерборд.
   Сетка main подтягивается к верху. */
body.game-mode .hero { display: none !important; }
body.game-mode .grid { padding-top: clamp(20px, 3vw, 32px); }

.status-row {
  margin-top: clamp(24px, 3vw, 32px);
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 14px;
}

@media (max-width: 880px) {
  .status-row {
    grid-template-columns: 1fr;
  }
}

.status-card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.status-card--timer { border-color: var(--accent-dim); }
.status-card--actions {
  justify-content: center;
  align-items: stretch;
  gap: 10px;
}

.status-card-label {
  font-size: 11px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.status-card-value {
  font-variant-numeric: tabular-nums;
  font-size: 30px;
  font-weight: 400;
  letter-spacing: -0.01em;
  color: var(--accent);
}

.status-card-value--small { font-size: 18px; color: var(--fg); }

.status-card-bar {
  margin-top: 6px;
  height: 4px;
  background: rgba(200, 149, 108, 0.1);
  border-radius: 999px;
  overflow: hidden;
}

.status-card-bar-fill {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, var(--accent), var(--accent-2));
  transition: width 0.3s linear;
}

.status-card-foot {
  font-size: 12px;
  color: var(--fg-dim);
  margin-top: 2px;
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn-primary,
.btn-secondary,
.btn-reload {
  appearance: none;
  border: none;
  border-radius: 10px;
  padding: 12px 22px;
  font-size: 14px;
  font-weight: 500;
  letter-spacing: 0.02em;
  cursor: pointer;
  transition: transform 0.12s ease, background 0.16s ease, border-color 0.16s ease;
  font-family: inherit;
}

.btn-primary {
  background: linear-gradient(120deg, var(--accent) 0%, var(--accent-2) 100%);
  color: #1a1208;
  font-weight: 600;
}

.btn-primary:hover { transform: translateY(-1px); }
.btn-primary:active { transform: translateY(0); }

.btn-secondary {
  background: transparent;
  color: var(--fg);
  border: 1px solid var(--border-strong);
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-align: center;
}

.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }

.btn-reload {
  background: rgba(200, 149, 108, 0.16);
  color: var(--accent-2);
  border: 1px solid rgba(200, 149, 108, 0.3);
}

.btn-reload:hover {
  background: rgba(200, 149, 108, 0.26);
}

.btn-planetarium {
  appearance: none;
  border: 1px solid rgba(168, 130, 255, 0.4);
  background:
    linear-gradient(120deg, rgba(168, 130, 255, 0.22) 0%, rgba(86, 53, 184, 0.18) 100%);
  color: #d6c7ff;
  border-radius: 10px;
  padding: 12px 18px;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  letter-spacing: 0.02em;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: transform 0.12s ease, border-color 0.18s ease, box-shadow 0.2s ease;
  box-shadow: 0 0 0 0 rgba(168, 130, 255, 0);
}

.btn-planetarium:hover {
  transform: translateY(-1px);
  border-color: rgba(200, 170, 255, 0.7);
  box-shadow: 0 0 24px -4px rgba(168, 130, 255, 0.45);
}

.btn-planetarium-icon {
  font-size: 16px;
  display: inline-block;
  animation: planetarium-orbit 14s linear infinite;
  transform-origin: 50% 50%;
}

@keyframes planetarium-orbit {
  to { transform: rotate(360deg); }
}

.btn-refresh {
  appearance: none;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--fg-mute);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 18px;
  transition: transform 0.4s ease, color 0.2s ease, border-color 0.2s ease;
}

.btn-refresh:hover { color: var(--accent); border-color: var(--accent); transform: rotate(120deg); }

/* ─── Grid ───────────────────────────────────────────────────────────────── */
.grid {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  padding: 8px clamp(20px, 4vw, 48px) clamp(28px, 4vw, 48px);
  display: grid;
  grid-template-columns: minmax(0, 1.55fr) minmax(0, 1fr);
  gap: 22px;
  flex: 1;
}

@media (max-width: 980px) {
  .grid { grid-template-columns: 1fr; }
}

.card {
  background: var(--bg-elev);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 22px 22px 18px;
  box-shadow: var(--shadow);
}

.card-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.card-head--sub { margin-top: 18px; }

.card-eyebrow {
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-dim);
  margin-bottom: 4px;
}

.card-title {
  margin: 0;
  font-size: 20px;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.game-stats {
  display: flex;
  gap: 18px;
  text-align: right;
}

.game-stat-label {
  font-size: 10px;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.game-stat-value {
  font-variant-numeric: tabular-nums;
  font-size: 22px;
  font-weight: 500;
  color: var(--accent);
}

/* ─── Canvas + overlays ─────────────────────────────────────────────────── */
.canvas-wrap {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background:
    linear-gradient(180deg, #0a0d18 0%, #14233a 55%, #1f3c5e 100%);
  aspect-ratio: 540 / 640;
  max-height: 70vh;
  margin: 4px 0 14px;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  user-select: none;
}

.overlay {
  position: absolute;
  inset: 0;
  background: rgba(8, 8, 12, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 2;
  transition: opacity 0.25s ease;
}

.overlay.hidden { opacity: 0; pointer-events: none; }

.overlay-inner {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.04), rgba(255, 255, 255, 0.01));
  border: 1px solid var(--border-strong);
  border-radius: var(--radius);
  padding: 28px 26px;
  width: 100%;
  max-width: 360px;
  text-align: center;
}

.overlay-emoji {
  font-size: 42px;
  margin-bottom: 8px;
  filter: drop-shadow(0 4px 12px rgba(0, 0, 0, 0.5));
}

.overlay-title {
  font-size: 22px;
  font-weight: 500;
  letter-spacing: 0.02em;
  margin-bottom: 8px;
  color: var(--accent);
}

.overlay-text {
  font-size: 14px;
  color: var(--fg-mute);
  margin: 6px 0 18px;
  line-height: 1.55;
}

.overlay-hint {
  margin-top: 12px;
  font-size: 11px;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

kbd {
  display: inline-block;
  padding: 1px 6px;
  border: 1px solid var(--border-strong);
  border-bottom-width: 2px;
  border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
  font-size: 11px;
  color: var(--fg);
  background: rgba(255, 255, 255, 0.04);
}

.end-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 14px;
  border-bottom: 1px solid var(--border);
  color: var(--fg-mute);
}

.end-row b {
  color: var(--fg);
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.end-row--rank b { color: var(--accent); }

.end-row.hidden { display: none; }

.save-form {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.save-label {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-size: 11px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

.save-label input {
  appearance: none;
  background: var(--bg);
  border: 1px solid var(--border-strong);
  border-radius: 10px;
  padding: 12px 14px;
  color: var(--fg);
  font-size: 15px;
  font-family: inherit;
  letter-spacing: 0;
  text-transform: none;
}

.save-label input:focus {
  outline: none;
  border-color: var(--accent);
  background: #18130c;
}

.save-msg {
  font-size: 13px;
  min-height: 18px;
  color: var(--green);
}

.save-msg.error { color: var(--red); }

.end-actions {
  margin-top: 14px;
  display: flex;
  justify-content: center;
}

.game-foot {
  font-size: 12px;
  color: var(--fg-dim);
  text-align: center;
  padding-top: 4px;
}

/* ─── Leaderboard ───────────────────────────────────────────────────────── */
.leaders,
.recent {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.leaders li,
.recent li {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: var(--bg-elev-2);
  border: 1px solid transparent;
  transition: border-color 0.18s ease, transform 0.18s ease;
}

.leaders li:hover,
.recent li:hover {
  border-color: var(--border-strong);
}

.leaders li.is-fresh {
  animation: highlight 1.4s ease;
}

@keyframes highlight {
  0% { background: rgba(200, 149, 108, 0.35); transform: translateX(4px); }
  100% { background: var(--bg-elev-2); transform: translateX(0); }
}

.leaders-empty {
  background: transparent !important;
  color: var(--fg-dim);
  font-size: 13px;
  padding: 12px 4px;
  justify-content: center;
}

.rank {
  width: 28px;
  font-variant-numeric: tabular-nums;
  font-size: 14px;
  color: var(--fg-dim);
  text-align: center;
}

.rank.rank-1 { color: #ffd56b; font-weight: 600; }
.rank.rank-2 { color: #d6d6d6; font-weight: 600; }
.rank.rank-3 { color: #d49b6c; font-weight: 600; }

.row-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.row-name {
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.row-meta {
  font-size: 11px;
  color: var(--fg-dim);
  letter-spacing: 0.04em;
}

.row-score {
  font-variant-numeric: tabular-nums;
  font-weight: 600;
  font-size: 16px;
  color: var(--accent);
}

.totals {
  margin-top: 18px;
  padding: 14px 16px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.totals-item {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  color: var(--fg-mute);
}

.totals-item b {
  color: var(--fg);
  font-variant-numeric: tabular-nums;
}

/* ─── Footer ────────────────────────────────────────────────────────────── */
.foot {
  position: relative;
  z-index: 1;
  max-width: 1240px;
  margin: 0 auto;
  width: 100%;
  padding: 18px clamp(20px, 4vw, 48px) 28px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 12px;
  color: var(--fg-dim);
}

.foot-meta { font-variant-numeric: tabular-nums; }

@media (max-width: 600px) {
  .game-stats { gap: 12px; }
  .game-stat-value { font-size: 18px; }
  .card { padding: 18px 16px; }
  .hero-title { font-size: 32px; }
  .foot { flex-direction: column; gap: 6px; }
}
