/*
File: frontend/public/style.css
Purpose:
    Defines premium visual styling for ONE-SHOT static frontend pages.
Primary Responsibility:
    Provide consistent layout, typography, glassmorphism UI, and tight animations.
Design Intent:
    Keep the interface visually bold while separating reusable surface primitives from
    feature-specific panels such as auth, ranking, and guess-history controls.
Non-Goals:
    Does not implement gameplay behavior, ranking policy, or client-side persistence logic.
Dependencies:
    Google Fonts, SUIT webfont, static HTML class names rendered by frontend/public/index.html.

Constraints & Assumptions:
- Styles must remain compatible with static hosting and plain browser execution.
- Mobile layouts must preserve gameplay input, history review, and ranking readability.

Extension Points:
- Additional panel-specific control cards can reuse the existing glass surface tokens.
*/
@import url("https://fonts.googleapis.com/css2?family=Do+Hyeon&display=swap");
@import url("https://cdn.jsdelivr.net/gh/sunn-us/SUIT/fonts/variable/woff2/SUIT-Variable.css");

:root {
  /* Dynamic Background Colors */
  --bg-dark: #0f172a;
  --bg-gradient-1: #3b0764;
  --bg-gradient-2: #1e1b4b;
  --bg-gradient-3: #020617;
  
  /* Surface & Glassmorphism */
  --glass-bg: rgba(255, 255, 255, 0.05);
  --glass-bg-hover: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.15);
  --glass-inner: rgba(0, 0, 0, 0.2);
  
  /* Text Colors */
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-highlight: #e2e8f0;
  
  /* Accents */
  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --secondary: #3b82f6;
  --accent: #10b981;
  --danger: #ef4444;
  
  /* Shadows & Glows */
  --shadow-soft: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
  --glow-primary: 0 0 20px rgba(139, 92, 246, 0.4);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "SUIT Variable", "Pretendard Variable", "Noto Sans KR", sans-serif;
  color: var(--text-main);
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 15% 50%, var(--bg-gradient-1), transparent 50%),
    radial-gradient(circle at 85% 30%, var(--bg-gradient-2), transparent 50%),
    radial-gradient(circle at 50% 100%, var(--bg-gradient-3), transparent 60%);
  background-attachment: fixed;
  background-size: cover;
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* Floating Background Orbs */
.bg-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  z-index: -1;
  opacity: 0.6;
  animation: float 20s infinite ease-in-out alternate;
}
.orb-1 {
  width: 400px; height: 400px;
  background: var(--primary);
  top: -100px; left: -100px;
}
.orb-2 {
  width: 300px; height: 300px;
  background: var(--secondary);
  bottom: 20%; right: -50px;
  animation-delay: -5s;
}
.orb-3 {
  width: 250px; height: 250px;
  background: var(--accent);
  top: 40%; left: 30%;
  animation-delay: -10s;
  opacity: 0.4;
}

@keyframes float {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(30px, 50px) scale(1.1); }
  100% { transform: translate(-30px, 20px) scale(0.9); }
}

.layout {
  max-width: 1180px;
  margin: 0 auto;
  padding: 30px 20px 60px;
  display: grid;
  gap: 24px;
  position: relative;
  z-index: 1;
}

/* Glass Panels */
.glass-panel {
  background: var(--glass-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  border-radius: 20px;
  box-shadow: var(--shadow-soft);
  padding: 24px;
  transition: transform 0.3s ease, background 0.3s ease;
}

.glass-panel:hover {
  background: var(--glass-bg-hover);
}

.glass-inner {
  background: var(--glass-inner);
  border: 1px solid rgba(255,255,255,0.05);
  border-radius: 12px;
}

/* Hero Section */
.hero-panel {
  display: grid;
  gap: 16px;
  background: linear-gradient(135deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02));
  border-top: 1px solid rgba(255,255,255,0.3);
  border-left: 1px solid rgba(255,255,255,0.3);
}

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

