:root {
  --bg: #F4F7FE;
  --surface: #FFFFFF;
  --text: #2D3436;
  --text-muted: #636E72;
  --primary: #6C5CE7;
  --primary-shadow: #5041C8;
  --accent-yellow: #FDCB6E;
  --accent-green: #00B894;
  --accent-green-shadow: #008E72;
  --accent-coral: #FF7675;
  --border: #DFE6E9;
  --card-shadow: 0 8px 24px rgba(108, 92, 231, 0.1);
  --btn-shadow: 0 6px 0 var(--primary-shadow);
  --btn-green-shadow: 0 6px 0 var(--accent-green-shadow);
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Modal scrolling containment per modern-web-guidance */
dialog:modal {
  overscroll-behavior: contain;
}
dialog::backdrop {
  overflow: hidden;
  overscroll-behavior: contain;
  background: rgba(16, 24, 40, 0.6);
  backdrop-filter: blur(4px);
}

/* Typography & Toys */
h1, h2, h3 { font-weight: 800; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  font-family: inherit;
  font-weight: 800;
  font-size: 16px;
  border-radius: 999px;
  padding: 14px 28px;
  border: none;
  cursor: pointer;
  background: var(--primary);
  color: #fff;
  box-shadow: var(--btn-shadow);
  transition: transform 0.1s, box-shadow 0.1s;
}
.btn:active {
  transform: translateY(3px);
  box-shadow: 0 3px 0 var(--primary-shadow);
}
.btn-green {
  background: var(--accent-green);
  box-shadow: var(--btn-green-shadow);
}
.btn-green:active {
  box-shadow: 0 3px 0 var(--accent-green-shadow);
}
.btn-yellow {
  background: var(--accent-yellow);
  color: #2D3436;
  box-shadow: 0 6px 0 #E1A73E;
}
.btn-yellow:active {
  box-shadow: 0 3px 0 #E1A73E;
}
.btn-ghost {
  background: transparent;
  color: var(--text);
  box-shadow: none;
  border: 2px solid var(--border);
  padding: 10px 20px;
}
.btn-ghost:active {
  background: #EDF2F7;
  transform: none;
}
.btn-danger {
  background: var(--accent-coral);
  box-shadow: 0 6px 0 #D63031;
}
.btn-danger:active {
  box-shadow: 0 3px 0 #D63031;
}
.btn-sm {
  padding: 8px 14px;
  font-size: 13px;
  border-radius: 12px;
  box-shadow: 0 3px 0 rgba(0,0,0,0.15);
}
.btn-sm:active {
  transform: translateY(2px);
  box-shadow: 0 1px 0 rgba(0,0,0,0.15);
}

/* Learner Header */
.topbar {
  background: var(--surface);
  border-bottom: 2px solid var(--border);
  padding: 12px 20px;
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 900;
  font-size: 20px;
  color: var(--primary);
}
.brand .mascot { font-size: 28px; }
.stats {
  display: flex;
  align-items: center;
  gap: 12px;
}
.stat-pill {
  display: flex;
  align-items: center;
  gap: 6px;
  background: var(--bg);
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 800;
  font-size: 14px;
  border: 1px solid var(--border);
}

/* Banner */
.retry-banner {
  background: linear-gradient(135deg, #FFEAA7, #FDCB6E);
  color: #2D3436;
  padding: 14px 20px;
  text-align: center;
  font-weight: 700;
  font-size: 15px;
  box-shadow: inset 0 -2px 0 rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

/* Path view container */
.path-container {
  flex: 1;
  max-width: 480px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 80px;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.day-card {
  background: var(--surface);
  border-radius: 24px;
  padding: 18px 24px;
  width: 100%;
  box-shadow: var(--card-shadow);
  border: 2px solid #E8EEFF;
  margin-bottom: 32px;
  text-align: center;
}
.day-card h2 {
  font-size: 24px;
  color: var(--primary);
  margin-bottom: 6px;
}
.day-card .day-progress-text {
  font-weight: 700;
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 12px;
}
.progress-track {
  background: #EDF2F7;
  height: 14px;
  border-radius: 999px;
  overflow: hidden;
  position: relative;
}
.progress-fill {
  background: linear-gradient(90deg, var(--accent-yellow), var(--accent-green));
  height: 100%;
  border-radius: 999px;
  transition: width 0.4s ease;
}

/* Winding Path */
.winding-path {
  position: relative;
  width: 100%;
  min-height: 400px;
}
.path-svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 1;
}

/* Nodes */
.path-node {
  position: absolute;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  text-decoration: none;
  z-index: 2;
  cursor: pointer;
  background: none;
  border: none;
}
.node-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  position: relative;
  transition: transform 0.15s;
}
.node-circle:active {
  transform: scale(0.94);
}
.node-title {
  margin-top: 8px;
  font-size: 13px;
  font-weight: 800;
  color: var(--text);
  max-width: 120px;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  background: rgba(255,255,255,0.9);
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid var(--border);
}

/* Node States */
.node-done .node-circle {
  background: var(--accent-green);
  box-shadow: 0 8px 0 var(--accent-green-shadow);
  color: #fff;
}
.node-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #fff;
  border-radius: 50%;
  width: 26px;
  height: 26px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 15px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.node-current .node-circle {
  background: linear-gradient(135deg, #FF9F43, #EE5A24);
  box-shadow: 0 8px 0 #B83B0E, 0 0 24px rgba(238, 90, 36, 0.4);
  color: #fff;
  animation: pulse 1.6s infinite alternate ease-in-out;
}
.node-current .start-pill {
  position: absolute;
  top: -24px;
  background: #2D3436;
  color: #fff;
  font-size: 11px;
  font-weight: 900;
  padding: 4px 10px;
  border-radius: 999px;
  letter-spacing: 0.5px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.2);
}
.node-current .start-pill::after {
  content: "";
  position: absolute;
  bottom: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-width: 4px 4px 0;
  border-style: solid;
  border-color: #2D3436 transparent transparent;
}

.node-locked .node-circle {
  background: #DFE6E9;
  box-shadow: 0 8px 0 #B2BEC3;
  color: #636E72;
  cursor: not-allowed;
}

@keyframes pulse {
  0% { transform: scale(1); }
  100% { transform: scale(1.08); }
}

/* Day Complete Card / Trophy */
.day-complete-hero {
  background: var(--surface);
  border-radius: 28px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--card-shadow);
  border: 3px solid var(--accent-yellow);
  margin-top: 24px;
  width: 100%;
}
.day-complete-hero .trophy { font-size: 64px; margin-bottom: 12px; }
.day-complete-hero h3 { font-size: 24px; color: var(--primary); margin-bottom: 8px; }
.day-complete-hero p { color: var(--text-muted); font-weight: 600; line-height: 1.5; }

/* Player Dialog */
.player-dialog {
  border: none;
  border-radius: 24px;
  padding: 0;
  max-width: 900px;
  width: calc(100vw - 32px);
  max-height: calc(100vh - 32px);
  margin: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.3);
  display: flex;
  flex-direction: column;
  background: #111;
  color: #fff;
  overflow: hidden;
}
.player-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 18px;
  background: #1E272E;
  border-bottom: 1px solid #2F3542;
}
.player-header h3 {
  font-size: 16px;
  font-weight: 700;
  color: #fff;
  max-width: 70%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-close {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}
.player-close:hover { background: rgba(255,255,255,0.3); }

.player-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  background: #000;
  min-height: 340px;
  overflow: auto;
}
video.media-player {
  max-width: 100%;
  max-height: 70vh;
  width: 100%;
  height: auto;
  outline: none;
}

