:root {
  color-scheme: dark;
  --bg: #14151a;
  --panel: #1c1e26;
  --border: #30323c;
  --text: #e6e6ea;
  --muted: #9a9ca6;
  --accent: #5b8dee;
  --ac: #4caf6e;
  --bad: #e05a5a;
  --warn: #d8a53d;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", sans-serif;
  line-height: 1.6;
}

.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 16px 16px 48px;
}

header.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 16px;
}

header.page-header h1 {
  font-size: 1.3rem;
  margin: 0;
}

#home-link {
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  padding: 4px 10px;
  border-radius: 6px;
  white-space: nowrap;
}
#home-link:hover { color: var(--text); border-color: var(--accent); }

a { color: var(--accent); }

.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 16px;
  margin-bottom: 16px;
}

.room-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
}
.room-card {
  background: var(--panel); border: 1px solid var(--border); border-radius: 10px;
  padding: 16px; text-decoration: none; color: var(--text); display: block;
}
.room-card:hover { border-color: var(--accent); }
.room-card.disabled { opacity: 0.5; pointer-events: none; }
.room-card h2 { margin: 0 0 6px; font-size: 1.05rem; }
.room-card p { margin: 0; color: var(--muted); font-size: 0.85rem; }

.problem-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 8px; }
.problem-list li a {
  display: flex; justify-content: space-between; align-items: center; gap: 8px;
  background: var(--panel); border: 1px solid var(--border); border-radius: 8px;
  padding: 12px 14px; text-decoration: none; color: var(--text);
}
.problem-list li a:hover { border-color: var(--accent); }
.problem-title { font-weight: 600; }
.badge-group { display: flex; gap: 6px; flex-wrap: wrap; }

.badge {
  font-size: 0.75rem; padding: 2px 8px; border-radius: 999px; border: 1px solid var(--border); color: var(--muted);
  white-space: nowrap;
}

.filters { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 12px; }
.filters select {
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px;
}

.statement {
  white-space: pre-wrap;
}

/* Colab風のシンタックスハイライト付きエディタ(code-editor.js)。
   透明なtextareaを、ハイライト済みのpre>codeの上に重ねる方式。
   両者のfont-family/font-size/line-height/paddingは必ず一致させること
   (ずれると入力位置とハイライトの見た目が合わなくなる)。 */
:root {
  --code-font: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  --code-font-size: 0.9rem;
  --code-line-height: 1.6;
}

.code-editor-wrap {
  display: flex;
  width: 100%;
  height: 320px;
  background: #0f1015;
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
}

.code-editor-gutter {
  flex: 0 0 auto;
  min-width: 2.6em;
  padding: 12px 8px 12px 0;
  text-align: right;
  color: var(--muted);
  font-family: var(--code-font);
  font-size: var(--code-font-size);
  line-height: var(--code-line-height);
  background: #0f1015;
  border-right: 1px solid var(--border);
  overflow: hidden;
  user-select: none;
}

.code-editor-scroll {
  position: relative;
  flex: 1 1 auto;
  min-width: 0;
}

.code-editor-highlight,
.code-editor-input {
  position: absolute;
  inset: 0;
  margin: 0;
  padding: 12px;
  border: none;
  box-sizing: border-box;
  font-family: var(--code-font);
  font-size: var(--code-font-size);
  line-height: var(--code-line-height);
  white-space: pre;
  overflow: auto;
  tab-size: 4;
}

.code-editor-highlight {
  color: #e6e6ea;
  pointer-events: none;
  z-index: 1;
}
.code-editor-highlight code { font: inherit; }

.code-editor-input {
  z-index: 2;
  background: transparent;
  color: transparent;
  caret-color: #e6e6ea;
  resize: none;
  outline: none;
}
.code-editor-input::selection { background: rgba(91, 141, 238, 0.35); color: transparent; }

.tok-keyword { color: #ff7ab6; }
.tok-string { color: #a5e075; }
.tok-comment { color: #8b8fa3; font-style: italic; }
.tok-number { color: #f2c94c; }

.stdin-box {
  width: 100%;
  min-height: 80px;
  background: #0f1015;
  color: #e6e6ea;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85rem;
}

.toolbar { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; margin: 10px 0; }

button.primary {
  background: var(--accent); color: #0c0d10; border: none; border-radius: 8px;
  padding: 8px 16px; font-weight: 600; cursor: pointer;
}
button.primary:disabled { opacity: 0.5; cursor: default; }
button.secondary {
  background: transparent; color: var(--text); border: 1px solid var(--border); border-radius: 8px;
  padding: 8px 16px; cursor: pointer;
}
button.secondary:disabled { opacity: 0.5; cursor: default; }

.output-panel {
  background: #0f1015; border: 1px solid var(--border); border-radius: 8px;
  padding: 12px; white-space: pre-wrap; word-break: break-word;
  font-family: "SFMono-Regular", Consolas, "Liberation Mono", Menlo, monospace;
  font-size: 0.85rem; min-height: 40px;
}

.verdict {
  display: inline-block; padding: 4px 12px; border-radius: 6px; font-weight: 700; letter-spacing: 0.03em;
}
.verdict-AC { background: rgba(76,175,110,0.2); color: var(--ac); }
.verdict-WA, .verdict-RE, .verdict-CE { background: rgba(224,90,90,0.2); color: var(--bad); }
.verdict-TLE, .verdict-MLE, .verdict-OLE { background: rgba(216,165,61,0.2); color: var(--warn); }

.testcase-row { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.testcase-row:last-child { border-bottom: none; }

.muted { color: var(--muted); }

.select-lang {
  background: var(--panel); color: var(--text); border: 1px solid var(--border); border-radius: 6px; padding: 6px 10px;
}

label.field-label { display: block; font-size: 0.85rem; color: var(--muted); margin: 12px 0 4px; }

@media (max-width: 480px) {
  header.page-header h1 { font-size: 1.1rem; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar button { width: 100%; }
}
