/* ==========================================================================
   LazerthBot — stylesheet
   1. Theme and reset  2. Global layout  3. Settings  4. Title generator\n   5. First-to panel  6. Match history  7. Game-over overlay  8. Responsive
   ========================================================================== */

/* 1. Theme and reset */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #0f0f1a;
  --surface: #1a1a2e;
  --surface-alt: #16213e;
  --accent: #e94560;
  --accent-glow: rgba(233, 69, 96, 0.35);
  --gold: #f5c518;
  --gold-glow: rgba(245, 197, 24, 0.3);
  --text: #eaeaea;
  --text-dim: #8a8a9a;
  --border: #2a2a4a;
  --green: #00d68f;
  --red: #ff6b6b;
  --radius: 12px;
}

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 2rem 1rem;
  position: relative;
  overflow-x: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
}

button, input, select { font: inherit; }
button { cursor: pointer; }
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* 2. Settings shortcut and dialog */
.settings-btn {
  position: fixed;
  top: 1.25rem;
  right: 1.25rem;
  z-index: 900;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--surface);
  color: var(--text-dim);
  transition: transform 0.3s, color 0.2s, background 0.2s;
}
.settings-btn:hover { color: var(--gold); background: var(--surface-alt); transform: rotate(60deg); }
.settings-btn svg { width: 22px; height: 22px; fill: currentColor; }

