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

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Inter", sans-serif;
  background: radial-gradient(circle at top, #1e1b4b, #0f172a);
  color: #f8fafc;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.container {
  width: 100%;
  max-width: 600px;
  padding: 24px 20px 40px;
}

.hero {
  margin-bottom: 8px;
}

h1 {
  font-weight: 800;
  font-size: 2.5rem;
  background: linear-gradient(to right, #38bdf8, #818cf8);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  text-align: center;
  margin: 0 0 8px;
}

.subtitle {
  text-align: center;
  color: #94a3b8;
  margin: 0 0 24px;
  font-size: 1rem;
  line-height: 1.4;
  max-width: 420px;
  margin-left: auto;
  margin-right: auto;
}

.card-title {
  margin-top: 0;
}

.card {
  background: rgba(30, 41, 59, 0.7);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
  animation: fadeIn 0.35s ease-out;
}

.logo {
  width: 160px;
  height: auto;
  display: block;
  margin: 0 auto 16px;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hidden {
  display: none !important;
}

label {
  display: block;
  font-size: 0.9rem;
  color: #94a3b8;
  margin-bottom: 6px;
}

.onboarding-hints {
  list-style: none;
  padding: 0;
  margin: 0 0 18px;
  font-size: 0.88rem;
  color: #cbd5e1;
  line-height: 1.6;
}

.onboarding-hints li {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.hint-icon {
  flex-shrink: 0;
}

input {
  width: 100%;
  padding: 14px;
  border-radius: 12px;
  border: 2px solid #334155;
  background: #0f172a;
  color: #f8fafc;
  font-size: 1rem;
  margin: 0 0 14px;
  transition: border-color 0.2s;
}

input:focus {
  outline: none;
  border-color: #38bdf8;
}

button {
  width: 100%;
  border: none;
  border-radius: 12px;
  padding: 16px;
  background: linear-gradient(135deg, #38bdf8, #2563eb);
  color: white;
  font-weight: 600;
  font-size: 1.1rem;
  cursor: pointer;
  transition: transform 0.12s ease, box-shadow 0.2s;
}

button:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(56, 189, 248, 0.4);
}

button:active:not(:disabled) {
  transform: scale(0.97);
}

button:disabled {
  transform: none;
  cursor: not-allowed;
  filter: grayscale(0.5);
}

.btn-secondary {
  background: rgba(51, 65, 85, 0.9);
  border: 1px solid rgba(148, 163, 184, 0.35);
  margin-top: 12px;
}

.btn-secondary:hover:not(:disabled) {
  box-shadow: 0 4px 15px rgba(148, 163, 184, 0.2);
}

/* Lobby */
.user-panel {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 12px;
  padding: 14px 16px;
  margin-bottom: 18px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.user-line-main {
  margin: 0 0 6px;
  font-weight: 700;
  font-size: 1.05rem;
}

.user-line-extra {
  margin: 0;
  font-size: 0.9rem;
  color: #fbbf24;
}

.online-stats {
  margin: 0 0 16px;
  padding: 10px 12px;
  font-size: 0.84rem;
  line-height: 1.45;
  color: #a5b4c8;
  background: rgba(15, 23, 42, 0.55);
  border: 1px solid rgba(148, 163, 184, 0.18);
  border-radius: 10px;
  letter-spacing: 0.02em;
}

.lobby-section-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  margin: 0 0 10px;
}

.opponent-type-row,
.opponent-type-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 18px;
}

.opp-type-btn {
  width: 100%;
  padding: 12px 10px;
  font-size: 0.88rem;
  background: rgba(15, 23, 42, 0.85);
  border: 2px solid #334155;
  color: #e2e8f0;
}

.opp-type-btn:hover:not(:disabled) {
  border-color: #64748b;
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
}

.opp-type-btn.active {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.25);
}

.battle-modes {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(108px, 1fr));
  gap: 10px;
  margin-bottom: 18px;
}

.mode-card {
  position: relative;
  background: #0f172a;
  border: 2px solid #334155;
  border-radius: 12px;
  padding: 12px 10px;
  cursor: pointer;
  text-align: center;
  transition: border-color 0.2s, box-shadow 0.2s, transform 0.15s;
}

.mode-card:active {
  transform: scale(0.97);
}

.mode-emoji {
  font-size: 1.35rem;
  display: block;
  margin-bottom: 4px;
}

