:root {
  --bg: #fde8ef;
  --card: #ffffff;
  --text: #1f2937;
  --muted: #6b7280;
  --border: #e5e7eb;
  --hover: #fff1f5;
  --accent: #ec4899;
  --quiz-card-max: 760px;
  --page-pad: clamp(12px, 4vw, 24px);
  --card-pad: clamp(16px, 4vw, 28px);
}

* {
  box-sizing: border-box;
  user-select: none;
  -webkit-user-select: none;
  -ms-user-select: none;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: var(--page-pad);
  padding-bottom: max(var(--page-pad), env(safe-area-inset-bottom, 0px));
  padding-left: max(var(--page-pad), env(safe-area-inset-left, 0px));
  padding-right: max(var(--page-pad), env(safe-area-inset-right, 0px));
  padding-top: max(env(safe-area-inset-top, 0px), 0px);
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  color: var(--text);
  background: var(--bg);
  overflow-x: hidden;
}

.top-nav {
  position: sticky;
  top: 0;
  z-index: 1000;
  display: flex;
  justify-content: center;
  width: 100vw;
  margin-left: calc(50% - 50vw);
  margin-right: calc(50% - 50vw);
  box-sizing: border-box;
  gap: 0.75rem;
  padding: 0.6rem 1rem;
  background: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(6px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  font-family: "Sour Gummy", sans-serif;
  text-transform: lowercase;
}

@supports (width: 100svw) {
  .top-nav {
    width: 100svw;
    margin-left: calc(50% - 50svw);
    margin-right: calc(50% - 50svw);
  }
}

.top-nav a {
  color: #333;
  text-decoration: none;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
}

.top-nav a:hover {
  background: rgba(0, 0, 0, 0.06);
}

.top-nav a.active {
  background: rgba(0, 0, 0, 0.1);
  font-weight: 600;
  color: #000;
  position: relative;
}

.top-nav a.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  width: 20px;
  height: 2px;
  background: #ff7eb9;
  border-radius: 1px;
}

.top-nav {
  position: relative;
}

.top-nav .nav-toggle {
  display: none; /* Hidden by default */
  align-items: center;
  justify-content: center;
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  background: #fff;
  cursor: pointer;
  font-size: 1.1em;
  color: var(--color-text, #2a3a4b);
  transition: background 0.2s;
}

.top-nav .nav-toggle:hover {
  background: rgba(0, 0, 0, 0.06);
}

.top-nav .nav-dropdown {
  display: none;
}

.nav-dropdown {
  position: absolute;
  right: 0.8rem;
  top: 2.6rem;
  background: #fff;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  display: none;
  flex-direction: column;
  min-width: 160px;
  z-index: 1200;
}

.nav-dropdown a {
  padding: 0.6rem 0.9rem;
}

.nav-dropdown a:hover {
  background: rgba(0, 0, 0, 0.06);
}

.nav-dropdown a.active {
  background: rgba(0, 0, 0, 0.1);
  font-weight: 600;
  color: #000;
}

@media (max-width: 900px) {
  .top-nav {
    justify-content: space-between;
    gap: 0.4rem;
    padding: 0.5rem 0.8rem;
    position: relative;
    align-items: center;
  }

  .top-nav .nav-links {
    display: none;
  }

  .top-nav .nav-toggle {
    display: inline-flex;
    position: relative;
    right: auto;
    margin-left: auto;
  }

  .top-nav a.active::after {
    display: none;
  }
}

@media (max-width: 600px) {
  .top-nav {
    padding: 0.4rem 0.6rem;
  }

  .top-nav .nav-toggle {
    padding: 0.3rem 0.5rem;
    font-size: 1em;
  }

  .nav-dropdown {
    right: 0.6rem;
    top: 2.4rem;
    min-width: 140px;
  }
}

.quiz-layout {
  width: 100%;
  max-width: var(--quiz-card-max);
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: clamp(8px, 2vw, 12px);
  flex: 0 1 auto;
  margin-block: auto;
}

.quiz-card {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--quiz-card-max);
  margin-inline: auto;
  min-height: min(420px, 72dvh);
  max-height: min(520px, 88dvh);
  overflow: hidden;
  background: var(--card);
  border: 2px solid #be185d;
  border-radius: clamp(12px, 2.5vw, 16px);
  padding: var(--card-pad);
  box-shadow: 0 10px 26px rgba(236, 72, 153, 0.08);
}

