@import url('https://fonts.googleapis.com/css2?family=Sora:wght@600;700;800&family=Inter:wght@400;500;600;700;800&display=swap');

* { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --purple:       #2563EB;
  --purple-mid:   #3B82F6;
  --purple-light: #93C5FD;
  --green:        #14B8A6;
  --green-light:  #2DD4BF;
  --yellow:       #F59E0B;
  --yellow-light: #FCD34D;
  --red:          #EF4444;
  --red-light:    #FCA5A5;
  --blue:         #38BDF8;
  --bg:           #0B1220;
  --bg2:          #0F172A;
  --bg3:          #111827;
  --surface:      #121B2D;
  --surface2:     #182235;
  --border:       rgba(148,163,184,0.18);
  --border-hover: rgba(148,163,184,0.3);
  --text:         #E5EEF9;
  --text-muted:   rgba(226,232,240,0.62);
  --text-dim:     rgba(226,232,240,0.4);
  --radius:    14px;
  --radius-sm: 10px;
  --radius-xs:  7px;
  --shadow:    0 8px 28px rgba(2,6,23,0.32);
  --shadow-lg: 0 16px 52px rgba(2,6,23,0.42);
}

body {
  font-family: 'Inter', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: 'Inter', sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  padding: 0.8rem 1.8rem;
  border-radius: 50px;
  border: none;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s, opacity 0.15s;
  white-space: nowrap;
}
.btn:hover  { transform: translateY(-2px); box-shadow: var(--shadow); }
.btn:active { transform: translateY(0) scale(0.98); }
.btn:disabled { opacity: 0.35; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-primary  { background: var(--purple); color: #fff; }
.btn-primary:hover { background: var(--purple-mid); box-shadow: 0 8px 28px rgba(124,58,237,0.45); }
.btn-secondary { background: var(--green); color: #062318; font-weight: 800; }
.btn-secondary:hover { background: var(--green-light); box-shadow: 0 8px 28px rgba(16,185,129,0.4); }
.btn-yellow { background: var(--yellow); color: #1a0a00; font-weight: 800; }
.btn-yellow:hover { background: var(--yellow-light); box-shadow: 0 8px 28px rgba(245,158,11,0.4); }
.btn-danger { background: var(--red); color: #fff; }
.btn-danger:hover { box-shadow: 0 8px 28px rgba(239,68,68,0.4); }
.btn-outline { background: transparent; border: 1.5px solid var(--border-hover); color: var(--text-muted); }
.btn-outline:hover { border-color: rgba(255,255,255,0.4); color: var(--text); }
.btn-sm   { padding: 0.5rem 1.1rem; font-size: 0.82rem; }
.btn-full { width: 100%; }

.page-home {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  overflow: hidden;
}
.page-home::before {
  content: '';
  position: absolute;
  width: 700px; height: 700px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(124,58,237,0.15) 0%, transparent 65%);
  top: -200px; left: 50%;
  transform: translateX(-50%);
  pointer-events: none;
}
.page-home::after {
  content: '';
  position: absolute;
  width: 400px; height: 400px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(16,185,129,0.1) 0%, transparent 65%);
  bottom: -100px; right: 10%;
  pointer-events: none;
}
.home-container { text-align: center; padding: 2rem; max-width: 820px; width: 100%; position: relative; z-index: 1; }
.home-logo { font-family: 'Sora', sans-serif; font-weight: 900; font-size: 5rem; line-height: 1; margin-bottom: 0.75rem; letter-spacing: -2px; }
.logo-quiz { color: var(--text); }
.logo-ua { 
  background: linear-gradient(135deg, #93C5FD 0%, #67E8F9 55%, #FCD34D 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.home-tagline { color: var(--text-muted); font-size: 1.1rem; margin-bottom: 3.5rem; font-weight: 500; }
.home-cards { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; margin-bottom: 2.5rem; }
@media (max-width: 600px) { .home-cards { grid-template-columns: 1fr; } .home-logo { font-size: 3.5rem; } }
.home-card { background: var(--surface); border: 1px solid var(--border); border-radius: 20px; padding: 2.25rem 1.75rem; transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s; }
.home-card:hover { transform: translateY(-5px); box-shadow: var(--shadow-lg); }
.card-host:hover { border-color: rgba(124,58,237,0.45); box-shadow: 0 12px 40px rgba(124,58,237,0.15); }
.card-play:hover { border-color: rgba(16,185,129,0.45); box-shadow: 0 12px 40px rgba(16,185,129,0.15); }
.card-icon { font-size: 2.75rem; margin-bottom: 1.1rem; display: block; }
.home-card h2 { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 1.3rem; margin-bottom: 0.6rem; }
.home-card p { color: var(--text-muted); font-size: 0.88rem; margin-bottom: 1.75rem; line-height: 1.7; }
.home-footer { color: var(--text-dim); font-size: 0.82rem; }

body:not(.page-play) .join-card,
body:not(.page-play) .auth-card {
  margin: auto;
}
.page-auth {
  min-height: 100vh;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
}

.page-admin { min-height: 100vh; background: var(--bg2); }
.topbar { background: rgba(8,11,20,0.85); backdrop-filter: blur(12px); border-bottom: 1px solid var(--border); padding: 0 1.5rem; height: 56px; display: flex; align-items: center; gap: 1rem; position: sticky; top: 0; z-index: 50; }
.topbar-logo { font-family: 'Sora', sans-serif; font-weight: 900; font-size: 1.25rem; letter-spacing: -0.5px; }
.topbar-logo .logo-ua { 
  background: linear-gradient(135deg, #93C5FD 0%, #67E8F9 55%, #FCD34D 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.topbar-right { margin-left: auto; display: flex; align-items: center; gap: 0.75rem; }
.badge { font-size: 0.67rem; font-weight: 700; padding: 0.22rem 0.65rem; border-radius: 999px; text-transform: uppercase; letter-spacing: 0.08em; }
.badge-purple { background: rgba(124,58,237,0.2); color: var(--purple-light); border: 1px solid rgba(124,58,237,0.35); }
.badge-green  { background: rgba(16,185,129,0.2); color: var(--green-light); border: 1px solid rgba(16,185,129,0.35); }

.tabs { display: flex; border-bottom: 1px solid var(--border); padding: 0 1.5rem; background: rgba(8,11,20,0.5); gap: 0.25rem; }
.tab-btn { background: transparent; border: none; border-bottom: 2px solid transparent; color: var(--text-muted); font-family: 'Inter', sans-serif; font-weight: 600; font-size: 0.875rem; padding: 0.9rem 1.1rem; cursor: pointer; transition: color 0.2s, border-color 0.2s; margin-bottom: -1px; }
.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--purple-light); border-bottom-color: var(--purple-light); }
.tab-content { display: none; }
.tab-content.active { display: block; }

.admin-main { padding: 1.75rem; max-width: 900px; margin: 0 auto; }
.section-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 1.25rem; }
.section-title { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 1rem; letter-spacing: -0.3px; }
.quiz-list { display: flex; flex-direction: column; gap: 0.65rem; }
.quiz-item { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.1rem 1.35rem; display: flex; align-items: center; gap: 1rem; transition: border-color 0.2s, transform 0.15s; }
.quiz-item:hover { border-color: rgba(124,58,237,0.4); transform: translateX(3px); }
.quiz-item-info { flex: 1; min-width: 0; }
.quiz-item-title { font-weight: 700; font-size: 0.95rem; margin-bottom: 3px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.quiz-item-meta  { font-size: 0.76rem; color: var(--text-muted); }
.quiz-item-actions { display: flex; gap: 0.5rem; flex-shrink: 0; flex-wrap: wrap; }

.quiz-editor { padding: 1.75rem; max-width: 800px; margin: 0 auto; }
.form-group { margin-bottom: 1.1rem; }
.form-label { display: block; font-size: 0.75rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-muted); margin-bottom: 0.45rem; }
.form-input { width: 100%; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 0.75rem 1rem; color: var(--text); font-family: 'Inter', sans-serif; font-size: 0.92rem; outline: none; transition: border-color 0.2s, box-shadow 0.2s; }
.form-input:focus { border-color: rgba(124,58,237,0.6); box-shadow: 0 0 0 3px rgba(124,58,237,0.12); }
.form-input::placeholder { color: var(--text-dim); }
select.form-input { cursor: pointer; }

.questions-list { display: flex; flex-direction: column; gap: 1.1rem; margin-bottom: 1rem; }
.question-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem 1.35rem; transition: border-color 0.2s; }
.question-card:hover { border-color: rgba(124,58,237,0.3); }
.question-card-header { display: flex; align-items: center; gap: 0.75rem; margin-bottom: 1rem; }
.q-num { min-width: 28px; height: 28px; border-radius: 50%; background: var(--purple); display: flex; align-items: center; justify-content: center; font-size: 0.75rem; font-weight: 800; flex-shrink: 0; }
.q-delete { background: transparent; border: 1px solid rgba(239,68,68,0.3); color: var(--red-light); border-radius: var(--radius-xs); padding: 0.35rem 0.6rem; font-size: 0.78rem; cursor: pointer; transition: background 0.15s; flex-shrink: 0; }
.q-delete:hover { background: rgba(239,68,68,0.15); border-color: rgba(239,68,68,0.6); }

.answers-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 0.65rem; }
@media (max-width: 540px) { .answers-grid { grid-template-columns: 1fr; } }

.answer-opt { display: flex; align-items: center; gap: 0.65rem; padding: 0.65rem 0.85rem; border-radius: var(--radius-sm); border: 1.5px solid var(--border); cursor: pointer; transition: border-color 0.15s, background 0.15s; background: var(--bg3); }
.answer-opt:hover { border-color: var(--border-hover); }
.answer-opt.correct { border-color: var(--green) !important; background: rgba(16,185,129,0.12) !important; }
.answer-opt.correct .opt-radio { background: var(--green) !important; border-color: var(--green) !important; }
.opt-radio { width: 16px; height: 16px; border-radius: 50%; border: 2px solid var(--border-hover); flex-shrink: 0; transition: border-color 0.15s, background 0.15s; }
.answer-opt.opt-0 .opt-radio { border-color: #FF3355; }
.answer-opt.opt-1 .opt-radio { border-color: #46CCF0; }
.answer-opt.opt-2 .opt-radio { border-color: #57E58A; }
.answer-opt.opt-3 .opt-radio { border-color: #FFCC00; }
.opt-input { flex: 1; background: transparent; border: none; color: var(--text); font-family: 'Inter', sans-serif; font-size: 0.88rem; font-weight: 500; outline: none; }
.opt-input::placeholder { color: var(--text-dim); }

.add-question-btn { width: 100%; padding: 0.85rem; background: transparent; border: 1.5px dashed rgba(124,58,237,0.4); border-radius: var(--radius); color: var(--purple-light); font-family: 'Inter', sans-serif; font-weight: 700; font-size: 0.9rem; cursor: pointer; transition: border-color 0.2s, background 0.2s; margin-bottom: 1.25rem; }
.add-question-btn:hover { border-color: var(--purple); background: rgba(124,58,237,0.07); }

.room-layout { display: grid; grid-template-columns: 1fr 280px; gap: 1.5rem; padding: 1.75rem; max-width: 1100px; margin: 0 auto; height: calc(100vh - 100px); overflow: hidden; }
@media (max-width: 780px) { .room-layout { grid-template-columns: 1fr; height: auto; overflow: visible; } }
.room-main    { overflow-y: auto; padding-right: 0.5rem; }
.room-sidebar { display: flex; flex-direction: column; gap: 1.5rem; overflow-y: auto; }

.room-code-card { background: linear-gradient(135deg, rgba(124,58,237,0.2), rgba(167,139,250,0.08)); border: 1px solid rgba(124,58,237,0.3); border-radius: var(--radius); padding: 1.35rem; text-align: center; }
.room-code-label { font-size: 0.68rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.14em; color: var(--text-muted); margin-bottom: 0.5rem; }
.room-code { font-family: 'Sora', sans-serif; font-weight: 900; font-size: 2.6rem; color: var(--purple-light); letter-spacing: 0.18em; }
.room-code-hint { font-size: 0.72rem; color: var(--text-muted); margin-top: 0.45rem; }

.players-list { display: flex; flex-direction: column; gap: 0.45rem; margin-top: 0.6rem; }
.player-item { display: flex; align-items: center; gap: 0.65rem; padding: 0.55rem 0.8rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius-sm); animation: slideIn 0.3s ease; }
@keyframes slideIn { from { opacity:0; transform:translateX(-10px); } to { opacity:1; transform:translateX(0); } }
.player-avatar { width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-family: 'Sora', sans-serif; font-weight: 900; font-size: 0.65rem; color: white; flex-shrink: 0; }
.player-name  { font-weight: 600; font-size: 0.85rem; flex: 1; }
.player-ready { font-size: 0.65rem; color: var(--green); margin-left: auto; }

.pulse-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); animation: pulse 1.6s infinite; flex-shrink: 0; }
@keyframes pulse { 0%,100%{opacity:1;transform:scale(1)} 50%{opacity:0.4;transform:scale(1.5)} }

.timer-wrap {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  flex-shrink: 0;
}
.timer-wrap::after {
  content: '';
  position: absolute;
  inset: 5px;
  border-radius: 50%;
  background: var(--surface);
  z-index: 0;
}
.timer-num {
  font-family: 'Sora', sans-serif;
  font-weight: 900;
  z-index: 1;
  position: relative;
}

.question-box { background: var(--surface); border: 1px solid var(--border); border-radius: 18px; padding: 2rem 2.25rem; text-align: center; width: 100%; max-width: 760px; margin-bottom: 1.5rem; }
.question-label { font-size: 0.7rem; font-weight: 700; text-transform: uppercase; letter-spacing: 0.12em; color: var(--text-muted); margin-bottom: 0.85rem; }
.question-text { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 1.5rem; line-height: 1.4; }

.answers-grid-game { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; width: 100%; max-width: 900px; }
@media (max-width: 560px) { .answers-grid-game { grid-template-columns: 1fr; } }

.answer-btn {
  padding: 1.4rem 1.75rem;
  border-radius: 16px;
  font-family: 'Sora', sans-serif;
  font-weight: 800;
  font-size: 1.05rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  cursor: pointer;
  transition: transform 0.15s, opacity 0.2s, filter 0.2s, box-shadow 0.2s;
  border: none;
  color: white;
  text-align: left;
  line-height: 1.35;
  text-shadow: 0 1px 3px rgba(0,0,0,0.3);
  min-height: 72px;
}
.answer-btn:hover:not(:disabled) { transform: scale(1.03); filter: brightness(1.1); }
.answer-btn:active:not(:disabled) { transform: scale(0.98); }
.answer-btn.ans-0 { background: #E21B3C; box-shadow: 0 4px 20px rgba(226,27,60,0.4); }
.answer-btn.ans-1 { background: #1368CE; box-shadow: 0 4px 20px rgba(19,104,206,0.4); }
.answer-btn.ans-2 { background: #D89E00; box-shadow: 0 4px 20px rgba(216,158,0,0.4); color: #1a0a00; text-shadow: none; }
.answer-btn.ans-3 { background: #26890C; box-shadow: 0 4px 20px rgba(38,137,12,0.4); }

.answer-btn.selected { box-shadow: 0 0 0 4px white, 0 0 20px rgba(255,255,255,0.2) !important; transform: scale(1.02) !important; }
.answer-btn.dimmed   { opacity: 0.25; transform: scale(0.97) !important; filter: saturate(0.2); box-shadow: none !important; }
.answer-btn.correct  { opacity: 0.25; transform: scale(0.97) !important; filter: saturate(0.2); box-shadow: none !important; }
.answer-btn.wrong    { opacity: 0.25; transform: scale(0.97) !important; filter: saturate(0.2); box-shadow: none !important; }
.answer-btn:disabled { cursor: default; }

.ans-shape { min-width: 32px; height: 32px; border-radius: 8px; background: rgba(255,255,255,0.22); display: flex; align-items: center; justify-content: center; font-size: 0.9rem; font-weight: 900; flex-shrink: 0; }

.lb-title { font-family: 'Sora', sans-serif; font-weight: 900; font-size: 1.9rem; margin-bottom: 1.5rem; color: var(--text); text-align: center; letter-spacing:-0.02em; }
.lb-list { width: 100%; max-width: 540px; display: flex; flex-direction: column; gap: 0.65rem; margin-bottom: 1.75rem; }
.lb-item { display: flex; align-items: center; gap: 0.9rem; padding: 0.85rem 1.2rem; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); animation: slideUp 0.4s ease both; opacity: 0; }
.lb-item:nth-child(1) { animation-delay:0.07s; border-color:rgba(245,158,11,0.4); background:rgba(245,158,11,0.07); }
.lb-item:nth-child(2) { animation-delay:0.14s; }
.lb-item:nth-child(3) { animation-delay:0.21s; }
.lb-item:nth-child(4) { animation-delay:0.28s; }
.lb-item:nth-child(5) { animation-delay:0.35s; }
@keyframes slideUp { to { opacity:1; transform:translateY(0); } from { transform:translateY(14px); } }
.lb-rank  { 
  font-family:'Sora',sans-serif; 
  font-weight:900; 
  font-size:0.98rem; 
  min-width:34px; 
  width:34px;
  height:34px;
  border-radius:999px;
  display:flex;
  align-items:center;
  justify-content:center;
  text-align:center;
  color:#93C5FD;
  background: rgba(37,99,235,0.14);
  border:1px solid rgba(59,130,246,0.2);
}
.lb-info  { flex:1; min-width:0; }
.lb-name  { font-weight:700; font-size:0.9rem; margin-bottom:4px; white-space:nowrap; overflow:hidden; text-overflow:ellipsis; }
.lb-bar-bg   { height:3px; border-radius:2px; background:rgba(255,255,255,0.08); overflow:hidden; }
.lb-bar-fill { height:100%; border-radius:2px; transition:width 1.1s ease; }
.lb-score { font-family:'Sora',sans-serif; font-weight:900; font-size:1rem; color:var(--purple-light); min-width:60px; text-align:right; }

.page-play {
  min-height: 100vh;
  min-height: 100dvh;
  background: var(--bg);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  position: relative;
  overflow-x: hidden;
  overflow-y: auto;
}
.page-play::before { content: ''; position: absolute; width: 500px; height: 500px; border-radius: 50%; background: radial-gradient(circle, rgba(16,185,129,0.1) 0%, transparent 65%); bottom: -150px; left: -100px; pointer-events: none; }

.screen-center {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  min-height: 100dvh;
  padding: 1.5rem;
  position: relative;
  z-index: 1;
}

.screen-question {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 1;
}

.q-top {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0.85rem 1.5rem 0.8rem;
  text-align: center;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
}
.q-timer-row {
  margin-bottom: 0.35rem;
}
.q-image {
  width: 100%;
  max-height: 180px;
  object-fit: cover;
  border-radius: 8px;
  margin-top: 0.6rem;
  display: block;
}

.q-bottom {
  flex: 1;
  min-height: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem 1.5rem;
  overflow-y: auto;
}

.answers-grid-game { display: grid; grid-template-columns: 1fr 1fr; gap: 0.85rem; width: 100%; max-width: 880px; }

.result-overlay {
  position: fixed !important;
  bottom: 0; left: 0; right: 0;
  z-index: 900;
  padding: 0.75rem 1rem;
  padding-bottom: max(0.75rem, env(safe-area-inset-bottom));
  background: linear-gradient(to top, rgba(8,11,20,0.98) 70%, transparent);
  pointer-events: none;
}
.result-overlay > * { pointer-events: auto; }

.join-card { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 2.75rem 2.25rem; width: 100%; max-width: 420px; text-align: center; position: relative; z-index: 1; box-shadow: var(--shadow-lg); }
.join-title { font-family:'Sora',sans-serif; font-weight:900; font-size:1.65rem; margin-bottom:0.4rem; }
.join-sub   { color:var(--text-muted); font-size:0.88rem; margin-bottom:2rem; }

.player-status { background: var(--surface); border: 1px solid var(--border); border-radius: 22px; padding: 2.5rem 2rem; text-align: center; width: 100%; max-width: 420px; position: relative; z-index: 1; box-shadow: var(--shadow-lg); }
.status-emoji  { font-size: 3.5rem; margin-bottom: 1rem; display: block; }
.status-title  { font-family:'Sora',sans-serif; font-weight:900; font-size:1.5rem; margin-bottom:0.5rem; }
.status-sub    { color:var(--text-muted); font-size:0.88rem; }

.end-card { background: var(--surface); border: 1px solid var(--border); border-radius: 24px; padding: 2.5rem 2rem; text-align: center; width: 100%; max-width: 520px; position: relative; z-index: 1; box-shadow: var(--shadow-lg); }
.end-trophy { font-size: 4.5rem; margin-bottom: 0.75rem; animation: bounceIn 0.6s cubic-bezier(0.34,1.56,0.64,1); }
@keyframes bounceIn { from { transform:scale(0); } to { transform:scale(1); } }
.end-title { font-family: 'Sora', sans-serif; font-weight: 900; font-size: 1.8rem; margin-bottom: 0.5rem; }
.end-sub { color: var(--text-muted); font-size: 0.95rem; font-weight: 600; }

.toast { position: fixed; bottom: 1.75rem; left: 50%; transform: translateX(-50%) translateY(80px); background: var(--surface2); border: 1px solid var(--border-hover); padding: 0.7rem 1.5rem; border-radius: 50px; font-weight: 600; font-size: 0.88rem; transition: transform 0.3s cubic-bezier(0.34,1.56,0.64,1); z-index: 1000; white-space: nowrap; box-shadow: var(--shadow); }
.toast.show    { transform: translateX(-50%) translateY(0); }
.toast.error   { border-color: rgba(239,68,68,0.45);  color: var(--red-light); }
.toast.success { border-color: rgba(16,185,129,0.45); color: var(--green-light); }

.hidden      { display: none !important; }
.text-muted  { color: var(--text-muted); }
.text-center { text-align: center; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mt-3 { margin-top: 1.75rem; }
.gap-row { display: flex; gap: 0.75rem; flex-wrap: wrap; align-items: center; }

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

@keyframes slideUpOverlay {
  from { opacity:0; transform:translateY(60px); }
  to   { opacity:1; transform:translateY(0); }
}
.result-overlay-inner {
  border-radius: 14px;
  padding: 0.9rem 1.1rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  animation: slideUpOverlay 0.35s cubic-bezier(0.34,1.56,0.64,1);
}
.result-overlay-left {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
}
.result-overlay-copy {
  min-width: 0;
}
.result-correct { background: rgba(16,185,129,0.15); border: 2px solid #10B981; }
.result-wrong   { background: rgba(239,68,68,0.15);  border: 2px solid #EF4444; }
.result-neutral { background: rgba(14,165,233,0.12); border: 2px solid rgba(56,189,248,0.45); }
.result-overlay-emoji { font-size: 1.75rem; flex-shrink: 0; }
.result-overlay-title { font-family: 'Sora', sans-serif; font-weight: 800; font-size: 1rem; line-height: 1.05; }
.result-correct .result-overlay-title { color: #34D399; }
.result-wrong   .result-overlay-title { color: #FCA5A5; }
.result-neutral .result-overlay-title { color: #BAE6FD; }
.result-overlay-points { font-family: 'Sora', sans-serif; font-weight: 900; font-size: 1.6rem; flex-shrink: 0; }
.result-correct .result-overlay-points { color: #FCD34D; }
.result-wrong   .result-overlay-points { color: rgba(255,255,255,0.75); }
.result-neutral .result-overlay-points { color: #E5EEF9; }
.result-overlay-total {
  font-size: 0.78rem;
  color: rgba(241,245,255,0.72);
  margin-top: 0.2rem;
}
.result-overlay-streak { font-size: 0.85rem; font-weight: 700; color: #F59E0B; }

@media (max-width: 768px) {
  .page-home { align-items: flex-start; padding: 1rem; }
  .home-container { padding: 1rem 0.5rem; }
  .home-logo { font-size: 2.8rem; margin-bottom: 0.5rem; }
  .home-tagline { font-size: 0.9rem; margin-bottom: 1.5rem; }
  .home-cards { grid-template-columns: 1fr; gap: 0.75rem; margin-bottom: 1.25rem; }
  .home-card { padding: 1.25rem 1rem; border-radius: 16px; }
  .home-card h2 { font-size: 1rem; margin-bottom: 0.35rem; }
  .home-card p { font-size: 0.82rem; margin-bottom: 1.1rem; line-height: 1.5; }
  .card-icon { font-size: 2rem; margin-bottom: 0.65rem; }
  .home-footer { font-size: 0.75rem; }

  .topbar { padding: 0 1rem; gap: 0.5rem; }
  .topbar-logo { font-size: 1.1rem; }
  #userName { display: none; }

  .tabs { padding: 0 0.5rem; overflow-x: auto; gap: 0; }
  .tab-btn { padding: 0.75rem 0.75rem; font-size: 0.78rem; white-space: nowrap; }

  .admin-main { padding: 1rem; }
  .quiz-editor { padding: 1rem; }
  .quiz-item { flex-direction: column; align-items: flex-start; gap: 0.75rem; }
  .quiz-item-actions { display: flex; flex-wrap: wrap; gap: 0.4rem; width: 100%; }
  .quiz-item-actions .btn { flex: 1; min-width: calc(50% - 0.2rem); font-size: 0.75rem; padding: 0.45rem 0.5rem; }

  .question-card-header { flex-wrap: wrap; gap: 0.5rem; }
  .question-card-header .form-input[style*="flex:1"] { width: 100%; order: -1; flex: none !important; }
  .question-card-header select { width: calc(50% - 0.25rem) !important; }
  .question-card-header .btn-outline { padding: 0.4rem 0.6rem; font-size: 0.75rem; }

  .room-layout {
    grid-template-columns: 1fr;
    height: auto;
    overflow: visible;
    padding: 1rem;
    gap: 1rem;
  }
  .room-sidebar { flex-direction: row; flex-wrap: wrap; gap: 1rem; }
  .room-code-card { flex: 1; min-width: 160px; }
  .room-code { font-size: 2rem; letter-spacing: 0.1em; }

  .question-box { padding: 1.25rem 1rem; }
  .question-text { font-size: 1.1rem; }
  .answers-grid-game { grid-template-columns: 1fr; gap: 0.65rem; }
  .answer-btn { padding: 1rem 1.25rem; font-size: 0.95rem; border-radius: 14px; }

  .screen-center {
    padding: 0.75rem;
    padding-top: 1.25rem;
    align-items: flex-start;
  }
  .join-card  { padding: 1.5rem 1.1rem; border-radius: 16px; }
  .join-title { font-size: 1.2rem; }
  .join-sub   { font-size: 0.8rem; margin-bottom: 1rem; }
  #codeInput  { font-size: 1.3rem !important; letter-spacing: 4px !important; }
  .player-status { padding: 1.75rem 1.1rem; }
  .status-emoji  { font-size: 2.75rem; margin-bottom: 0.65rem; }
  .status-title  { font-size: 1.1rem; }

  .q-top {
    padding: 0.55rem 0.75rem 0.5rem;
  }
  .q-timer-row { margin-bottom: 0.2rem; }
  #playerTimer     { width: 38px !important; height: 38px !important; }
  #playerTimerNum  { font-size: 0.8rem !important; }
  .question-label  { font-size: 0.58rem; margin-bottom: 0.2rem; letter-spacing: 0.1em; }
  .question-text   { font-size: 0.88rem !important; line-height: 1.35; }
  .q-image         { max-height: 110px; border-radius: 6px; margin-top: 0.4rem; }

  .q-bottom {
    padding: 0.5rem 0.5rem;
    padding-bottom: max(4.5rem, calc(env(safe-area-inset-bottom) + 4.5rem));
    align-items: flex-start;
  }

  .answers-grid-game {
    grid-template-columns: 1fr;
    gap: 0.4rem;
    max-width: 100%;
  }
  .answer-btn {
    padding: 0.75rem 0.75rem 0.75rem 0.5rem !important;
    font-size: 0.9rem !important;
    border-radius: 10px !important;
    min-height: 0 !important;
    gap: 0.65rem !important;
  }
  .ans-shape {
    min-width: 28px !important;
    height: 28px !important;
    font-size: 0.72rem !important;
    border-radius: 6px !important;
    flex-shrink: 0 !important;
  }

  .result-overlay {
    padding: 0.5rem 0.6rem !important;
    padding-bottom: max(0.6rem, env(safe-area-inset-bottom)) !important;
  }
  .result-overlay-inner  { padding: 0.65rem 0.85rem; border-radius: 11px; gap: 0.65rem; }
  .result-overlay-emoji  { font-size: 1.3rem; }
  .result-overlay-title  { font-size: 0.82rem; }
  .result-overlay-points { font-size: 1.15rem; }
  .result-overlay-total  { font-size: 0.67rem; }

  .lb-wrap  { max-width: 100%; }
  .lb-title { font-size: 1.2rem; margin-bottom: 0.6rem; }
  .lb-list  { max-width: 100%; margin-bottom: 0.5rem; }
  .lb-item  { padding: 0.55rem 0.75rem; gap: 0.5rem; border-radius: 11px; }
  .lb-rank  { font-size: 0.95rem; min-width: 24px; }
  .lb-name  { font-size: 0.8rem; }
  .lb-score { font-size: 0.8rem; min-width: 34px; }

  .end-card   { padding: 1.5rem 1rem; border-radius: 16px; }
  .end-trophy { font-size: 2.75rem; }
  .end-title  { font-size: 1.2rem; }

  #reportStats { grid-template-columns: 1fr 1fr; }

  .toast {
    width: calc(100% - 2rem);
    white-space: normal;
    text-align: center;
    font-size: 0.8rem;
    bottom: max(1rem, calc(env(safe-area-inset-bottom) + 0.5rem));
  }
}

@media (max-width: 400px) {
  .home-logo { font-size: 2.4rem; }
  .home-card { padding: 1rem 0.85rem; }
  .answer-btn { font-size: 0.82rem; padding: 0.8rem 0.75rem; }
  .join-card { padding: 1.35rem 0.9rem; }
  #codeInput { font-size: 1.15rem !important; letter-spacing: 3px !important; }
  .quiz-item-actions .btn { font-size: 0.7rem; padding: 0.4rem 0.4rem; }
  #playerQImage { max-height: 130px !important; }
}

@keyframes slideDown {
  from { transform: translateY(-100%); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ===== QUIZUA PLAY MOBILE / DESKTOP FIX ===== */

.kahoot-mobile.screen-question,
#screenQuestion.screen-question {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-height: 100dvh;
  background:
    linear-gradient(180deg, #101933 0%, #081127 54%, #03101c 100%);
}

.km-top {
  flex: 0 0 auto;
  background: #121d3d;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  padding: calc(env(safe-area-inset-top) + 8px) 18px 14px;
  text-align: center;
}

.km-timer-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 8px;
}

.km-timer {
  width: 82px;
  height: 82px;
  background: conic-gradient(#F59E0B 360deg, rgba(255,255,255,0.08) 0deg);
  box-shadow: 0 10px 26px rgba(2,6,23,0.34), inset 0 0 0 1px rgba(255,255,255,0.06);
}
.km-timer::after {
  inset: 6px;
  background: radial-gradient(circle at 50% 30%, rgba(22,34,53,0.98), rgba(11,18,32,0.98));
  box-shadow: inset 0 0 0 1px rgba(148,163,184,0.08);
}
.km-timer .timer-num {
  font-size: 1.7rem;
  color: #F59E0B;
  letter-spacing: -0.03em;
}

.km-question-text {
  font-family: 'Sora', sans-serif;
  font-weight: 800;
  font-size: 2rem;
  line-height: 1.16;
  margin: 0 auto;
  max-width: 1100px;
}

.km-image-frame {
  width: min(1200px, calc(100vw - 60px));
  margin: 14px auto 0;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 18px;
  overflow: hidden;
  padding: 10px;
}

.km-image {
  display: block;
  width: 100%;
  height: clamp(180px, 33vh, 340px);
  object-fit: contain;
  object-position: center;
  background: #0f1731;
  border-radius: 12px;
}

.km-bottom {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  padding: 14px 18px 18px;
  gap: 12px;
  overflow-y: auto;
}

.km-bottom.km-bottom-center {
  justify-content: center;
  align-items: center;
}

.km-multiple-hint {
  text-align: center;
  font-size: 0.96rem;
  font-weight: 800;
  color: #FCD34D;
  padding: 2px 0 4px;
}

.km-answers-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
}

.km-answer {
  border: 1px solid rgba(148,163,184,0.18);
  border-radius: 22px;
  min-height: 110px;
  display: flex;
  align-items: center;
  gap: 18px;
  text-align: left;
  padding: 20px 22px;
  font-family: 'Inter', sans-serif;
  font-weight: 800;
  font-size: 1.5rem;
  color: #fff;
  cursor: pointer;
  transition: transform 0.14s ease, box-shadow 0.14s ease, filter 0.14s ease, opacity 0.14s ease, border-color 0.14s ease;
  box-shadow: 0 8px 26px rgba(0,0,0,0.22);
  background: linear-gradient(135deg, rgba(18,27,45,0.98), rgba(11,18,32,0.98));
  position: relative;
}
.km-answer::before {
  content: '';
  width: 22px;
  height: 22px;
  border-radius: 999px;
  border: 3px solid rgba(148,163,184,0.35);
  flex-shrink: 0;
  box-shadow: inset 0 0 0 4px rgba(11,18,32,0.98);
}
.km-answer:hover:not(:disabled) {
  transform: translateY(-2px);
  border-color: rgba(96,165,250,0.42);
  box-shadow: 0 14px 34px rgba(2,6,23,0.3);
}
.km-answer:disabled {
  cursor: default;
}
.km-answer-text {
  display: block;
  line-height: 1.15;
}
.km-color-0,
.km-color-1,
.km-color-2,
.km-color-3 {
  background: linear-gradient(135deg, rgba(18,27,45,0.98), rgba(11,18,32,0.98));
  color: #fff;
}
.km-answer.selected {
  border-color: rgba(56,189,248,0.88);
  box-shadow: 0 0 0 3px rgba(56,189,248,0.12), 0 14px 36px rgba(3,105,161,0.2) !important;
  transform: translateY(-1px) !important;
}
.km-answer.selected::before {
  border-color: #38BDF8;
  background: radial-gradient(circle at center, #38BDF8 0 45%, transparent 46%);
}
.km-answer.dimmed {
  opacity: 0.28;
  transform: scale(0.985) !important;
  filter: saturate(0.18);
  box-shadow: none !important;
}
.km-answer.correct {
  border-color: rgba(45,212,191,0.72) !important;
  box-shadow: 0 0 0 3px rgba(45,212,191,0.12), 0 12px 28px rgba(20,184,166,0.18) !important;
}
.km-answer.correct::before {
  border-color: #2DD4BF;
  background: radial-gradient(circle at center, #2DD4BF 0 45%, transparent 46%);
}
.km-answer.wrong {
  border-color: rgba(248,113,113,0.68) !important;
  box-shadow: 0 0 0 3px rgba(248,113,113,0.12), 0 12px 28px rgba(239,68,68,0.14) !important;
}
.km-answer.wrong::before {
  border-color: #F87171;
  background: radial-gradient(circle at center, #F87171 0 45%, transparent 46%);
}

.km-end-badge {
  width: 88px;
  height: 88px;
  margin: 0 auto 0.9rem;
  border-radius: 999px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Sora', sans-serif;
  font-weight: 900;
  font-size: 2.3rem;
  line-height: 1;
  background: linear-gradient(180deg, rgba(37,99,235,0.18), rgba(15,23,42,0.98));
  color: #E5EEF9;
  border: 1px solid rgba(148,163,184,0.18);
  box-shadow: 0 18px 42px rgba(2,6,23,0.28);
}
.km-end-badge-gold {
  color: #FCD34D;
  border-color: rgba(245,158,11,0.34);
  background: linear-gradient(180deg, rgba(245,158,11,0.18), rgba(15,23,42,0.98));
}
.km-end-badge-silver {
  color: #E2E8F0;
  border-color: rgba(148,163,184,0.28);
}
.km-end-badge-bronze {
  color: #FDBA74;
  border-color: rgba(249,115,22,0.28);
}
@media (max-width: 1100px) {
  .km-question-text {
    font-size: 1.65rem;
  }

  .km-answer {
    min-height: 104px;
    font-size: 1.2rem;
    padding: 18px 18px;
    border-radius: 18px;
  }

  .km-image-frame {
    width: min(980px, calc(100vw - 42px));
  }
}

@media (max-width: 768px) {
  #screenQuestion.screen-question {
    min-height: 100dvh;
  }

  .km-top {
    padding: calc(env(safe-area-inset-top) + 6px) 10px 10px;
  }

  .km-timer {
    width: 60px;
    height: 60px;
  }

  .km-timer::after {
    inset: 5px;
  }

  .km-timer .timer-num {
    font-size: 1.16rem;
  }

  .question-label {
    font-size: 0.74rem;
    margin-bottom: 6px;
  }

  .km-question-text {
    font-size: 1.02rem;
    line-height: 1.18;
    max-width: 100%;
  }

  .km-image-frame {
    width: 100%;
    margin-top: 10px;
    padding: 6px;
    border-radius: 12px;
  }

  .km-image {
    height: min(24vh, 160px);
    border-radius: 8px;
  }

  .km-bottom {
    justify-content: flex-start;
    padding: 8px;
    gap: 8px;
  }

  .km-multiple-hint {
    font-size: 0.84rem;
    padding: 0;
  }

  .km-answers-grid {
    grid-template-columns: 1fr;
    gap: 8px;
    max-width: 100%;
  }

  .km-answer {
    min-height: 72px;
    padding: 14px 14px;
    font-size: 0.9rem;
    gap: 12px;
    border-radius: 14px;
  }

  .km-answer-icon {
    width: 40px;
    height: 40px;
    font-size: 1rem;
    border-radius: 10px;
  }

  .km-text-wrap,
  .km-action-bar,
  .km-reveal-text {
    max-width: 100%;
  }

  .km-text-input {
    min-height: 58px;
    font-size: 1rem;
    border-radius: 14px;
  }

  .km-panel,
  .km-panel-wide {
    border-radius: 22px;
    padding: 1.25rem 1rem;
    max-width: 100%;
  }

  .km-reveal-text {
    padding: 18px 16px;
  }

  .km-reveal-value {
    font-size: 1.05rem;
  }

  .km-end-badge {
    font-size: 3.2rem;
    margin-bottom: 0.65rem;
  }

  .result-overlay {
    padding: 0.55rem 0.65rem !important;
    padding-bottom: max(0.65rem, env(safe-area-inset-bottom)) !important;
  }

  .result-overlay-inner {
    padding: 0.75rem 0.9rem;
    border-radius: 12px;
  }
}


/* === PLAYER UX POLISH FIX === */
.km-answer.selected {
  box-shadow: 0 0 0 3px rgba(255,255,255,0.96), 0 0 24px rgba(255,255,255,0.18) !important;
  transform: translateY(-2px) scale(1.01) !important;
}

.km-answer.dimmed {
  opacity: 0.3;
  transform: scale(0.98);
  filter: saturate(0.35);
}

.km-answer.correct {
  box-shadow: 0 0 0 3px rgba(16,185,129,0.95), 0 0 24px rgba(16,185,129,0.24) !important;
  transform: translateY(-2px) scale(1.01) !important;
}

.km-answer.wrong {
  box-shadow: 0 0 0 3px rgba(239,68,68,0.95), 0 0 24px rgba(239,68,68,0.22) !important;
  transform: translateY(-2px) scale(1.01) !important;
}

.km-answer.correct .km-answer-icon,
.km-answer.wrong .km-answer-icon,
.km-answer.selected .km-answer-icon {
  background: rgba(255,255,255,0.22);
}

.km-answer:disabled {
  cursor: default;
}

.km-reveal-text {
  width: min(100%, 640px);
  margin: 0 auto;
  padding: 1.1rem 1.2rem;
  border-radius: 16px;
  background: rgba(16,185,129,0.12);
  border: 1px solid rgba(16,185,129,0.34);
  text-align: center;
  box-shadow: 0 12px 28px rgba(0,0,0,0.24);
}

.km-reveal-label {
  font-size: 0.72rem;
  font-weight: 800;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(241,245,255,0.62);
  margin-bottom: 0.45rem;
}

.km-reveal-value {
  font-family: 'Sora', sans-serif;
  font-weight: 800;
  font-size: 1.1rem;
  line-height: 1.35;
  color: #86EFAC;
}

.lb-item-me {
  border-color: rgba(124,58,237,0.4) !important;
  background: rgba(124,58,237,0.1) !important;
}

@media (max-width: 640px) {
  .km-reveal-text {
    padding: 0.95rem 0.9rem;
    border-radius: 14px;
  }

  .km-reveal-value {
    font-size: 0.98rem;
  }
}


/* === PLAYER WOW POLISH === */
.km-timer {
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s linear;
}

.km-timer-pulse {
  animation: kmTimerPulse 0.6s ease;
  box-shadow: 0 0 0 10px rgba(239,68,68,0.10), 0 0 26px rgba(239,68,68,0.22);
}

@keyframes kmTimerPulse {
  0% { transform: scale(1); }
  35% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.km-answer {
  transition: transform 0.14s ease, filter 0.14s ease, opacity 0.14s ease, box-shadow 0.14s ease, border-color 0.14s ease;
}

.km-answer:hover:not(:disabled) {
  transform: translateY(-3px);
  filter: brightness(1.06);
}

.km-answer.selected .km-answer-text,
.km-answer.correct .km-answer-text,
.km-answer.wrong .km-answer-text {
  font-weight: 800;
}

.result-overlay-inner {
  animation: kmResultPop 0.28s ease;
}

@keyframes kmResultPop {
  0% { opacity: 0; transform: translateY(12px) scale(0.94); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.km-score-burst {
  position: fixed;
  right: 20px;
  top: 22px;
  z-index: 120;
  font-family: 'Sora', sans-serif;
  font-weight: 900;
  font-size: 1.2rem;
  color: #86EFAC;
  text-shadow: 0 6px 20px rgba(16,185,129,0.35);
  pointer-events: none;
  animation: kmScoreBurst 1.2s ease forwards;
}

@keyframes kmScoreBurst {
  0% { opacity: 0; transform: translateY(10px) scale(0.7); }
  15% { opacity: 1; transform: translateY(0) scale(1); }
  100% { opacity: 0; transform: translateY(-56px) scale(1.08); }
}

.lb-item {
  animation: kmLbSlideIn 0.36s ease both;
}

.lb-item:nth-child(1) { animation-delay: 0.02s; }
.lb-item:nth-child(2) { animation-delay: 0.06s; }
.lb-item:nth-child(3) { animation-delay: 0.10s; }
.lb-item:nth-child(4) { animation-delay: 0.14s; }
.lb-item:nth-child(5) { animation-delay: 0.18s; }
.lb-item:nth-child(6) { animation-delay: 0.22s; }

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

.lb-bar-fill {
  transition: width 0.55s ease;
}

@media (max-width: 640px) {
  .km-score-burst {
    right: 14px;
    top: 16px;
    font-size: 1rem;
  }
}

/* WOW PACK 2 */
.km-streak {
  position: fixed;
  left: 20px;
  top: 20px;
  z-index: 200;
  font-weight: 900;
  font-size: 1.2rem;
  color: #F59E0B;
  animation: kmStreakPop 1.2s ease forwards;
}

@keyframes kmStreakPop {
  0% { opacity:0; transform:scale(0.7);}
  20% { opacity:1; transform:scale(1);}
  100% { opacity:0; transform:translateY(-40px);}
}

.km-answer.correct {
  animation: kmCorrectFlash 0.4s ease;
}

@keyframes kmCorrectFlash {
  0% { transform:scale(1);}
  50% { transform:scale(1.05);}
  100% { transform:scale(1);}
}

/* Leaderboard PRO */
.lb-up {
  animation: lbUp 0.5s ease;
}
.lb-down {
  animation: lbDown 0.5s ease;
}

@keyframes lbUp {
  0% { transform: translateY(10px); }
  100% { transform: translateY(0); }
}

@keyframes lbDown {
  0% { transform: translateY(-10px); }
  100% { transform: translateY(0); }
}

.lb-item-me {
  box-shadow: 0 0 0 2px rgba(124,58,237,0.5);
}


/* === FINAL WOW === */
.km-end-badge {
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  animation: kmEndBadgePop 0.5s ease;
}

.km-end-badge-gold {
  background: linear-gradient(135deg, rgba(245,158,11,0.22), rgba(250,204,21,0.18)) !important;
  box-shadow: 0 0 0 2px rgba(245,158,11,0.28), 0 14px 34px rgba(245,158,11,0.18);
}

.km-end-badge-silver {
  background: linear-gradient(135deg, rgba(148,163,184,0.22), rgba(226,232,240,0.16)) !important;
  box-shadow: 0 0 0 2px rgba(203,213,225,0.24), 0 14px 34px rgba(148,163,184,0.16);
}

.km-end-badge-bronze {
  background: linear-gradient(135deg, rgba(180,83,9,0.22), rgba(251,146,60,0.15)) !important;
  box-shadow: 0 0 0 2px rgba(251,146,60,0.22), 0 14px 34px rgba(180,83,9,0.16);
}

@keyframes kmEndBadgePop {
  0% { opacity: 0; transform: scale(0.7) translateY(8px); }
  100% { opacity: 1; transform: scale(1) translateY(0); }
}

.km-end-place {
  font-weight: 900;
  color: #D8B4FE;
}

.km-end-place-gold { color: #FCD34D; }
.km-end-place-silver { color: #E2E8F0; }
.km-end-place-bronze { color: #FDBA74; }

.km-podium {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  align-items: end;
  gap: 0.85rem;
  margin-bottom: 1.35rem;
  animation: kmPodiumAppear 0.55s ease;
}

@keyframes kmPodiumAppear {
  0% { opacity: 0; transform: translateY(14px); }
  100% { opacity: 1; transform: translateY(0); }
}

.km-podium-col {
  display: flex;
  flex-direction: column;
  align-items: center;
}

.km-podium-player {
  width: 100%;
  border-radius: 16px 16px 12px 12px;
  padding: 0.85rem 0.65rem;
  margin-bottom: 0.45rem;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
  text-align: center;
  box-shadow: 0 10px 26px rgba(0,0,0,0.18);
}

.km-podium-winner {
  background: linear-gradient(180deg, rgba(245,158,11,0.14), rgba(255,255,255,0.05));
  border-color: rgba(245,158,11,0.3);
  box-shadow: 0 14px 34px rgba(245,158,11,0.18);
}

.km-podium-medal {
  font-size: 1.2rem;
  margin-bottom: 0.35rem;
}

.km-podium-name {
  font-weight: 800;
  font-size: 0.82rem;
  line-height: 1.25;
  word-break: break-word;
}

.km-podium-score {
  font-size: 0.76rem;
  color: rgba(241,245,255,0.62);
  margin-top: 0.28rem;
  font-weight: 700;
}

.km-podium-base {
  width: 100%;
  border-radius: 12px 12px 0 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Sora', sans-serif;
  font-weight: 900;
  color: rgba(255,255,255,0.9);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.12);
}

.km-podium-base-1 {
  height: 88px;
  background: linear-gradient(180deg, #F59E0B, #D97706);
}

.km-podium-base-2 {
  height: 68px;
  background: linear-gradient(180deg, #94A3B8, #64748B);
}

.km-podium-base-3 {
  height: 54px;
  background: linear-gradient(180deg, #C2410C, #9A3412);
}

@media (max-width: 640px) {
  .km-podium {
    gap: 0.55rem;
    margin-bottom: 1.1rem;
  }

  .km-podium-player {
    padding: 0.72rem 0.45rem;
    border-radius: 14px 14px 10px 10px;
  }

  .km-podium-name {
    font-size: 0.74rem;
  }

  .km-podium-score {
    font-size: 0.7rem;
  }

  .km-podium-base-1 { height: 74px; }
  .km-podium-base-2 { height: 58px; }
  .km-podium-base-3 { height: 46px; }
}


/* === WOW+ FINAL SCREEN === */
.km-confetti {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 160;
}

.km-end-panel {
  position: relative;
  overflow: hidden;
  background: radial-gradient(circle at top, rgba(124,58,237,0.24), rgba(18,29,61,0.96) 28%, rgba(9,18,42,0.98) 100%);
  box-shadow: 0 24px 70px rgba(0,0,0,0.45), 0 0 0 1px rgba(255,255,255,0.03) inset;
}
.km-end-panel::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 50% -10%, rgba(252,211,77,0.14), transparent 34%);
  pointer-events: none;
}
.km-end-badge-wrap {
  display: flex;
  justify-content: center;
  margin-bottom: 0.45rem;
}
.km-end-badge {
  width: 118px;
  height: 118px;
  border-radius: 999px;
  font-size: 4rem;
  background: linear-gradient(180deg, rgba(255,255,255,0.08), rgba(255,255,255,0.03));
  border: 1px solid rgba(255,255,255,0.08);
}
.km-end-badge-gold {
  animation: kmWinnerPulse 2.2s ease-in-out infinite;
}
@keyframes kmWinnerPulse {
  0%,100% { transform: translateY(0) scale(1); box-shadow: 0 0 0 2px rgba(245,158,11,0.24), 0 18px 40px rgba(245,158,11,0.22); }
  50% { transform: translateY(-4px) scale(1.04); box-shadow: 0 0 0 3px rgba(245,158,11,0.3), 0 20px 46px rgba(245,158,11,0.3); }
}
#endHeroTitle {
  font-size: clamp(2rem, 5vw, 3rem);
  letter-spacing: -0.04em;
  margin-bottom: 0.45rem;
  animation: wowRiseIn 0.5s ease both;
}
#endPosition {
  font-size: 1rem;
  color: rgba(241,245,255,0.82);
  animation: wowRiseIn 0.64s ease both;
}
@keyframes wowRiseIn {
  0% { opacity: 0; transform: translateY(16px) scale(0.96); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}

.km-grade-card {
  margin-top: 1.15rem;
  margin-bottom: 1.35rem;
  padding: 1.35rem;
  border-radius: 24px;
  background: linear-gradient(180deg, rgba(53,35,136,0.92) 0%, rgba(33,34,100,0.94) 100%);
  border: 1px solid rgba(124,58,237,0.34);
  box-shadow: 0 18px 44px rgba(0,0,0,0.28), inset 0 1px 0 rgba(255,255,255,0.05);
  animation: wowRiseIn 0.72s ease both;
}
.km-grade-card-title {
  text-align: center;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  color: #F8EDFF;
  margin-bottom: 0.9rem;
  font-size: 1.05rem;
}
.km-grade-main {
  padding: 1.05rem 1rem 1.1rem;
  border-radius: 20px;
  background: linear-gradient(180deg, rgba(255,194,64,0.13) 0%, rgba(255,194,64,0.04) 100%);
  border: 1px solid rgba(245,158,11,0.28);
  text-align: center;
}
.km-grade-main-label {
  font-size: 0.8rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(255,235,176,0.92);
  margin-bottom: 0.28rem;
}
.km-grade-main-value {
  font-family: 'Sora', sans-serif;
  font-size: clamp(2.5rem, 7vw, 4.2rem);
  font-weight: 900;
  line-height: 1;
  color: #FCD34D;
  text-shadow: 0 0 24px rgba(245,158,11,0.18);
  animation: wowGradePop 0.72s cubic-bezier(0.22,1.2,0.36,1) both;
}
.km-grade-main-value span {
  font-size: 0.54em;
  color: #FFE8A3;
}
@keyframes wowGradePop {
  0% { opacity: 0; transform: scale(0.75); }
  100% { opacity: 1; transform: scale(1); }
}
.km-grade-badges {
  display: flex;
  justify-content: center;
  gap: 0.65rem;
  flex-wrap: wrap;
  margin-top: 0.9rem;
}
.km-grade-badge {
  padding: 0.46rem 0.82rem;
  border-radius: 999px;
  font-size: 0.84rem;
  font-weight: 800;
}
.km-grade-badge-green { background: rgba(16,185,129,0.14); border: 1px solid rgba(16,185,129,0.28); color: #86EFAC; }
.km-grade-badge-red { background: rgba(239,68,68,0.14); border: 1px solid rgba(239,68,68,0.28); color: #FCA5A5; }
.km-grade-badge-muted { background: rgba(255,255,255,0.06); border: 1px solid rgba(255,255,255,0.12); color: rgba(241,245,255,0.82); }
.km-grade-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0,1fr));
  gap: 0.75rem;
  margin-top: 0.9rem;
}
.km-grade-mini {
  padding: 0.8rem 0.75rem;
  border-radius: 18px;
  background: rgba(255,255,255,0.045);
  border: 1px solid rgba(255,255,255,0.08);
  text-align: center;
}
.km-grade-mini-label {
  font-size: 0.74rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(241,245,255,0.56);
  margin-bottom: 0.3rem;
}
.km-grade-mini-value {
  font-weight: 900;
  font-size: 1.08rem;
  color: #F8FAFC;
}
.km-grade-meta {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 0.4rem 0.75rem;
  margin-top: 1rem;
  font-size: 0.88rem;
  color: rgba(241,245,255,0.84);
}
.km-grade-meta .dot { opacity: 0.5; }

.km-podium {
  gap: 1rem;
  margin-top: 0.15rem;
  margin-bottom: 1.55rem;
}
.km-podium-col { animation: wowPodiumLift 0.65s cubic-bezier(0.22,1.1,0.36,1) both; }
.km-podium-col-2 { animation-delay: 0.08s; }
.km-podium-col-1 { animation-delay: 0.16s; }
.km-podium-col-3 { animation-delay: 0.24s; }
@keyframes wowPodiumLift {
  0% { opacity: 0; transform: translateY(28px) scale(0.94); }
  100% { opacity: 1; transform: translateY(0) scale(1); }
}
.km-podium-player {
  border-radius: 18px 18px 14px 14px;
  padding: 1rem 0.8rem;
}
.km-podium-player-me {
  box-shadow: 0 0 0 2px rgba(124,58,237,0.36), 0 16px 30px rgba(124,58,237,0.14);
}
.km-podium-player-you-win {
  animation: wowWinnerBounce 1.8s ease-in-out infinite;
}
@keyframes wowWinnerBounce {
  0%,100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.km-podium-winner {
  transform: scale(1.09);
  transform-origin: bottom center;
  background: linear-gradient(180deg, rgba(245,158,11,0.18), rgba(255,255,255,0.05));
  border-color: rgba(245,158,11,0.34);
  box-shadow: 0 18px 42px rgba(245,158,11,0.2), 0 0 0 1px rgba(255,219,102,0.14) inset;
}
.km-podium-medal { font-size: 1.4rem; margin-bottom: 0.45rem; }
.km-podium-name { font-size: 0.88rem; }
.km-podium-score { font-size: 0.82rem; }
.km-podium-final {
  margin-top: 0.32rem;
  font-size: 0.76rem;
  font-weight: 900;
  color: #FCD34D;
}
.km-podium-base { font-size: 2rem; }
.km-podium-base-1 { height: 112px; }
.km-podium-base-2 { height: 82px; }
.km-podium-base-3 { height: 62px; }

.wow-stagger { animation: wowRiseIn 0.7s ease both; }

@media (max-width: 768px) {
  .km-end-badge { width: 94px; height: 94px; font-size: 3rem; }
  #endHeroTitle { font-size: 1.55rem; }
  #endPosition { font-size: 0.92rem; }
  .km-grade-card { padding: 1rem 0.85rem; border-radius: 20px; }
  .km-grade-grid { gap: 0.55rem; }
  .km-grade-mini { padding: 0.7rem 0.45rem; border-radius: 14px; }
  .km-grade-mini-label { font-size: 0.68rem; }
  .km-grade-mini-value { font-size: 0.92rem; }
  .km-podium { gap: 0.6rem; }
  .km-podium-player { padding: 0.78rem 0.45rem; }
  .km-podium-winner { transform: scale(1.04); }
  .km-podium-name { font-size: 0.76rem; }
  .km-podium-score, .km-podium-final { font-size: 0.68rem; }
  .km-podium-base { font-size: 1.7rem; }
  .km-podium-base-1 { height: 84px; }
  .km-podium-base-2 { height: 62px; }
  .km-podium-base-3 { height: 48px; }
}


@keyframes popIn {
  from { transform: scale(0.5); opacity:0; }
  to { transform: scale(1); opacity:1; }
}


/* === PULSARA REBRAND OVERRIDES === */
.home-logo,
.auth-logo,
.topbar-logo,
.sidebar-logo-text,
.timer-num,
.question-text,
.lb-title,
.result-overlay-title,
.result-overlay-points,
.km-end-place,
.km-grade-main-value,
.km-podium-base,
#endHeroTitle {
  font-family: 'Sora', sans-serif;
}

.page-home::before,
.page-home::after,
.page-play::before {
  opacity: 0.7;
}

.btn {
  border-radius: 14px;
}
.btn-primary {
  background: linear-gradient(135deg, #2563EB, #38BDF8);
  box-shadow: 0 10px 26px rgba(37,99,235,0.24);
}
.btn-primary:hover {
  background: linear-gradient(135deg, #1D4ED8, #0EA5E9);
  box-shadow: 0 14px 28px rgba(14,165,233,0.24);
}
.btn-secondary {
  background: rgba(20,184,166,0.16);
  color: #99F6E4;
  border: 1px solid rgba(45,212,191,0.28);
}
.btn-secondary:hover {
  background: rgba(20,184,166,0.22);
  box-shadow: 0 12px 24px rgba(20,184,166,0.18);
}
.btn-outline {
  color: var(--text);
  background: rgba(255,255,255,0.02);
}
.join-card,
.auth-card,
.home-card,
.quiz-item,
.question-box,
.player-status,
.km-panel,
.km-panel-wide,
.km-end-panel,
.km-grade-card {
  background: linear-gradient(180deg, rgba(18,27,45,0.98), rgba(15,23,42,0.98));
  border: 1px solid rgba(148,163,184,0.14);
  box-shadow: 0 18px 48px rgba(2,6,23,0.35);
}
.timer-wrap,
.km-timer {
  background: conic-gradient(#2563EB 0deg, #14B8A6 140deg, rgba(255,255,255,0.08) 140deg 360deg) !important;
  box-shadow: 0 10px 28px rgba(37,99,235,0.18);
}
.timer-wrap::after {
  background: #0F172A;
}
.answer-btn,
.km-answer {
  background: linear-gradient(180deg, rgba(30,41,59,0.96), rgba(15,23,42,0.96)) !important;
  color: #E5EEF9 !important;
  text-shadow: none;
  border: 1px solid rgba(148,163,184,0.18);
  box-shadow: 0 10px 28px rgba(2,6,23,0.24) !important;
}
.answer-btn:hover:not(:disabled),
.km-answer:hover:not(:disabled) {
  transform: translateY(-2px);
  filter: none;
  border-color: rgba(56,189,248,0.34);
}
.answer-btn.selected,
.km-answer.selected {
  box-shadow: 0 0 0 2px rgba(56,189,248,0.55), 0 12px 30px rgba(37,99,235,0.18) !important;
}
.answer-btn.correct,
.km-answer.correct {
  box-shadow: 0 0 0 2px rgba(45,212,191,0.55), 0 12px 30px rgba(20,184,166,0.16) !important;
  filter: none;
}
.answer-btn.wrong,
.km-answer.wrong {
  opacity: 0.5;
}
.ans-shape,
.km-answer-icon {
  background: rgba(59,130,246,0.16);
  border: 1px solid rgba(96,165,250,0.22);
  color: #93C5FD;
}
.lb-title {
  background: linear-gradient(135deg, #E5EEF9, #93C5FD);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.lb-item:nth-child(1) {
  border-color: rgba(56,189,248,0.32);
  background: rgba(37,99,235,0.08);
}
.result-overlay-inner {
  background: rgba(15,23,42,0.95);
  border: 1px solid rgba(148,163,184,0.14);
}
.result-correct .result-overlay-title,
.km-grade-badge-green { color: #99F6E4; }
.result-correct .result-overlay-points { color: #93C5FD; }
.km-end-badge,
.km-end-badge-gold,
.km-end-badge-silver,
.km-end-badge-bronze {
  background: linear-gradient(180deg, rgba(37,99,235,0.18), rgba(15,23,42,0.96)) !important;
  box-shadow: 0 0 0 1px rgba(96,165,250,0.18), 0 16px 36px rgba(2,6,23,0.28) !important;
}
.km-podium-base-1,
.km-podium-base-2,
.km-podium-base-3 {
  background: linear-gradient(180deg, #2563EB, #1E3A8A);
}
.km-confetti,
.km-score-burst,
.km-streak { display: none !important; }
.km-end-panel::before,
.page-home::before,
.page-home::after { filter: none; }


/* ZNAVIYA v2 refinements */
.km-answer,
.answer-btn {
  border-radius: 22px !important;
  min-height: 116px;
  padding: 1.25rem 1.4rem !important;
}
.km-answer-icon,
.ans-shape {
  display: none !important;
}
.km-answer-text {
  font-size: clamp(1.15rem, 2vw, 1.65rem);
  font-weight: 800;
  line-height: 1.2;
}
.km-answer.selected {
  border-color: rgba(56,189,248,0.64) !important;
  background: linear-gradient(180deg, rgba(22,40,68,0.98), rgba(12,24,44,0.98)) !important;
}
.km-answer.correct {
  border-color: rgba(45,212,191,0.58) !important;
}
.km-answer.wrong {
  border-color: rgba(248,113,113,0.34) !important;
}
.question-text,
.km-question-text {
  letter-spacing: -0.03em;
}
.result-overlay-inner {
  min-width: 340px;
  padding: 0.95rem 1.1rem !important;
}
.result-overlay-title {
  font-size: 0.94rem !important;
}
.result-overlay-points {
  font-size: 1.15rem !important;
}
.km-summary-top {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1rem;
  margin-top: 1.4rem;
}
.km-summary-card {
  background: linear-gradient(180deg, rgba(18,27,45,0.98), rgba(15,23,42,0.98));
  border: 1px solid rgba(148,163,184,0.14);
  border-radius: 22px;
  padding: 1.35rem 1.2rem;
  text-align: center;
  box-shadow: 0 18px 48px rgba(2,6,23,0.28);
}
.km-summary-card-top {
  border-color: rgba(245,158,11,0.34);
  background: linear-gradient(180deg, rgba(32,35,28,0.98), rgba(21,22,21,0.98));
}
.km-summary-card-me {
  box-shadow: 0 0 0 2px rgba(56,189,248,0.28), 0 18px 48px rgba(2,6,23,0.28);
}
.km-summary-rank {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border-radius: 999px;
  background: rgba(37,99,235,0.16);
  color: #93C5FD;
  font-family: 'Sora', sans-serif;
  font-weight: 800;
  margin-bottom: 0.75rem;
}
.km-summary-name {
  font-family: 'Sora', sans-serif;
  font-size: 1.7rem;
  font-weight: 800;
  line-height: 1.05;
  margin-bottom: 0.45rem;
}
.km-summary-score {
  color: var(--text-muted);
  font-size: 0.95rem;
  font-weight: 700;
}
.km-summary-final {
  margin-top: 0.75rem;
  color: #FCD34D;
  font-size: 1rem;
  font-weight: 800;
}
@media (max-width: 900px) {
  .km-summary-top { grid-template-columns: 1fr; }
}
@media (max-width: 768px) {
  .km-answer,
  .answer-btn {
    min-height: 92px;
    border-radius: 18px !important;
    padding: 1rem 1rem !important;
  }
  .km-answer-text {
    font-size: 1.05rem;
  }
  .result-overlay-inner {
    min-width: 0;
    width: calc(100vw - 1.5rem);
  }
}


/* ZNAVIYA v3 production-safe refinements */
.km-timer-wrap {
  margin-bottom: 6px;
}
.km-timer,
.timer-wrap.km-timer {
  width: 64px !important;
  height: 64px !important;
  box-shadow: 0 8px 20px rgba(37,99,235,0.14) !important;
}
.km-timer .timer-num,
.timer-wrap.km-timer .timer-num {
  font-size: 1.45rem !important;
}
.question-label,
#playerQLabel {
  margin-bottom: 0.35rem !important;
}
.km-question-text {
  font-size: clamp(1.55rem, 3vw, 2.2rem) !important;
  max-width: 900px;
}
.km-image-frame {
  width: min(980px, calc(100vw - 48px));
  margin-top: 12px;
}
.km-image {
  height: clamp(180px, 28vh, 300px);
}
.km-bottom {
  padding-top: 12px;
}
.km-answers-grid {
  max-width: 1040px;
  gap: 10px;
}
.km-answer,
.answer-btn {
  position: relative;
  min-height: 84px !important;
  padding: 0.95rem 1.15rem 0.95rem 1.2rem !important;
  border-radius: 18px !important;
  gap: 0 !important;
  align-items: center !important;
}
.km-answer::before,
.answer-btn::before {
  content: '';
  width: 18px;
  height: 18px;
  border-radius: 999px;
  border: 2px solid rgba(148,163,184,0.46);
  display: inline-block;
  flex-shrink: 0;
  margin-right: 14px;
  background: transparent;
}
.km-answer.selected::before,
.answer-btn.selected::before {
  border-color: #38BDF8;
  background: radial-gradient(circle at center, #38BDF8 0 40%, transparent 45% 100%);
}
.km-answer.correct::before,
.answer-btn.correct::before {
  border-color: #2DD4BF;
  background: radial-gradient(circle at center, #2DD4BF 0 40%, transparent 45% 100%);
}
.km-answer-text {
  font-size: clamp(1rem, 1.6vw, 1.28rem) !important;
  font-weight: 800;
  line-height: 1.22;
}
.km-answer.selected,
.answer-btn.selected {
  transform: none !important;
  border-color: rgba(56,189,248,0.62) !important;
}
.km-answer.correct,
.answer-btn.correct {
  border-color: rgba(45,212,191,0.58) !important;
}
.km-answer.wrong,
.answer-btn.wrong {
  opacity: 0.42;
}
.km-multiple-hint {
  font-size: 0.92rem;
  color: #FBBF24;
}
.result-overlay-title {
  font-size: 0.88rem !important;
  letter-spacing: 0.02em;
  text-transform: uppercase;
}
.result-overlay-points {
  font-size: 1rem !important;
}
.km-summary-top {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0.8rem;
}
.km-summary-card {
  display: grid;
  grid-template-columns: 44px 1fr auto auto;
  align-items: center;
  gap: 0.85rem;
  padding: 1rem 1rem;
  text-align: left;
  border-radius: 18px;
}
.km-summary-card-top {
  background: linear-gradient(180deg, rgba(19,45,58,0.98), rgba(15,23,42,0.98));
}
.km-summary-rank {
  margin: 0;
  width: 40px;
  height: 40px;
  font-size: 0.95rem;
}
.km-summary-name {
  margin: 0;
  font-size: 1.1rem;
}
.km-summary-score {
  font-size: 0.88rem;
  white-space: nowrap;
}
.km-summary-final {
  margin: 0;
  white-space: nowrap;
  font-size: 0.95rem;
}
.km-end-panel {
  max-width: 980px;
}
.km-end-top .end-title,
.end-title {
  font-size: clamp(2rem, 6vw, 3.6rem) !important;
  letter-spacing: -0.04em;
}
.km-end-badge-wrap,
.km-end-badge {
  display: none !important;
}
.km-end-panel .lb-list {
  margin-top: 1rem !important;
}
.km-grade-card {
  border-radius: 20px;
}
.km-grade-main-value {
  letter-spacing: -0.03em;
}
/* landing header fix */
.nav-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.nav-toggle {
  display: none !important;
  width: 44px;
  height: 44px;
  padding: 0;
  border-radius: 12px;
  border: 1px solid rgba(148,163,184,0.16);
  background: rgba(255,255,255,0.03);
  color: var(--text);
  align-items: center;
  justify-content: center;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  outline: none;
  box-shadow: none;
  font-size: 0;
}
.nav-toggle::before,
.nav-toggle::after {
  content: none !important;
}
.nav-toggle span {
  display: block !important;
  width: 18px;
  height: 2px;
  border-radius: 999px;
  background: currentColor;
  transition: transform 0.2s ease, opacity 0.2s ease;
}
.nav-toggle.open span:nth-child(1) { transform: translateY(6px) rotate(45deg); }
.nav-toggle.open span:nth-child(2) { opacity: 0; }
.nav-toggle.open span:nth-child(3) { transform: translateY(-6px) rotate(-45deg); }
@media (max-width: 760px) {
  .nav {
    padding: calc(env(safe-area-inset-top) + 0.85rem) 1rem 0.9rem !important;
  }
  .nav-row {
    width: 100%;
  }
  .nav-toggle {
    display: inline-flex !important;
    flex: 0 0 44px;
  }
  .nav-logo {
    margin-bottom: 0 !important;
  }
  .nav-links {
    display: none !important;
    margin-top: 0.85rem;
    grid-template-columns: 1fr;
    gap: 0.55rem;
  }
  .nav-links.open { display: grid !important; }
  .nav-link,
  .nav-btn {
    width: 100%;
    justify-content: center;
    text-align: center;
  }
  .hero {
    padding: 8rem 1rem 2.4rem !important;
  }
  .hero-badge {
    font-size: 0.64rem !important;
    padding: 0.42rem 0.8rem !important;
  }
  .hero-title {
    font-size: clamp(1.9rem, 9vw, 3rem) !important;
    line-height: 0.98 !important;
    max-width: 12ch;
  }
  .hero-title .line1,
  .hero-title .line2,
  .hero-title .line3 {
    display: block;
  }
  .hero-title .line3 {
    background: linear-gradient(135deg, #E5EEF9 0%, #93C5FD 100%) !important;
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
  }
  .hero-sub {
    font-size: 0.96rem !important;
    line-height: 1.58 !important;
    max-width: 32ch !important;
  }
  .btn-primary-lg,
  .btn-secondary-lg {
    max-width: 100% !important;
    border-radius: 18px !important;
    padding: 0.9rem 1rem !important;
    box-shadow: none !important;
  }
  .hero-stats {
    width: 100%;
  }
}
@media (min-width: 761px) {
  .nav-toggle {
    display: none !important;
    visibility: hidden !important;
  }
}
#answerAcceptedState {
  max-width: 680px;
  margin-left: auto !important;
  margin-right: auto !important;
}

@media (max-width: 768px) {
  .km-top {
    padding-top: 0.5rem !important;
  }
  .km-timer,
  .timer-wrap.km-timer {
    width: 52px !important;
    height: 52px !important;
    margin-bottom: 0.25rem;
  }
  .km-timer .timer-num,
  .timer-wrap.km-timer .timer-num {
    font-size: 1.1rem !important;
  }
  .question-label,
  #playerQLabel {
    font-size: 0.78rem !important;
    letter-spacing: 0.1em !important;
  }
  .km-question-text,
  #playerQText {
    font-size: 1rem !important;
    line-height: 1.2 !important;
    max-width: 26ch !important;
    margin-bottom: 0.65rem !important;
  }
  .km-multiple-hint {
    font-size: 0.85rem !important;
    margin-bottom: 0.45rem !important;
  }
  .km-image-frame {
    margin-top: 0.35rem !important;
    margin-bottom: 0.45rem !important;
  }
  .km-answers-grid {
    grid-template-columns: 1fr !important;
    gap: 0.6rem !important;
  }
  .km-answer,
  .answer-btn {
    min-height: 54px !important;
    border-radius: 14px !important;
    padding: 0.72rem 0.85rem !important;
    box-shadow: none !important;
  }
  .km-answer::before,
  .answer-btn::before {
    width: 14px !important;
    height: 14px !important;
    margin-right: 10px !important;
    border-width: 2px !important;
  }
  .km-answer-text,
  .answer-btn,
  .answer-btn .ans-shape {
    font-size: 0.95rem !important;
  }
  #submitMultipleBtn,
  #submitTextBtn {
    min-height: 52px !important;
    border-radius: 14px !important;
    font-size: 0.98rem !important;
  }
  #answerAcceptedState {
    margin-top: 0.55rem !important;
    padding: 0.72rem 0.85rem !important;
    border-radius: 12px !important;
    font-size: 0.86rem !important;
    line-height: 1.35 !important;
  }
  #answerAcceptedState div + div {
    font-size: 0.74rem !important;
    margin-top: 0.18rem !important;
  }
  .result-overlay {
    bottom: 5.2rem !important;
    padding: 0.4rem !important;
  }
  .result-overlay-inner {
    width: calc(100vw - 1rem) !important;
    max-width: none !important;
    padding: 0.55rem 0.7rem !important;
    gap: 0.55rem !important;
  }
  .result-overlay-title {
    font-size: 0.74rem !important;
  }
  .result-overlay-points {
    font-size: 0.92rem !important;
  }
  .result-overlay-total {
    font-size: 0.66rem !important;
  }
  .km-end-panel {
    max-width: calc(100vw - 1rem) !important;
    border-radius: 20px !important;
    padding: 1rem 0.8rem 1rem !important;
  }
  .end-title,
  .km-end-top .end-title {
    font-size: clamp(1.65rem, 10vw, 2.4rem) !important;
    line-height: 0.98 !important;
  }
  #endPodium,
  .km-summary-top {
    display: none !important;
  }
  #endLbList,
  .km-lb-list-wide {
    margin-top: 0.75rem !important;
  }
  .lb-item {
    border-radius: 16px !important;
    padding: 0.75rem 0.75rem !important;
    gap: 0.6rem !important;
  }
  .lb-item-left {
    gap: 0.55rem !important;
    min-width: 0 !important;
  }
  .lb-avatar {
    width: 34px !important;
    height: 34px !important;
    font-size: 0.92rem !important;
  }
  .lb-name {
    font-size: 0.94rem !important;
  }
  .lb-meta,
  .lb-score,
  .lb-sub {
    font-size: 0.78rem !important;
  }
  .km-grade-card {
    padding: 0.9rem 0.75rem !important;
    border-radius: 18px !important;
  }
  .km-grade-card-title {
    font-size: 0.82rem !important;
  }
  .km-grade-main-value {
    font-size: 2.5rem !important;
  }
  .km-grade-badges {
    gap: 0.45rem !important;
    flex-wrap: wrap !important;
  }
  .km-grade-badge {
    font-size: 0.78rem !important;
    padding: 0.5rem 0.7rem !important;
  }
  .km-grade-grid {
    grid-template-columns: 1fr !important;
    gap: 0.5rem !important;
  }
  .km-grade-meta {
    font-size: 0.82rem !important;
    flex-wrap: wrap !important;
    justify-content: center !important;
  }
  .km-grade-meta .dot {
    display: none !important;
  }
  .landing-mobile-menu-fix .nav-btn,
  .nav-links .nav-btn {
    border-radius: 999px !important;
  }
}


/* === Player Layout & Results Fix Pack === */
.km-end-panel {
  width: min(1280px, calc(100vw - 64px)) !important;
  max-width: none !important;
}
.km-end-panel .lb-list,
.km-end-panel .km-lb-list-wide,
#endLbList {
  width: 100%;
}
.km-end-panel .lb-item {
  width: 100%;
}
.km-summary-top {
  margin-bottom: 1rem;
}
.km-text-wrap {
  width: min(100%, 760px);
  margin: 0 auto;
}
.km-action-bar {
  width: min(100%, 760px);
  margin: 0 auto;
}
.km-text-input {
  width: 100%;
  min-height: 64px;
  padding: 0 18px;
}
.km-bottom.km-text-mode {
  justify-content: flex-start;
  align-items: center;
  padding-top: 2rem;
}
.km-bottom.km-text-mode #playerAnswers {
  display: none !important;
}
.km-bottom.km-text-mode #textAnswerWrap,
.km-bottom.km-text-mode #actionBar {
  width: min(100%, 760px);
}
.km-bottom.km-text-mode #actionBar {
  margin-top: 0.25rem;
}
.km-bottom.km-text-mode #submitTextBtn {
  min-height: 56px;
}
@media (max-width: 768px) {
  .km-end-panel {
    width: calc(100vw - 1rem) !important;
    max-width: calc(100vw - 1rem) !important;
  }
  .km-text-wrap,
  .km-action-bar,
  .km-bottom.km-text-mode #textAnswerWrap,
  .km-bottom.km-text-mode #actionBar {
    width: 100% !important;
    max-width: 100% !important;
  }
  .km-bottom.km-text-mode {
    justify-content: flex-start;
    align-items: stretch;
    padding-top: 1.1rem !important;
  }
  .km-text-input {
    min-height: 58px !important;
    font-size: 1rem !important;
  }
  #submitTextBtn,
  #submitMultipleBtn {
    width: 100% !important;
  }
}


/* === SAFE BUILD #3: player final screen stable layout === */
.screen-end {
  display: block;
  min-height: 100vh;
  min-height: 100dvh;
  padding: max(16px, env(safe-area-inset-top)) 16px calc(20px + env(safe-area-inset-bottom));
  position: relative;
  z-index: 1;
  overflow-y: auto;
  overflow-x: hidden;
}

#screenEnd.screen-end {
  align-items: initial !important;
  justify-content: initial !important;
}

#screenEnd.screen-end .km-end-panel {
  width: min(1280px, calc(100vw - 32px)) !important;
  max-width: 1280px !important;
  margin: 0 auto !important;
  display: block;
}

@media (max-width: 768px) {
  .screen-end {
    padding: max(12px, env(safe-area-inset-top)) 12px calc(96px + env(safe-area-inset-bottom));
  }

  #screenEnd.screen-end .km-end-panel {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    padding: 1rem 0.8rem 1rem !important;
    border-radius: 20px !important;
  }

  .km-grade-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 0.45rem !important;
  }

  .km-grade-mini {
    padding: 0.62rem 0.35rem !important;
    border-radius: 14px !important;
  }

  .km-grade-mini-label {
    font-size: 0.58rem !important;
    line-height: 1.15 !important;
    letter-spacing: 0.03em !important;
    margin-bottom: 0.22rem !important;
  }

  .km-grade-mini-value {
    font-size: 0.88rem !important;
    line-height: 1.1 !important;
  }

  .km-grade-meta {
    gap: 0.45rem !important;
    font-size: 0.8rem !important;
  }

  .km-grade-meta .dot {
    display: inline !important;
  }

  .km-summary-top,
  #endPodium {
    display: none !important;
  }
}
/* ===== PLAYER FINAL FIX (FINAL) ===== */

.screen-end {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: block;
  overflow-y: auto;
  padding: 16px;
  background: var(--bg);
}

.screen-end .km-panel {
  max-width: 1000px;
  margin: 0 auto;
}

/* мобілка */
@media (max-width: 768px) {
  .screen-end {
    padding: 10px;
  }

  .km-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 6px;
  }

  .km-summary > * {
    font-size: 0.75rem;
    padding: 8px;
  }
}


/* ===== PLAYER FINAL DESKTOP/MOBILE parity with admin final ===== */
#screenEnd.screen-end {
  position: fixed;
  inset: 0;
  z-index: 30;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 24px;
  background:
    radial-gradient(circle at 50% 12%, rgba(124,58,237,0.16), transparent 42%),
    linear-gradient(180deg, rgba(3,6,15,0.98) 0%, rgba(6,10,24,0.98) 100%);
}

#screenEnd.screen-end .km-end-panel {
  width: min(1280px, calc(100vw - 48px)) !important;
  max-width: 1280px !important;
  margin: 0 auto !important;
  border-radius: 32px;
  border: 1px solid rgba(255,255,255,0.10);
  background: linear-gradient(180deg, rgba(15,21,43,0.98) 0%, rgba(9,13,29,0.98) 100%);
  box-shadow: 0 24px 90px rgba(0,0,0,0.45);
  padding: 36px 36px 34px !important;
}

#screenEnd .km-end-badge-wrap,
#screenEnd #endBadge,
#screenEnd .km-end-badge,
#screenEnd .lb-list,
#screenEnd .km-lb-list-wide {
  display: none !important;
}

#screenEnd .km-end-top {
  text-align: center;
  margin-bottom: 28px;
}

#screenEnd .end-title {
  font-family: 'Sora', sans-serif;
  font-weight: 900;
  font-size: clamp(42px, 7vw, 82px);
  line-height: 0.95;
  letter-spacing: -0.03em;
  color: #fff;
  margin-bottom: 10px;
}

#screenEnd .end-sub {
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: rgba(241,245,255,0.62);
  margin-bottom: 0;
}

.player-final-place { color: #E5EEF9; font-weight: 900; }
.player-final-place-gold { color: #FCD34D; }
.player-final-place-silver { color: #DDD6FE; }
.player-final-place-bronze { color: #FDBA74; }

.player-final-hero-card {
  max-width: 760px;
  margin: 0 auto 26px;
  border-radius: 30px;
  padding: 28px 34px 30px;
  text-align: center;
  background:
    radial-gradient(circle at 50% 0%, rgba(20,184,166,0.18), transparent 42%),
    linear-gradient(180deg, rgba(8,61,78,0.42), rgba(11,24,46,0.28));
  border: 1px solid rgba(20,184,166,0.30);
  box-shadow: 0 24px 70px rgba(0,0,0,0.30);
}

.player-final-hero-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 7px 14px;
  background: rgba(245,158,11,0.16);
  border: 1px solid rgba(245,158,11,0.30);
  color: #FCD34D;
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.player-final-hero-name {
  font-family: 'Sora', sans-serif;
  font-size: clamp(28px, 4vw, 52px);
  line-height: 1.04;
  font-weight: 900;
  color: #fff;
  margin-top: 18px;
  word-break: break-word;
}

.player-final-hero-score {
  font-family: 'Sora', sans-serif;
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 900;
  color: #FCD34D;
  margin-top: 12px;
}

.player-final-hero-meta {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}

.player-final-hero-meta span {
  border-radius: 999px;
  padding: 8px 14px;
  background: rgba(255,255,255,0.08);
  font-size: 13px;
  font-weight: 800;
  color: rgba(241,245,255,0.9);
}

.player-final-standings {
  margin-top: 26px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.player-final-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 18px;
  border-radius: 26px;
  padding: 22px 28px;
  border: 1px solid rgba(255,255,255,0.10);
  background: linear-gradient(180deg, rgba(124,58,237,0.18), rgba(124,58,237,0.10));
  box-shadow: 0 18px 50px rgba(0,0,0,0.26);
}

.player-final-row.winner {
  background: linear-gradient(180deg, rgba(245,158,11,0.24), rgba(245,158,11,0.11));
  border-color: rgba(245,158,11,0.30);
}

.player-final-row.me:not(.winner) {
  border-color: rgba(59,130,246,0.42);
  box-shadow: 0 0 0 1px rgba(59,130,246,0.18) inset;
}

.player-final-row-left,
.player-final-row-right {
  display: flex;
  align-items: center;
  gap: 14px;
}

.player-final-row-right {
  margin-left: auto;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.player-final-medal {
  font-size: 30px;
  line-height: 1;
  min-width: 36px;
  text-align: center;
}

.player-final-row-name {
  font-size: clamp(20px, 2.5vw, 32px);
  font-weight: 900;
  color: #fff;
  line-height: 1.08;
  word-break: break-word;
}

.player-final-row-name span {
  color: #93C5FD;
  font-size: 0.72em;
}

.player-final-row-grade {
  font-size: 18px;
  font-weight: 900;
  color: #FCD34D;
}

.player-final-row-score {
  font-size: 18px;
  font-weight: 800;
  color: rgba(241,245,255,0.82);
}

.player-final-stats {
  margin-top: 28px;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 14px;
}

.player-final-stat {
  border-radius: 20px;
  padding: 18px;
  text-align: center;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.08);
}

.player-final-stat .label {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: rgba(241,245,255,0.52);
}

.player-final-stat .value {
  margin-top: 8px;
  font-family: 'Sora', sans-serif;
  font-size: clamp(22px, 3vw, 34px);
  font-weight: 900;
  color: #fff;
}

@media (max-width: 900px) {
  #screenEnd.screen-end {
    padding: 10px;
  }

  #screenEnd.screen-end .km-end-panel {
    width: min(100vw - 20px, 100%) !important;
    max-width: min(100vw - 20px, 100%) !important;
    padding: 22px 16px 20px !important;
    border-radius: 24px !important;
  }

  #screenEnd .end-title {
    font-size: clamp(32px, 10vw, 52px);
  }

  .player-final-hero-card {
    padding: 22px 16px 20px;
    border-radius: 24px;
    margin-bottom: 18px;
  }

  .player-final-hero-meta {
    gap: 8px;
  }

  .player-final-hero-meta span {
    font-size: 12px;
    padding: 7px 12px;
  }

  .player-final-row {
    padding: 16px 14px;
    border-radius: 20px;
    gap: 10px;
  }

  .player-final-medal {
    font-size: 24px;
    min-width: 28px;
  }

  .player-final-row-name {
    font-size: 16px;
  }

  .player-final-row-grade,
  .player-final-row-score {
    font-size: 14px;
  }

  .player-final-stats {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 640px) {
  .km-grade-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 0.45rem !important;
  }

  .km-grade-mini {
    padding: 0.62rem 0.35rem !important;
    border-radius: 14px !important;
  }

  .km-grade-mini-label {
    font-size: 0.58rem !important;
    line-height: 1.15 !important;
    letter-spacing: 0.03em !important;
    margin-bottom: 0.22rem !important;
  }

  .km-grade-mini-value {
    font-size: 0.88rem !important;
    line-height: 1.1 !important;
  }

  .player-final-row {
    flex-direction: column;
    align-items: stretch;
  }

  .player-final-row-left,
  .player-final-row-right {
    width: 100%;
    justify-content: space-between;
  }

  .player-final-row-right {
    padding-left: 42px;
  }

  .player-final-stats {
    grid-template-columns: 1fr 1fr;
    gap: 10px;
  }
}


/* === MOBILE LAYER: compact player final === */
@media (max-width: 768px) {
  #screenEnd.screen-end,
  .screen-end {
    padding: max(12px, env(safe-area-inset-top)) 12px calc(96px + env(safe-area-inset-bottom)) !important;
  }

  #screenEnd.screen-end .km-end-panel,
  .screen-end .km-end-panel {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    padding: 1rem 0.9rem 1rem !important;
    border-radius: 22px !important;
  }

  .km-end-top {
    text-align: left !important;
    align-items: flex-start !important;
    margin-bottom: 0.85rem !important;
  }

  .km-end-top .end-title,
  .end-title {
    width: 100% !important;
    text-align: left !important;
    font-size: clamp(1.7rem, 9vw, 2.65rem) !important;
    line-height: 1.02 !important;
    letter-spacing: -0.04em !important;
    margin-bottom: 0.35rem !important;
  }

  #endPosition,
  .end-sub {
    text-align: left !important;
    font-size: 0.98rem !important;
    line-height: 1.45 !important;
    max-width: none !important;
  }

  .km-end-badge-wrap,
  .km-end-badge {
    display: none !important;
  }

  #endHeroCard {
    margin-top: 0.3rem !important;
  }

  .km-grade-card {
    padding: 0.95rem 0.8rem !important;
    border-radius: 18px !important;
    margin-bottom: 0.9rem !important;
  }

  .km-grade-card-title {
    font-size: 0.84rem !important;
    margin-bottom: 0.85rem !important;
  }

  .km-grade-main {
    padding: 1rem 0.85rem !important;
    border-radius: 18px !important;
  }

  .km-grade-main-label {
    font-size: 0.8rem !important;
  }

  .km-grade-main-value {
    font-size: clamp(2.8rem, 16vw, 4.3rem) !important;
    line-height: 0.96 !important;
  }

  .km-grade-badges {
    gap: 0.55rem !important;
    flex-wrap: wrap !important;
    justify-content: flex-start !important;
  }

  .km-grade-badge {
    font-size: 0.82rem !important;
    padding: 0.55rem 0.78rem !important;
    border-radius: 999px !important;
  }

  .km-grade-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 0.45rem !important;
    margin-top: 0.8rem !important;
  }

  .km-grade-mini {
    padding: 0.72rem 0.35rem !important;
    border-radius: 14px !important;
  }

  .km-grade-mini-label {
    font-size: 0.58rem !important;
    line-height: 1.15 !important;
    margin-bottom: 0.2rem !important;
    letter-spacing: 0.03em !important;
  }

  .km-grade-mini-value {
    font-size: 0.96rem !important;
    line-height: 1.08 !important;
  }

  .km-grade-meta {
    margin-top: 0.7rem !important;
    font-size: 0.92rem !important;
    justify-content: center !important;
    gap: 0.4rem !important;
    flex-wrap: wrap !important;
  }

  .km-grade-meta .dot {
    display: inline !important;
  }

  #endPodium,
  .player-final-standings,
  .player-final-stats,
  .km-summary-top {
    display: none !important;
  }

  #endLbList,
  .km-lb-list-wide,
  .km-end-panel .lb-list {
    display: flex !important;
    flex-direction: column !important;
    gap: 0.7rem !important;
    width: 100% !important;
    margin-top: 0.9rem !important;
    margin-bottom: 0 !important;
  }

  .km-end-panel .lb-item,
  .lb-item {
    width: 100% !important;
    padding: 0.82rem 0.78rem !important;
    border-radius: 18px !important;
    gap: 0.65rem !important;
  }

  .lb-rank {
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
    font-size: 0.95rem !important;
  }

  .lb-avatar {
    width: 40px !important;
    height: 40px !important;
    font-size: 1rem !important;
  }

  .lb-name {
    font-size: 0.95rem !important;
  }

  .lb-meta,
  .lb-sub,
  .lb-score {
    font-size: 0.82rem !important;
  }

  .lb-bar-bg {
    height: 4px !important;
  }

  .screen-end .btn.btn-secondary,
  #screenEnd .btn.btn-secondary {
    width: 100% !important;
    min-height: 56px !important;
    margin-top: 1rem !important;
    border-radius: 16px !important;
    font-size: 1.02rem !important;
  }
}

/* ===== FINAL RESULT LAYOUT FIX v2 ===== */
#screenEnd.screen-end {
  padding: max(16px, env(safe-area-inset-top)) 16px calc(24px + env(safe-area-inset-bottom));
}

#screenEnd.screen-end .km-end-panel {
  width: min(980px, calc(100vw - 32px)) !important;
  max-width: 980px !important;
  padding: 28px 28px 24px !important;
  border-radius: 28px !important;
}

#screenEnd .km-end-top {
  margin-bottom: 20px !important;
}

#screenEnd .end-title {
  font-size: clamp(42px, 5.6vw, 72px) !important;
  line-height: 0.94 !important;
  margin-bottom: 8px !important;
}

