@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;700&family=Poppins:wght@400;500;600;700&display=swap');

:root {
  --primary: #ffffff;
  --glass-bg: rgba(255, 255, 255, 0.1);
  --glass-border: rgba(255, 255, 255, 0.2);
  --glass-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
  --correct-bg: rgba(0, 213, 8, 0.8);
  --wrong-bg: rgba(244, 67, 54, 0.8);
  --font-main: 'Outfit', sans-serif;
  --font-secondary: 'Poppins', sans-serif;
}

html,body,div,span,object,iframe,h1,h2,h3,h4,h5,h6,p,blockquote,pre,abbr,address,cite,code,del,dfn,em,img,ins,kbd,q,samp,small,strong,sub,sup,var,b,i,dl,dt,dd,ol,ul,li,fieldset,form,label,legend,table,caption,tbody,tfoot,thead,tr,th,td,article,aside,canvas,details,figcaption,figure,footer,header,hgroup,menu,nav,section,summary,time,mark,audio,video{margin:0;padding:0;border:0;outline:0;font-size:100%;vertical-align:baseline;background:transparent}

body {
  font-family: var(--font-main);
  background: linear-gradient(-45deg, #1e1366, #2a0845, #6441A5, #3a0ca3);
  background-size: 400% 400%;
  animation: gradientBG 15s ease infinite;
  color: var(--primary);
  overflow: hidden;
  height: 100vh;
  margin: 0;
}

@keyframes gradientBG {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

/* Floating ambient orbs */
body::before, body::after {
  content: '';
  position: absolute;
  width: 50vh;
  height: 50vh;
  border-radius: 50%;
  filter: blur(80px);
  z-index: -1;
  opacity: 0.5;
  animation: floatOrb 20s infinite alternate ease-in-out;
}

body::before {
  background: #ff007f;
  top: -10%;
  left: -10%;
}

body::after {
  background: #00f0ff;
  bottom: -10%;
  right: -10%;
  animation-delay: -10s;
}

@keyframes floatOrb {
  0% { transform: translate(0, 0) scale(1); }
  50% { transform: translate(20%, 20%) scale(1.2); }
  100% { transform: translate(-20%, -20%) scale(0.8); }
}

.container {
  display: flex;
  justify-content: center;
  align-items: center;
  flex-direction: column;
  height: 100vh;
  width: 100%;
  position: absolute;
  top: 0;
  left: 0;
  box-sizing: border-box;
  padding-bottom: 50px; /* Offset for footer */
  z-index: 10;
}

.logo {
  position: fixed;
  top: 10%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
}

.logo img {
  height: 48px;
  width: auto;
  filter: drop-shadow(0 4px 6px rgba(0,0,0,0.3));
}

.response {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  margin-bottom: 2rem;
  background: var(--glass-bg);
  padding: 1.5rem 3rem;
  border-radius: 24px;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  color: #fff;
  min-width: 300px;
}

.word-row {
  display: flex;
  flex-direction: row;
  align-items: baseline;
  justify-content: center;
}

.eng {
  text-transform: uppercase;
  font-size: 36px;
  font-weight: 700;
  letter-spacing: 2px;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

#cls {
  font-size: 16px;
  margin-left: 12px;
  color: rgba(255,255,255,0.7);
  font-family: var(--font-secondary);
}

.mon {
  margin-top: 10px;
  font-family: var(--font-secondary);
  font-size: 1.2rem;
  color: #00f0ff;
  font-weight: 500;
}

/* RESULTS OPTIONS */
.results {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  width: 100%;
  max-width: 400px;
}

.rs-row {
  display: flex;
  flex-direction: row;
  align-items: center;
  cursor: pointer;
  min-width: 280px;
  padding: 16px 24px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  overflow: hidden;
}

.rs-row::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; bottom: 0;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transform: translateX(-100%);
  transition: 0.5s;
}

@media(hover: hover) and (pointer: fine) {
  .rs-row:hover::before {
    transform: translateX(100%);
  }

  .rs-row:hover {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 12px 24px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.4);
  }
}

