:root {
  --bg: #1e293b;
  --panel: #0f172a;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --accent: #38bdf8;
  --correct: #4ade80;
  --wrong: #f87171;
  --key: #334155;
  --key-hover: #475569;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  background: var(--bg);
  color: var(--text);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.game {
  width: 100%;
  max-width: 520px;
  margin: 2rem 1rem;
  padding: 1.5rem;
  background: var(--panel);
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.4);
  text-align: center;
}

.home-btn {
  display: block;
  margin: 1.5rem auto 0;
  max-width: 220px;
  border-radius: 10px;
  overflow: hidden;
  opacity: 0.8;
  transition: opacity 0.15s, transform 0.12s;
}
.home-btn img { display: block; width: 100%; }
.home-btn:hover { opacity: 1; transform: scale(1.04); }

h1 {
  margin: 0 0 1rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--accent);
}

/* ---- Score bar ---- */
.score {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  margin-bottom: 1rem;
  padding: 0.6rem 1rem;
  background: var(--bg);
  border-radius: 12px;
}
.score-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  min-width: 5rem;
  position: relative;
}
.score-label {
  font-size: 0.75rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}
.name-btn {
  max-width: 7rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-family: inherit;
  font-weight: 600;
  background: none;
  border: none;
  padding: 0;
  cursor: pointer;
  border-bottom: 1px dashed var(--muted);
}
.name-btn:hover { color: var(--accent); border-bottom-color: var(--accent); }
.name-input {
  width: 7rem;
  font-family: inherit;
  font-size: 0.8rem;
  text-align: center;
  color: var(--text);
  background: var(--key);
  border: 1px solid var(--accent);
  border-radius: 6px;
  padding: 0.1rem 0.3rem;
}
.name-input:focus { outline: none; }
.name-list {
  position: absolute;
  top: 1.6rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  min-width: 7rem;
  max-height: 9rem;
  overflow-y: auto;
  margin: 0;
  padding: 0.2rem;
  list-style: none;
  text-align: left;
  background: var(--panel);
  border: 1px solid var(--key-hover);
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}
.name-list li {
  padding: 0.35rem 0.6rem;
  border-radius: 6px;
  font-size: 0.9rem;
  cursor: pointer;
}
.name-list li:hover { background: var(--key); color: var(--accent); }
.name-list li.name-add-hint { color: var(--muted); font-style: italic; }
.name-list li.name-add-hint:hover { color: var(--accent); }
.score-num {
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.1;
}
.score-side:first-child .score-num { color: var(--correct); }
.score-side:last-child  .score-num { color: var(--wrong); }
.score-vs {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--muted);
}

/* ---- Countdown animation ---- */
.countdown {
  min-height: 7rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.countdown-word {
  font-size: clamp(3rem, 16vw, 5.5rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  line-height: 1;
  display: inline-block;
}

@keyframes flash-in {
  0%   { transform: scale(0.4); opacity: 0; }
  55%  { transform: scale(1.18); opacity: 1; }
  100% { transform: scale(1);   opacity: 1; }
}

.countdown-word.flash {
  animation: flash-in 0.38s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

/* ---- Choice buttons ---- */
.choices {
  display: flex;
  gap: clamp(0.5rem, 3vw, 1.2rem);
  justify-content: center;
  margin: 1.25rem 0 1.5rem;
}

.choice-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  width: clamp(5.5rem, 24vw, 8.5rem);
  height: clamp(7rem, 30vw, 10.5rem);
  padding: 0.5rem;
  background: linear-gradient(160deg, #3b5068 0%, #273848 100%);
  border: none;
  border-radius: 16px;
  cursor: pointer;
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 6px 0 #101926,
    0 10px 20px rgba(0, 0, 0, 0.5);
  transition: box-shadow 0.08s ease, transform 0.08s ease, background 0.1s;
  color: var(--text);
}

.choice-btn:hover:not(:disabled) {
  background: linear-gradient(160deg, #455e77 0%, #304355 100%);
  transform: translateY(-3px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 9px 0 #101926,
    0 14px 24px rgba(0, 0, 0, 0.55);
}

.choice-btn:active:not(:disabled) {
  transform: translateY(4px);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.09),
    0 2px 0 #101926,
    0 4px 10px rgba(0, 0, 0, 0.4);
}

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

.choice-btn.chosen {
  background: linear-gradient(160deg, #1e4566 0%, #14324e 100%);
  box-shadow:
    inset 0 1px 0 rgba(56, 189, 248, 0.3),
    0 4px 0 #091422,
    0 6px 14px rgba(0, 0, 0, 0.5);
  opacity: 1;
}

.choice-btn:not(.chosen):disabled {
  opacity: 0.35;
}

.btn-emoji {
  font-size: clamp(2.8rem, 12vw, 4.5rem);
  line-height: 1;
}

.btn-label {
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--muted);
}

/* ---- Result area ---- */
.result-area {
  margin: 0.25rem 0 0.75rem;
}

.showdown {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 5vw, 2.5rem);
  margin-bottom: 0.75rem;
}

.showdown-side {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.showdown-emoji {
  font-size: clamp(3.5rem, 16vw, 5.5rem);
  line-height: 1;
}

.showdown-label {
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--muted);
}

.showdown-vs {
  font-size: 1.3rem;
  font-weight: 900;
  color: var(--muted);
  align-self: center;
}

.result-text {
  font-size: 1.7rem;
  font-weight: 800;
  margin: 0.25rem 0 0;
  min-height: 2.2rem;
}
.result-text.win  { color: var(--correct); }
.result-text.loss { color: var(--wrong); }
.result-text.tie  { color: var(--accent); }

/* ---- New Game button ---- */
.new-game {
  padding: 0.7rem 1.6rem;
  font-size: 1rem;
  font-weight: 700;
  color: #06351a;
  background: var(--accent);
  border: none;
  border-radius: 10px;
  cursor: pointer;
  transition: filter 0.15s;
}
.new-game:hover { filter: brightness(1.1); }
