/*--------------------------------------------------------------
# Snake game page
# Reuses .calc-card / .search-button / .reset-button /
# .result-unit-toggle / .unit-tab / .calc-error / .presets-panel /
# .presets-header / .presets-title / .file-count / .action-row /
# .calc-field / .input-unit-wrap / .field-help from style.css.
--------------------------------------------------------------*/
.snake-section { padding: 60px 0; }

.sn-card {
  padding: 28px 36px 32px;
}

/* Top toolbar: live stats + difficulty tabs */
.sn-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  flex-wrap: wrap;
  padding-bottom: 20px;
  margin-bottom: 20px;
  border-bottom: 1px solid #eef0f2;
}
.sn-stats {
  display: flex;
  gap: 28px;
  flex-wrap: wrap;
}
.sn-stat {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  line-height: 1.1;
}
.sn-stat-label {
  font-size: 11px;
  font-weight: 700;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-bottom: 4px;
}
.sn-stat-value {
  font-family: "Poppins", sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: #45505b;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s;
}
.sn-stat-value.is-running { color: #0563bb; }
.sn-stat-value.is-pulse {
  animation: sn-pulse 0.35s ease;
}
@keyframes sn-pulse {
  0%   { transform: scale(1); color: #28a745; }
  60%  { transform: scale(1.15); color: #28a745; }
  100% { transform: scale(1); }
}

/* Game stage */
.sn-stage {
  position: relative;
  width: 100%;
  max-width: 600px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  border-radius: 12px;
  background: #f8fafd;
  border: 1px solid #e4eaf1;
  overflow: hidden;
  touch-action: none;
}
.sn-stage canvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Overlay (start / paused / game-over) */
.sn-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(248, 250, 253, 0.92);
  backdrop-filter: blur(2px);
  transition: opacity 0.18s;
}
.sn-overlay[hidden] { display: none; }
.sn-overlay-card {
  text-align: center;
  padding: 24px 32px;
  max-width: 320px;
}
.sn-overlay-title {
  font-family: "Poppins", sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: #45505b;
  margin-bottom: 6px;
}
.sn-overlay-sub {
  font-size: 14px;
  color: #6c757d;
  margin-bottom: 18px;
}
.sn-overlay-sub kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #d6dde5;
  background: #fff;
  color: #45505b;
  font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
  font-size: 12px;
  box-shadow: 0 1px 0 #d6dde5;
}

.sn-hint {
  font-size: 13px;
  color: #6c757d;
  text-align: center;
  margin: 14px 0 14px;
}
/* Show desktop vs mobile hint text based on viewport. Touch devices have no
   keyboard, so the keyboard-flavored hint is irrelevant there — and vice
   versa. The mobile breakpoint matches the rest of the page (768px). */
.hint-mobile { display: none; }
@media (hover: none) and (pointer: coarse), (max-width: 768px) {
  .hint-desktop { display: none; }
  .hint-mobile  { display: inline; }
}
.sn-hint kbd {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 4px;
  border: 1px solid #d6dde5;
  background: #f8fafd;
  color: #45505b;
  font-family: 'SFMono-Regular', Consolas, Menlo, monospace;
  font-size: 12px;
}

/* ── Result card ───────────────────────────────────────────────── */
.sn-result-card { margin-top: 24px; }
.sn-result-body { padding: 26px 28px 28px; }

.sn-result-stats {
  display: flex;
  justify-content: center;
  gap: 28px;
  flex-wrap: wrap;
  padding-bottom: 22px;
  margin-bottom: 22px;
  border-bottom: 1px solid #eef0f2;
}
.sn-result-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #f8fafd;
  border: 1px solid #e4eaf1;
  border-radius: 10px;
  padding: 20px 28px;
  min-width: 120px;
}
.sn-result-num {
  font-family: "Poppins", sans-serif;
  font-size: 32px;
  font-weight: 700;
  color: #0563bb;
  font-variant-numeric: tabular-nums;
}
.sn-result-label {
  font-size: 12px;
  font-weight: 700;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  margin-top: 4px;
}

.sn-submit-form { max-width: 520px; margin: 0 auto; }

.sn-submit-status {
  margin-top: 14px;
  padding: 10px 14px;
  border-radius: 6px;
  font-size: 14px;
  text-align: center;
}
.sn-submit-status.is-success {
  background: #e8f5ee;
  color: #146c2e;
  border-left: 4px solid #28a745;
}
.sn-submit-status.is-error {
  background: #fff3f3;
  color: #dc3545;
  border-left: 4px solid #dc3545;
}

.sn-btn-label, .sn-btn-spinner {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.sn-btn-spinner .bx { animation: sn-spin 0.8s linear infinite; }
@keyframes sn-spin { to { transform: rotate(360deg); } }
.search-button[aria-busy="true"] { pointer-events: none; opacity: 0.85; }

/* ── Leaderboard ───────────────────────────────────────────────── */
.sn-leaderboard { margin-top: 24px; }
.sn-lb-body { padding: 4px 0 8px; }

.sn-lb-table {
  width: 100%;
  border-collapse: collapse;
}
.sn-lb-table thead th {
  font-size: 11px;
  font-weight: 700;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 10px 28px;
  text-align: left;
  border-bottom: 1px solid #eef0f2;
}
.sn-lb-table tbody td {
  padding: 12px 28px;
  font-size: 14px;
  color: #45505b;
  border-bottom: 1px solid #f1f4f8;
  vertical-align: middle;
}
.sn-lb-table tbody tr:last-child td { border-bottom: none; }
.sn-lb-table tbody tr.is-self {
  background: rgba(5, 99, 187, 0.06);
  font-weight: 600;
}
.sn-lb-rank { width: 50px; }
.sn-lb-num  { width: 80px; text-align: right; font-variant-numeric: tabular-nums; }
.sn-lb-date { width: 120px; color: #6c757d; font-size: 12px; }
.sn-lb-empty {
  padding: 28px !important;
  text-align: center;
  color: #adb5bd;
  font-size: 14px;
}
.sn-lb-rank-medal {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px; height: 24px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.sn-lb-rank-medal.r1 { background: #d4af37; }
.sn-lb-rank-medal.r2 { background: #aab2bd; }
.sn-lb-rank-medal.r3 { background: #cd7f32; }

/* ── Responsive ────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sn-card { padding: 22px 18px 26px; }
  .sn-toolbar { gap: 14px; }
  .sn-stats { gap: 18px; }
  .sn-stat-value { font-size: 22px; }
  .sn-result-body { padding: 22px 18px; }
  .sn-result-stat { padding: 16px 20px; min-width: 0; flex: 1; }
  .sn-result-num { font-size: 26px; }
  .sn-lb-table thead th, .sn-lb-table tbody td { padding: 10px 14px; }
  .sn-lb-date { display: none; }
}
@media (max-width: 480px) {
  .sn-result-stats { gap: 12px; }
  .sn-lb-num { width: 64px; }
}