#screenEnd .end-sub {
  max-width: 760px;
  margin: 0 auto;
}

#endHeroCard {
  max-width: 720px;
  margin: 0 auto 22px !important;
}

.km-grade-card {
  border-radius: 24px !important;
  padding: 18px 18px 16px !important;
  background: linear-gradient(180deg, rgba(10,22,54,0.96) 0%, rgba(8,18,45,0.98) 100%) !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03), 0 14px 48px rgba(0,0,0,0.28) !important;
}

.km-grade-card-title {
  text-align: center !important;
  font-family: 'Sora', sans-serif !important;
  font-size: 0.92rem !important;
  font-weight: 800 !important;
  letter-spacing: 0.04em !important;
  text-transform: uppercase !important;
  color: #F1F5FF !important;
  margin-bottom: 14px !important;
}

.km-grade-main {
  border-radius: 22px !important;
  padding: 22px 22px 18px !important;
  background: linear-gradient(180deg, rgba(63,52,35,0.58) 0%, rgba(33,35,53,0.44) 100%) !important;
  border: 1px solid rgba(245,158,11,0.32) !important;
}

.km-grade-player-name {
  text-align: center;
  font-family: 'Sora', sans-serif;
  font-size: clamp(2rem, 4vw, 3rem);
  font-weight: 900;
  line-height: 1.02;
  color: #FFFFFF;
  letter-spacing: -0.03em;
  margin-bottom: 10px;
  word-break: break-word;
}

