/* ===== Typing Game styles ===== */

.app {
  max-width: 560px;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding-bottom: 24px;
}

.header {
  margin-bottom: 4px;
}

/* Score boxes – smaller for 4-up layout */
.scores {
  gap: 6px;
}
.score-box {
  min-width: 56px;
}
#lives-display {
  font-size: 13px;
  letter-spacing: -1px;
}

/* Combo bar */
.combo-bar {
  text-align: center;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 4px;
}
.combo-bar[hidden] { display: none; }
#combo-text {
  font-weight: 800;
  font-size: 15px;
  color: var(--accent);
  background: var(--surface);
  border-radius: 999px;
  padding: 2px 14px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
}

/* Game area */
#game-area {
  position: relative;
  width: 100%;
  height: 320px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  margin-bottom: 10px;
}

#start-prompt {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 15px;
  font-weight: 600;
  pointer-events: none;
}
#start-prompt kbd {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 1px 6px;
  font-size: 13px;
  font-family: inherit;
  box-shadow: var(--shadow-sm);
}

/* Falling words */
.falling-word {
  position: absolute;
  padding: 5px 14px;
  border-radius: 999px;
  background: var(--btn-bg);
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.4px;
  white-space: nowrap;
  box-shadow: var(--shadow-sm);
  user-select: none;
  pointer-events: none;
  transition: border-color 0.1s, box-shadow 0.1s;
  border: 2px solid transparent;
}
.falling-word.matched {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(237, 194, 46, 0.35), var(--shadow-sm);
  color: #fff;
  background: var(--btn-bg-hover);
}
.falling-word.hit {
  background: #6aaa64;
  border-color: #4e9450;
  animation: word-hit 0.25s ease-out forwards;
}
@keyframes word-hit {
  0%   { transform: scale(1.15); opacity: 1; }
  100% { transform: scale(0.7);  opacity: 0; }
}
.falling-word.miss {
  background: var(--danger);
  border-color: #c0392b;
  animation: word-miss 0.35s ease-out forwards;
}
@keyframes word-miss {
  0%   { transform: translateY(0)  scale(1); opacity: 1; }
  100% { transform: translateY(20px) scale(0.8); opacity: 0; }
}

/* Danger zone line at bottom */
#game-area::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--danger), transparent);
  opacity: 0.5;
}

/* Input row */
.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}

#word-input {
  flex: 1;
  background: var(--surface);
  color: var(--text-strong);
  border: 2px solid var(--border);
  border-radius: 999px;
  padding: 10px 18px;
  font-size: 17px;
  font-weight: 700;
  font-family: inherit;
  letter-spacing: 0.5px;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s, box-shadow 0.15s;
}
#word-input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(237, 194, 46, 0.28);
}
#word-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
#word-input.shake {
  animation: shake 0.35s ease;
  border-color: var(--danger);
}
@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20%       { transform: translateX(-6px); }
  40%       { transform: translateX(6px); }
  60%       { transform: translateX(-4px); }
  80%       { transform: translateX(4px); }
}

.input-hint {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  font-weight: 600;
}

/* Toolbar */
.toolbar {
  justify-content: center;
  margin-top: 0;
}

/* Overlay */
.overlay {
  position: fixed;
  inset: 0;
  background: var(--overlay-bg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 14px;
  z-index: 100;
  animation: fadein 0.3s ease;
}
.overlay[hidden] { display: none; }
.overlay-text {
  font-size: clamp(36px, 8vmin, 56px);
  font-weight: 800;
  color: var(--text-strong);
  text-align: center;
}
.overlay-sub {
  font-size: 16px;
  color: var(--text-muted);
  font-weight: 600;
  text-align: center;
  line-height: 1.6;
}
.overlay-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  justify-content: center;
  margin-top: 4px;
}
@keyframes fadein { from { opacity: 0; } to { opacity: 1; } }

/* Chinese word display */
.falling-word .zh-char {
  display: block;
  font-size: 18px;
  font-weight: 900;
  letter-spacing: 2px;
  line-height: 1.2;
  font-family: 'Noto Serif TC', 'Source Han Serif TC', 'Noto Serif CJK TC', 'PMingLiU', serif;
}
.falling-word .zh-hint {
  display: block;
  font-size: 10px;
  font-weight: 600;
  opacity: 0.7;
  letter-spacing: 0.5px;
  line-height: 1.2;
}

/* Dark mode tweaks */
body.dark .falling-word {
  background: var(--btn-bg);
  color: var(--text-strong);
}
body.dark .falling-word.matched {
  background: var(--btn-bg-hover);
  color: var(--text-strong);
}