.settings-overlay {
  position: fixed;
  inset: 0;
  z-index: 950;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: rgba(0, 0, 0, 0.7);
  animation: overlayIn 0.3s ease;
}
.settings-overlay.visible { display: flex; }
.settings-panel {
  width: 90vw;
  max-width: 800px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  animation: slideIn 0.35s ease;
}
.settings-panel h2 {
  margin-bottom: 1.5rem;
  color: var(--text-dim);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 1.2rem;
}
.settings-columns { display: grid; grid-template-columns: 1fr 1fr; gap: 1.5rem; }
.settings-col h3 {
  margin-bottom: 0.75rem;
  color: var(--gold);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 0.85rem;
}
.settings-list {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  max-height: 45vh;
  overflow-y: auto;
  margin-bottom: 0.75rem;
  padding-right: 4px;
}
.settings-list::-webkit-scrollbar { width: 5px; }
.settings-list::-webkit-scrollbar-track { background: transparent; }
.settings-list::-webkit-scrollbar-thumb { border-radius: 3px; background: var(--border); }
.settings-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.45rem 0.65rem;
  border-radius: 8px;
  background: var(--bg);
  font-size: 0.85rem;
}
.settings-item span { flex: 1; overflow-wrap: anywhere; }
.settings-item .del-btn {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border: 1px solid var(--red);
  border-radius: 50%;
  background: transparent;
  color: var(--red);
  font-size: 1rem;
  line-height: 1;
  transition: background 0.15s;
}
.settings-item .del-btn:hover { background: rgba(255, 107, 107, 0.15); }
.settings-add-row { display: flex; gap: 0.5rem; }
.settings-add-row input {
  flex: 1;
  min-width: 0;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  outline: none;
  background: var(--bg);
  color: var(--text);
  font-size: 0.9rem;
}
.settings-add-row input:focus { border-color: var(--accent); }
.settings-add-row input::placeholder { color: var(--text-dim); }
.settings-add-row button {
  padding: 0.5rem 1rem;
  border: 1px solid var(--green);
  border-radius: 8px;
  background: transparent;
  color: var(--green);
  font-size: 0.9rem;
  font-weight: 600;
  white-space: nowrap;
  transition: background 0.15s;
}
.settings-add-row button:hover { background: rgba(0, 214, 143, 0.12); }
.settings-close {
  display: block;
  margin: 1.5rem auto 0;
  padding: 0.6rem 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface-alt);
  color: var(--text);
  font-size: 0.95rem;
  font-weight: 600;
  transition: background 0.15s;
}
.settings-close:hover { background: #1e2a4a; }

/* 3. App heading and title generator */
.header { display: flex; flex-direction: column; align-items: center; margin-bottom: 2rem; }
.header-img {
  width: 120px;
  height: 120px;
  margin-bottom: 1rem;
  border: 3px solid var(--accent);
  border-radius: 50%;
  object-fit: contain;
  box-shadow: 0 0 24px var(--accent-glow);
}
h1 {
  background: linear-gradient(135deg, var(--accent), var(--gold));
  background-clip: text;
  -webkit-background-clip: text;
  color: transparent;
  -webkit-text-fill-color: transparent;
  text-align: center;
  letter-spacing: 1px;
  font-size: 2rem;
  font-weight: 700;
}
.game-selection { display: flex; flex-direction: column; gap: 8px; width: 100%; max-width: 700px; margin-bottom: 20px; }
#gameSelect, .player-row select {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--accent);
  border-radius: 8px;
  background: var(--surface);
  color: var(--text);
}
.actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 1rem; margin: 2rem 0; }
.btn {
  padding: 0.75rem 1.75rem;
  border: none;
  border-radius: var(--radius);
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  transition: transform 0.15s, box-shadow 0.25s;
}
.btn:active { transform: scale(0.96); }
.btn-primary { background: linear-gradient(135deg, var(--accent), #c73659); color: #fff; box-shadow: 0 4px 20px var(--accent-glow); }
.btn-primary:hover { box-shadow: 0 6px 30px var(--accent-glow); }
.btn-secondary { border: 1px solid var(--border); background: var(--surface-alt); color: var(--text); }
.btn-secondary:hover { background: #1e2a4a; }
.compliment-box {
  display: none;
  position: relative;
  width: 100%;
  max-width: 640px;
  margin-bottom: 1.5rem;
  overflow: hidden;
  padding: 2rem 2.5rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  text-align: center;
  animation: slideIn 0.35s ease;
}
.compliment-box.visible { display: flex; justify-content: center; }
.compliment-box::before {
  content: '';
  position: absolute;
  inset: 0;
  background: radial-gradient(ellipse at 50% 0%, var(--accent-glow), transparent 70%);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s;
}
.compliment-box.flash::before { opacity: 1; }
.compliment-text {
  position: relative;
  min-height: 2.4rem;
  color: var(--gold);
  font-size: 1.6rem;
  font-weight: 700;
  text-shadow: 0 0 20px var(--gold-glow);
  transition: opacity 0.3s;
}
.compliment-text.fade { opacity: 0; }

/* 4. First-to match panel */
.ft-panel {
  position: relative;
  isolation: isolate;
  width: 100%;
  max-width: 700px;
  overflow: hidden;
  padding: 2rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  animation: slideIn 0.35s ease;
}
.ft-game-logo { display: flex; justify-content: center; align-items: center; margin-bottom: 18px; }
#gameLogo { display: block; width: 100%; max-width: 280px; max-height: 120px; object-fit: contain; }
.ft-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}
.ft-header > span, .ft-header > input { position: relative; z-index: 4; }
.ft-header span {
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 1.2rem;
  font-weight: 700;
}
.ft-target-input {
  width: 60px;
  padding: 0.4rem 0.5rem;
  border: 2px solid var(--accent);
  border-radius: 8px;
  outline: none;
  background: var(--bg);
  color: var(--gold);
  text-align: center;
  font-size: 1.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.2s;
}
.ft-target-input:focus { border-color: var(--gold); }
.match-reset-btn {
  padding: 0.45rem 0.8rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-alt);
  color: var(--text-dim);
  font-size: 0.85rem;
  font-weight: 700;
  transition: border-color 0.2s, color 0.2s, background 0.2s;
}
.match-reset-btn:hover { border-color: var(--accent); color: var(--text); background: rgba(233, 69, 96, 0.12); }
.players {
  position: relative;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto minmax(0, 1fr);
  gap: 1.25rem;
  align-items: start;
  margin-bottom: 1.5rem;
}
.player-card {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}
/* Character art is a centered overlay anchored to the character dropdown. */
.player-art {
  position: absolute;
  z-index: 2;
  /* The bottom edge lands behind the dropdown, without affecting card layout. */
  height: 280px;
  bottom: calc(100% - 94px);
  left: 0;
  width: 100%;
  background-repeat: no-repeat;
  background-position: center bottom;
  background-size: contain;
  opacity: 0.28;
  pointer-events: none;
}
/* Mirror player 2 so both characters face inward while staying centered. */
.player-card-right .player-art {
  transform: scaleX(-1);
  background-position: center bottom;
}
.player-card > :not(.player-art) { position: relative; z-index: 3; }
.player-card input[type="text"] {
  width: 100%;
  padding: 0.7rem 1rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  background: var(--bg);
  color: var(--text);
  text-align: center;
  font-size: 1rem;
}
.player-card input[type="text"]:focus { border-color: var(--accent); }
.player-card input[type="text"]::placeholder { color: var(--text-dim); }
.player-row { width: 100%; }
.player-score { display: flex; flex-direction: column; align-items: center; gap: 0.4rem; }
.player-score-label { color: var(--text-dim); text-transform: uppercase; letter-spacing: 2px; font-size: 0.7rem; }
.player-score-row { display: flex; align-items: center; gap: 0.6rem; }
.score-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: 2px solid var(--border);
  border-radius: 50%;
  background: var(--surface-alt);
  color: var(--text);
  font-size: 1.3rem;
  font-weight: 700;
  line-height: 1;
  transition: transform 0.12s, background 0.2s, border-color 0.2s;
}
.score-btn:active { transform: scale(0.9); }
.score-btn.plus { border-color: var(--green); color: var(--green); }
.score-btn.plus:hover { background: rgba(0, 214, 143, 0.12); }
.score-btn.minus { border-color: var(--red); color: var(--red); }
.score-btn.minus:hover { background: rgba(255, 107, 107, 0.12); }
.player-score-value {
  min-width: 50px;
  color: var(--gold);
  text-align: center;
  font-size: 2.4rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 16px var(--gold-glow);
}
.vs-divider {
  align-self: center;
  padding-top: 1.5rem;
  color: var(--accent);
  font-size: 1.4rem;
  font-weight: 800;
  text-shadow: 0 0 12px var(--accent-glow);
}