.km-grade-main-label {
  text-align: center !important;
  font-size: 0.9rem !important;
  font-weight: 900 !important;
  letter-spacing: 0.08em !important;
  text-transform: uppercase !important;
  color: #F7E6A2 !important;
  margin-bottom: 8px !important;
}

.km-grade-main-value {
  text-align: center !important;
  font-family: 'Sora', sans-serif !important;
  font-size: clamp(4.2rem, 8vw, 6.2rem) !important;
  font-weight: 900 !important;
  line-height: 0.95 !important;
  color: #FFD84E !important;
  letter-spacing: -0.05em !important;
  margin-bottom: 14px !important;
}

.km-grade-main-value span {
  font-size: 0.52em !important;
  color: #FFE89A !important;
}

.km-grade-badges {
  justify-content: center !important;
  gap: 10px !important;
}

.km-grade-badge {
  min-height: 42px;
  padding: 0.7rem 1rem !important;
  font-size: 0.95rem !important;
  font-weight: 800 !important;
}

.km-grade-grid {
  margin-top: 14px !important;
  gap: 10px !important;
}

.km-grade-mini {
  min-height: 84px;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
  border-radius: 18px !important;
}

.km-grade-mini-label {
  font-size: 0.72rem !important;
  margin-bottom: 6px !important;
}