.hero-brand {
  display: grid;
  gap: 4px;
}

.hero-kicker {
  margin: 0;
  font-size: 13px;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: 0.15em;
  text-transform: uppercase;
}

h1, h2, h3 {
  margin: 0;
  color: var(--text-highlight);
  font-family: "Do Hyeon", "SUIT Variable", sans-serif;
  letter-spacing: -0.01em;
  text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}

h1 {
  font-size: clamp(36px, 5vw, 52px);
  line-height: 1.1;
  background: linear-gradient(to right, #fff, #cbd5e1);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

h2 {
  font-size: 24px;
  line-height: 1.2;
  margin-bottom: 16px;
}

.subtitle {
  margin: 0;
  font-size: 16px;
  color: var(--text-muted);
  line-height: 1.5;
}

.meta {
  margin: 0;
  font-size: 14px;
  color: #64748b;
  line-height: 1.5;
}

.copy-stack,
.history-sort-caption,
.guide-copy {
  white-space: pre-line;
  line-height: 1.6;
  text-wrap: balance;
}

.guide-copy {
  text-wrap: balance;
}

/* Buttons and Links */
.hero-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}

.glass-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 8px 16px;
  border-radius: 9999px;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text-main);
  font-weight: 600;
  text-decoration: none;
  font-size: 14px;
  transition: all 0.2s ease;
  backdrop-filter: blur(8px);
}

.glass-btn:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.4);
  transform: translateY(-2px);
  text-decoration: none;
}

.hero-chips {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 4px;
}

.hero-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  border-radius: 9999px;
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.2), rgba(59, 130, 246, 0.2));
  border: 1px solid rgba(139, 92, 246, 0.3);
  font-size: 13px;
  font-weight: 700;
  color: #e2e8f0;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

/* Session Area */
.session-summary {
  padding: 16px 20px;
  display: grid;
  gap: 8px;
  margin-top: 8px;
}

.session-title {
  margin: 0;
  font-weight: 700;
  font-size: 18px;
  color: #e2e8f0;
}

.session-identity {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}

.session-identity code {
  background: rgba(0,0,0,0.4);
  color: #cbd5e1;
  padding: 4px 10px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 13px;
  border: 1px solid rgba(255,255,255,0.1);
  max-width: 220px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

#identity-label {
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 700;
}

.session-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.nickname-editor {
  display: grid;
  gap: 8px;
  margin-top: 2px;
}

.nickname-editor-label {
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.nickname-editor-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 10px;
  align-items: center;
}

.nickname-editor-row input {
  width: 100%;
  min-width: 0;
}

.nickname-editor-message {
  min-height: 1.4em;
  color: #93c5fd;
}