.mode-card h3 {
  margin: 0 0 4px;
  font-size: 1rem;
  color: #f8fafc;
}

.mode-desc {
  margin: 0 0 8px;
  font-size: 0.72rem;
  color: #94a3b8;
}

.mode-diff {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(100, 116, 139, 0.35);
  color: #e2e8f0;
}

.mode-diff-easy {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

.mode-diff-med {
  background: rgba(251, 191, 36, 0.15);
  color: #fbbf24;
}

.mode-diff-hard {
  background: rgba(248, 113, 113, 0.15);
  color: #f87171;
}

.mode-mix.active {
  border-color: #a78bfa;
  background: rgba(167, 139, 250, 0.12);
  box-shadow: 0 0 16px rgba(167, 139, 250, 0.35);
}

.mode-4.active {
  border-color: #34d399;
  background: rgba(52, 211, 153, 0.1);
  box-shadow: 0 0 14px rgba(52, 211, 153, 0.3);
}

.mode-9.active {
  border-color: #4ade80;
  background: rgba(74, 222, 128, 0.08);
  box-shadow: 0 0 14px rgba(74, 222, 128, 0.28);
}

.mode-11.active {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.12);
  box-shadow: 0 0 14px rgba(56, 189, 248, 0.35);
}

.mode-12.active {
  border-color: #f472b6;
  background: rgba(244, 114, 182, 0.1);
  box-shadow: 0 0 14px rgba(244, 114, 182, 0.3);
}

.mode-13.active {
  border-color: #fb923c;
  background: rgba(251, 146, 60, 0.1);
  box-shadow: 0 0 14px rgba(251, 146, 60, 0.3);
}

.mode-card:hover {
  border-color: #64748b;
}

/* Matchmaking */
.matchmaking-bar {
  height: 6px;
  background: rgba(51, 65, 85, 0.5);
  border-radius: 999px;
  overflow: hidden;
  margin-top: 16px;
}

