:root {
  --bg: #0f1117;
  --bg-card: #181b24;
  --bg-elevated: #1f2430;
  --border: #2a3142;
  --text: #e8eaef;
  --text-muted: #9aa3b5;
  --true: #4d9fff;
  --true-dim: #2a5a99;
  --false: #ff5c6c;
  --false-dim: #992a35;
  --accent: #7c6cff;
  --radius: 12px;
  --font: "Noto Sans JP", system-ui, sans-serif;
  --mono: "JetBrains Mono", ui-monospace, monospace;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.35);
}

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

html {
  color-scheme: dark;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  background-image:
    radial-gradient(ellipse 80% 50% at 50% -20%, rgba(77, 159, 255, 0.08), transparent),
    radial-gradient(ellipse 60% 40% at 100% 100%, rgba(255, 92, 108, 0.06), transparent);
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

.site-header {
  text-align: center;
  padding: 2rem 1rem 1rem;
}

.brand {
  display: inline-block;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.site-header h1 {
  margin: 0;
  font-size: clamp(1.75rem, 5vw, 2.25rem);
  font-weight: 700;
}

.tagline {
  margin: 0.5rem 0 0;
  color: var(--text-muted);
  font-size: 0.95rem;
}

.container {
  max-width: 720px;
  margin: 0 auto;
  padding: 0 1rem 3rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem 1.5rem;
  box-shadow: var(--shadow);
}

.intro p {
  margin: 0;
  font-size: 0.95rem;
}

.true-label {
  color: var(--true);
}

.false-label {
  color: var(--false);
}

.btn-grid {
  display: grid;
  grid-template-columns: 1fr 1fr auto;
  grid-template-rows: auto auto;
  gap: 0.65rem;
  align-items: stretch;
}

.btn-grid .btn {
  width: 100%;
  min-width: 0;
}

#btn-true {
  grid-column: 1;
  grid-row: 1;
}

#btn-false {
  grid-column: 2;
  grid-row: 1;
}

#btn-true-batch {
  grid-column: 1;
  grid-row: 2;
}

#btn-false-batch {
  grid-column: 2;
  grid-row: 2;
}

#btn-reset {
  grid-column: 3;
  grid-row: 1 / span 2;
  align-self: stretch;
  min-width: 5.25rem;
  padding-left: 0.85rem;
  padding-right: 0.85rem;
}

.btn-batch {
  font-size: 0.85rem;
}

.btn {
  padding: 0.75rem 1rem;
  border: none;
  border-radius: 8px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: transform 0.12s ease, filter 0.12s ease, opacity 0.12s ease;
}

.btn:hover:not(:disabled) {
  transform: translateY(-1px);
  filter: brightness(1.08);
}

.btn:active:not(:disabled) {
  transform: translateY(0);
}

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

.btn-true {
  background: var(--true);
  color: #0a1628;
}

.btn-false {
  background: var(--false);
  color: #1a080a;
}

.btn-reset {
  background: var(--bg-elevated);
  color: var(--text);
  border: 1px solid var(--border);
}

.message {
  margin: 0.75rem 0 0;
  font-size: 0.85rem;
  color: var(--text-muted);
  min-height: 1.25em;
}

.message.error {
  color: var(--false);
}

.numberline-labels {
  display: flex;
  justify-content: space-between;
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
}

.numberline-track {
  position: relative;
  height: 72px;
  margin: 0 8px;
}

.numberline-axis {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 3px;
  transform: translateY(-50%);
  background: linear-gradient(90deg, var(--border), var(--text-muted), var(--border));
  border-radius: 2px;
}

.numberline-dots {
  position: absolute;
  inset: 0;
}

.dot {
  position: absolute;
  top: 50%;
  width: 14px;
  height: 14px;
  margin-left: -7px;
  margin-top: -7px;
  border-radius: 50%;
  border: 2px solid var(--bg-card);
  cursor: default;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  z-index: 1;
}

.dot:hover,
.dot:focus-visible {
  transform: scale(1.35);
  z-index: 2;
  outline: none;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.15);
}

.dot-true {
  background: var(--true);
  box-shadow: 0 0 12px var(--true-dim);
}