.km-grade-mini-value {
  font-size: 1.55rem !important;
  font-weight: 900 !important;
}

.km-grade-meta {
  justify-content: center !important;
  margin-top: 14px !important;
  font-size: 1rem !important;
  font-weight: 700 !important;
}

#endPodium {
  display: none !important;
}

#endLbList,
#screenEnd .km-lb-list-wide,
#screenEnd .lb-list {
  display: flex !important;
  flex-direction: column !important;
  gap: 14px !important;
  width: 100% !important;
  max-width: 920px !important;
  margin: 0 auto !important;
}

#screenEnd .lb-item,
#endLbList .lb-item {
  padding: 18px 22px !important;
  border-radius: 24px !important;
  background: linear-gradient(90deg, rgba(18,25,52,0.96) 0%, rgba(13,20,41,0.96) 100%) !important;
  border: 1px solid rgba(255,255,255,0.08) !important;
  gap: 14px !important;
}

#screenEnd .lb-item.lb-item-me,
#endLbList .lb-item.lb-item-me {
  background: linear-gradient(90deg, rgba(62,36,131,0.38) 0%, rgba(30,23,82,0.92) 100%) !important;
  border-color: rgba(124,58,237,0.55) !important;
  box-shadow: 0 10px 30px rgba(88,28,135,0.22) !important;
}