/* 5. Match history */
.ft-history { margin-top: 1.5rem; padding-top: 1rem; border-top: 1px solid var(--border); }
.ft-history h3 {
  margin-bottom: 0.75rem;
  color: var(--text-dim);
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 2px;
  font-size: 0.8rem;
}
.history-list { display: flex; flex-direction: column; gap: 0.5rem; max-height: 200px; overflow-y: auto; }
.history-item {
  padding: 0.6rem 1rem;
  border-radius: 8px;
  background: var(--bg);
  color: var(--gold);
  text-align: center;
  font-size: 0.9rem;
  animation: fadeIn 0.3s ease;
}
.history-list::-webkit-scrollbar { width: 6px; }
.history-list::-webkit-scrollbar-track { background: transparent; }
.history-list::-webkit-scrollbar-thumb { border-radius: 3px; background: var(--border); }

/* 6. Game-over overlay */
.game-over-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0);
  cursor: pointer;
  animation: overlayFadeIn 1.5s ease forwards;
}
.game-over-img {
  width: 80vw;
  max-width: 420px;
  border-radius: 16px;
  opacity: 0;
  transform: scale(0.8);
  animation: imgReveal 2s ease 0.8s forwards, imgPulse 2.5s ease-in-out 2.8s infinite alternate;
}
.game-over-text {
  max-width: 90vw;
  margin-top: 2rem;
  color: var(--accent);
  text-align: center;
  font-size: 1.8rem;
  font-weight: 800;
  line-height: 1.4;
  text-shadow: 0 0 20px var(--accent-glow);
  opacity: 0;
  animation: textReveal 1.2s ease 2.2s forwards;
}
.game-over-hint {
  margin-top: 1.25rem;
  color: var(--text-dim);
  font-size: 0.85rem;
  letter-spacing: 1px;
  opacity: 0;
  animation: textReveal 1s ease 3s forwards;
}
.game-over-actions {
  display: flex;
  justify-content: center;
  margin-top: 1.25rem;
  opacity: 0;
  animation: textReveal 1s ease 3s forwards;
}
.results-image-btn {
  padding: 0.85rem 1.25rem;
  border: 1px solid var(--gold);
  border-radius: 10px;
  background: var(--gold);
  color: #15151e;
  font-weight: 800;
  box-shadow: 0 0 24px var(--gold-glow);
  transition: transform 0.15s, filter 0.2s;
}
.results-image-btn:hover { transform: translateY(-2px); filter: brightness(1.08); }
.results-image-btn:active { transform: translateY(0); }

/* 7. Animations */
@keyframes slideIn { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeIn { from { opacity: 0; transform: translateY(-6px); } to { opacity: 1; transform: translateY(0); } }
@keyframes overlayIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes overlayFadeIn { from { background: rgba(0, 0, 0, 0); } to { background: rgba(0, 0, 0, 0.92); } }
@keyframes imgReveal { from { opacity: 0; transform: scale(0.8); } to { opacity: 1; transform: scale(1); box-shadow: 0 0 60px rgba(233, 69, 96, 0.5); } }
@keyframes imgPulse { from { box-shadow: 0 0 40px rgba(233, 69, 96, 0.4); } to { box-shadow: 0 0 80px rgba(233, 69, 96, 0.7); } }
@keyframes textReveal { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }

/* 8. Responsive layout */
@media (max-width: 600px) {
  body { padding: 1.5rem 0.75rem; }
  .compliment-text { font-size: 1.2rem; }
  .ft-panel { padding: 1.25rem; }
  .ft-header { flex-wrap: wrap; }
  .players { grid-template-columns: minmax(0, 1fr); gap: 0.75rem; }
  .vs-divider { padding: 0; }
  .player-score-value { min-width: 40px; font-size: 1.8rem; }
  .game-over-text { font-size: 1.3rem; }
  .settings-columns { grid-template-columns: 1fr; }
  .player-art { opacity: 0.24; }
}