.quiz-card.is-result-view {
  min-height: min(480px, 78dvh);
  max-height: min(620px, 92dvh);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.tracker-wrap {
  display: flex;
  flex-direction: column;
  width: 100%;
  max-width: var(--quiz-card-max);
  margin-inline: auto;
  border: 2px solid #be185d;
  border-radius: clamp(10px, 2vw, 14px);
  overflow: hidden;
  background: #fff;
  box-shadow: 0 10px 20px rgba(236, 72, 153, 0.08);
  flex-shrink: 0;
}

.tracker-panel {
  --tr-pad: clamp(10px, 2.5vw, 12px);
  --tr-gap: clamp(4px, 1.2vw, 6px);
  --tr-cell: clamp(26px, 6.5vw, 32px);
  width: 100%;
  border-radius: inherit;
  background: #fff;
  padding: var(--tr-pad);
  /* Title + 3 rows × 10 questions (scroll for more) */
  max-height: calc(
    var(--tr-pad) * 2 + 2.25rem + 3 * var(--tr-cell) + 2 * var(--tr-gap)
  );
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  -ms-overflow-style: none;
}

.tracker-panel::-webkit-scrollbar {
  display: none;
  width: 0;
  height: 0;
}

.tracker-title {
  margin: 0 0 10px;
  color: #9d174d;
  font-weight: 700;
}

.tracker-grid {
  display: grid;
  grid-template-columns: repeat(10, minmax(0, 1fr));
  gap: clamp(4px, 1.2vw, 6px);
}

.tracker-item {
  border: 1px solid #f2bfd7;
  border-radius: 6px;
  background: #fff7fb;
  color: #9d174d;
  min-height: 0;
  height: clamp(26px, 6.5vw, 32px);
  font-size: clamp(0.62rem, 2.2vw, 0.75rem);
  font-weight: 700;
  cursor: pointer;
  padding: 0;
}

.tracker-item.is-answered {
  background: #ff4fa3;
  border-color: #ff4fa3;
  color: #fff;
}

.tracker-item.is-current {
  outline: 2px solid #d61f77;
  outline-offset: 1px;
}

.question {
  margin: 0 0 clamp(8px, 2.4vw, 14px);
  font-size: clamp(0.92rem, 3.2vw, 1.28rem);
  font-weight: 800;
  line-height: 1.32;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

#start-view,
#quiz-view,
#result-view,
#review-view {
  flex: 1 1 auto;
  min-height: 0;
}

.nav-btn,
.confirm-btn,
.restart-btn,
.review-btn,
.review-next-btn {
  border: 1px solid #be185d;
  border-radius: 10px;
  padding: 10px clamp(12px, 3vw, 16px);
  min-height: 44px;
  background: #fff;
  color: #9d174d;
  font-weight: 600;
  cursor: pointer;
  font-size: clamp(0.85rem, 2.8vw, 1rem);
}

.confirm-btn,
.restart-btn,
.review-next-btn.is-finish {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}

.confirm-btn.is-warning {
  background: #fff1f2;
  border-color: #fb7185;
  color: #be123c;
}

.nav-btn:disabled,
.review-next-btn:disabled {
  cursor: not-allowed;
  opacity: 0.45;
}

.nav-btn:hover:not(:disabled),
.confirm-btn:hover:not(:disabled),
.restart-btn:hover:not(:disabled),
.review-btn:hover:not(:disabled),
.review-next-btn:hover:not(:disabled),
.tracker-item:hover:not(:disabled) {
  filter: brightness(0.94);
}

@media (max-width: 480px) {
  .quiz-card,
  .quiz-card.is-result-view {
    min-height: 0;
    max-height: none;
  }

  .tracker-panel {
    --tr-cell: 26px;
    --tr-gap: 4px;
    max-height: calc(
      var(--tr-pad) * 2 + 2.25rem + 3 * var(--tr-cell) + 2 * var(--tr-gap)
    );
  }
}

@media (max-width: 360px) {
  :root {
    --page-pad: 10px;
  }
}

@media (max-height: 480px) and (orientation: landscape) {
  .quiz-card,
  .quiz-card.is-result-view {
    min-height: 0;
    max-height: min(92dvh, 520px);
  }
}