#screenEnd .lb-rank,
#endLbList .lb-rank {
  width: 42px !important;
  min-width: 42px !important;
  height: 42px !important;
}

#screenEnd .player-avatar,
#endLbList .player-avatar {
  width: 52px !important;
  height: 52px !important;
  min-width: 52px !important;
  border-radius: 50% !important;
  font-size: 1.2rem !important;
  font-weight: 900 !important;
}

#screenEnd .lb-name,
#endLbList .lb-name {
  font-size: 1.25rem !important;
  font-weight: 900 !important;
}

#screenEnd .lb-bar-bg,
#endLbList .lb-bar-bg {
  height: 5px !important;
  margin-top: 8px !important;
}

#screenEnd .lb-score,
#endLbList .lb-score {
  font-size: 1rem !important;
  font-weight: 900 !important;
}

#screenEnd .btn.btn-secondary {
  width: 100% !important;
  max-width: 920px !important;
  margin: 18px auto 0 !important;
  display: flex !important;
  min-height: 62px !important;
  border-radius: 18px !important;
  font-size: 1.16rem !important;
}

@media (max-width: 768px) {
  #screenEnd.screen-end {
    padding: max(12px, env(safe-area-inset-top)) 12px calc(18px + env(safe-area-inset-bottom)) !important;
  }

  #screenEnd.screen-end .km-end-panel {
    width: calc(100vw - 24px) !important;
    max-width: calc(100vw - 24px) !important;
    padding: 16px 12px 14px !important;
    border-radius: 22px !important;
  }

  #screenEnd .km-end-top {
    margin-bottom: 14px !important;
  }

  #screenEnd .end-title {
    font-size: clamp(2.1rem, 10.5vw, 3rem) !important;
    text-align: left !important;
    margin-bottom: 6px !important;
  }

  #screenEnd .end-sub {
    text-align: left !important;
    font-size: 0.96rem !important;
    line-height: 1.35 !important;
  }

  #endHeroCard {
    max-width: 100% !important;
    margin: 0 0 14px !important;
  }

  .km-grade-card {
    border-radius: 20px !important;
    padding: 12px 10px 12px !important;
  }

  .km-grade-card-title {
    font-size: 0.82rem !important;
    margin-bottom: 10px !important;
  }

  .km-grade-main {
    padding: 16px 12px 14px !important;
    border-radius: 18px !important;
  }

  .km-grade-player-name {
    font-size: 1.25rem !important;
    margin-bottom: 8px !important;
  }

  .km-grade-main-label {
    font-size: 0.82rem !important;
    margin-bottom: 6px !important;
  }

  .km-grade-main-value {
    font-size: clamp(3.9rem, 22vw, 5.6rem) !important;
    margin-bottom: 10px !important;
  }

  .km-grade-badges {
    justify-content: flex-start !important;
    gap: 8px !important;
  }

  .km-grade-badge {
    min-height: 38px !important;
    padding: 0.58rem 0.85rem !important;
    font-size: 0.86rem !important;
  }

  .km-grade-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr)) !important;
    gap: 8px !important;
    margin-top: 12px !important;
  }

  .km-grade-mini {
    min-height: 70px !important;
    padding: 10px 6px !important;
    border-radius: 14px !important;
  }

  .km-grade-mini-label {
    font-size: 0.58rem !important;
    margin-bottom: 4px !important;
  }

  .km-grade-mini-value {
    font-size: 1.05rem !important;
  }

  .km-grade-meta {
    font-size: 0.88rem !important;
    gap: 0.34rem !important;
  }

  #endLbList,
  #screenEnd .km-lb-list-wide,
  #screenEnd .lb-list {
    gap: 10px !important;
  }

  #screenEnd .lb-item,
  #endLbList .lb-item {
    padding: 12px 12px !important;
    border-radius: 18px !important;
    gap: 10px !important;
  }

  #screenEnd .lb-rank,
  #endLbList .lb-rank {
    width: 34px !important;
    min-width: 34px !important;
    height: 34px !important;
    font-size: 0.9rem !important;
  }

  #screenEnd .player-avatar,
  #endLbList .player-avatar {
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    font-size: 1rem !important;
  }

  #screenEnd .lb-name,
  #endLbList .lb-name {
    font-size: 0.98rem !important;
  }

  #screenEnd .lb-bar-bg,
  #endLbList .lb-bar-bg {
    height: 4px !important;
    margin-top: 6px !important;
  }

  #screenEnd .lb-score,
  #endLbList .lb-score {
    font-size: 0.88rem !important;
  }

  #screenEnd .btn.btn-secondary {
    min-height: 56px !important;
    margin-top: 14px !important;
    border-radius: 16px !important;
    font-size: 1.02rem !important;
  }
}


