/* Tile Explorer — DOM overlay UI */

.panel {
  position: absolute;
  inset: 0;
  background: rgba(13, 16, 24, 0.78);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: fade-in 200ms ease-out;
  z-index: 20;
}

@keyframes fade-in {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.panel-card {
  width: min(420px, 100%);
  max-height: calc(100vh - 48px);
  overflow-y: auto;
  background: var(--bg-1);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 14px;
  animation: pop-in 240ms cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

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

.title {
  font-size: 32px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent) 0%, var(--accent-2) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  text-align: center;
  letter-spacing: 0.5px;
}

.subtitle {
  text-align: center;
  color: var(--fg-2);
  font-size: 14px;
  margin-bottom: 8px;
}

h2 {
  font-size: 20px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 4px;
}

.btn {
  display: block;
  width: 100%;
  padding: 13px 16px;
  background: var(--bg-2);
  color: var(--fg-0);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 10px;
  font-size: 15px;
  font-weight: 500;
  cursor: pointer;
  transition: transform 100ms ease, background 150ms ease;
  font-family: inherit;
}

.btn:hover {
  background: #2c344a;
}

.btn:active {
  transform: scale(0.97);
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent) 0%, #34d399 100%);
  color: #0d1018;
  font-weight: 600;
  border-color: transparent;
}

.btn-primary:hover {
  filter: brightness(1.06);
  background: linear-gradient(135deg, var(--accent) 0%, #34d399 100%);
}

.hint {
  font-size: 13px;
  color: var(--fg-2);
  text-align: center;
}

/* Toggles */
.toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  cursor: pointer;
  font-size: 15px;
}

.toggle input {
  display: none;
}

.toggle .slider {
  width: 44px;
  height: 24px;
  background: var(--bg-2);
  border-radius: 12px;
  position: relative;
  transition: background 200ms ease;
}

.toggle .slider::before {
  content: "";
  position: absolute;
  top: 3px;
  left: 3px;
  width: 18px;
  height: 18px;
  background: var(--fg-0);
  border-radius: 50%;
  transition: transform 200ms ease;
}

.toggle input:checked + .slider {
  background: var(--accent);
}

.toggle input:checked + .slider::before {
  transform: translateX(20px);
  background: #0d1018;
}

/* Form fields */
.field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field label {
  font-size: 13px;
  color: var(--fg-1);
}

.field input {
  background: var(--bg-2);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 8px;
  padding: 10px 12px;
  color: var(--fg-0);
  font-size: 15px;
  font-family: inherit;
}

.field input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}

/* Tabs */
.tabs {
  display: flex;
  gap: 8px;
  background: var(--bg-2);
  padding: 4px;
  border-radius: 8px;
}

.tab {
  flex: 1;
  padding: 8px 10px;
  background: transparent;
  border: 0;
  border-radius: 6px;
  color: var(--fg-2);
  cursor: pointer;
  font-size: 14px;
  font-family: inherit;
  transition: background 150ms ease, color 150ms ease;
}

.tab.active {
  background: var(--bg-1);
  color: var(--fg-0);
  box-shadow: var(--shadow);
}

