:root {
  --bg-primary: #0a0e17;
  --bg-secondary: #141b2d;
  --bg-tertiary: #1a2236;
  --editor-bg: #1e1e1e;
  --text-primary: #e4e6f1;
  --text-secondary: #8b949e;
  --border-color: #30363d;
  --primary-color: #58a6ff;
  --success-color: #3fb950;
  --warning-color: #d29922;
  --error-color: #f85149;
  --font-main: 'Russo One', sans-serif;
  --font-secondary: 'Orbitron', sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: 'Inter', sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

.btn-leaderboard {
  position: fixed;
  top: 20px;
  right: 20px;
  background: var(--success-color);
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  z-index: 1100;
  transition: background-color 0.2s ease;
}
.btn-leaderboard:hover {
  background: #36a340;
}

.login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  height: 100vh;
  background: linear-gradient(135deg, #0F172A, #1E293B);
}
.login-box {
  background: var(--bg-secondary);
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,0.3);
  width: 90%;
  max-width: 400px;
  text-align: center;
}
.site-title {
  font-family: var(--font-secondary);
  font-size: 2.5rem;
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}
.site-tagline {
  font-family: var(--font-main);
  font-size: 1rem;
  margin-bottom: 1.5rem;
  color: var(--text-secondary);
}
.login-form .input-group {
  margin-bottom: 1rem;
}
.login-form .input-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-secondary);
  text-align: left;
}
.login-form .input-group input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
}
.login-form .button-group {
  display: flex;
  justify-content: center;
}
.btn-primary {
  background: var(--success-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.btn-primary:hover {
  transform: translateY(-1px);
}
.btn-outline {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.5rem;
  border-radius: 6px;
  cursor: pointer;
}

.login-footer {
  margin-top: 1.5rem;
  font-size: 0.8rem;
  color: var(--text-secondary);
}

.rules-screen {
  display: flex;
  flex-direction: column;
  height: 100vh;
}
.rules-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  font-family: var(--font-secondary);
  font-size: 1.5rem;
}
.rules-header .corner {
  width: 25%;
  text-align: center;
}
.header-logo {
  max-height: 50px;
  width: auto;
  object-fit: contain;
}
.rules-header .center {
  width: 50%;
  text-align: center;
  font-family: var(--font-main);
  font-size: 2rem;
}
.rules-container {
  flex: 1;
  background: var(--bg-secondary);
  padding: 1.5rem;
  overflow-y: auto;
}
.rules-container h3 {
  text-align: center;
  color: var(--warning-color);
  margin-bottom: 1rem;
}
.rules-content ul {
  list-style-type: none;
  padding-left: 1rem;
  margin-bottom: 1rem;
}
.rules-content li {
  margin-bottom: 0.5rem;
}
.center-btn-container {
  display: flex;
  justify-content: center;
  margin-top: 1.5rem;
}

.competition-screen {
  height: 100vh;
}
main {
  display: flex;
  height: 100%;
  overflow: hidden;
}
.problem-list {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  padding: 1.5rem;
  width: 280px;
  overflow-y: auto;
}
.problem-list-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 0.5rem;
}
.round-info {
  font-size: 0.9rem;
  color: var(--text-secondary);
  margin-bottom: 1rem;
}
.question-progress {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
}
.progress-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background-color: var(--border-color);
  transition: background-color 0.3s;
}
.progress-dot.active {
  background-color: var(--primary-color);
}
.progress-dot.solved {
  background-color: var(--success-color);
}
.question-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  overflow-y: auto;
}
.question-item {
  padding: 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  transition: transform 0.2s ease;
}
.question-item:hover {
  transform: translateY(-1px);
}
.question-item.solved {
  background: var(--success-color);
  color: white;
}
.question-item.failed {
  background: var(--error-color);
  color: white;
  opacity: 0.8;
}
.question-item.failed:hover {
  transform: none;
  cursor: not-allowed;
}

