*,
*::before,
*::after {
  box-sizing: border-box;
}

:root {
  color-scheme: light dark;
  --bg: #f4f1ee;
  --card-bg: #ffffff;
  --border: #e1dcd6;
  --text: #111;
  --muted: #5f5a55;
  --code-bg: #f3ede6;
  --choice-bg: #fffdfa;
  --choice-result-bg: #f6efe8;
  --accent: #ff7a3d;
  --accent-strong: #e85d2e;
  --accent-ink: #1b0f0a;
  --shadow: 0 18px 40px rgba(28, 22, 18, 0.12);
  --btn-bg: #ffffff;
  --btn-border: #c9c0b8;
  --btn-text: #1f1a15;
}
html[data-theme="light"] {
  color-scheme: light;
  --bg: #f4f1ee;
  --card-bg: #ffffff;
  --border: #e1dcd6;
  --text: #111;
  --muted: #5f5a55;
  --code-bg: #f3ede6;
  --choice-bg: #fffdfa;
  --choice-result-bg: #f6efe8;
  --accent: #ff7a3d;
  --accent-strong: #e85d2e;
  --accent-ink: #1b0f0a;
  --shadow: 0 18px 40px rgba(28, 22, 18, 0.12);
  --btn-bg: #ffffff;
  --btn-border: #c9c0b8;
  --btn-text: #1f1a15;
}
html[data-theme="dark"] {
  color-scheme: dark;
  --bg: #0f1114;
  --card-bg: #161a1e;
  --border: #2b3138;
  --text: #e8e9ec;
  --muted: #a7adba;
  --code-bg: #1e232a;
  --choice-bg: #1b2027;
  --choice-result-bg: #20262f;
  --accent: #ff8b3d;
  --accent-strong: #ff6b35;
  --accent-ink: #1b0f0a;
  --shadow: 0 18px 40px rgba(0, 0, 0, 0.35);
  --btn-bg: #1c2129;
  --btn-border: #343b44;
  --btn-text: #f1f3f6;
}
body {
  font-family: "Avenir Next", "Hiragino Kaku Gothic ProN", "Yu Gothic", "Meiryo", sans-serif;
  margin: 0;
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  background:
    radial-gradient(800px 400px at 10% -10%, rgba(255, 122, 61, 0.25), transparent 60%),
    radial-gradient(700px 420px at 90% 0%, rgba(44, 140, 255, 0.18), transparent 60%),
    var(--bg);
  color: var(--text);
  overflow-x: hidden;
}
.page { width: min(820px, 100%); padding: 24px; margin: 0 auto 24px; }
.adRail {
  display: none;
}
.inlineAd {
  display: none;
  width: 100%;
  margin: 18px auto 0;
  overflow: hidden;
}
.inlineAd--ready {
  display: block;
  min-height: 120px;
}
.inlineAd--placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px dashed #0f766e;
  border-radius: 14px;
  background: linear-gradient(145deg, #ccfbf1, #dbeafe);
  color: #134e4a;
  box-shadow: 0 10px 24px rgba(15, 118, 110, 0.14);
  font-size: 0.9rem;
  font-weight: 700;
  line-height: 1.7;
  text-align: center;
  white-space: pre-line;
}
html[data-theme="dark"] .inlineAd--placeholder {
  border-color: #5eead4;
  background: linear-gradient(145deg, #134e4a, #1e3a8a);
  color: #ccfbf1;
}
@media (min-width: 1220px) {
  .adRail {
    position: fixed;
    top: 112px;
    z-index: 5;
    display: flex;
    width: 160px;
    min-height: 600px;
    align-items: center;
    justify-content: center;
    overflow: hidden;
  }
  .adRail--left { left: calc(50% - 590px); }
  .adRail--right { right: calc(50% - 590px); }
  .adRail--placeholder {
    border: 2px dashed #7c3aed;
    border-radius: 14px;
    background: linear-gradient(145deg, #ede9fe, #dbeafe);
    color: #4c1d95;
    box-shadow: 0 12px 28px rgba(76, 29, 149, 0.18);
    font-size: 0.9rem;
    font-weight: 700;
    line-height: 1.7;
    text-align: center;
    white-space: pre-line;
  }
  html[data-theme="dark"] .adRail--placeholder {
    border-color: #a78bfa;
    background: linear-gradient(145deg, #312e81, #1e3a8a);
    color: #ede9fe;
  }
}
.card { border: 1px solid var(--border); border-radius: 16px; padding: 18px; background: var(--card-bg); box-shadow: var(--shadow); }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
button { padding: 12px 18px; border-radius: 14px; border: 1px solid var(--btn-border); background: var(--btn-bg); cursor: pointer; color: var(--btn-text); font-size: 15px; font-weight: 600; letter-spacing: 0.01em; box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08); transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease; }
button:hover { transform: translateY(-1px); box-shadow: 0 10px 18px rgba(0, 0, 0, 0.12); }
.loginBtn { display: inline-block; }
button:disabled { opacity: .5; cursor: not-allowed; }
.choice { margin: 8px 0; }
.choice.selected button {
  border: 2px solid var(--tab-accent, var(--accent));
  background: linear-gradient(
    135deg,
    color-mix(in srgb, var(--tab-accent-start, var(--tab-accent, var(--accent))) 20%, var(--btn-bg)),
    color-mix(in srgb, var(--tab-accent-end, var(--tab-accent, var(--accent))) 20%, var(--btn-bg))
  );
  box-shadow: 0 0 0 1px rgba(0, 0, 0, 0.04), 0 10px 18px rgba(0, 0, 0, 0.16);
}
.choice.expanded button { padding: 16px 18px; font-size: 1.05em; border-color: var(--accent); background: var(--choice-bg); }
.choiceResult { margin-top: 6px; padding: 8px; background: var(--choice-result-bg); border-radius: 8px; }
.statusList { display: flex; flex-wrap: wrap; gap: 8px; }
.statusItem { display: flex; gap: 6px; align-items: center; }
.questionSection { display: flex; flex-direction: column; align-items: center; }
.questionText {
  width: 100%;
  font-size: 1.1rem;
  font-weight: 600;
  line-height: 1.5;
  text-align: left;
  white-space: normal;
}
.codeBlock {
  margin: 10px auto 18px;
  width: min(720px, 100%);
  background: #111827;
  color: #e5e7eb;
  padding: 12px;
  border-radius: 12px;
  font-size: 0.95rem;
  line-height: 1.5;
  text-align: left;
  overflow-x: auto;
}
.codeBlock code {
  display: block;
  background: transparent;
  padding: 0;
  border-radius: 0;
  color: inherit;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-weight: 400;
  text-align: left;
  white-space: pre;
}
.choicesWrap { width: min(520px, 100%); margin: 0 auto; display: flex; flex-direction: column; align-items: center; }
#choices { width: 100%; display: flex; flex-direction: column; align-items: center; }
.choice { width: 100%; }
.choice button { width: 100%; }
.choice button {
  display: flex;
  align-items: center;
  gap: 10px;
}
.choiceNumber {
  min-width: 28px;
  text-align: left;
  font-weight: 700;
}
.choiceLabel {
  flex: 1;
  text-align: center;
  padding-right: 28px;
}
.choiceJudge {
  font-size: 11px;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 999px;
  white-space: nowrap;
  background: rgba(0, 0, 0, 0.08);
}
.choice-correct .choiceJudge {
  color: #065f46;
  background: rgba(16, 185, 129, 0.2);
}
.choice-wrong .choiceJudge {
  color: #991b1b;
  background: rgba(239, 68, 68, 0.2);
}
.choice-correct button {
  border: 2px solid #10b981;
}
.choice-wrong button {
  border: 2px solid #ef4444;
}
.choiceNav { width: 100%; display: flex; justify-content: space-between; margin-top: 12px; }
.ok { color: #0a7; font-weight: 700; }
.ng { color: #d33; font-weight: 700; }
code { background: var(--code-bg); padding: 2px 6px; border-radius: 6px; }
pre { background: var(--choice-result-bg); padding: 12px; border-radius: 10px; overflow: auto; }
.small { font-size: 12px; color: var(--muted); }
label { user-select: none; }
h1 { margin-top: 0; }
.hidden { display: none; }
input, select { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--btn-border); background: var(--card-bg); color: inherit; }
textarea { padding: 10px 12px; border-radius: 10px; border: 1px solid var(--btn-border); background: var(--card-bg); color: inherit; resize: vertical; width: 100%; }
.historyChart {
  width: 100%;
  height: 220px;
  display: block;
}
.buttonGrid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 10px;
  margin-top: 10px;
}
.tabs {
  display: flex;
  gap: 6px;
  margin: 10px 0 18px;
  padding: 6px;
  background: rgba(255, 255, 255, 0.6);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  overflow-x: auto;
}
.connectedTabs {
  margin-bottom: 0;
  border-radius: 16px 16px 0 0;
  background: var(--card-bg);
  box-shadow: none;
}
.connectedCard {
  border-top-left-radius: 0;
  border-top-right-radius: 0;
  border-top: none;
  border-left: 2px solid var(--tab-accent, var(--border));
  border-right: 2px solid var(--tab-accent, var(--border));
  border-bottom: 2px solid var(--tab-accent, var(--border));
  box-shadow: 0 20px 40px rgba(28, 22, 18, 0.12);
}
.tab {
  border: 1px solid transparent;
  border-radius: 12px 12px 6px 6px;
  padding: 8px 16px;
  font-weight: 600;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  position: relative;
}
.tab.active {
  color: var(--text);
  background: var(--card-bg);
  border-color: var(--tab-accent, var(--border));
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.08);
}
.tab.active::after {
  content: "";
  position: absolute;
  left: 12px;
  right: 12px;
  bottom: -4px;
  height: 3px;
  border-radius: 999px;
  background: var(--tab-accent-gradient, var(--tab-accent, var(--accent)));
}
.choice-btn {
  width: 100%;
  text-align: center;
}
.modeBtn { width: 100%; }
.choice-btn.selected {
  background: var(--tab-accent-gradient, var(--tab-accent, var(--accent)));
  color: #fff;
  border: none;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}
.modeBtn.selected {
  background: var(--tab-accent-gradient, var(--tab-accent, var(--accent)));
  color: #fff;
  border: none;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25);
}
.feedbackBlock { margin-top: 16px; }
.feedbackForm {
  margin-top: 10px;
  padding: 12px;
  border: 1px dashed var(--border);
  border-radius: 12px;
  background: var(--choice-result-bg);
}
.primary {
  background: #1f6feb;
  border: none;
  color: #fff;
  box-shadow: 0 14px 28px rgba(31, 111, 235, 0.35);
}
.primary:hover { box-shadow: 0 18px 32px rgba(31, 111, 235, 0.45); }
.startAction { display: flex; justify-content: center; margin-top: 18px; }
.startButton { min-width: 260px; font-size: 1.05rem; padding: 16px 28px; }
.topbar {
  position: sticky;
  top: 0;
  z-index: 10;
  border-bottom: 1px solid var(--border);
  background: var(--card-bg);
}
.footerbar {
  border-top: 1px solid var(--border);
  background: var(--card-bg);
}
.topbar-inner {
  width: 100%;
  max-width: 980px;
  margin: 0 auto;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}