.rs {
  font-family: var(--font-secondary);
  font-size: 1.1rem;
  font-weight: 500;
  color: #fff;
}

.result {
  padding-left: 12px;
}

.correct {
  background: var(--correct-bg) !important;
  border-color: rgba(255, 255, 255, 0.5) !important;
  box-shadow: 0 0 20px rgba(0, 213, 8, 0.5) !important;
}

/* SCORE AND PROGRESS */
.scorebox {
  display: flex;
  align-items: center;
  justify-content: center;
  position: fixed;
  top: 6%;
  left: 6%;
  height: 48px;
  padding: 0 24px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--glass-border);
  border-radius: 24px;
  box-shadow: var(--glass-shadow);
  z-index: 20;
}

.score {
  display: flex;
  flex-direction: row;
  align-items: center;
}

#score, #total {
  font-family: var(--font-main);
  font-weight: 700;
  font-size: 20px;
  color: #fff;
  text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Spacer utilities */
.spacer {
  flex-grow: 1;
}

/* COUNTDOWN TIMER */
#countdown, #countstroke {
  position: fixed;
  top: 6%;
  right: 6%;
  height: 60px;
  width: 60px;
  text-align: center;
  z-index: 20;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 50%;
  box-shadow: var(--glass-shadow);
  border: 1px solid var(--glass-border);
}

#countdown-number {
  color: white;
  font-weight: 700;
  font-size: 20px;
  font-family: var(--font-main);
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
}

#cdsvg {
  transform: rotateY(-180deg) rotateZ(-90deg);
}

#countdown svg, #countstroke svg {
  width: 100%;
  height: 100%;
  position: absolute;
  top: 0;
  left: 0;
}

#static-crl, #cdcrl {
  cx: 30;
  cy: 30;
  r: 27;
}

#cdcrl {
  stroke-dasharray: 170px; 
  stroke-dashoffset: 0px;
  stroke-linecap: round;
  stroke-width: 4px;
  stroke: #00f0ff;
  fill: none;
  animation: countdown 10s linear backwards;
  filter: drop-shadow(0 0 4px #00f0ff);
}

@keyframes countdown {
  from { stroke-dashoffset: 0px; }
  to { stroke-dashoffset: 170px; }
}

/* FOOTER & SOCIALS */
.footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: fixed;
  bottom: 0;
  width: 100%;
  padding-bottom: 24px;
  z-index: 20;
}

.ft-items {
  display: flex;
  flex-direction: row;
  gap: 16px;
  margin-bottom: 12px;
}

.ft-item a {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  backdrop-filter: blur(4px);
  transition: all 0.3s ease;
  border: 1px solid rgba(255,255,255,0.1);
}

.ft-item a:hover {
  background: rgba(255, 255, 255, 0.25);
  transform: translateY(-4px);
  box-shadow: 0 8px 16px rgba(0,0,0,0.2);
}

.ft-item img {
  height: 20px;
  width: 20px;
  opacity: 0.9;
}

.credit {
  color: rgba(255,255,255,0.7);
  font-family: var(--font-secondary);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 6px;
}

.heart {
  fill: #ff007f;
  width: 14px;
  height: 14px;
  animation: heartbeat 1.5s infinite;
}

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

.credit a {
  color: #fff;
  font-weight: 600;
  text-decoration: none;
  border-bottom: 1px dotted rgba(255,255,255,0.5);
  transition: color 0.3s;
}

.credit a:hover {
  color: #00f0ff;
}

/* MODAL / OVERLAY */
.overlay {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  background: rgba(10, 5, 25, 0.8);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.modal {
  display: flex;
  flex-direction: column;
  width: 90%;
  max-width: 480px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 32px;
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.4);
  padding: 40px 32px;
  text-align: center;
  color: #fff;
}

.modalHead {
  margin-bottom: 24px;
}