/* PDF Viewer */
.pdf-viewer {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  background: #2D3436;
  padding: 16px;
}
.pdf-canvas-wrapper {
  max-width: 100%;
  overflow: auto;
  box-shadow: 0 8px 30px rgba(0,0,0,0.5);
  border-radius: 8px;
  background: #fff;
}
.pdf-controls {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-top: 14px;
}
.pdf-page-num {
  font-weight: 800;
  font-size: 14px;
  color: #DFE6E9;
}

.player-footer {
  padding: 12px 18px;
  background: #1E272E;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 12px;
}

/* Celebration Dialog */
.celebrate-dialog {
  border: none;
  border-radius: 28px;
  padding: 32px 28px;
  max-width: 440px;
  width: calc(100vw - 40px);
  margin: auto;
  background: var(--surface);
  color: var(--text);
  text-align: center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.25);
}
.celebrate-dialog .emoji-pop {
  font-size: 72px;
  margin-bottom: 12px;
  animation: bounce 0.6s ease;
}
@keyframes bounce {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.25); }
}
.celebrate-dialog h2 {
  color: var(--primary);
  font-size: 26px;
  margin-bottom: 8px;
}
.celebrate-dialog p {
  color: var(--text-muted);
  font-size: 16px;
  line-height: 1.5;
  margin-bottom: 24px;
}

