:root {
  --primary-color: #4a90e2;
  --primary-hover: #357abd;
  --secondary-color: #f8fafc;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --text-primary: #1e293b;
  --text-muted: #64748b;
  --text-light: #ffffff;
  --bg-color: #f1f5f9;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  --card-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
  --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

body.dark-mode {
  --secondary-color: #334155;
  --text-primary: #f1f5f9;
  --text-muted: #94a3b8;
  --bg-color: #0f172a;
  --card-bg: #1e293b;
  --border-color: #475569;
}

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

body {
  font-family: 'Pretendard', -apple-system, BlinkMacSystemFont, system-ui, Roboto, sans-serif;
  background-color: var(--bg-color);
  background-image: radial-gradient(at 0% 0%, rgba(74, 144, 226, 0.05) 0px, transparent 50%),
                    radial-gradient(at 100% 0%, rgba(74, 144, 226, 0.05) 0px, transparent 50%);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 20px;
  transition: var(--transition);
}

body.dark-mode {
  background-image: radial-gradient(at 0% 0%, rgba(74, 144, 226, 0.1) 0px, transparent 50%),
                    radial-gradient(at 100% 0%, rgba(74, 144, 226, 0.1) 0px, transparent 50%);
}

.container {
  width: 100%;
  max-width: 520px;
  background: var(--card-bg);
  padding: 40px;
  border-radius: 24px;
  box-shadow: var(--card-shadow);
  text-align: center;
  transition: var(--transition);
  position: relative;
  overflow: hidden;
}

body.dark-mode .container {
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.3), 0 10px 10px -5px rgba(0, 0, 0, 0.2);
}

h1 { 
  margin-bottom: 30px; 
  font-size: 28px; 
  font-weight: 800;
  color: var(--primary-color);
  letter-spacing: -0.5px;
}

#theme-btn {
  position: fixed; 
  top: 24px; 
  right: 24px;
  padding: 10px 18px; 
  border-radius: 14px;
  font-weight: 600; 
  cursor: pointer; 
  border: 1px solid var(--border-color);
  background: var(--card-bg); 
  color: var(--text-primary);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  transition: var(--transition);
  z-index: 100;
}

#theme-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

.selector-group { 
  margin-bottom: 24px; 
  text-align: left; 
}

.selector-label { 
  font-size: 14px; 
  font-weight: 700; 
  margin-bottom: 8px; 
  display: block; 
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-group {
  display: flex;
  gap: 8px;
}

#limit-select, #nickname-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 15px;
  background: var(--secondary-color);
  color: var(--text-primary);
  border: 2px solid transparent;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: var(--transition);
  outline: none;
}

#nickname-input {
  cursor: text;
  flex: 1;
}

#limit-select:focus, #nickname-input:focus {
  border-color: var(--primary-color);
  background: var(--card-bg);
  box-shadow: 0 0 0 4px rgba(74, 144, 226, 0.1);
}

#limit-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 1.2em;
}

body.dark-mode #limit-select {
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23f1f5f9' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
}

.btn-group { 
  display: flex; 
  gap: 10px; 
  justify-content: center; 
  margin-bottom: 12px; 
}

.btn-group button {
  flex: 1; 
  padding: 12px; 
  font-size: 14px;
  background: var(--secondary-color); 
  color: var(--text-muted); 
  border: none;
  border-radius: 12px; 
  cursor: pointer; 
  font-weight: 700;
  transition: var(--transition);
}

.btn-group button.active { 
  background: var(--primary-color); 
  color: white; 
  box-shadow: 0 4px 6px -1px rgba(74, 144, 226, 0.4);
}

#word-display { 
  margin: 30px 0; 
  min-height: 100px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

#word { 
  font-size: 42px; 
  font-weight: 800; 
  margin-bottom: 16px; 
  letter-spacing: -1px;
}

#speak-btn {
  background: var(--card-bg) !important;
  color: var(--primary-color) !important;
  border: 2px solid var(--primary-color) !important;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 700;
  border-radius: 10px;
  cursor: pointer;
  transition: var(--transition);
}

#speak-btn:hover {
  background: var(--primary-color) !important;
  color: white !important;
}

.choices-grid { 
  display: grid; 
  grid-template-columns: 1fr; 
  gap: 12px; 
  margin-bottom: 24px; 
}

.choice {
  padding: 16px; 
  font-size: 16px; 
  border-radius: 16px;
  background: var(--secondary-color); 
  color: var(--text-primary);
  border: 2px solid transparent; 
  font-weight: 600; 
  cursor: pointer;
  transition: var(--transition);
  text-align: center;
}