.modalTitle span {
  font-size: 1.8rem;
  font-weight: 700;
  line-height: 1.3;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.4);
}

.modalBody {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 32px;
}

.m1 {
  font-size: 1.2rem;
  line-height: 1.5;
  color: rgba(255,255,255,0.9);
}

.m1 strong {
  color: #fff;
}

.m2 {
  font-family: var(--font-secondary);
  font-size: 0.95rem;
  color: rgba(255,255,255,0.7);
  background: rgba(0,0,0,0.2);
  padding: 16px;
  border-radius: 12px;
}

.modalButton {
  background: linear-gradient(45deg, #ff007f, #6441a5);
  border: none;
  border-radius: 100px;
  color: #fff;
  font-size: 1.2rem;
  font-weight: 700;
  font-family: var(--font-main);
  padding: 16px 32px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(255, 0, 127, 0.4);
  transition: all 0.3s ease;
  width: 100%;
}

.modalButton:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 32px rgba(255, 0, 127, 0.6);
  background: linear-gradient(45deg, #ff1a8c, #7b51c6);
}

.btn-mode {
  display: flex !important;
  flex-direction: column !important;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 14px 20px;
  background: rgba(255, 255, 255, 0.05); /* slightly transparent */
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
  text-transform: none;
  width: 100%;
}

.btn-mode:first-child {
  background: linear-gradient(135deg, rgba(233,30,99,0.3), rgba(156,39,176,0.5));
  border-color: rgba(233,30,99,0.4);
}

.btn-mode:nth-child(2) {
  background: linear-gradient(135deg, rgba(156,39,176,0.3), rgba(63,81,181,0.5));
  border-color: rgba(63,81,181,0.4);
}

@media(hover: hover) and (pointer: fine) {
  .btn-mode:hover {
    transform: translateY(-3px);
    background: rgba(255, 255, 255, 0.15) !important;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3) !important;
    border-color: rgba(255, 255, 255, 0.5) !important;
  }
}

.mode-title {
  font-size: 1.4rem;
  font-weight: 700;
  text-shadow: 0 2px 4px rgba(0,0,0,0.3);
}

.mode-desc {
  font-size: 0.9rem;
  font-weight: 400;
  color: rgba(255, 255, 255, 0.8);
  font-family: var(--font-secondary);
  letter-spacing: normal;
}

/* LISTENING MODE STYLES */
#listening-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 30px;
  width: 100%;
}

#speaker-btn {
  width: 120px;
  height: 120px;
  background: rgba(255, 255, 255, 0.1);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
}

#speaker-btn svg, #speaker-btn path {
  pointer-events: none;
}

#speaker-btn:active {
  transform: scale(0.95);
  background: rgba(255, 255, 255, 0.3);
}

#speaker-btn svg {
  width: 60px;
  height: 60px;
  fill: #fff;
  transition: fill 0.3s;
}

#speaker-btn:hover svg {
  fill: #00f0ff;
}

#spelling-container {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 12px;
  padding: 20px;
}

#translation-display {
  font-family: var(--font-secondary);
  font-size: 1.5rem;
  font-weight: 600;
  color: #00f0ff;
  text-align: center;
  margin-top: 10px;
  text-shadow: 0 2px 10px rgba(0, 240, 255, 0.3);
}

#skip-btn {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(5px);
  -webkit-backdrop-filter: blur(5px);
  border-radius: 12px;
  cursor: pointer;
  transition: all 0.3s;
}

#skip-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
  border-color: rgba(255, 255, 255, 0.4);
}