.dot-false {
  background: var(--false);
  box-shadow: 0 0 12px var(--false-dim);
}

.dot-tooltip {
  position: absolute;
  bottom: calc(100% + 10px);
  left: 50%;
  transform: translateX(-50%);
  padding: 0.2rem 0.45rem;
  font-family: var(--mono);
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 4px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease;
}

.dot:hover .dot-tooltip,
.dot:focus-visible .dot-tooltip {
  opacity: 1;
}

.history-row {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 0.5rem 1rem;
  margin-bottom: 0.5rem;
}

.history-row:last-child {
  margin-bottom: 0;
}

.history-label {
  font-weight: 700;
  font-size: 0.9rem;
  min-width: 3rem;
}

.history-values {
  color: var(--text);
  word-break: break-all;
}

.mono {
  font-family: var(--mono);
  font-size: 0.9rem;
}

.stats h2 {
  margin: 0 0 0.35rem;
  font-size: 1.1rem;
}

.stats-note {
  margin: 0 0 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.stats-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.stats-table th,
.stats-table td {
  padding: 0.5rem 0.6rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.stats-table thead th {
  font-weight: 700;
}

.stats-table tbody th {
  font-weight: 500;
  color: var(--text-muted);
}

.stats-table td {
  font-family: var(--mono);
  text-align: right;
}

.logic-help-wrap {
  display: flex;
  justify-content: center;
  margin-top: 0.25rem;
}

.btn-logic-help {
  padding: 0.65rem 1.25rem;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--text-muted);
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: color 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.btn-logic-help:hover {
  color: var(--text);
  border-color: var(--false);
  background: rgba(255, 92, 108, 0.06);
}

.modal {
  width: min(92vw, 32rem);
  max-height: min(85vh, 36rem);
  padding: 0;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-card);
  color: var(--text);
  box-shadow: var(--shadow);
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(2px);
}

.modal-panel {
  display: flex;
  flex-direction: column;
  max-height: min(85vh, 36rem);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.modal-header h2 {
  margin: 0;
  font-size: 1.1rem;
  color: var(--false);
}

.modal-close {
  flex-shrink: 0;
  width: 2rem;
  height: 2rem;
  padding: 0;
  font-size: 1.35rem;
  line-height: 1;
  color: var(--text-muted);
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  cursor: pointer;
}

.modal-close:hover {
  color: var(--text);
  border-color: var(--text-muted);
}

.modal-body {
  padding: 1rem 1.25rem 1.25rem;
  overflow-y: auto;
  font-size: 0.9rem;
}

.modal-body h3 {
  margin: 1.1rem 0 0.4rem;
  font-size: 0.95rem;
}

.modal-body h3:first-of-type {
  margin-top: 0;
}

.modal-body p {
  margin: 0 0 0.65rem;
}

.modal-body ol,
.modal-body ul {
  margin: 0 0 0.65rem;
  padding-left: 1.25rem;
}

.modal-body li {
  margin-bottom: 0.45rem;
}

.modal-body li ul {
  margin-top: 0.35rem;
  margin-bottom: 0;
}

.modal-examples {
  list-style: disc;
}

.modal-note {
  margin-top: 0.75rem !important;
  padding-top: 0.75rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
  color: var(--text-muted);
}

.modal-body code {
  font-family: var(--mono);
  font-size: 0.82em;
  padding: 0.1em 0.35em;
  background: var(--bg-elevated);
  border-radius: 4px;
}

.site-footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.8rem;
  color: var(--text-muted);
}

.site-footer p {
  margin: 0;
}

@media (max-width: 560px) {
  .btn-grid {
    grid-template-columns: 1fr 1fr;
  }

  #btn-reset {
    grid-column: 1 / -1;
    grid-row: 3;
    min-width: 0;
  }
}

@media (max-width: 480px) {
  .card {
    padding: 1rem;
  }

  .numberline-track {
    height: 88px;
  }

  .stats-table {
    font-size: 0.78rem;
  }

  .stats-table th,
  .stats-table td {
    padding: 0.4rem 0.35rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .btn,
  .dot {
    transition: none;
  }
}