/* Leaderboard list */
.lb-list {
  max-height: 320px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.lb-row {
  display: grid;
  grid-template-columns: 32px 1fr auto auto;
  gap: 8px;
  align-items: center;
  padding: 8px 10px;
  background: var(--bg-2);
  border-radius: 8px;
  font-size: 14px;
}

.lb-row.self {
  background: rgba(110, 231, 183, 0.12);
  border: 1px solid rgba(110, 231, 183, 0.3);
}

.lb-rank {
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
}

.lb-name {
  color: var(--fg-0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-stars {
  color: var(--accent-2);
  letter-spacing: 1px;
}

.lb-steps {
  color: var(--fg-2);
  font-variant-numeric: tabular-nums;
  font-size: 12px;
}

/* Stars row */
.stars-row {
  font-size: 48px;
  text-align: center;
  letter-spacing: 6px;
  color: var(--accent-2);
  text-shadow: 0 0 16px rgba(251, 191, 36, 0.4);
  line-height: 1;
  padding: 8px 0;
  animation: stars-pop 600ms cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

@keyframes stars-pop {
  0%   { transform: scale(0); opacity: 0; }
  60%  { transform: scale(1.15); }
  100% { transform: scale(1); opacity: 1; }
}

.stats {
  text-align: center;
  color: var(--fg-1);
  font-size: 14px;
}

/* Reward grid */
.reward-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 6px;
}

.reward-btn {
  background: var(--bg-2);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 12px 4px;
  font-size: 24px;
  cursor: pointer;
  transition: transform 100ms ease, border-color 150ms ease;
  font-family: inherit;
  color: var(--fg-0);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
}

.reward-btn:hover:not(:disabled) {
  transform: translateY(-2px);
}

.reward-btn.selected {
  border-color: var(--accent);
}

.reward-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.reward-btn .reward-label {
  font-size: 10px;
  color: var(--fg-2);
}

/* Description block under the reward grid: 1 line per powerup. */
.reward-desc {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-top: 10px;
  padding: 10px 12px;
  background: rgba(13, 16, 24, 0.45);
  border-radius: 10px;
  font-size: 12px;
  color: var(--fg-1);
  line-height: 1.4;
  text-align: left;
}

.reward-desc-row {
  display: flex;
  align-items: baseline;
  gap: 8px;
}

.reward-desc-ic {
  font-size: 14px;
  flex: 0 0 18px;
  text-align: center;
}

.reward-desc-txt {
  flex: 1;
}

/* Highlighted "skip reward" CTA on the level-complete panel. */
.btn-skip {
  background: linear-gradient(135deg, #fbbf24, #f97316);
  color: #1a1f2e;
  border: 1px solid rgba(255, 255, 255, 0.25);
  font-weight: 700;
  box-shadow: 0 0 18px rgba(251, 191, 36, 0.45);
  animation: skip-pulse 1.6s ease-in-out infinite;
}

.btn-skip:hover {
  filter: brightness(1.05);
}

@keyframes skip-pulse {
  0%, 100% { box-shadow: 0 0 14px rgba(251, 191, 36, 0.35); }
  50%      { box-shadow: 0 0 22px rgba(251, 191, 36, 0.7); }
}

/* HUD */
.hud-btn {
  position: absolute;
  top: calc(12px + var(--safe-top));
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(35, 42, 61, 0.85);
  color: var(--fg-0);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
  z-index: 5;
  backdrop-filter: blur(4px);
}

/* Tutorial bubble */
.tutorial-bubble {
  position: absolute;
  bottom: 30%;
  left: 50%;
  transform: translateX(-50%);
  max-width: 80%;
  padding: 12px 18px;
  background: rgba(35, 42, 61, 0.95);
  color: var(--fg-0);
  border: 1px solid var(--accent);
  border-radius: 12px;
  font-size: 14px;
  text-align: center;
  box-shadow: 0 4px 18px rgba(110, 231, 183, 0.2);
  animation: bubble-in 300ms ease-out;
  pointer-events: auto;
  cursor: pointer;
  z-index: 6;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translate(-50%, 12px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* Toast — must sit above .panel (z-index 20) so action feedback (e.g. the
   "记录排名" result) is visible while a panel is open. */
.toast {
  position: absolute;
  top: 14%;
  left: 50%;
  transform: translateX(-50%);
  padding: 10px 18px;
  background: rgba(13, 16, 24, 0.92);
  color: var(--fg-0);
  border-radius: 999px;
  font-size: 13px;
  z-index: 100;
  animation: toast-in 220ms ease-out;
  pointer-events: none;
}

@keyframes toast-in {
  from { opacity: 0; transform: translate(-50%, -8px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}