.choice:hover { 
  background: rgba(74, 144, 226, 0.1); 
  transform: translateY(-2px);
  border-color: var(--primary-color);
}

.choice.correct { 
  background-color: var(--success-color) !important; 
  color: white !important; 
  border-color: var(--success-color);
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.4);
}

.choice.wrong { 
  background-color: var(--danger-color) !important; 
  color: white !important; 
  border-color: var(--danger-color);
  box-shadow: 0 4px 10px rgba(239, 68, 68, 0.4);
}

#result { 
  font-weight: 800; 
  font-size: 20px; 
  margin-bottom: 16px; 
}

#example-box {
  background: var(--secondary-color);
  border-left: 6px solid var(--primary-color);
  padding: 20px;
  margin: 20px 0;
  text-align: left;
  border-radius: 12px;
  display: none;
  animation: slideDown 0.4s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

#example-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 10px;
}

#example-en {
  color: var(--text-primary);
  font-style: italic;
  font-weight: 600;
  font-size: 16px;
  line-height: 1.5;
  flex: 1;
}

.highlight {
  color: var(--primary-color) !important;
  font-weight: 800;
  text-decoration: underline;
  text-underline-offset: 4px;
}

#example-ko { 
  color: var(--text-muted); 
  font-size: 14px; 
  font-weight: 500;
}

.ex-speak-btn {
  background: transparent;
  border: 2px solid var(--border-color);
  border-radius: 8px;
  padding: 6px 10px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 700;
  transition: var(--transition);
}

.ex-speak-btn:hover {
  background: var(--primary-color);
  color: white;
  border-color: var(--primary-color);
}

#score-board { 
  background: var(--secondary-color); 
  padding: 16px; 
  border-radius: 16px; 
  margin-bottom: 24px; 
  font-size: 15px;
  font-weight: 700;
  color: var(--text-primary);
}

.action-btns { 
  display: flex; 
  gap: 12px; 
  margin-top: 20px;
}

.btn-main { 
  flex: 1; 
  padding: 16px; 
  border-radius: 14px; 
  border: none; 
  cursor: pointer; 
  font-weight: 800; 
  color: white; 
  font-size: 16px;
  transition: var(--transition);
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.btn-main:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  filter: brightness(1.1);
}

.btn-save { background-color: var(--primary-color); width: auto; flex: none; padding: 10px 20px; }
.btn-start { background-color: var(--primary-color); }
.btn-review { background-color: var(--text-muted); }

#next-btn {
  width: 100%; 
  margin-bottom: 16px; 
  padding: 18px; 
  font-size: 18px;
  font-weight: 800; 
  background-color: var(--success-color);
  color: white; 
  border: none; 
  border-radius: 16px; 
  cursor: pointer;
  transition: var(--transition);
  box-shadow: 0 4px 10px rgba(16, 185, 129, 0.3);
}

#next-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 15px -3px rgba(16, 185, 129, 0.4);
  filter: brightness(1.1);
}

#scoreboard-container { 
  margin-top: 40px; 
  border-top: 2px solid var(--border-color); 
  padding-top: 30px; 
}

#scoreboard-container h2 {
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 20px;
  color: var(--primary-color);
}

#scoreboard-list div {
  padding: 12px 16px;
  border-radius: 12px;
  margin-bottom: 4px;
  transition: var(--transition);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

#scoreboard-list div:nth-child(even) {
  background: rgba(0, 0, 0, 0.02);
}

body.dark-mode #scoreboard-list div:nth-child(even) {
  background: rgba(255, 255, 255, 0.03);
}

#scoreboard-list div:hover {
  background: rgba(74, 144, 226, 0.08);
  transform: translateX(4px);
}

.rank-badge {
  display: inline-block;
  width: 24px;
  text-align: center;
  margin-right: 12px;
  font-weight: 800;
}

@media (max-width: 480px) {
  .container {
    padding: 24px;
  }
  
  h1 { font-size: 24px; }
  
  #word { font-size: 32px; }
  
  .btn-main { padding: 14px; font-size: 14px; }
}

.choice:active {
  transform: scale(0.98);
}

#choices h3 {
  font-size: 24px;
  margin: 20px 0 10px;
  color: var(--primary-color);
  font-weight: 800;
}

#choices p {
  font-size: 18px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 20px;
}

#user-welcome {
  padding: 10px 0;
  border-radius: 12px;
  font-weight: 700;
  color: var(--primary-color);
  font-size: 16px;
  animation: fadeIn 0.5s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}
