:root {
  --bg-main: #f0f2f5;
  --bg-card: #ffffff;
  --text-main: #1a1a2e;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  --border: #e2e8f0;
  --primary: #1a1a2e;
  --primary-hover: #272744;
  --accent: #8c9eff;
  --accent-light: #e0e7ff;
  --danger: #fee2e2;
  --danger-text: #991b1b;
  --success: #dcfce7;
  --success-text: #166534;
  --skip: #f1f5f9;
  --skip-text: #64748b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  background-image: radial-gradient(circle at 0% 50%, rgba(140, 158, 255, 0.15), transparent 40%),
    radial-gradient(circle at 100% 50%, rgba(140, 158, 255, 0.15), transparent 40%);
  background-attachment: fixed;
}

.top-nav {
  display: flex;
  justify-content: center;
  gap: 2rem;
  padding: 1.5rem;
  font-weight: 600;
  font-size: 1rem;
}

.mobile-menu-btn {
  display: none;
  background: transparent;
  border: none;
  font-size: 1.8rem;
  padding: 0.5rem;
  color: var(--text-main);
  cursor: pointer;
  position: absolute;
  top: 1rem;
  right: 1rem;
  z-index: 100;
}

.close-menu-btn {
  display: none;
}

.nav-item {
  color: var(--text-muted);
  text-decoration: none;
  padding-bottom: 0.25rem;
  border-bottom: 2px solid transparent;
  transition: all 0.2s;
  background: none;
  border: none;
  cursor: pointer;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 600;
}

.nav-item:hover,
.nav-item.active {
  color: var(--text-main);
  border-bottom-color: var(--text-main);
}

.main-container {
  display: flex;
  justify-content: center;
  padding: 0 1rem 2rem;
}

.card {
  background: var(--bg-card);
  border-radius: 12px;
  width: 100%;
  max-width: 700px;
  box-shadow: 0 4px 25px rgba(0, 0, 0, 0.05);
  padding: 2rem;
  position: relative;
}

.card-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.game-date {
  text-transform: uppercase;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  letter-spacing: 0.5px;
  margin: 0 0 0.5rem;
}

.logo {
  margin: 0;
  font-size: 2rem;
  font-weight: 700;
  color: var(--text-main);
}

.game-case {
  font-size: 0.85rem;
  color: var(--text-light);
  margin: 0.25rem 0 0;
}

.card-nav-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.5rem;
}

.nav-arrow {
  background: transparent;
  border: 1px solid var(--border);
  padding: 0.5rem 1rem;
  border-radius: 20px;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.nav-arrow:hover:not(:disabled) {
  background: var(--bg-main);
  color: var(--text-main);
}

.nav-arrow:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.title-diagnosis {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  text-align: center;
}

.ep-tag-container {
  text-align: center;
  margin-bottom: 1rem;
}

.ep-tag {
  background: var(--accent-light);
  color: #3730a3;
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.3rem 0.8rem;
  border-radius: 20px;
}

.progress-dots {
  display: flex;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: 1.5rem;
}

.attempt-pip {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background-color: var(--border);
  transition: all 0.3s;
}

.attempt-pip.used {
  background-color: var(--text-light);
}

.attempt-pip.won {
  background-color: #22c55e;
}

.attempt-pip.current {
  background-color: var(--accent);
  transform: scale(1.2);
}

.scenario-section {
  margin-bottom: 2rem;
}

.scenario-title {
  text-transform: uppercase;
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--text-light);
  letter-spacing: 1px;
  margin-bottom: 1rem;
}

.symptom-list {
  display: flex;
  flex-direction: column;
}

.clue-block {
  animation: fadeIn 0.3s ease;
}

.clue-row {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
  font-size: 1.05rem;
  line-height: 1.5;
  color: var(--text-main);
  padding: 0.5rem 0;
}

.clue-badge {
  background: var(--accent-light);
  color: #3730a3;
  width: 24px;
  height: 24px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.85rem;
  flex-shrink: 0;
  margin-top: 3px;
}

.clue-separator {
  height: 1px;
  background: #f1f5f9;
  margin: 0.5rem 0;
}

.instruction {
  font-size: 0.85rem;
  color: var(--text-light);
  margin-bottom: 0.5rem;
}

