:root {
  --bg: #00263e;
  --bg-deep: #001a2c;
  --surface: #0a3a57;
  --surface-2: #114a6b;
  --text: #f4f8fb;
  --text-dim: #9fb8cb;
  --accent: #2c3e50;
  --accent-2: #1f7a8c;
  --correct: #27d1a0;
  --wrong: #f1605b;
  --warn: #ffc857;
  --border: rgba(255, 255, 255, 0.08);
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

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

html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: var(--bg-deep);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  overscroll-behavior: none;
}

body {
  display: flex;
  flex-direction: column;
  height: 100vh;
  height: 100dvh;
}

#app {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  padding-top: var(--safe-top);
}

.screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 16px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  position: relative;
}

.sound-toggle {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
}

.brand-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: #e7f1f5;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 5;
  padding: 0;
}

.brand-badge svg {
  width: 20px;
  height: 20px;
}

.brand-toast {
  position: absolute;
  top: 58px;
  left: 12px;
  right: 12px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.4;
  text-align: center;
  color: var(--text);
  z-index: 6;
  opacity: 0;
  transform: translateY(-6px);
  transition: opacity 0.25s ease, transform 0.25s ease;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

.brand-toast.show {
  opacity: 1;
  transform: translateY(0);
}

/* ---------- Card / question ---------- */

.clue-card {
  flex: 0 0 50%;
  min-height: 220px;
  background: linear-gradient(160deg, var(--surface) 0%, var(--accent) 100%);
  border-radius: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  margin-bottom: 16px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
  text-align: center;
  animation: slideUp 0.35s ease-out;
  position: relative;
}

.clue-card.type-def {
  background: linear-gradient(160deg, #0d4566 0%, #314759 100%);
}

.clue-card.type-reverse {
  background: linear-gradient(160deg, #0a3450 0%, #28394b 100%);
}

.clue-card.type-reverse .clue-text {
  font-size: clamp(24px, 7vw, 34px);
  font-weight: 800;
}

.clue-card.flash-correct {
  background: linear-gradient(160deg, var(--correct) 0%, #1a9d7c 100%);
}

.clue-card.flash-wrong {
  background: linear-gradient(160deg, var(--wrong) 0%, #b8362f 100%);
}

.clue-text {
  font-size: clamp(18px, 5.2vw, 24px);
  line-height: 1.4;
  font-weight: 600;
}

.clue-meta {
  position: absolute;
  top: 12px;
  left: 16px;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.7);
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 700;
}

.clue-card.type-ex .clue-meta {
  color: #1eb7df;
}

.clue-card.type-def .clue-meta {
  color: #ffc000;
}

.clue-card.type-reverse .clue-meta {
  color: #26d1a0;
}

.reveal-term {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 8px;
}

.reveal-def {
  font-size: 15px;
  line-height: 1.4;
  color: rgba(255, 255, 255, 0.9);
}

@keyframes slideUp {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

/* ---------- Answer buttons ---------- */

.answers {
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}

.answer-btn {
  min-height: 52px;
  width: 100%;
  border: none;
  border-radius: 14px;
  background: var(--surface-2);
  color: var(--text);
  font-size: 16px;
  font-weight: 600;
  padding: 14px 16px;
  text-align: left;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
  -webkit-user-select: none;
  user-select: none;
}

.answer-btn:active {
  transform: scale(0.98);
}

.answer-btn.correct {
  background: var(--correct);
  color: #00261c;
}

.answer-btn.wrong {
  background: var(--wrong);
  color: #2b0b09;
}

.answer-btn.disabled-attempt {
  opacity: 0.45;
  pointer-events: none;
  text-decoration: line-through;
}

.answer-btn:disabled {
  cursor: default;
}

.tap-continue {
  margin-top: 14px;
  text-align: center;
  font-size: 14px;
  color: var(--text-dim);
}

/* ---------- Bottom nav ---------- */

.tab-bar {
  display: flex;
  border-top: 1px solid var(--border);
  background: var(--bg-deep);
  padding-bottom: var(--safe-bottom);
  flex-shrink: 0;
}

.tab-btn {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 10px 0 8px;
  background: none;
  border: none;
  color: var(--text-dim);
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
  min-height: 52px;
}

.tab-btn svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
}

.tab-btn.active {
  color: var(--correct);
}

/* ---------- Daily challenge ---------- */

.daily-header {
  text-align: center;
  margin-bottom: 12px;
}

.daily-title {
  font-size: 20px;
  font-weight: 800;
}

.daily-sub {
  font-size: 13px;
  color: var(--text-dim);
  margin-top: 4px;
}

.attempts-row {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 14px 0;
}

.attempt-box {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 700;
}

.attempt-box.used-wrong { background: var(--wrong); border-color: var(--wrong); }
.attempt-box.used-correct { background: var(--correct); border-color: var(--correct); }

.locked-wrap {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 16px;
}

.streak-badge {
  font-size: 40px;
  font-weight: 800;
  color: var(--warn);
}

.streak-label {
  font-size: 13px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.countdown {
  font-size: 28px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.share-card {
  background: var(--surface);
  border-radius: 14px;
  padding: 18px;
  text-align: center;
  margin: 8px 0 4px;
}

.share-text {
  font-size: 15px;
  font-weight: 600;
  margin-bottom: 4px;
}

.share-squares {
  font-size: 26px;
  letter-spacing: 6px;
  margin: 8px 0;
}

.share-btn, .primary-btn {
  display: inline-block;
  margin-top: 8px;
  background: var(--correct);
  color: #00261c;
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
}

.secondary-btn {
  display: inline-block;
  margin-top: 8px;
  background: var(--surface-2);
  color: var(--text);
  border: none;
  border-radius: 12px;
  padding: 12px 24px;
  font-size: 15px;
  font-weight: 700;
  cursor: pointer;
  min-height: 48px;
}

/* ---------- Speed round ---------- */

.speed-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  min-height: 40px;
  padding: 0 52px;
  margin-bottom: 10px;
}

.speed-timer {
  font-size: 28px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: color 0.2s ease;
}

.speed-timer.urgent {
  color: var(--wrong);
  animation: pulse 0.6s infinite;
}

.speed-score {
  font-size: 16px;
  font-weight: 700;
  color: var(--text-dim);
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.12); }
}

.end-screen {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  gap: 8px;
}

.end-score {
  font-size: 56px;
  font-weight: 800;
}

.end-label {
  font-size: 14px;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.end-best {
  font-size: 16px;
  margin-top: 4px;
  color: var(--warn);
}

/* ---------- Boss round ---------- */

.boss-header {
  text-align: center;
  margin-bottom: 8px;
}

.boss-title {
  font-size: 18px;
  font-weight: 800;
}

.boss-sub {
  font-size: 12px;
  color: var(--text-dim);
  margin-top: 2px;
}

.chain {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  margin: 12px 0 16px;
}

.chain-node {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  background: transparent;
  transition: all 0.2s ease;
}

.chain-node.filled {
  background: var(--correct);
  border-color: var(--correct);
}

.chain-line {
  width: 24px;
  height: 2px;
  background: var(--text-dim);
}

.chain-line.filled {
  background: var(--correct);
}

/* ---------- Report card / feedback ---------- */

.report-card {
  width: 100%;
  margin-top: 16px;
  background: var(--surface);
  border-radius: 14px;
  padding: 14px;
  max-height: 38vh;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.report-title {
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-align: center;
}

.report-item {
  padding: 8px 4px;
  border-top: 1px solid var(--border);
  text-align: left;
}

.report-item:first-of-type {
  border-top: none;
}

.report-term {
  font-size: 14px;
  font-weight: 700;
  color: var(--warn);
}

.report-def {
  font-size: 12px;
  color: var(--text-dim);
  line-height: 1.35;
  margin-top: 2px;
}

.mastery-line {
  font-size: 12px;
  color: var(--text-dim);
  text-align: center;
  margin-top: -4px;
}