/* Admin Styles */
.admin-shell {
  max-width: 1100px;
  width: 100%;
  margin: 0 auto;
  padding: 24px 20px 80px;
}
.admin-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
  flex-wrap: wrap;
  gap: 12px;
}
.admin-header h1 {
  font-size: 28px;
  color: var(--primary);
}
.admin-summary-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 20px 24px;
  box-shadow: var(--card-shadow);
  border: 2px solid var(--border);
  margin-bottom: 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 16px;
}
.summary-info h3 {
  font-size: 18px;
  margin-bottom: 4px;
}
.summary-info p {
  color: var(--text-muted);
  font-size: 14px;
}

.days-list {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.admin-day-card {
  background: var(--surface);
  border-radius: 20px;
  padding: 20px;
  box-shadow: var(--card-shadow);
  border: 2px solid var(--border);
}
.day-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 2px dashed var(--border);
  flex-wrap: wrap;
  gap: 8px;
}
.day-header .title-group {
  display: flex;
  align-items: center;
  gap: 10px;
}
.day-header h2 {
  font-size: 20px;
  color: var(--primary);
}

.item-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-bottom: 16px;
}
.item-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: var(--bg);
  border-radius: 14px;
  border: 1px solid var(--border);
  gap: 12px;
}
.item-info {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
.item-icon { font-size: 22px; flex-shrink: 0; }
.item-title-input {
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  border: 1px solid transparent;
  background: transparent;
  padding: 4px 8px;
  border-radius: 8px;
  color: var(--text);
  flex: 1;
  min-width: 140px;
}
.item-title-input:hover { border-color: var(--border); background: #fff; }
.item-title-input:focus { border-color: var(--primary); background: #fff; outline: none; }
.item-meta {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 600;
  flex-shrink: 0;
}

.item-status {
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
}
.status-ready { background: #D4EDDA; color: #155724; }
.status-processing { background: #FFF3CD; color: #856404; animation: pulse 1s infinite alternate; }
.status-failed { background: #F8D7DA; color: #721C24; }

.item-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.upload-zone {
  border: 2px dashed var(--primary);
  background: rgba(108, 92, 231, 0.04);
  border-radius: 16px;
  padding: 24px;
  text-align: center;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.upload-zone:hover, .upload-zone.dragover {
  background: rgba(108, 92, 231, 0.1);
  border-color: #5041C8;
}
.upload-zone p {
  color: var(--primary);
  font-weight: 700;
  font-size: 14px;
}
.upload-zone span {
  color: var(--text-muted);
  font-size: 12px;
}

.upload-progress-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.upload-progress-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 12px;
  background: #EDF2F7;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
}

/* Login Page */
.login-shell {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}
.login-card {
  background: var(--surface);
  border-radius: 28px;
  padding: 40px 32px;
  max-width: 400px;
  width: 100%;
  box-shadow: var(--card-shadow);
  border: 2px solid var(--border);
  text-align: center;
}
.login-card .mascot { font-size: 64px; margin-bottom: 12px; }
.login-card h1 { color: var(--primary); margin-bottom: 8px; font-size: 26px; }
.login-card p { color: var(--text-muted); font-size: 14px; margin-bottom: 24px; }
.login-card input {
  width: 100%;
  padding: 14px 18px;
  border-radius: 14px;
  border: 2px solid var(--border);
  font-size: 18px;
  font-weight: 700;
  font-family: inherit;
  margin-bottom: 16px;
  text-align: center;
}
.login-card input:focus {
  outline: none;
  border-color: var(--primary);
}
.login-error {
  color: var(--accent-coral);
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 12px;
  min-height: 20px;
}