.letter-slot {
  width: 40px;
  height: 60px;
  border-bottom: 3px solid rgba(255, 255, 255, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
  font-weight: 700;
  color: #fff;
  text-transform: uppercase;
  transition: all 0.2s;
}

.letter-slot.filled {
  border-bottom-color: #00f0ff;
  text-shadow: 0 0 10px rgba(0, 240, 255, 0.5);
}

.letter-slot.active {
  border-bottom-color: #fff;
  background: rgba(255, 255, 255, 0.05);
}

.letter-slot.correct {
  color: #00d508;
  border-bottom-color: #00d508;
  text-shadow: 0 0 15px rgba(0, 213, 8, 0.6);
}

/* Ensure #listening-ui is responsive */
@media (max-width: 480px) {
  #speaker-btn {
    width: 90px;
    height: 90px;
    border-radius: 20px;
  }
  #speaker-btn svg {
    width: 45px;
    height: 45px;
  }
  .letter-slot {
    width: 30px;
    height: 50px;
    font-size: 24px;
    gap: 8px;
  }
}

/* BACK BUTTON */
.btn-back {
  position: fixed;
  top: 6%;
  left: 6%;
  z-index: 30;
  width: 48px;
  height: 48px;
  background: var(--glass-bg);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 50%;
  border: 1px solid var(--glass-border);
  box-shadow: var(--glass-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-back:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.25);
  box-shadow: 0 12px 24px rgba(0,0,0,0.3);
}

.btn-back svg {
  width: 24px;
  height: 24px;
}

/* Scorebox shifted right when back button exists */
.scorebox {
  left: calc(6% + 64px); 
}

/* RESPONSIVE */
@media (max-width: 480px) {
  .eng { font-size: 28px; }
  .response { padding: 1rem 1.5rem; }
  .rs-row { min-width: 240px; padding: 12px 20px; }
  .modal { padding: 32px 20px; }
  .modalTitle span { font-size: 1.5rem; }
  .scorebox { top: 20px; left: 20px; height: 40px; padding: 0 16px; }
  .btn-back { top: 20px; left: 20px; width: 40px; height: 40px; }
  .scorebox { left: calc(20px + 52px); } /* Offset scorebox when back button is active on mobile */
  .logo { top: 50px; }
  #score, #total { font-size: 16px; }
  #countdown, #countstroke { top: 15px; right: 15px; width: 40px; height: 40px; }
  #countstroke svg { width: 40px; height: 40px; }
  #cdsvg { width: 40px; height: 40px; }
  #countdown-number { font-size: 16px; }
  
  /* Footer Shrinking */
  .footer { padding-bottom: 10px; }
  .ft-items { gap: 10px; margin-bottom: 8px; }
  .ft-item a { width: 32px; height: 32px; }
  .ft-item img { height: 16px; width: 16px; }
  .credit { font-size: 0.75rem; gap: 4px; }
  .heart { width: 12px; height: 12px; }

  @keyframes countdown {
    from { stroke-dashoffset: 0px; }
    to { stroke-dashoffset: 170px; }
  }
}

#pronunciation-ui {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  margin-bottom: 24px;
}

#speak-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.08);
  border: 2px solid rgba(255, 255, 255, 0.18);
  border-radius: 50%;
  cursor: pointer;
  color: #fff;
  font-family: var(--font-main);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
  position: relative;
  width: 100px;
  height: 100px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  gap: 8px;
}

#speak-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  border-color: rgba(255, 255, 255, 0.3);
  transform: translateY(-5px) scale(1.05);
  box-shadow: 0 12px 32px rgba(0,0,0,0.3);
}

#speak-btn:active {
  transform: translateY(0) scale(0.95);
}

#speak-btn svg {
  width: 28px;
  height: 28px;
  stroke: #fff;
  transition: stroke 0.3s;
}

#speak-btn:hover {
  background: rgba(255, 255, 255, 0.18);
  border-color: #00f0ff;
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(0, 240, 255, 0.3);
}

#speak-btn:hover svg { stroke: #00f0ff; }
#speak-btn:active    { transform: scale(0.94); }

/* Pulsing ring when mic is recording */
#speak-btn.listening {
  background: rgba(255, 0, 127, 0.15);
  border-color: #ff007f;
  animation: micPulse 1.2s ease-in-out infinite;
}
#speak-btn.listening svg { stroke: #ff007f; }