.identity-badge {
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.provider-google { background: rgba(59, 130, 246, 0.2); color: #93c5fd; border: 1px solid rgba(59, 130, 246, 0.4); }
.provider-naver { background: rgba(16, 185, 129, 0.2); color: #6ee7b7; border: 1px solid rgba(16, 185, 129, 0.4); }
.provider-guest { background: rgba(148, 163, 184, 0.2); color: #cbd5e1; border: 1px solid rgba(148, 163, 184, 0.4); }

/* Grid Layout */
.dashboard-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.8fr) minmax(320px, 1fr);
  gap: 24px;
}

.dashboard-primary,
.dashboard-secondary {
  display: grid;
  gap: 24px;
  align-content: start;
}

.dashboard-secondary .auth-panel {
  order: 1;
}

.dashboard-secondary .guide-panel {
  order: 2;
}

.dashboard-secondary .ranking-panel {
  order: 3;
}

/* Buttons */
button {
  font-family: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: 12px;
  font-weight: 700;
  font-size: 15px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #a855f7);
  color: white;
  border: 1px solid rgba(255,255,255,0.2);
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

.btn-glow {
  position: relative;
}
.btn-glow::after {
  content: "";
  position: absolute;
  top: -2px; left: -2px; right: -2px; bottom: -2px;
  background: inherit;
  border-radius: inherit;
  z-index: -1;
  filter: blur(8px);
  opacity: 0.6;
  transition: opacity 0.2s ease;
}
.btn-glow:hover::after { opacity: 0.9; }

.btn-outline {
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.2);
  color: var(--text-highlight);
}
.btn-outline:hover:not(:disabled) {
  background: rgba(255,255,255,0.1);
  border-color: rgba(255,255,255,0.4);
}

.btn-danger {
  background: linear-gradient(135deg, #ef4444, #b91c1c);
  color: white;
  border: 1px solid rgba(255,100,100,0.3);
}

/* Social Logins */
.auth-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 12px;
}

.social-btn {
  width: 100%;
}
.social-btn.google { background: #ffffff; color: #1e293b; }
.social-btn.google:hover { background: #f8fafc; transform: translateY(-2px); }
.social-btn.naver { background: #03c75a; color: white; }
.social-btn.naver:hover { background: #02b351; transform: translateY(-2px); }
.social-btn.guest { background: rgba(255,255,255,0.1); color: white; border: 1px solid rgba(255,255,255,0.2); }
.social-btn.guest:hover { background: rgba(255,255,255,0.2); transform: translateY(-2px); }

/* Forms & Inputs */
form {
  display: grid;
  gap: 16px;
}

label {
  font-weight: 600;
  color: var(--text-highlight);
  font-size: 14px;
  display: block;
}

input, select {
  width: 100%;
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 12px;
  padding: 14px 16px;
  color: white;
  font-size: 16px;
  font-family: inherit;
  transition: all 0.2s ease;
}

input:focus, select:focus {
  outline: none;
  border-color: var(--primary);
  background: rgba(0,0,0,0.5);
  box-shadow: var(--glow-primary);
}

input::placeholder {
  color: rgba(255,255,255,0.3);
}

.input-group {
  display: flex;
  gap: 12px;
  align-items: center;
}
.input-group .input-wrapper {
  flex: 1;
}
.input-group input {
  margin: 0;
}
.input-group button {
  height: 52px;
  padding: 0 28px;
}

/*
Purpose:
    Styles the public hall-of-fame podium and remaining leaderboard list.
Design Intent:
    Give the top three cumulative winners a medal-stand visual hierarchy while
    keeping lower ranks scannable and compact below the fold.
Non-Goals:
    Does not change hall ranking policy or fetch behavior.
Dependencies:
    `hall-of-fame.html` structure and `hall.js` rendering hooks.
*/
.hall-shell {
  max-width: 980px;
}

.hall-page {
  background-image:
    radial-gradient(circle at 50% -10%, rgba(245, 245, 244, 0.08), transparent 34%),
    linear-gradient(180deg, #0a0a0b 0%, #121214 52%, #1a1a1d 100%);
  user-select: none;
  -webkit-user-select: none;
  caret-color: transparent;
  -webkit-tap-highlight-color: transparent;
}

.hall-page .bg-orb {
  display: none;
}

.hall-page *,
.hall-page *::before,
.hall-page *::after {
  user-select: none;
  -webkit-user-select: none;
  caret-color: transparent;
}

.hall-hero-panel {
  text-align: center;
}

.hall-title {
  font-size: clamp(34px, 5vw, 46px);
}

.hall-lead {
  max-width: 620px;
  margin: 0 auto;
}

.hall-empty-state {
  padding: 20px 18px;
  color: #cbd5e1;
  font-weight: 600;
}

.hall-podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 18px;
  align-items: end;
  margin-top: 14px;
}

.hall-podium-card {
  position: relative;
  display: grid;
  gap: 0;
  align-content: stretch;
  min-height: 246px;
  padding: 16px;
  border-radius: 24px 24px 18px 18px;
  border: 1px solid var(--podium-border, rgba(255,255,255,0.16));
  background:
    radial-gradient(circle at 50% 0%, var(--podium-surface-glow, rgba(255,255,255,0.12)), transparent 58%),
    linear-gradient(145deg, rgba(255,255,255,0.08), rgba(255,255,255,0.02) 36%, rgba(255,255,255,0) 72%),
    linear-gradient(180deg, var(--podium-surface-top, rgba(56, 56, 61, 0.96)), var(--podium-surface-bottom, rgba(46, 46, 51, 0.94)));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.12),
    inset 0 -1px 0 rgba(255,255,255,0.04),
    0 22px 44px var(--podium-shadow, rgba(0, 0, 0, 0.28)),
    0 0 0 1px rgba(255,255,255,0.03);
  text-align: left;
  overflow: hidden;
}

.hall-podium-body {
  position: relative;
  z-index: 1;
  display: grid;
  gap: 8px;
  align-content: end;
  min-height: 100%;
  padding: 18px 18px 22px;
  border-radius: 18px 18px 14px 14px;
  border: 1px solid rgba(255,255,255,0.12);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03) 44%, rgba(255,255,255,0.02)),
    linear-gradient(180deg, rgba(18, 18, 20, 0.76), rgba(30, 30, 33, 0.84));
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.12),
    inset 0 -1px 0 rgba(255,255,255,0.04),
    0 12px 24px rgba(0, 0, 0, 0.16);
}

.hall-podium-card::before {
  content: "";
  position: absolute;
  inset: auto 0 0 0;
  height: var(--podium-base-height, 72px);
  background:
    linear-gradient(180deg, rgba(255,255,255,0.12), rgba(255,255,255,0.03) 18%, rgba(255,255,255,0) 42%),
    linear-gradient(180deg, var(--podium-pedestal-top, rgba(255,255,255,0.12)), var(--podium-pedestal-bottom, rgba(82,82,91,0.62)));
  border-top: 1px solid rgba(255,255,255,0.16);
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.12),
    0 -18px 30px rgba(255, 255, 255, 0.04);
  z-index: 0;
}

.hall-podium-card::after {
  content: "";
  position: absolute;
  inset: 0 0 auto 0;
  height: 6px;
  opacity: 1;
  background: linear-gradient(90deg, var(--podium-accent-soft, rgba(255,255,255,0.28)), var(--podium-accent, rgba(255,255,255,0.9)));
}

.hall-podium-medal {
  justify-self: start;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  border-radius: 50%;
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  border: 1px solid rgba(255,255,255,0.28);
  background:
    radial-gradient(circle at 30% 28%, rgba(255,255,255,0.65), transparent 26%),
    linear-gradient(135deg, var(--podium-medal-start, #e5e7eb), var(--podium-medal-end, #94a3b8));
  box-shadow:
    inset 0 2px 4px rgba(255,255,255,0.28),
    inset 0 -3px 8px rgba(24, 24, 28, 0.22),
    0 10px 22px rgba(0, 0, 0, 0.16);
  position: relative;
  z-index: 1;
}

.hall-podium-rank {
  margin: 0;
  color: var(--podium-accent, #e2e8f0);
  font-size: 14px;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  position: relative;
  z-index: 1;
}

.hall-podium-name {
  font-size: clamp(20px, 3vw, 28px);
  line-height: 1.1;
  color: #f8fafc;
  margin-top: 2px;
  position: relative;
  z-index: 1;
}

.hall-podium-subname {
  margin: -2px 0 0;
  color: #cbd5e1;
  font-size: 13px;
  font-weight: 700;
  line-height: 1.35;
  position: relative;
  z-index: 1;
}

.hall-podium-count {
  margin: 0;
  color: #e2e8f0;
  font-size: 17px;
  font-weight: 800;
  position: relative;
  z-index: 1;
}

.hall-podium-time {
  margin: 0;
  color: #94a3b8;
  font-size: 13px;
  line-height: 1.5;
  position: relative;
  z-index: 1;
}

.podium-rank-1 {
  --podium-border: rgba(250, 204, 21, 0.42);
  --podium-accent-soft: rgba(253, 224, 71, 0.42);
  --podium-accent: #fde68a;
  --podium-surface-glow: rgba(253, 224, 71, 0.18);
  --podium-surface-top: rgba(107, 76, 26, 0.92);
  --podium-surface-bottom: rgba(140, 103, 40, 0.94);
  --podium-pedestal-top: rgba(253, 224, 71, 0.34);
  --podium-pedestal-bottom: rgba(180, 132, 44, 0.94);
  --podium-medal-start: #fef3c7;
  --podium-medal-end: #facc15;
  --podium-base-height: 94px;
  --podium-shadow: rgba(120, 53, 15, 0.22);
  min-height: 300px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.14),
    inset 0 -1px 0 rgba(255,255,255,0.04),
    0 24px 48px rgba(120, 53, 15, 0.24),
    0 0 0 1px rgba(253, 224, 71, 0.08);
}

.podium-rank-1 .hall-podium-medal {
  color: #5b4100;
}

.podium-rank-2 {
  --podium-border: rgba(203, 213, 225, 0.34);
  --podium-accent-soft: rgba(226, 232, 240, 0.34);
  --podium-accent: #e2e8f0;
  --podium-surface-glow: rgba(226, 232, 240, 0.16);
  --podium-surface-top: rgba(110, 116, 126, 0.92);
  --podium-surface-bottom: rgba(138, 144, 154, 0.94);
  --podium-pedestal-top: rgba(226, 232, 240, 0.28);
  --podium-pedestal-bottom: rgba(156, 163, 175, 0.92);
  --podium-medal-start: #f8fafc;
  --podium-medal-end: #cbd5e1;
  --podium-base-height: 68px;
  --podium-shadow: rgba(71, 85, 105, 0.18);
  min-height: 256px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.12),
    inset 0 -1px 0 rgba(255,255,255,0.04),
    0 20px 42px rgba(51, 65, 85, 0.22),
    0 0 0 1px rgba(226, 232, 240, 0.07);
}

.podium-rank-2 .hall-podium-medal {
  color: #334155;
}

.podium-rank-3 {
  --podium-border: rgba(249, 115, 22, 0.34);
  --podium-accent-soft: rgba(251, 146, 60, 0.32);
  --podium-accent: #fdba74;
  --podium-surface-glow: rgba(251, 146, 60, 0.16);
  --podium-surface-top: rgba(116, 75, 44, 0.92);
  --podium-surface-bottom: rgba(146, 94, 56, 0.94);
  --podium-pedestal-top: rgba(251, 146, 60, 0.28);
  --podium-pedestal-bottom: rgba(180, 107, 54, 0.9);
  --podium-medal-start: #fed7aa;
  --podium-medal-end: #f97316;
  --podium-base-height: 54px;
  --podium-shadow: rgba(124, 45, 18, 0.18);
  min-height: 232px;
  box-shadow:
    inset 0 1px 0 rgba(255,255,255,0.12),
    inset 0 -1px 0 rgba(255,255,255,0.04),
    0 18px 40px rgba(124, 45, 18, 0.2),
    0 0 0 1px rgba(251, 146, 60, 0.07);
}

.podium-rank-3 .hall-podium-medal {
  color: #5c2d12;
}

.hall-rest-section {
  display: grid;
  gap: 14px;
  text-align: left;
}

.hall-rest-head {
  display: grid;
  gap: 6px;
  margin-top: 8px;
}

.hall-rest-head h2 {
  margin-bottom: 0;
}

.hall-rest-list {
  gap: 10px;
}

.hall-rest-entry {
  gap: 16px;
}

.hall-rest-rank {
  min-width: 54px;
  color: #d6d3d1;
  font-size: 15px;
  font-weight: 800;
}

.hall-rest-copy {
  flex: 1;
  display: grid;
  gap: 4px;
}

.hall-rest-name {
  color: #f8fafc;
  font-size: 16px;
}

.hall-rest-subname {
  color: #cbd5e1;
  font-size: 12px;
  font-weight: 700;
}

.hall-rest-time {
  color: #94a3b8;
  font-size: 13px;
}

.hall-rest-count {
  color: #f8fafc;
  font-size: 15px;
  font-weight: 800;
  white-space: nowrap;
}

.hall-actions {
  justify-content: center;
  margin-top: 8px;
}

/* Lists and Ranks */
.rank-list {
  margin: 0;
  padding: 0;
  list-style: none;
  display: grid;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(168, 85, 247, 0.82) rgba(15, 23, 42, 0.9);
}

.rank-list li {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 12px;
  padding: 12px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: transform 0.2s ease, background 0.2s ease;
}

.rank-list li:hover {
  background: rgba(255,255,255,0.08);
  transform: translateX(4px);
}

.ranking-panel .rank-list,
.history-panel .rank-list {
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-gutter: stable;
  padding-right: 8px;
}

.ranking-panel .rank-list {
  height: auto;
  max-height: clamp(180px, 34vh, 320px);
}

.history-panel .rank-list {
  max-height: clamp(160px, 30vh, 320px);
}

.rank-list::-webkit-scrollbar {
  width: 10px;
}

.rank-list::-webkit-scrollbar-track {
  border-radius: 999px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(30, 41, 59, 0.88));
}

.rank-list::-webkit-scrollbar-thumb {
  border-radius: 999px;
  border: 2px solid rgba(15, 23, 42, 0.92);
  background: linear-gradient(180deg, rgba(139, 92, 246, 0.9), rgba(59, 130, 246, 0.84));
}

.rank-list::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(168, 85, 247, 0.98), rgba(99, 102, 241, 0.92));
}

