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

:root {
  --bg: #0d1117;
  --panel: #161b22;
  --panel-alt: #1c2129;
  --border: #30363d;
  --text: #e6edf3;
  --text-dim: #8b949e;
  --accent: #2ea043;
  --accent-hover: #3fb950;
  --fail: #f85149;
  --pass: #3fb950;
  --code-bg: #21262d;
  --mono: "SF Mono", "Fira Code", Menlo, Consolas, monospace;
}

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.topbar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.logo {
  font-weight: 700;
  font-size: 15px;
}

.lang-badge {
  font-size: 12px;
  padding: 2px 10px;
  border-radius: 12px;
  background: #f7df1e;
  color: #000;
  font-weight: 600;
}

.layout {
  flex: 1;
  display: grid;
  grid-template-columns: minmax(320px, 42%) 1fr;
  min-height: 0;
}

.panel {
  min-height: 0;
  overflow: hidden;
}

.description-panel {
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 24px 28px;
  background: var(--panel);
}

.description-panel h1 {
  font-size: 22px;
  margin-bottom: 8px;
}

.description-panel h2 {
  font-size: 15px;
  margin: 20px 0 8px;
}

.description-panel p,
.description-panel li {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text);
  margin-bottom: 8px;
}

.description-panel ul {
  padding-left: 20px;
}

.description-panel code {
  font-family: var(--mono);
  font-size: 12.5px;
  background: var(--code-bg);
  padding: 2px 5px;
  border-radius: 4px;
}

.description-panel .hp {
  font-size: 2px;
  line-height: 0;
  color: var(--panel);
  user-select: text;
}

.description-panel pre {
  font-family: var(--mono);
  font-size: 13px;
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 12px;
  overflow-x: auto;
  margin-bottom: 8px;
}

.meta {
  margin-bottom: 16px;
}

.tag {
  font-size: 12px;
  font-weight: 600;
  padding: 2px 10px;
  border-radius: 12px;
}

.tag.easy {
  background: rgba(63, 185, 80, 0.15);
  color: var(--pass);
}

.tag.project {
  background: rgba(210, 153, 34, 0.15);
  color: #d29922;
}

.upload-panel {
  flex: 1;
  padding: 24px 28px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  overflow-y: auto;
}

.upload-panel h2 {
  font-size: 18px;
}

.upload-deadline {
  font-size: 13px;
  color: #d29922;
}

.upload-controls {
  display: flex;
  gap: 10px;
  align-items: center;
}

.upload-controls input[type="file"] {
  font-size: 13px;
  color: var(--text-dim);
}

.upload-status {
  font-size: 13px;
  color: var(--text-dim);
  min-height: 18px;
}

.upload-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.upload-item {
  font-size: 13px;
  padding: 8px 12px;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.upload-item span {
  color: var(--text-dim);
  font-size: 12px;
}

.editor-panel {
  display: flex;
  flex-direction: column;
}

.editor-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}

.filename {
  font-family: var(--mono);
  font-size: 13px;
  color: var(--text-dim);
}

.actions {
  display: flex;
  gap: 8px;
}

.btn {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 16px;
  border-radius: 6px;
  border: 1px solid transparent;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
}

.btn-ghost {
  background: transparent;
  color: var(--text-dim);
  border-color: var(--border);
}

.btn-ghost:hover {
  color: var(--text);
}

.editor-wrap {
  flex: 1;
  display: flex;
  min-height: 0;
  background: var(--bg);
}

.line-numbers {
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  color: var(--text-dim);
  padding: 14px 8px 14px 16px;
  text-align: right;
  user-select: none;
  overflow: hidden;
  min-width: 44px;
}

.editor-stack {
  position: relative;
  flex: 1;
  min-width: 0;
}

.highlight-layer,
#editor {
  position: absolute;
  inset: 0;
  margin: 0;
  border: none;
  font-family: var(--mono);
  font-size: 13px;
  line-height: 1.55;
  padding: 14px 16px 14px 8px;
  white-space: pre;
  tab-size: 2;
}

.highlight-layer {
  color: var(--text);
  overflow: hidden;
  pointer-events: none;
}

