@import url('https://fonts.googleapis.com/css2?family=Noto+Serif+TC:wght@400;700;900&family=Noto+Sans+TC:wght@300;400;700&display=swap');

:root {
  --ink: #1a1208;
  --paper: #f5efe0;
  --gold: #c9922a;
  --gold-light: #f0c060;
  --red: #c0392b;
  --green: #27ae60;
  --brush: #2c1a0e;
  --shadow: rgba(44, 26, 14, 0.25);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: 'Noto Sans TC', sans-serif;
  background: var(--ink);
  color: var(--paper);
  min-height: 100vh;
  overflow: hidden;
  position: relative;
}

/* Ink wash background */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 60% at 15% 10%, rgba(80,40,10,0.4) 0%, transparent 60%),
    radial-gradient(ellipse 60% 80% at 85% 85%, rgba(60,20,5,0.5) 0%, transparent 55%),
    radial-gradient(ellipse 100% 100% at 50% 50%, #1a1208 0%, #0d0a04 100%);
  pointer-events: none;
  z-index: 0;
}

/* Bamboo decorative line */
body::after {
  content: '';
  position: fixed;
  top: 0; right: 60px;
  width: 2px;
  height: 100%;
  background: linear-gradient(to bottom,
    transparent 0%, rgba(201,146,42,0.15) 20%,
    rgba(201,146,42,0.08) 80%, transparent 100%);
  pointer-events: none;
  z-index: 0;
}

#app {
  position: relative;
  z-index: 1;
  width: 100vw;
  height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ===== CORNER DECORATIONS ===== */
.corner {
  position: fixed;
  width: 40px; height: 40px;
  border-color: rgba(201,146,42,0.2);
  border-style: solid;
  z-index: 0;
}
.corner-tl { top: 20px; left: 20px;   border-width: 2px 0 0 2px; }
.corner-tr { top: 20px; right: 20px;  border-width: 2px 2px 0 0; }
.corner-bl { bottom: 20px; left: 20px;  border-width: 0 0 2px 2px; }
.corner-br { bottom: 20px; right: 20px; border-width: 0 2px 2px 0; }

/* ===== INTRO SCREEN ===== */
#intro-screen {
  text-align: center;
  animation: fadeIn 0.8s ease;
}

.title-seal {
  display: inline-block;
  border: 3px solid var(--gold);
  padding: 8px 20px;
  margin-bottom: 24px;
  font-family: 'Noto Serif TC', serif;
  font-size: 13px;
  letter-spacing: 4px;
  color: var(--gold);
  position: relative;
}
.title-seal::before, .title-seal::after {
  content: '◆';
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  font-size: 8px;
  color: var(--gold);
}
.title-seal::before { left: -14px; }
.title-seal::after  { right: -14px; }

h1 {
  font-family: 'Noto Serif TC', serif;
  font-size: clamp(3rem, 8vw, 5rem);
  font-weight: 900;
  color: var(--paper);
  letter-spacing: 0.15em;
  text-shadow: 0 4px 20px rgba(201,146,42,0.3);
  line-height: 1;
  margin-bottom: 8px;
}
h1 span { color: var(--gold); }

.subtitle {
  font-size: 14px;
  letter-spacing: 3px;
  color: rgba(245,239,224,0.5);
  margin-bottom: 48px;
}

.instructions {
  background: rgba(245,239,224,0.04);
  border: 1px solid rgba(201,146,42,0.2);
  border-radius: 4px;
  padding: 28px 40px;
  max-width: 480px;
  margin: 0 auto 40px;
  text-align: left;
}
.instructions h3 {
  font-family: 'Noto Serif TC', serif;
  font-size: 15px;
  color: var(--gold);
  margin-bottom: 16px;
  letter-spacing: 2px;
}

.gesture-list {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}
.gesture-item {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  color: rgba(245,239,224,0.75);
}
.gesture-num {
  width: 36px; height: 36px;
  border: 1.5px solid var(--gold);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-family: 'Noto Serif TC', serif;
  font-size: 16px;
  color: var(--gold);
  flex-shrink: 0;
}

.note {
  font-size: 12px;
  color: rgba(245,239,224,0.4);
  margin-top: 14px;
  line-height: 1.8;
}

