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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Noto Sans JP", "Helvetica Neue", sans-serif;
  font-size: 16px;
  line-height: 1.6;
  color: #333;
  background: #f0f4f8;
}

/* ===== HEADER ===== */
header {
  background: linear-gradient(135deg, #1a237e 0%, #283593 100%);
  color: white;
  padding: 1.5rem 1rem;
  text-align: center;
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  position: relative;
}

.back-link {
  display: inline-block;
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  font-size: 0.875rem;
  margin-bottom: 0.75rem;
  padding: 0.25rem 0;
  min-height: 44px;
  line-height: 44px;
}

.back-link:hover {
  color: white;
}

header h1 {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.4;
}

.subtitle {
  font-size: 0.875rem;
  opacity: 0.85;
  margin-top: 0.375rem;
}

/* ===== MAIN ===== */
main {
  max-width: 900px;
  margin: 0 auto;
  padding: 1rem;
}

/* ===== AD UNITS ===== */
.ad-unit {
  margin: 1.25rem 0;
}

/* ===== SECTION CARDS ===== */
.section-card {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  margin-bottom: 1.25rem;
}

.section-card h2 {
  font-size: 1.1rem;
  color: #1a237e;
  margin-bottom: 0.5rem;
}

.section-desc {
  font-size: 0.9rem;
  color: #666;
  margin-bottom: 1.25rem;
}

.hidden {
  display: none !important;
}

/* ===== COURSE GRID ===== */
.course-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 0.75rem;
}

.course-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  padding: 1rem 0.5rem;
  min-height: 90px;
  background: #f8f9ff;
  border: 2px solid #e0e4f0;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
  text-align: center;
}

.course-btn:hover {
  border-color: #3949ab;
  background: #eef0fc;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(57,73,171,0.15);
}

.course-btn[aria-pressed="true"],
.course-btn.active {
  border-color: #1a237e;
  background: #e8eaf6;
  box-shadow: 0 0 0 3px rgba(26,35,126,0.15);
}

.course-icon {
  font-size: 1.75rem;
  line-height: 1;
}

.course-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: #1a237e;
}

.course-desc {
  font-size: 0.75rem;
  color: #777;
}

/* ===== ROADMAP HEADER ===== */
.roadmap-header {
  margin-bottom: 1.5rem;
}

.roadmap-title-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.75rem;
  gap: 0.5rem;
}

#roadmap-title {
  font-size: 1.15rem;
  color: #1a237e;
}

/* ===== PROGRESS BAR ===== */
.progress-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.progress-bar-wrap {
  flex: 1;
  height: 10px;
  background: #e0e4f0;
  border-radius: 99px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, #3949ab, #5c6bc0);
  border-radius: 99px;
  width: 0%;
  transition: width 0.4s ease;
}

.progress-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: #3949ab;
  white-space: nowrap;
  min-width: 60px;
  text-align: right;
}