.rank-empty {
  color: #cbd5e1;
  justify-content: center;
}

.history-empty-state {
  min-height: 86px;
  padding: 18px 16px;
  align-items: center;
  justify-content: center;
  text-align: center;
  color: #cbd5e1;
  font-size: 14px;
  line-height: 1.5;
}

.rank-entry {
  display: grid !important;
  grid-template-columns: minmax(4.5rem, 4.5rem) minmax(0, 1fr) minmax(5.5rem, 5.5rem);
  align-items: center;
  gap: 14px;
  font-variant-numeric: tabular-nums;
}

.rank-entry-rank,
.rank-entry-score,
.rank-entry-count {
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}

.rank-entry-rank {
  color: #ddd6fe;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.02em;
}

.rank-entry-score {
  justify-self: end;
  color: #e2e8f0;
  text-align: right;
}

.rank-entry-count {
  justify-self: end;
  color: #94a3b8;
  text-align: right;
}

/*
Purpose:
    Styles the guess-history panel header and sort controls.
Design Intent:
    Present sort selection as a first-class review tool inside the panel instead of as a
    lone utility button, so users can understand both the active mode and its effect.
Non-Goals:
    Does not define history ordering policy or localStorage behavior.
Dependencies:
    `.history-panel-*` and `.history-sort-*` hooks from frontend/public/index.html and app.js.
*/
.history-panel-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(260px, 340px);
  gap: 16px;
  align-items: start;
  margin-bottom: 16px;
}