.input-row {
  display: flex;
  gap: 0.5rem;
  align-items: stretch;
}

.input-container {
  flex: 1;
  position: relative;
}

#diagInput {
  width: 100%;
  padding: 0.85rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  font-family: inherit;
  outline: none;
  background: #f8fafc;
}

#diagInput:focus {
  border-color: var(--accent);
  background: #fff;
}

.btn-skip,
.btn-submit,
.btn-anki,
.btn-share {
  border: none;
  border-radius: 8px;
  padding: 0.85rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-skip {
  background: var(--bg-main);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

.btn-skip:hover {
  background: #e2e8f0;
  color: var(--text-main);
}

.btn-submit {
  background: var(--primary);
  color: white;
}

.btn-submit:hover {
  background: var(--primary-hover);
}

.suggestions {
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
  box-shadow: 0 -10px 15px -3px rgba(0, 0, 0, 0.1);
  margin-bottom: 4px;
  display: none;
}

.sug-item {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #f1f5f9;
  cursor: pointer;
  font-size: 0.95rem;
  color: var(--text-main);
}

.sug-item:hover,
.sug-item.sel {
  background: var(--bg-main);
}

.sug-item mark {
  background: #fef08a;
  font-weight: bold;
}

.guess-history {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.guess-row {
  padding: 0.75rem 1rem;
  border-radius: 8px;
  font-size: 0.95rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border: 1px solid transparent;
}

.guess-row.correct {
  background: var(--success);
  color: var(--success-text);
  border-color: #bbf7d0;
}

.guess-row.wrong {
  background: var(--danger);
  color: var(--danger-text);
  border-color: #fecaca;
}

.guess-row.skipped {
  background: var(--skip);
  color: var(--skip-text);
  border-color: #e2e8f0;
}

.guess-icon {
  font-weight: bold;
  width: 20px;
  text-align: center;
}

.guess-label {
  font-size: 0.8rem;
  opacity: 0.7;
  text-transform: uppercase;
  margin-right: 0.5rem;
}

.result-banner {
  margin-top: 1.5rem;
  padding: 1.5rem;
  border-radius: 12px;
  display: flex;
  gap: 1rem;
  align-items: center;
  animation: fadeIn 0.4s ease;
}

.result-banner.win {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.result-banner.lose {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.banner-emoji {
  font-size: 2.5rem;
}

.banner-text h3 {
  margin: 0 0 0.25rem;
  font-size: 1.2rem;
}

.banner-text p {
  margin: 0;
  font-size: 0.95rem;
  opacity: 0.9;
}

.summary-section {
  margin-top: 1rem;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.summary-header {
  background: #f8fafc;
  padding: 1rem 1.5rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}

.summary-header:hover {
  background: #f1f5f9;
}

.summary-body {
  padding: 0 1.5rem;
  max-height: 0;
  overflow: hidden;
  transition: max-height 0.3s ease, padding 0.3s ease;
}

.summary-body.open {
  padding: 1.5rem;
  max-height: 1000px;
}

.dx-name {
  margin: 0 0 0.5rem;
  font-size: 1.2rem;
  color: var(--primary);
}

.dx-facts {
  margin: 0 0 1.5rem;
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--text-main);
}

.anki-row {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1rem;
}

.btn-anki {
  background: #fff;
  color: #0284c7;
  border: 1px solid #bae6fd;
  flex: 1;
  padding: 0.6rem;
  font-size: 0.85rem;
}

.btn-anki:hover {
  background: #f0f9ff;
}

.share-row {
  display: flex;
}

.btn-share {
  background: #22c55e;
  color: white;
  flex: 1;
}

.btn-share:hover {
  background: #16a34a;
}

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal-content {
  background: #fff;
  border-radius: 12px;
  width: 90%;
  max-width: 700px;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  transform: translateY(20px);
  transition: all 0.3s;
}

.modal-overlay.open .modal-content {
  transform: translateY(0);
}

.modal-close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: rgba(0, 0, 0, 0.1);
  border: none;
  color: inherit;
  font-size: 1.5rem;
  cursor: pointer;
  z-index: 10;
  width: 40px;
  height: 40px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.modal-close-btn:hover {
  background: rgba(0, 0, 0, 0.2);
}

.archive-header {
  background: white;
  color: var(--primary);
  padding: 2rem;
  text-align: center;
  position: relative;
  border-bottom: 1px solid var(--border);
}

.archive-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 1rem;
  padding: 1.5rem;
}

.arc-item {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  cursor: pointer;
  position: relative;
  transition: all 0.2s;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.arc-item:hover {
  border-color: var(--accent);
  transform: translateY(-2px);
}

.arc-num-badge {
  font-weight: bold;
  font-family: Georgia, serif;
  color: var(--primary);
  font-size: 1.2rem;
}

.arc-ep {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 600;
  text-transform: uppercase;
}

.arc-clue {
  font-size: 0.85rem;
  color: var(--text-main);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.arc-status {
  position: absolute;
  top: 1rem;
  right: 1rem;
  font-weight: bold;
}

.arc-status.done {
  color: #22c55e;
}

.arc-status.new {
  color: #cbd5e1;
}

.stats-content,
.restart-content {
  padding: 2.5rem;
  max-width: 400px;
}

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.stat-num {
  font-size: 1.8rem;
  font-weight: bold;
  color: var(--primary);
}

.stat-label {
  font-size: 0.8rem;
  color: var(--text-muted);
  text-transform: uppercase;
  margin-top: 0.25rem;
}

.dist-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.dist-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.dist-n {
  width: 15px;
  font-weight: bold;
  color: var(--text-muted);
}

.dist-track {
  flex: 1;
  background: #f1f5f9;
  height: 24px;
}

.dist-fill {
  height: 100%;
  background: var(--text-light);
  color: white;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  padding: 0 0.5rem;
  justify-content: flex-end;
  min-width: 20px;
  transition: width 0.5s ease;
}

.dist-fill.highlight {
  background: #22c55e;
}

.restart-actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.cookie-banner {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #1e293b;
  color: white;
  padding: 1rem;
  text-align: center;
  z-index: 2000;
}

.cookie-banner button {
  background: white;
  color: #1e293b;
  border: none;
  padding: 0.4rem 1rem;
  border-radius: 4px;
  font-weight: bold;
  cursor: pointer;
  margin-left: 1rem;
}

.toast {
  position: fixed;
  bottom: 2rem;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #1e293b;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-weight: 600;
  opacity: 0;
  transition: all 0.3s;
  z-index: 3000;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
  opacity: 1;
}

.disclaimer-area {
  margin-top: 2rem;
  text-align: center;
}

.disclaimer {
  font-size: 0.8rem;
  color: var(--text-light);
  margin: 0;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@media (max-width: 600px) {
  .mobile-menu-btn {
    display: block;
  }
  
  .top-nav {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(15, 23, 42, 0.95);
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    z-index: 2000;
  }

  .top-nav.open {
    transform: translateX(0);
  }

  .close-menu-btn {
    display: block;
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    font-size: 2rem;
    color: white;
    background: transparent;
    border: none;
    cursor: pointer;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 8px;
  }

  .nav-item {
    background: white;
    color: var(--primary);
    padding: 1.5rem;
    border-radius: 8px;
    width: 80%;
    text-align: center;
    margin-bottom: 1rem;
    border: none;
    font-size: 1.1rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
  }

  .nav-item.active {
    background: var(--accent);
    color: white;
  }

  .input-row {
    flex-direction: column;
  }

  .anki-row {
    flex-direction: column;
  }
  
  .main-container {
    padding-top: 5rem;
  }
}

/* Tooltips */
.clue-row[data-tooltip] {
  position: relative;
  cursor: help;
}

.clue-row[data-tooltip]:hover::after {
  content: attr(data-tooltip);
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: #1e293b;
  color: #fff;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  font-size: 0.85rem;
  white-space: pre-wrap;
  width: max-content;
  max-width: 300px;
  text-align: center;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
  z-index: 100;
  margin-bottom: 8px;
  opacity: 0;
  animation: tooltipFadeIn 0.2s forwards;
}

.clue-row[data-tooltip]:hover::before {
  content: '';
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 6px solid transparent;
  border-top-color: #1e293b;
  margin-bottom: -4px;
  z-index: 100;
  opacity: 0;
  animation: tooltipFadeIn 0.2s forwards;
}