:root {
  --bg-a: #072545;
  --bg-b: #0b5f6b;
  --card: rgba(255, 255, 255, 0.12);
  --card-strong: rgba(255, 255, 255, 0.2);
  --text: #f5fbff;
  --muted: #c4deef;
  --good: #39d98a;
  --warn: #ff9f43;
  --danger: #ff5b6e;
  --accent: #ffd166;
  --shadow: 0 14px 40px rgba(4, 17, 32, 0.28);
  --radius: 22px;
  --radius-sm: 14px;
  --font-main: "Baloo 2", "Trebuchet MS", "Segoe UI", sans-serif;
  --font-title: "Fredoka One", "Baloo 2", "Trebuchet MS", sans-serif;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  min-height: 100%;
  color: var(--text);
  font-family: var(--font-main);
  background: linear-gradient(135deg, var(--bg-a), var(--bg-b));
}

body::before,
body::after {
  content: "";
  position: fixed;
  z-index: -1;
  border-radius: 999px;
  filter: blur(2px);
  opacity: 0.45;
  pointer-events: none;
}

body::before {
  width: 42vw;
  height: 42vw;
  left: -14vw;
  top: -8vw;
  background: radial-gradient(circle at 35% 35%, #61dafb, #1f75c0);
  animation: drift 12s ease-in-out infinite;
}

body::after {
  width: 34vw;
  height: 34vw;
  right: -10vw;
  bottom: -10vw;
  background: radial-gradient(circle at 60% 35%, #ffe97f, #ff9f43);
  animation: drift 14s ease-in-out infinite reverse;
}

@keyframes drift {
  0%, 100% {
    transform: translate(0, 0) scale(1);
  }
  50% {
    transform: translate(10px, -14px) scale(1.05);
  }
}

.app {
  width: min(1100px, calc(100vw - 24px));
  margin: 24px auto;
  background: var(--card);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  backdrop-filter: blur(8px);
  overflow: hidden;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.16);
  background: linear-gradient(90deg, rgba(255, 255, 255, 0.18), rgba(255, 255, 255, 0.07));
}

.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-title);
  letter-spacing: 0.3px;
  font-size: clamp(1.05rem, 1.5vw, 1.4rem);
}

.brand-icon {
  width: 38px;
  height: 38px;
  display: inline-grid;
  place-items: center;
  border-radius: 11px;
  background: linear-gradient(145deg, #ffd166, #ff9f43);
  color: #3d2200;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.4);
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

button {
  border: 0;
  background: linear-gradient(145deg, #1ed6c5, #00a5be);
  color: white;
  font: inherit;
  font-weight: 700;
  border-radius: 999px;
  padding: 10px 16px;
  cursor: pointer;
  transition: transform 0.15s ease, filter 0.2s ease, box-shadow 0.2s ease;
  box-shadow: 0 8px 18px rgba(5, 18, 35, 0.24);
}

button:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

button:active {
  transform: translateY(0);
}

button.secondary {
  background: linear-gradient(145deg, #87b7d7, #5f90b2);
}

button.warn {
  background: linear-gradient(145deg, #ffd166, #ff9f43);
  color: #4a2b00;
}

button.ghost {
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.2);
}

button.locked,
button:disabled {
  filter: grayscale(0.45);
  opacity: 0.62;
  cursor: not-allowed;
  transform: none;
}

.screen {
  padding: 18px;
  animation: fade-up 0.25s ease;
}

@keyframes fade-up {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.hero {
  padding: 18px;
  border-radius: var(--radius-sm);
  background: linear-gradient(125deg, rgba(255, 209, 102, 0.28), rgba(30, 214, 197, 0.26));
  border: 1px solid rgba(255, 255, 255, 0.24);
  margin-bottom: 16px;
}

.hero h1 {
  margin: 0 0 6px;
  font-family: var(--font-title);
  letter-spacing: 0.3px;
  font-size: clamp(1.45rem, 2.6vw, 2rem);
}

.hero p {
  margin: 0;
  color: var(--muted);
  font-size: 1.02rem;
  line-height: 1.45;
}

.stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  margin-bottom: 16px;
}

.stat {
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.22);
  min-height: 86px;
}

.stat .label {
  color: var(--muted);
  font-size: 0.92rem;
  margin-bottom: 4px;
}

.stat .value {
  font-size: clamp(1.4rem, 2.8vw, 2rem);
  font-family: var(--font-title);
}

.week-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 12px;
}

.week-card {
  border-radius: var(--radius-sm);
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  display: flex;
  flex-direction: column;
  gap: 9px;
  min-height: 190px;
}

.week-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.week-title {
  margin: 0;
  font-family: var(--font-title);
  font-size: 1.18rem;
}

.chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.84rem;
  border: 1px solid rgba(255, 255, 255, 0.36);
  background: rgba(255, 255, 255, 0.16);
  white-space: nowrap;
}

.week-desc {
  color: rgba(255, 255, 255, 0.9);
  font-size: 0.98rem;
  min-height: 48px;
  margin: 0;
}

.word-preview {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  list-style: none;
}

.word-preview li {
  font-size: 0.84rem;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.week-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: auto;
  flex-wrap: wrap;
}

.panel {
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.12);
  padding: 14px;
}