.history-panel-copy {
  display: grid;
  gap: 6px;
}

.history-panel-copy h2 {
  margin-bottom: 0;
}

.history-sort-card {
  padding: 14px 16px;
  display: grid;
  gap: 12px;
  background: linear-gradient(180deg, rgba(15, 23, 42, 0.62), rgba(15, 23, 42, 0.42));
}

.history-sort-head {
  display: grid;
  gap: 4px;
}

.history-sort-label {
  display: inline-flex;
  align-items: center;
  width: fit-content;
  padding: 4px 10px;
  border-radius: 999px;
  background: rgba(139, 92, 246, 0.16);
  border: 1px solid rgba(139, 92, 246, 0.32);
  color: #ddd6fe;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.history-sort-caption {
  color: #94a3b8;
  font-size: 13px;
}

.history-sort-toggle {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.history-sort-button {
  min-height: 42px;
  border: 1px solid rgba(148, 163, 184, 0.25);
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.48);
  color: #cbd5e1;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition:
    transform 0.18s ease,
    border-color 0.18s ease,
    background 0.18s ease,
    color 0.18s ease,
    box-shadow 0.18s ease;
}

.history-sort-button:hover {
  transform: translateY(-1px);
  border-color: rgba(96, 165, 250, 0.48);
  background: rgba(30, 41, 59, 0.72);
}