.question-workspace {
  flex: 1;
  padding: 1.5rem;
  overflow-y: auto;
}
.big-question-container {
  min-width: 600px;
  padding: 1rem;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  margin-bottom: 1rem;
}
.question-details-container {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1.5rem;
  background: var(--bg-secondary);
}
.problem-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}
.problem-difficulty {
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  font-size: 0.8rem;
  font-weight: 600;
  background: var(--border-color);
  color: var(--text-primary);
}
.problem-details section {
  background: var(--bg-tertiary);
  border-radius: 6px;
  padding: 1rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
}
.problem-details h3 {
  margin-bottom: 0.75rem;
  color: var(--text-secondary);
}
.editor-toolbar {
  margin-bottom: 0.5rem;
  display: flex;
  justify-content: flex-start;
  align-items: center;
  gap: 8px;
}
#runLanguageSelect {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.5rem;
  font-size: 1rem;
  transition: border-color 0.2s ease;
}
#runLanguageSelect:hover {
  border-color: var(--primary-color);
}
.editor-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}
.editor-container {
  height: 250px;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  overflow: hidden;
  background: var(--editor-bg);
  margin-bottom: 1rem;
}
.code-editor {
  width: 100%;
  height: 100%;
}
.console-output-section {
  background: var(--bg-tertiary);
  border: 1px solid var(--border-color);
  border-radius: 6px;
  padding: 0.75rem;
  min-height: 100px;
  max-height: 150px;
  overflow-y: auto;
}
.console-header {
  font-size: 0.9rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: var(--text-secondary);
}
.console-content {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.9rem;
  white-space: pre-wrap;
  word-break: break-all;
}
.problem-navigation {
  display: flex;
  justify-content: space-between;
  margin-top: 1rem;
}
.btn-nav {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.5rem 1rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s ease;
}
.btn-nav:hover {
  background: var(--border-color);
}
.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(4px);
  justify-content: center;
  align-items: center;
  animation: modalFadeIn 0.3s ease;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.modal-content {
  background: linear-gradient(145deg, var(--bg-secondary), var(--bg-tertiary));
  padding: 2rem;
  border-radius: 12px;
  width: 90%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(255, 255, 255, 0.1);
  animation: contentSlideUp 0.3s ease;
}

@keyframes contentSlideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.warning-modal .modal-content {
  border-left: 4px solid var(--warning-color);
}