.matchmaking-bar-fill {
  height: 100%;
  width: 30%;
  border-radius: 999px;
  background: linear-gradient(90deg, #38bdf8, #818cf8);
  animation: mmSlide 1.2s ease-in-out infinite alternate;
}

@keyframes mmSlide {
  from {
    transform: translateX(-20%);
    width: 35%;
  }
  to {
    transform: translateX(180%);
    width: 45%;
  }
}

.matchmaking-actions {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.matchmaking-actions .btn-secondary {
  margin-top: 0;
}

/* Match */
.match-meta-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 12px;
}

.match-chip {
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(51, 65, 85, 0.6);
  border: 1px solid rgba(148, 163, 184, 0.25);
  color: #cbd5e1;
}

.match-chip-accent {
  border-color: rgba(251, 191, 36, 0.45);
  color: #fbbf24;
  background: rgba(251, 191, 36, 0.08);
}

.match-chip-blitz {
  border-color: rgba(250, 204, 21, 0.55);
  color: #fde047;
  background: rgba(250, 204, 21, 0.12);
  text-transform: none;
  letter-spacing: 0.04em;
  font-size: 0.78rem;
}

.match-actions-top {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
  align-items: center;
}

.btn-risk {
  flex: 1;
  min-width: 120px;
  padding: 10px 14px;
  font-size: 0.88rem;
  font-weight: 700;
  border-radius: 10px;
  border: 2px solid #f97316;
  background: rgba(249, 115, 22, 0.12);
  color: #fdba74;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s, box-shadow 0.2s;
}

.btn-risk:hover {
  border-color: #fb923c;
  box-shadow: 0 0 16px rgba(249, 115, 22, 0.35);
}

.btn-risk.active {
  border-color: #ef4444;
  background: rgba(239, 68, 68, 0.2);
  color: #fecaca;
  box-shadow: 0 0 18px rgba(239, 68, 68, 0.35);
}

.btn-forfeit {
  padding: 10px 14px;
  font-size: 0.85rem;
  border-radius: 10px;
  border: 2px solid #64748b;
  background: rgba(15, 23, 42, 0.6);
  color: #94a3b8;
  cursor: pointer;
}

.btn-forfeit:hover {
  border-color: #94a3b8;
  color: #e2e8f0;
}

.match-header {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 12px;
  padding-bottom: 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.match-header-left {
  flex: 1;
  min-width: 140px;
}

.match-header-right {
  text-align: right;
  min-width: 120px;
}

.timer-hint {
  font-size: 0.72rem;
  color: #64748b;
  margin: 0 0 6px;
  min-height: 1.2em;
}

.combo-badge {
  display: inline-block;
  font-weight: 800;
  font-size: 0.85rem;
  padding: 8px 12px;
  border-radius: 12px;
  margin-bottom: 8px;
  border: 1px solid rgba(251, 146, 60, 0.35);
  background: rgba(251, 146, 60, 0.1);
  color: #fdba74;
  transition: transform 0.2s, box-shadow 0.2s;
}

.combo-tier-0 {
  opacity: 0.75;
}

.combo-tier-1 {
  border-color: rgba(251, 191, 36, 0.5);
  color: #fcd34d;
  box-shadow: 0 0 12px rgba(251, 191, 36, 0.2);
}

.combo-tier-2 {
  animation: comboPulse 1.1s ease-in-out infinite;
  border-color: rgba(56, 189, 248, 0.55);
  color: #7dd3fc;
  box-shadow: 0 0 16px rgba(56, 189, 248, 0.35);
}

.combo-tier-3 {
  animation: comboPulse 0.75s ease-in-out infinite;
  border-color: rgba(244, 114, 182, 0.6);
  color: #f9a8d4;
  box-shadow: 0 0 22px rgba(244, 114, 182, 0.45);
}

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

.emotion-hint {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: #c4b5fd;
  margin: 0 0 10px;
  min-height: 1.4em;
  animation: fadeIn 0.35s ease-out;
}

.opponent-status-line {
  text-align: center;
  font-weight: 600;
  color: #a5b4fc;
  margin: 0 0 10px;
  font-size: 0.92rem;
  animation: fadeIn 0.3s ease-out;
}

.match-header .score-line-header {
  margin: 0;
}

.timer-badge {
  display: inline-block;
  background: rgba(56, 189, 248, 0.15);
  color: #38bdf8;
  padding: 8px 16px;
  border-radius: 20px;
  font-weight: 800;
  font-size: 1.1rem;
  border: 1px solid rgba(56, 189, 248, 0.4);
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.2);
  margin-bottom: 8px;
}

.timer-badge.timer-urgent {
  color: #f87171;
  border-color: rgba(248, 113, 113, 0.65);
  background: rgba(248, 113, 113, 0.12);
  animation: timerPulse 0.85s ease-in-out infinite;
}

@keyframes timerPulse {
  0%,
  100% {
    transform: scale(1);
    box-shadow: 0 0 8px rgba(248, 113, 113, 0.35);
  }
  50% {
    transform: scale(1.04);
    box-shadow: 0 0 18px rgba(248, 113, 113, 0.55);
  }
}

.timer-track {
  height: 8px;
  background: rgba(30, 41, 59, 0.9);
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.timer-bar {
  height: 100%;
  width: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, #22d3ee, #38bdf8, #818cf8);
  transform-origin: left center;
  transition: transform 0.25s linear, background 0.3s;
}

.timer-bar.timer-bar-urgent {
  background: linear-gradient(90deg, #f97316, #ef4444);
}

.score-line-header {
  font-size: 1.05rem;
  font-weight: 800;
  text-align: right;
  color: #fbbf24;
  margin: 0;
  align-self: center;
}

.bot-status {
  text-align: center;
  font-weight: 600;
  color: #a5b4fc;
  margin: 0 0 12px;
  min-height: 1.5em;
  font-size: 0.95rem;
}

#question-counter {
  font-size: 0.88rem;
  color: #94a3b8;
  margin: 0 0 8px;
}

#question-text {
  font-size: 1.1rem;
  font-weight: 500;
  text-align: left;
  margin: 0 0 18px;
  line-height: 1.5;
  white-space: pre-wrap;
  background: rgba(0, 0, 0, 0.2);
  padding: 15px;
  border-radius: 8px;
}

.options {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.option-btn {
  background: #334155;
  text-align: left;
  font-weight: 400;
  width: 100%;
}

.option-btn:hover:not(:disabled) {
  background: #475569;
}

.option-btn:active:not(:disabled) {
  transform: scale(0.97);
}

.correct-btn {
  background: #16a34a !important;
  box-shadow: 0 0 15px rgba(22, 163, 74, 0.45);
}

.wrong-btn {
  background: #dc2626 !important;
  box-shadow: 0 0 15px rgba(220, 38, 38, 0.45);
}

#round-result {
  text-align: center;
  margin-top: 18px;
  font-size: 1.05rem;
  font-weight: 600;
  min-height: 3em;
}

.timer-text {
  color: #cbd5e1;
}

.round-flash-win {
  animation: flashGreen 0.55s ease-out;
}

.round-flash-lose {
  animation: flashRedShake 0.6s ease-out;
}

@keyframes flashGreen {
  0% {
    background-color: rgba(34, 197, 94, 0.35);
  }
  100% {
    background-color: transparent;
  }
}

@keyframes flashRedShake {
  0% {
    background-color: rgba(239, 68, 68, 0.35);
    transform: translateX(0);
  }
  20% {
    transform: translateX(-6px);
  }
  40% {
    transform: translateX(6px);
  }
  60% {
    transform: translateX(-4px);
  }
  80% {
    transform: translateX(4px);
  }
  100% {
    background-color: transparent;
    transform: translateX(0);
  }
}

.text-green {
  color: #4ade80;
}
.text-red {
  color: #f87171;
}
.text-amber {
  color: #fbbf24;
}

.delay-text {
  text-align: center;
  margin-top: 14px;
  padding: 12px;
  border-radius: 12px;
  background: rgba(15, 23, 42, 0.65);
  border: 1px solid rgba(148, 163, 184, 0.2);
  color: #e2e8f0;
  font-size: 0.95rem;
  font-weight: 600;
  animation: pulseSoft 1.2s ease-in-out infinite;
}

.delay-text-sub {
  display: block;
  margin-top: 6px;
  font-size: 0.82rem;
  font-weight: 500;
  color: #94a3b8;
}

@keyframes pulseSoft {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.82;
  }
}