.btn-start {
  background: var(--gold);
  color: var(--ink);
  border: none;
  padding: 16px 60px;
  font-family: 'Noto Serif TC', serif;
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 4px;
  cursor: pointer;
  transition: all 0.2s;
  position: relative;
  overflow: hidden;
}
.btn-start::before {
  content: '';
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0);
  transition: background 0.2s;
}
.btn-start:hover::before { background: rgba(255,255,255,0.15); }
.btn-start:active { transform: scale(0.97); }

.error-msg {
  color: #e74c3c;
  font-size: 13px;
  letter-spacing: 1px;
  margin-top: 12px;
  min-height: 20px;
}

/* ===== QUIZ SCREEN ===== */
#quiz-screen {
  display: none;
  width: 100%;
  height: 100%;
  position: relative;
}

#video-bg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  opacity: 0.18;
  transform: scaleX(-1);
}

#canvas-overlay {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  transform: scaleX(-1);
}

.quiz-ui {
  position: relative;
  z-index: 2;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 20px 40px;
}

/* Top bar */
.top-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 16px;
}
.progress-info {
  font-size: 13px;
  letter-spacing: 2px;
  color: rgba(245,239,224,0.5);
}
.score-badge {
  font-family: 'Noto Serif TC', serif;
  font-size: 15px;
  color: var(--gold);
  letter-spacing: 2px;
}
.progress-bar-track {
  width: 160px;
  height: 3px;
  background: rgba(245,239,224,0.1);
  border-radius: 2px;
}
.progress-bar-fill {
  height: 100%;
  background: var(--gold);
  border-radius: 2px;
  transition: width 0.4s ease;
}

/* Question */
.question-area {
  text-align: center;
  flex: 0 0 auto;
  margin-bottom: 20px;
}
.mode-tag {
  display: inline-block;
  border: 1px solid rgba(201,146,42,0.4);
  padding: 3px 14px;
  font-size: 11px;
  letter-spacing: 3px;
  color: rgba(201,146,42,0.7);
  margin-bottom: 12px;
}
.question-text {
  font-family: 'Noto Serif TC', serif;
  font-size: clamp(3rem, 7vw, 5.5rem);
  font-weight: 900;
  letter-spacing: 0.2em;
  color: var(--paper);
  text-shadow: 0 2px 20px rgba(245,239,224,0.1);
  line-height: 1;
}
.question-text .blank {
  color: var(--gold);
  text-shadow: 0 0 30px rgba(201,146,42,0.6);
  position: relative;
}

/* Options */
.options-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  max-width: 760px;
  margin: 0 auto;
  width: 100%;
  flex: 0 0 auto;
}
.option-card {
  background: rgba(245,239,224,0.04);
  border: 1.5px solid rgba(245,239,224,0.12);
  padding: 18px 24px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: all 0.25s;
  position: relative;
  overflow: hidden;
  cursor: default;
}
.option-card.highlighted {
  border-color: var(--gold);
  background: rgba(201,146,42,0.1);
}
.option-card.correct {
  border-color: var(--green);
  background: rgba(39,174,96,0.12);
  animation: pulse-correct 0.5s ease;
}
.option-card.wrong {
  border-color: var(--red);
  background: rgba(192,57,43,0.12);
}

@keyframes pulse-correct {
  0%   { transform: scale(1); }
  50%  { transform: scale(1.02); }
  100% { transform: scale(1); }
}

.opt-num {
  width: 40px; height: 40px;
  border: 1.5px solid rgba(201,146,42,0.5);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Noto Serif TC', serif;
  font-size: 18px;
  color: var(--gold);
  flex-shrink: 0;
  transition: all 0.25s;
}
.option-card.highlighted .opt-num {
  background: var(--gold);
  color: var(--ink);
  border-color: var(--gold);
}
.opt-char {
  font-family: 'Noto Serif TC', serif;
  font-size: 2rem;
  color: var(--paper);
  transition: color 0.25s;
}
.opt-label {
  font-size: 12px;
  color: rgba(245,239,224,0.45);
  letter-spacing: 1px;
}