/* ===== ZNAVIYA FINAL SCREEN SYSTEM v4 ===== */
#screenEnd.screen-end .km-end-panel {
  width: min(1040px, calc(100vw - 40px)) !important;
  max-width: 1040px !important;
  padding: 28px 28px 26px !important;
}

#screenEnd .km-end-top {
  margin-bottom: 1rem !important;
}

#screenEnd .end-title {
  font-size: clamp(2.4rem, 6vw, 4.8rem) !important;
  line-height: 0.98 !important;
}

#screenEnd #endPosition {
  color: rgba(241,245,255,0.72) !important;
}

#screenEnd #endHeroCard .km-grade-card {
  max-width: 820px;
  margin: 0 auto 1rem !important;
  padding: 1.1rem 1.1rem 1rem !important;
  border-radius: 22px !important;
}

#screenEnd #endHeroCard .km-grade-card-title {
  margin-bottom: 0.8rem !important;
}

#screenEnd #endHeroCard .km-grade-main {
  padding: 1.35rem 1.1rem 1rem !important;
  border-radius: 20px !important;
}

#screenEnd #endHeroCard .km-grade-player-name {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 0.6rem 1rem;
  margin: 0 auto 0.8rem !important;
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.08);
  box-shadow: inset 0 1px 0 rgba(255,255,255,0.03);
  font-size: clamp(1.15rem, 2.1vw, 1.6rem) !important;
  line-height: 1.1;
}