.topbar-left {
  display: flex;
  align-items: center;
  gap: 10px;
}
.categoryDrawerToggle {
  width: 42px;
  height: 36px;
  padding: 0;
  border-radius: 10px;
  font-size: 1.1rem;
  line-height: 1;
}
.footer-inner {
  width: min(980px, 100%);
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.footerLinks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 6px 16px;
  font-size: 0.82rem;
}
.footerLinks a { color: var(--muted); }
.legalPage { width: min(900px, 100%); }
.legalPage article > h1 { margin-top: 0; }
.legalPage h2 { margin-top: 28px; font-size: 1.12rem; }
.legalPage p, .legalPage li { line-height: 1.85; }
.legalPage a { overflow-wrap: anywhere; }
.brand { font-weight: 700; text-decoration: none; color: inherit; }
.aboutLink {
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 0.85rem;
  font-weight: 600;
  cursor: pointer;
}
.footerbar { margin-top: auto; }
.footerbar .small { font-size: 0.85rem; }
.topbar-actions { display: flex; align-items: center; gap: 8px; min-width: 0; flex-shrink: 0; }
.userDisplay {
  max-width: 180px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.menu { position: relative; }
.menuPanel {
  position: absolute;
  right: 0;
  top: 36px;
  min-width: 200px;
  z-index: 50;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card-bg);
  padding: 8px;
  box-shadow: 0 12px 24px rgba(0,0,0,0.12);
}
.menuItem {
  width: 100%;
  text-align: left;
  margin: 4px 0;
  display: block;
  padding: 8px 10px;
  border-radius: 12px;
  color: inherit;
  text-decoration: none;
  background: var(--btn-bg);
  border: 1px solid var(--btn-border);
  box-shadow: 0 6px 14px rgba(0, 0, 0, 0.08);
}
.menuItem:hover { transform: translateY(-1px); box-shadow: 0 10px 18px rgba(0, 0, 0, 0.12); }
.menuItem.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.menuLabel { margin-bottom: 6px; }
.drawerOverlay {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(0, 0, 0, 0.28);
}
.drawerOverlay.hidden {
  display: none;
}
.categoryDrawer {
  width: min(320px, 82vw);
  height: 100%;
  background: var(--card-bg);
  border-right: 1px solid var(--border);
  box-shadow: 12px 0 28px rgba(0, 0, 0, 0.18);
  padding: 12px;
  transform: translateX(0);
}
.drawerHeader {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.drawerHeader h3 {
  margin: 0;
  font-size: 1rem;
}
.drawerList {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.drawerCategoryBtn {
  width: 100%;
  text-align: left;
}
.drawerCategoryBtn.active {
  background: var(--tab-accent-gradient, var(--tab-accent, var(--accent)));
  color: #fff;
  border: none;
}
.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 100;
}
.overlay.hidden { display: none; }
.modalWindow {
  width: min(520px, 100%);
  border: 1px solid var(--border);
  border-radius: 16px;
  background: var(--card-bg);
  padding: 16px;
  box-shadow: 0 24px 48px rgba(0, 0, 0, 0.18);
}
#submitBtn {
  width: 100%;
  padding: 12px;
  font-size: 16px;
}
.modalHeader { display: flex; justify-content: space-between; align-items: center; }
.section { margin-top: 12px; }
@media (max-width: 600px) {
  body { align-items: stretch; }
  .page { padding: 16px 12px; }
  .row { flex-direction: column; align-items: flex-start; }
  .page .card button { width: 100%; }
  .topbar button { width: auto; }
  .topbar .loginBtn,
  .topbar .menuToggle,
  .topbar .categoryDrawerToggle {
    width: auto;
    min-width: 40px;
  }
  .card { padding: 14px; }
  .choiceNav { flex-direction: column; gap: 8px; }
  .topbar-inner {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 8px 10px;
  }
  .topbar-left {
    width: auto;
    min-width: 0;
    gap: 6px;
  }
  .brand {
    font-size: 1.45rem;
    white-space: nowrap;
    line-height: 1.1;
  }
  .topbar-actions {
    width: auto;
    justify-content: flex-end;
    flex-wrap: nowrap;
    gap: 4px;
  }
  .topbar .loginBtn {
    padding: 10px 14px;
    font-size: 0.95rem;
  }
  .topbar .menuToggle,
  .topbar .categoryDrawerToggle {
    width: 38px;
    height: 34px;
    min-width: 38px;
  }
  .topbar-actions .aboutLink {
    display: none;
  }
  .topbar-actions .userDisplay,
  .topbar-actions .small {
    display: none;
  }
  .buttonGrid {
    grid-template-columns: 1fr;
  }
  .historyChart { height: 180px; }
  .categoryDrawer {
    width: min(340px, 90vw);
  }
  body {
    background:
      radial-gradient(520px 260px at 100% -10%, rgba(44, 140, 255, 0.14), transparent 62%),
      var(--bg);
  }
}