.warning-modal h2 {
  color: var(--warning-color);
  font-size: 1.5rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.warning-modal p {
  color: var(--text-primary);
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.warning-modal button {
  background: var(--warning-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.warning-modal button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(210, 153, 34, 0.3);
}

.frozen-leaderboard .modal-content {
  background: linear-gradient(145deg, #1a237e, #0d47a1);
  border-left: 4px solid #42a5f5;
}

.frozen-leaderboard h2 {
  color: #42a5f5;
  font-size: 2rem;
  margin-bottom: 1rem;
  font-family: var(--font-secondary);
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.frozen-leaderboard p {
  color: #fff;
  font-size: 1.2rem;
  margin-bottom: 0.5rem;
  font-family: var(--font-main);
}

.frozen-leaderboard .timer {
  color: #ff4081;
  font-size: 1.5rem;
  margin: 1rem 0;
  font-family: 'Press Start 2P', cursive;
  animation: pulse 1.5s infinite;
}

.frozen-leaderboard button {
  background: #42a5f5;
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-top: 1rem;
}

.frozen-leaderboard button:hover {
  background: #1e88e5;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(66, 165, 245, 0.3);
}

::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-secondary);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb {
  background: var(--primary-color);
  border-radius: 4px;
  transition: background 0.3s ease;
}

::-webkit-scrollbar-thumb:hover {
  background: #4191e1;
}

.leaderboard-content {
  max-width: 500px !important;
  background: var(--bg-secondary) !important;
  border: 1px solid var(--border-color);
}

.leaderboard-content h2 {
  color: var(--warning-color);
  margin-bottom: 1.5rem;
  font-family: var(--font-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.leaderboard-table {
  background: var(--bg-tertiary);
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 1.5rem;
}

.leaderboard-header {
  display: flex;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg-primary);
  font-weight: bold;
  color: var(--text-secondary);
}

.leaderboard-row {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.2s;
}

.leaderboard-row:last-child {
  border-bottom: none;
}

.leaderboard-row span {
  flex: 1;
  text-align: left;
}

.leaderboard-row span:last-child {
  text-align: right;
}

.leaderboard-row:hover {
  background: var(--bg-secondary);
}

.leaderboard-row.top-1 {
  background: rgba(255, 215, 0, 0.1);
}

.leaderboard-row.top-2 {
  background: rgba(192, 192, 192, 0.1);
}

.leaderboard-row.top-3 {
  background: rgba(205, 127, 50, 0.1);
}

.modal-content button {
  margin-top: 1rem;
}

.round-selector {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border-radius: 6px;
}

.round-btn {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.round-btn:hover:not(:disabled) {
  background: var(--primary-color);
  transform: translateY(-1px);
}

.round-btn.active {
  background: var(--primary-color);
  color: white;
}

.round-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.round-btn.easy {
  border-bottom: 2px solid var(--success-color);
}

.round-btn.medium {
  border-bottom: 2px solid var(--warning-color);
}

.round-btn.hard {
  border-bottom: 2px solid var(--error-color);
}

.timer-container {
  position: fixed;
  top: 20px;
  left: 20px;
  background: rgba(20, 27, 45, 0.7);
  padding: 0.75rem 1rem;
  border-radius: 6px;
  border: 1px solid var(--border-color);
  z-index: 1100;
  display: none;
  align-items: center;
  gap: 0.5rem;
}

#timer {
  font-family: 'Press Start 2P', monospace;
  font-size: 1.2rem;
  color: var(--text-primary);
}

#timer.warning {
  color: var(--error-color);
  animation: pulse 1s infinite;
}

@keyframes pulse {
  0% { opacity: 1; }
  50% { opacity: 0.5; }
  100% { opacity: 1; }
}

#endTestBtn {
  display: none;
  position: fixed;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  z-index: 1100;
  transition: all 0.2s ease;
}

#endTestBtn:hover {
  background: var(--error-color);
  color: white;
  transform: translateX(-50%) translateY(-2px);
}

.modal-buttons {
  display: flex;
  gap: 1rem;
  justify-content: center;
}

.btn-danger {
  background: var(--error-color);
  color: white;
  border: none;
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-danger:hover {
  background: #d73a49;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(248, 81, 73, 0.3);
}

.btn-secondary {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  padding: 0.75rem 1.5rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-secondary:hover {
  background: var(--border-color);
  transform: translateY(-2px);
}

.loader {
  display: inline-block;
  width: 50px;
  height: 50px;
  border: 5px solid rgba(255, 255, 255, 0.3);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.fullscreen-warning {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 9999;
  backdrop-filter: blur(8px);
}

.fullscreen-warning-content {
  background: var(--bg-secondary);
  padding: 2rem;
  border-radius: 12px;
  text-align: center;
  max-width: 500px;
  border: 2px solid var(--warning-color);
}

.fullscreen-warning h2 {
  color: var(--warning-color);
  margin-bottom: 1rem;
  font-family: var(--font-secondary);
}

.fullscreen-warning p {
  margin-bottom: 1.5rem;
  line-height: 1.6;
}

.btn-fullscreen {
  background: var(--warning-color);
  color: white;
  border: none;
  padding: 1rem 2rem;
  border-radius: 6px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-fullscreen:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(210, 153, 34, 0.3);
}

.btn-compiler {
  position: fixed;
  top: 80px;
  right: 20px;
  background: var(--primary-color);
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 1rem;
  cursor: pointer;
  z-index: 1100;
  transition: background-color 0.2s ease;
  display: none;
}

.btn-compiler:hover {
  background: #4191e1;
}

.compiler-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.9);
  z-index: 2000;
  display: none;
  justify-content: center;
  align-items: center;
}

.compiler-modal-content {
  background: var(--bg-secondary);
  width: 90%;
  max-width: 1200px;
  height: 80vh;
  border-radius: 12px;
  position: relative;
  padding: 20px;
}

.compiler-close {
  position: absolute;
  top: 10px;
  right: 10px;
  background: var(--error-color);
  color: white;
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease;
}

.compiler-close:hover {
  transform: scale(1.1);
}

.compiler-iframe-container {
  width: 100%;
  height: calc(100% - 20px);
  margin-top: 20px;
}

.compiler-iframe {
  width: 100%;
  height: 100%;
  border: none;
  border-radius: 8px;
}

@media print {
  body * {
    display: none !important;
  }
  body:after {
    content: "Printing is not allowed!";
    display: block !important;
  }
}