#screenEnd #endHeroCard .km-grade-main-label {
  letter-spacing: 0.08em !important;
}

#screenEnd #endHeroCard .km-grade-main-value {
  font-size: clamp(3.7rem, 8vw, 5.8rem) !important;
  line-height: 0.9 !important;
  margin-top: 0.2rem !important;
  text-shadow: 0 10px 28px rgba(245,158,11,0.14);
}

#screenEnd #endHeroCard .km-grade-badges {
  margin-top: 0.9rem !important;
}

#screenEnd #endHeroCard .km-grade-grid {
  gap: 0.7rem !important;
}

#screenEnd #endHeroCard .km-grade-mini {
  border-radius: 18px !important;
}

#screenEnd #endLbList {
  max-width: 1040px;
  margin: 1rem auto 0 !important;
}

#screenEnd .lb-item {
  border-radius: 22px !important;
}

@media (max-width: 768px) {
  #screenEnd.screen-end {
    padding: max(10px, env(safe-area-inset-top)) 10px calc(92px + env(safe-area-inset-bottom)) !important;
  }

  #screenEnd.screen-end .km-end-panel {
    width: calc(100vw - 20px) !important;
    max-width: calc(100vw - 20px) !important;
    padding: 16px 14px 16px !important;
    border-radius: 22px !important;
  }

  #screenEnd .km-end-top {
    margin-bottom: 0.65rem !important;
  }

  #screenEnd .end-title {
    font-size: clamp(2rem, 11vw, 3.25rem) !important;
    letter-spacing: -0.05em !important;
    margin-bottom: 0.25rem !important;
  }

  #screenEnd #endHeroCard .km-grade-card {
    padding: 0.85rem 0.8rem 0.8rem !important;
    border-radius: 20px !important;
    margin-bottom: 0.4rem !important;
  }

  #screenEnd #endHeroCard .km-grade-card-title {
    margin-bottom: 0.7rem !important;
    font-size: 0.72rem !important;
  }

  #screenEnd #endHeroCard .km-grade-main {
    padding: 0.95rem 0.8rem 0.8rem !important;
    border-radius: 18px !important;
  }

  #screenEnd #endHeroCard .km-grade-player-name {
    padding: 0.5rem 0.8rem;
    margin-bottom: 0.75rem !important;
    font-size: 0.95rem !important;
    max-width: 100%;
  }

  #screenEnd #endHeroCard .km-grade-main-value {
    font-size: clamp(3.8rem, 18vw, 5rem) !important;
  }

  #screenEnd #endLbList,
  #screenEnd .player-final-standings,
  #screenEnd .player-final-stats {
    display: none !important;
  }
}


/* ===== FINAL POLISH v5 ===== */
#screenEnd #endHeroCard .km-grade-badges {
  justify-content: center !important;
}

@media (max-width: 768px) {
  #screenEnd .km-grade-badges {
    justify-content: center !important;
    width: 100% !important;
  }
}

#screenEnd .lb-item .lb-name span,
#endLbList .lb-item .lb-name span,
.player-final-row-name span {
  display: none !important;
}

#screenEnd .lb-item:nth-child(1),
#endLbList .lb-item:nth-child(1) {
  background: rgba(245,158,11,0.045) !important;
  border-color: rgba(245,158,11,0.22) !important;
}