/* Status area */
.status-area {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  margin-top: auto;
  padding-top: 16px;
}
.gesture-display {
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.gesture-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: rgba(245,239,224,0.35);
}
.gesture-value {
  font-family: 'Noto Serif TC', serif;
  font-size: 2.5rem;
  color: var(--gold);
  line-height: 1;
  min-height: 2.5rem;
  transition: all 0.2s;
}
.confirm-bar-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}
.confirm-label {
  font-size: 11px;
  letter-spacing: 2px;
  color: rgba(245,239,224,0.35);
}
.confirm-track {
  width: 200px;
  height: 4px;
  background: rgba(245,239,224,0.1);
  border-radius: 2px;
  overflow: hidden;
}
.confirm-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--gold), var(--gold-light));
  border-radius: 2px;
  transition: width 0.1s linear;
}
.cam-status {
  font-size: 12px;
  letter-spacing: 1px;
  color: rgba(245,239,224,0.3);
  text-align: right;
}
.cam-dot {
  display: inline-block;
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--red);
  margin-right: 6px;
  animation: blink 1.5s infinite;
}
.cam-dot.active {
  background: var(--green);
  animation: none;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.2; }
}

/* Result overlay */
.result-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.3s;
}
.result-overlay.show { opacity: 1; }

.result-banner {
  font-family: 'Noto Serif TC', serif;
  font-size: clamp(2rem, 5vw, 3.5rem);
  font-weight: 900;
  padding: 20px 60px;
  border: 3px solid;
  letter-spacing: 0.15em;
  backdrop-filter: blur(8px);
  animation: bannerIn 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.result-banner.correct {
  color: var(--green);
  border-color: var(--green);
  background: rgba(39,174,96,0.15);
  text-shadow: 0 0 40px rgba(39,174,96,0.5);
}
.result-banner.wrong {
  color: #e74c3c;
  border-color: #e74c3c;
  background: rgba(231,76,60,0.15);
  text-shadow: 0 0 40px rgba(231,76,60,0.4);
}

@keyframes bannerIn {
  from { transform: scale(0.7) translateY(20px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);    opacity: 1; }
}

/* ===== RESULTS SCREEN ===== */
#result-screen {
  display: none;
  text-align: center;
  animation: fadeIn 0.8s ease;
  max-width: 680px;
  padding: 0 20px;
}
.final-score {
  font-family: 'Noto Serif TC', serif;
  font-size: clamp(5rem, 12vw, 9rem);
  font-weight: 900;
  color: var(--gold);
  line-height: 1;
  text-shadow: 0 4px 40px rgba(201,146,42,0.4);
}
.final-label {
  font-size: 14px;
  letter-spacing: 4px;
  color: rgba(245,239,224,0.5);
  margin-bottom: 32px;
}
.wrong-list {
  background: rgba(245,239,224,0.04);
  border: 1px solid rgba(201,146,42,0.15);
  padding: 20px 28px;
  text-align: left;
  max-height: 260px;
  overflow-y: auto;
  margin-bottom: 32px;
}
.wrong-list h3 {
  font-family: 'Noto Serif TC', serif;
  font-size: 13px;
  color: var(--gold);
  letter-spacing: 2px;
  margin-bottom: 14px;
  border-bottom: 1px solid rgba(201,146,42,0.2);
  padding-bottom: 10px;
}
.wrong-item {
  padding: 8px 0;
  border-bottom: 1px solid rgba(245,239,224,0.06);
  font-size: 13px;
  color: rgba(245,239,224,0.65);
  line-height: 1.8;
}
.wrong-item .q-idiom {
  font-family: 'Noto Serif TC', serif;
  font-size: 18px;
  color: rgba(245,239,224,0.85);
  letter-spacing: 0.1em;
}
.wrong-item .correct-ans {
  color: var(--green);
  font-weight: 700;
}
.btn-restart {
  background: transparent;
  border: 2px solid var(--gold);
  color: var(--gold);
  padding: 14px 56px;
  font-family: 'Noto Serif TC', serif;
  font-size: 16px;
  letter-spacing: 4px;
  cursor: pointer;
  transition: all 0.25s;
}
.btn-restart:hover {
  background: var(--gold);
  color: var(--ink);
}

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

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(201,146,42,0.3); border-radius: 2px; }