/* Result */
#result-title {
  text-align: center;
  font-size: 2.4rem;
  margin: 0 0 10px;
  text-transform: uppercase;
  letter-spacing: 2px;
}

.title-win {
  color: #4ade80;
  text-shadow: 0 0 20px rgba(74, 222, 128, 0.4);
  animation: winPop 0.6s ease-out;
}

@keyframes winPop {
  0% {
    transform: scale(0.92);
    filter: brightness(1.2);
  }
  60% {
    transform: scale(1.03);
  }
  100% {
    transform: scale(1);
  }
}

.title-lose {
  color: #f87171;
  text-shadow: 0 0 20px rgba(248, 113, 113, 0.4);
}

.title-draw {
  color: #94a3b8;
}

.final-rank-line {
  text-align: center;
  font-size: 1.05rem;
  color: #c4b5fd;
  margin: 0 0 16px;
  min-height: 1.4em;
}

.final-score-board {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 20px;
  margin: 20px 0;
}

.score-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  background: #0f172a;
  padding: 18px 16px;
  border-radius: 16px;
  min-width: 100px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.score-value {
  font-size: 2.8rem;
  font-weight: 800;
  color: #f8fafc;
}

.score-label {
  color: #94a3b8;
  font-size: 0.85rem;
  text-transform: uppercase;
  margin-bottom: 6px;
  letter-spacing: 1px;
}

.score-divider {
  font-size: 2.2rem;
  font-weight: 800;
  color: #475569;
}

.mmr-text {
  text-align: center;
  font-size: 1.35rem;
  color: #fbbf24;
  margin: 8px 0 12px;
  font-weight: 700;
}

.streak-banner {
  text-align: center;
  font-size: 1rem;
  color: #fb923c;
  margin: 0 0 20px;
  min-height: 1.3em;
}

.result-actions {
  display: flex;
  flex-direction: column;
}

/* Leaderboard */
#leaderboard-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

#leaderboard-list li {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  font-size: 1rem;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(15, 23, 42, 0.45);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.lb-rank {
  font-weight: 800;
  min-width: 2em;
  color: #94a3b8;
}

.lb-medal {
  font-size: 1.15rem;
}

.lb-me {
  border-color: rgba(56, 189, 248, 0.45);
  background: rgba(56, 189, 248, 0.12);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.15);
}

.lb-name {
  flex: 1;
  font-weight: 600;
}

.lb-mmr {
  color: #fbbf24;
  font-weight: 700;
}