.history-sort-button:focus-visible {
  outline: 2px solid rgba(96, 165, 250, 0.82);
  outline-offset: 2px;
}

.history-sort-button.is-active {
  color: #eff6ff;
  border-color: rgba(96, 165, 250, 0.78);
  background: linear-gradient(135deg, rgba(59, 130, 246, 0.34), rgba(139, 92, 246, 0.3));
  box-shadow: 0 10px 24px rgba(37, 99, 235, 0.18);
}

.history-entry {
  display: grid !important;
  grid-template-columns: minmax(0, 1fr) minmax(15rem, 15rem);
  gap: 14px;
  align-items: center;
}

.history-entry-word {
  color: #f8fafc;
  font-size: 15px;
  font-weight: 700;
}

.history-entry-meta {
  display: grid;
  grid-template-columns: minmax(7.25rem, 7.25rem) minmax(7.5rem, 7.5rem) minmax(6rem, 6rem);
  align-items: center;
  justify-content: end;
  gap: 10px;
  color: #94a3b8;
  font-size: 13px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.history-entry-similarity,
.history-entry-rank,
.history-entry-count {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.history-entry-similarity {
  text-align: right;
  color: #cbd5e1;
}

.history-entry-rank {
  text-align: right;
  color: #94a3b8;
}

.history-entry-rank.is-empty {
  visibility: hidden;
}

.history-entry-count {
  text-align: right;
  color: #7dd3fc;
}

.guide-list {
  margin: 0;
  padding-left: 20px;
  color: var(--text-muted);
  display: grid;
  gap: 10px;
}
.guide-list li { line-height: 1.5; }
.guide-list strong { color: var(--text-highlight); }

/* Results */
.result-card {
  margin-top: 16px;
  padding: 16px;
}
pre.result-card {
  white-space: pre-wrap;
  word-break: break-word;
  font-family: monospace;
  font-size: 13px;
  color: #a7f3d0;
  max-height: 300px;
  overflow-y: auto;
}
pre.error {
  color: #fca5a5;
  border-color: rgba(239, 68, 68, 0.3);
}

.hidden { display: none !important; }

/* Helpers */
.panel-title-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.panel-title-row h2 { margin-bottom: 0; }

.actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 16px;
}

a {
  color: var(--primary);
  text-decoration: none;
  transition: color 0.2s ease;
}
a:hover {
  text-decoration: underline;
  color: #a855f7;
}

/* Animations */
.list-animated li {
  animation: slide-up 0.4s ease forwards;
  opacity: 0;
}
.list-animated li:nth-child(1) { animation-delay: 0.05s; }
.list-animated li:nth-child(2) { animation-delay: 0.1s; }
.list-animated li:nth-child(3) { animation-delay: 0.15s; }
.list-animated li:nth-child(4) { animation-delay: 0.2s; }
.list-animated li:nth-child(5) { animation-delay: 0.25s; }

.glass-panel {
  animation: fade-in-up 0.6s cubic-bezier(0.16, 1, 0.3, 1) both;
}

.dashboard-primary .glass-panel:nth-child(1) { animation-delay: 0.1s; }
.dashboard-primary .glass-panel:nth-child(2) { animation-delay: 0.2s; }
.dashboard-primary .glass-panel:nth-child(3) { animation-delay: 0.3s; }
.dashboard-secondary .glass-panel:nth-child(1) { animation-delay: 0.25s; }
.dashboard-secondary .glass-panel:nth-child(2) { animation-delay: 0.35s; }

@keyframes fade-in-up {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

@keyframes slide-up {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}

/*
Purpose:
    Applies reduced entrance-motion profile for same-session page transitions.
Design Intent:
    Keep navigation response within doherty-threshold-friendly range by skipping
    non-essential first-paint animations when a fast internal transition is detected.
Non-Goals:
    Does not alter static layout, colors, or interaction semantics.
Dependencies:
    `data-fast-nav="1"` marker set on `<html>` by each page bootstrap script.
*/
html[data-fast-nav="1"] .glass-panel {
  animation: none !important;
}

html[data-fast-nav="1"] .list-animated li {
  animation: none !important;
  opacity: 1 !important;
  transform: none !important;
}

/* Responsive */
@media (max-width: 980px) {
  .dashboard-grid { grid-template-columns: 1fr; }
  .bg-orb { display: none; }
  .history-panel-head { grid-template-columns: 1fr; }
  .dashboard-secondary .auth-panel { order: 1; }
  .dashboard-secondary .guide-panel { order: 2; }
  .dashboard-secondary .ranking-panel { order: 3; }
  .hall-podium {
    grid-template-columns: 1fr;
    align-items: stretch;
  }
  .hall-podium-card {
    order: 0;
  }
  .podium-rank-1 {
    order: 0;
  }
  .podium-rank-2 {
    order: 1;
  }
  .podium-rank-3 {
    order: 2;
  }
  .hall-podium-card,
  .podium-rank-1,
  .podium-rank-2,
  .podium-rank-3 {
    min-height: 0;
  }
}

@media (max-width: 680px) {
  .layout { padding: 16px 12px 40px; }
  h1 { font-size: 32px; }
  .hero-panel {
    grid-template-areas:
      "session"
      "hero"
      "chips";
  }
  .copy-stack,
  .history-sort-caption,
  .guide-copy {
    text-wrap: balance;
  }
  .hero-head {
    grid-area: hero;
  }
  .hero-chips {
    grid-area: chips;
  }
  .session-summary {
    grid-area: session;
  }
  .hero-head { flex-direction: column; align-items: stretch; }
  .hero-links { justify-content: flex-start; margin-top: 8px;}
  .input-group { flex-direction: column; align-items: stretch; }
  .input-group button { height: 48px; }
  .history-sort-card { padding: 12px; }
  .history-sort-toggle { grid-template-columns: 1fr; }
  .nickname-editor-row {
    grid-template-columns: 1fr;
  }
  .dashboard-grid {
    display: flex;
    flex-direction: column;
  }
  .dashboard-primary,
  .dashboard-secondary {
    display: contents;
  }
  .ranking-panel .rank-list {
    height: auto;
    max-height: clamp(160px, 28vh, 260px);
  }
  .history-panel .rank-list {
    max-height: clamp(140px, 24vh, 260px);
  }
  .auth-panel {
    order: 1;
  }
  .guide-panel {
    order: 2;
  }
  .game-panel {
    order: 3;
  }
  .history-panel {
    order: 4;
  }
  .dashboard-secondary .ranking-panel {
    order: 5;
  }
  .history-entry {
    flex-direction: column;
    align-items: flex-start;
    grid-template-columns: 1fr;
  }
  .history-entry-meta {
    text-align: left;
    justify-content: start;
    grid-template-columns: minmax(7rem, 7rem) minmax(7rem, 7rem) minmax(6rem, 6rem);
  }
  .rank-entry {
    grid-template-columns: minmax(3.5rem, 3.5rem) minmax(0, 1fr) minmax(5rem, 5rem);
  }
  .hall-rest-entry {
    flex-direction: column;
    align-items: flex-start;
  }
  .hall-rest-rank {
    min-width: 0;
  }
}