/* ===== LEGEND ===== */
.legend {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  font-size: 0.8rem;
  color: #666;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

.dot-required  { background: #1565c0; }
.dot-recommended { background: #2e7d32; }
.dot-optional  { background: #9e9e9e; }
.dot-done      { background: #43a047; opacity: 0.5; }

/* ===== ROADMAP TREE ===== */
.roadmap-tree {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

/* Phase separator */
.roadmap-phase {
  margin-top: 1rem;
  margin-bottom: 0.25rem;
  font-size: 0.8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #9e9e9e;
  padding-left: 0.5rem;
  border-left: 3px solid #e0e4f0;
}

/* Step item */
.roadmap-step {
  display: flex;
  align-items: stretch;
  gap: 0;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid #e0e4f0;
  background: white;
  transition: box-shadow 0.15s;
  position: relative;
}

.roadmap-step:hover {
  box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.roadmap-step.done {
  opacity: 0.6;
  background: #f5fff5;
}

.roadmap-step.done .step-name {
  text-decoration: line-through;
  color: #888;
}

/* Left color accent */
.step-accent {
  width: 5px;
  flex-shrink: 0;
}

.level-required .step-accent  { background: #1565c0; }
.level-recommended .step-accent { background: #2e7d32; }
.level-optional .step-accent  { background: #9e9e9e; }

/* Checkbox area */
.step-check-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 0.875rem;
  cursor: pointer;
  flex-shrink: 0;
}

.step-check-wrap input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
  accent-color: #3949ab;
  flex-shrink: 0;
}

/* Content area (clickable for popup) */
.step-content {
  flex: 1;
  padding: 0.75rem 0.5rem 0.75rem 0;
  cursor: pointer;
  min-height: 56px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 0.2rem;
}

.step-top-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.375rem;
}

.step-name {
  font-size: 0.95rem;
  font-weight: 600;
  color: #222;
}

.step-level-badge {
  font-size: 0.65rem;
  font-weight: 700;
  padding: 0.1rem 0.45rem;
  border-radius: 99px;
  flex-shrink: 0;
}

.badge-required {
  background: #e3f0fb;
  color: #1565c0;
}

.badge-recommended {
  background: #e8f5e9;
  color: #2e7d32;
}

.badge-optional {
  background: #f5f5f5;
  color: #757575;
}

.step-summary {
  font-size: 0.78rem;
  color: #888;
  line-height: 1.4;
}

/* Info icon */
.step-info-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1rem;
  color: #9e9e9e;
  font-size: 1rem;
  cursor: pointer;
  flex-shrink: 0;
  background: none;
  border: none;
  font-family: inherit;
  transition: color 0.15s;
  min-width: 44px;
  min-height: 44px;
}

.step-info-btn:hover {
  color: #3949ab;
}

/* Child (sub-step) indentation */
.roadmap-step.is-child {
  margin-left: 1.5rem;
  border-style: dashed;
}

/* ===== BUTTONS ===== */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: #1a237e;
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  cursor: pointer;
  padding: 0.875rem 1.5rem;
  min-height: 56px;
  transition: background 0.2s;
  text-decoration: none;
}

.btn-primary:hover {
  background: #283593;
}

.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #555;
  border: 1px solid #ccc;
  border-radius: 8px;
  font-size: 0.875rem;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  padding: 0.5rem 1rem;
  min-height: 44px;
  transition: all 0.2s;
}

.btn-ghost:hover {
  border-color: #888;
  color: #222;
}

.btn-sm {
  min-height: 44px;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
}

/* ===== POPUP ===== */
.popup-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: 1rem;
}

.popup-box {
  background: white;
  border-radius: 14px;
  padding: 1.5rem;
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
  max-height: 80vh;
  overflow-y: auto;
}

.popup-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.popup-title {
  font-size: 1.15rem;
  color: #1a237e;
  line-height: 1.35;
}

.popup-close {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #888;
  line-height: 1;
  padding: 0.25rem;
  min-width: 44px;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background 0.15s;
}

.popup-close:hover {
  background: #f0f0f0;
  color: #333;
}

.popup-tag-row {
  margin-bottom: 0.875rem;
}

.popup-level-badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.2rem 0.6rem;
  border-radius: 99px;
}

.popup-desc {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.7;
  margin-bottom: 1rem;
}

.popup-resources {
  font-size: 0.85rem;
  color: #666;
}

.popup-resources strong {
  display: block;
  color: #333;
  margin-bottom: 0.4rem;
  font-size: 0.85rem;
}

.popup-resources ul {
  padding-left: 1.25rem;
}

.popup-resources li {
  margin-bottom: 0.25rem;
}

/* ===== HOW-TO SECTION ===== */
.howto-section {
  background: white;
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  margin-bottom: 1.25rem;
}

.howto-section h2 {
  font-size: 1.05rem;
  color: #1a237e;
  margin-top: 1.25rem;
  margin-bottom: 0.6rem;
}

.howto-section h2:first-child {
  margin-top: 0;
}

.howto-section ol {
  padding-left: 1.35rem;
}

.howto-section li {
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 0.5rem;
  line-height: 1.6;
}

.howto-section p {
  font-size: 0.9rem;
  color: #555;
  line-height: 1.75;
}

/* ===== FOOTER ===== */
footer {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.85rem;
  color: #888;
}

footer p {
  margin-bottom: 0.25rem;
}

footer a {
  color: #666;
  text-decoration: none;
}

footer a:hover {
  text-decoration: underline;
}

/* ===== RESPONSIVE ===== */
@media (min-width: 480px) {
  .course-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

@media (min-width: 640px) {
  header h1 {
    font-size: 1.6rem;
  }

  main {
    padding: 1.5rem 2rem;
  }

  .course-btn {
    min-height: 100px;
  }

  .roadmap-step.is-child {
    margin-left: 2rem;
  }

  .step-name {
    font-size: 1rem;
  }
}

@media (min-width: 900px) {
  .course-grid {
    grid-template-columns: repeat(6, 1fr);
  }
}