.study-wrap {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 12px;
}

.card-large {
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.2), rgba(255, 255, 255, 0.08));
  border: 1px solid rgba(255, 255, 255, 0.32);
  border-radius: 18px;
  min-height: 280px;
  display: grid;
  place-content: center;
  text-align: center;
  padding: 20px;
}

.emoji {
  font-size: 2.4rem;
  margin-bottom: 8px;
}

.word {
  margin: 0;
  font-family: var(--font-title);
  letter-spacing: 0.5px;
  font-size: clamp(2rem, 5vw, 3rem);
}

.cn {
  margin: 8px 0 0;
  color: #fff7dd;
  font-size: clamp(1.2rem, 2.5vw, 1.55rem);
  font-weight: 700;
}

.sentence {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.4;
  font-size: 1rem;
}

.controls {
  margin-top: 12px;
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}

.study-side h3,
.challenge-main h3 {
  margin: 4px 0 8px;
  font-family: var(--font-title);
  font-size: 1.1rem;
}

.line {
  color: var(--muted);
  font-size: 0.92rem;
  line-height: 1.4;
  margin: 0 0 10px;
}

.badge-list {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
}

.badge {
  border-radius: 10px;
  padding: 8px;
  font-size: 0.86rem;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.progress {
  width: 100%;
  height: 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.22);
  overflow: hidden;
}

.progress > span {
  display: block;
  height: 100%;
  width: 0;
  border-radius: inherit;
  background: linear-gradient(90deg, #39d98a, #f8d90f);
  transition: width 0.3s ease;
}

.challenge-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 12px;
}

.hud {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
  margin-bottom: 10px;
}

.hud-item {
  border-radius: 12px;
  padding: 9px;
  border: 1px solid rgba(255, 255, 255, 0.24);
  background: rgba(255, 255, 255, 0.08);
  text-align: center;
}

.hud-label {
  font-size: 0.82rem;
  color: var(--muted);
  margin-bottom: 4px;
}

.hud-value {
  font-family: var(--font-title);
  font-size: 1.22rem;
}

.question {
  margin-top: 8px;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.14);
  padding: 14px;
}

.question-title {
  margin: 0;
  font-size: clamp(1.2rem, 2.5vw, 1.55rem);
  line-height: 1.3;
}

.question-sub {
  margin: 8px 0 0;
  color: var(--muted);
  font-size: 1rem;
}

.hint {
  margin-top: 8px;
  border-radius: 10px;
  padding: 8px 10px;
  background: rgba(255, 255, 255, 0.12);
  color: #e7f6ff;
  font-size: 0.95rem;
}

.options {
  margin-top: 12px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}

.option-btn {
  text-align: left;
  border-radius: 12px;
  padding: 10px 12px;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.25);
  min-height: 50px;
}

.option-btn.correct {
  background: rgba(57, 217, 138, 0.28);
  border-color: rgba(57, 217, 138, 0.95);
}

.option-btn.wrong {
  background: rgba(255, 91, 110, 0.22);
  border-color: rgba(255, 91, 110, 0.9);
}

.input-wrap {
  margin-top: 12px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

input.answer-input {
  border: 1px solid rgba(255, 255, 255, 0.33);
  background: rgba(255, 255, 255, 0.2);
  color: white;
  font: inherit;
  border-radius: 12px;
  padding: 10px 12px;
  min-width: 210px;
  flex: 1;
  outline: none;
}

input.answer-input::placeholder {
  color: #d3edf6;
}

.feedback {
  margin-top: 10px;
  min-height: 26px;
  font-size: 1.02rem;
  font-weight: 700;
}

.feedback.good {
  color: #9effc9;
}

.feedback.bad {
  color: #ffd2d7;
}

.small-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 6px;
  margin-top: 10px;
}

.small-pill {
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.11);
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 6px 8px;
  font-size: 0.82rem;
  display: flex;
  justify-content: space-between;
  gap: 6px;
}

.small-pill em {
  font-style: normal;
  color: #fff0b4;
}

.result {
  text-align: center;
  padding: 10px;
}

.result h2 {
  margin-top: 8px;
  margin-bottom: 8px;
  font-family: var(--font-title);
  font-size: clamp(1.55rem, 3vw, 2.15rem);
}

.stars {
  font-size: clamp(2rem, 4.8vw, 3rem);
  letter-spacing: 5px;
}

.result-lines {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin: 14px 0;
}

.result-line {
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.13);
  border: 1px solid rgba(255, 255, 255, 0.24);
  padding: 10px;
}

.muted {
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-note {
  margin-top: 10px;
  color: #fef5cd;
  font-size: 0.96rem;
}

.hidden {
  display: none !important;
}

@media (max-width: 920px) {
  .week-grid,
  .stats {
    grid-template-columns: 1fr;
  }

  .study-wrap,
  .challenge-layout {
    grid-template-columns: 1fr;
  }

  .hud {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .screen {
    padding: 14px;
  }

  .options {
    grid-template-columns: 1fr;
  }

  .result-lines {
    grid-template-columns: 1fr;
  }

  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
}