.highlight-layer code {
  font-family: inherit;
}

#editor {
  background: transparent;
  color: transparent;
  caret-color: var(--text);
  outline: none;
  resize: none;
  overflow: auto;
}

#editor::selection {
  background: rgba(56, 139, 253, 0.4);
  color: transparent;
}

.tok-cm {
  color: #8b949e;
  font-style: italic;
}

.tok-str {
  color: #a5d6ff;
}

.tok-num,
.tok-lit {
  color: #79c0ff;
}

.tok-kw {
  color: #ff7b72;
}

.tok-fn {
  color: #d2a8ff;
}

.results-wrap {
  height: 40%;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--border);
  background: var(--panel);
}

.results-header,
.console-header {
  display: flex;
  justify-content: space-between;
  padding: 8px 16px;
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-dim);
  border-bottom: 1px solid var(--border);
}

.summary-pass {
  color: var(--pass);
}

.summary-fail {
  color: var(--fail);
}

.results {
  flex: 1;
  overflow-y: auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.hint {
  color: var(--text-dim);
  font-size: 13px;
}

.all-passed {
  font-size: 14px;
  font-weight: 600;
  color: var(--pass);
  padding: 8px 12px;
  background: rgba(63, 185, 80, 0.1);
  border: 1px solid rgba(63, 185, 80, 0.4);
  border-radius: 6px;
}

.test-case {
  border: 1px solid var(--border);
  border-left-width: 3px;
  border-radius: 6px;
  padding: 8px 12px;
  background: var(--panel-alt);
}

.test-case.pass {
  border-left-color: var(--pass);
}

.test-case.fail {
  border-left-color: var(--fail);
}

.test-title {
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 4px;
}

.test-case.pass .test-title {
  color: var(--pass);
}

.test-case.fail .test-title {
  color: var(--fail);
}

.test-detail {
  font-size: 12.5px;
  color: var(--text-dim);
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.test-detail .label {
  display: inline-block;
  min-width: 70px;
}

.test-detail code {
  font-family: var(--mono);
  color: var(--text);
}

.console-output {
  font-family: var(--mono);
  font-size: 12.5px;
  color: var(--text-dim);
  padding: 8px 16px;
  max-height: 90px;
  overflow-y: auto;
  white-space: pre-wrap;
}

.hidden {
  display: none !important;
}

.spacer {
  flex: 1;
}

.candidate-name {
  font-size: 13px;
  color: var(--text-dim);
}

.timer {
  font-family: var(--mono);
  font-size: 14px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: 6px;
  background: var(--code-bg);
  border: 1px solid var(--border);
}

.timer-low {
  color: var(--fail);
  border-color: var(--fail);
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 100;
  background: rgba(1, 4, 9, 0.85);
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal {
  width: min(480px, 90vw);
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.modal h1 {
  font-size: 22px;
}

.modal p {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dim);
}

.modal input {
  font-size: 15px;
  padding: 10px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  outline: none;
}

.modal input:focus {
  border-color: var(--accent);
}

.warning {
  font-size: 13px;
  line-height: 1.6;
  padding: 12px 14px;
  border-radius: 6px;
  background: rgba(210, 153, 34, 0.1);
  border: 1px solid rgba(210, 153, 34, 0.5);
  color: #d29922;
}

.error {
  color: var(--fail);
  font-size: 13px;
}

.btn-lg {
  padding: 12px;
  font-size: 15px;
}

#start-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

#invite-blocked {
  font-size: 14px;
  line-height: 1.6;
  color: var(--text-dim);
}

.challenge-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}

.challenge-tab {
  font-size: 13px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: 6px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  cursor: pointer;
}

.challenge-tab:hover {
  color: var(--text);
}

.challenge-tab.active {
  background: var(--code-bg);
  color: var(--text);
  border-color: var(--accent);
}

.test-detail pre.value {
  font-family: var(--mono);
  display: inline-block;
  vertical-align: top;
  background: var(--code-bg);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--text);
  white-space: pre;
  overflow-x: auto;
  max-width: 100%;
}