@keyframes micPulse {
  0%   { box-shadow: 0 0 0 0   rgba(255, 0, 127, 0.7); }
  70%  { box-shadow: 0 0 0 18px rgba(255, 0, 127, 0); }
  100% { box-shadow: 0 0 0 0   rgba(255, 0, 127, 0); }
}

/* Success flash */
#speak-btn.success-flash {
  background: rgba(0, 213, 8, 0.25);
  border-color: #00d508;
  animation: successFlash 0.8s ease-out;
}

@keyframes successFlash {
  0%   { box-shadow: 0 0 0 0   rgba(0, 213, 8, 0.7); }
  100% { box-shadow: 0 0 0 24px rgba(0, 213, 8, 0); }
}

/* Result badge */
#speak-result {
  font-family: var(--font-secondary);
  font-size: 0.9rem;
  font-weight: 600;
  text-align: center;
  padding: 8px 20px;
  border-radius: 100px;
  opacity: 0;
  transform: translateY(8px);
  transition: opacity 0.35s, transform 0.35s;
  pointer-events: none;
}

#speak-result.show    { opacity: 1; transform: translateY(0); }
#speak-result.correct { background: rgba(0,213,8,0.2); border: 1px solid rgba(0,213,8,0.5); color: #00d508; }
#speak-result.wrong   { background: rgba(244,67,54,0.2); border: 1px solid rgba(244,67,54,0.4); color: #ff6b6b; }

@media (max-width: 480px) {
  #speak-btn { width: 72px; height: 72px; }
  #speak-btn svg { width: 22px; height: 22px; }
}

/* TODAY'S WORD MODAL */
.today-word-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 85%; /* Ensures visible margin on mobile */
  max-width: 380px;
  box-sizing: border-box; /* Includes padding in width calculate */
  background: #e8e8e8; /* Light gray to match the image */
  border-radius: 4px;
  padding: 40px 30px;
  text-align: center;
  color: #1a1a1a;
  box-shadow: 0 10px 40px rgba(0,0,0,0.6);
}

.today-word-header {
  font-family: var(--font-secondary);
  font-size: 0.85rem;
  font-weight: 600;
  color: #333;
  margin-bottom: 24px;
  letter-spacing: 0.5px;
}

#todayWordBody {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 30px;
  width: 100%;
}

.today-word-loading {
  color: #666;
  font-family: var(--font-secondary);
  font-size: 0.95rem;
  text-align: center;
  padding: 10px 0;
}

.today-word-eng {
  font-family: var(--font-main), sans-serif;
  font-size: 2.8rem;
  font-weight: 700;
  color: #000;
  margin-bottom: 4px;
}

.today-word-meta {
  font-family: var(--font-secondary);
  font-size: 0.9rem;
  color: #555;
  margin-bottom: 12px;
}

.today-word-mon {
  font-family: var(--font-secondary);
  font-size: 1.2rem;
  font-weight: 600;
  color: #111;
  margin-bottom: 10px;
  padding: 0;
  background: none;
  border: none;
}

.today-word-ex-en {
  font-family: var(--font-secondary), sans-serif;
  font-size: 14px;
  color: #333;
  line-height: 1.5;
  margin-top: 5px;
}

.today-word-ex-mn {
  font-family: var(--font-secondary), sans-serif;
  font-size: 14px;
  color: #444;
  line-height: 1.5;
  margin-top: 2px;
}

.today-word-footer {
  width: 100%;
  display: flex;
  justify-content: center;
}

.today-ok-btn {
  background: #0a0a0a;
  color: #fff;
  border: none;
  border-radius: 2px;
  padding: 12px 60px;
  font-size: 0.9rem;
  font-family: var(--font-secondary);
  font-weight: 500;
  letter-spacing: 1px;
  cursor: pointer;
  transition: background 0.2s;
}

.today-ok-btn:hover {
  background: #2a2a2a;
}
