:root {
  --red:          #E3350D;
  --red-dark:     #B02A0A;
  --red-light:    #FFF0EC;
  --cream:        #F7F2EB;
  --dark:         #151515;
  --muted:        #8A8A8A;
  --border:       #E4DDD4;
  --card-bg:      #FFFFFF;
  --accept:       #2D9B6A;
  --accept-light: #EAF6F0;
  --bg:           #F7F2EB;
  --text:         #151515;
}

[data-theme="dark"] {
  --cream:        #1A1A1A;
  --bg:           #1A1A1A;
  --dark:         #F0EBE3;
  --text:         #F0EBE3;
  --muted:        #888888;
  --border:       #2E2E2E;
  --card-bg:      #242424;
  --red-light:    #2A1510;
  --accept-light: #0E2A1C;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: 'Space Mono', monospace;
  background: var(--cream);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  align-items: center;
  transition: background 0.3s, color 0.3s;
}

h1, h2, h3 {
  font-family: 'Syne', sans-serif;
  font-weight: 800;
  letter-spacing: -1px;
}

.theme-toggle {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 100;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 50%;
  width: 40px;
  height: 40px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  transition: background 0.2s, border-color 0.2s, transform 0.2s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}

.theme-toggle:hover { transform: scale(1.1); border-color: var(--dark); }

.screen {
  display: none;
  min-height: 100vh;
  width: 100%;
  max-width: 780px;
  padding: 3rem 1.5rem 5rem;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.35s ease-out forwards;
}

@media (max-width: 500px) { .screen { padding: 2rem 0.75rem 2rem; } }

.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

#screen-intro { text-align: center; gap: 1.5rem; }

.logo {
  font-size: clamp(1.8rem, 8vw, 6.5rem);
  line-height: 1;
  letter-spacing: -3px;
  color: var(--text);
  letter-spacing: clamp(-1px, -0.5vw, -3px);
  display: inline-block;
}

.logo::after {
  content: '';
  display: block;
  width: 2.2ch;
  height: 5px;
  background: var(--red);
  border-radius: 2px;
  margin: 0.3rem auto 0;
}

.intro-tagline {
  color: var(--muted);
  font-size: 0.88rem;
  line-height: 1.8;
  max-width: 320px;
}

.intro-links {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  justify-content: center;
}

.intro-sep { color: var(--border); font-size: 0.8rem; }

.btn-primary {
  font-family: 'Syne', sans-serif;
  font-size: 1rem;
  font-weight: 800;
  padding: 1rem 2.8rem;
  background: var(--red);
  color: #fff;
  border: none;
  border-radius: 100px;
  cursor: pointer;
  letter-spacing: 1px;
  transition: transform 0.15s, background 0.15s, box-shadow 0.15s;
  box-shadow: 0 4px 20px rgba(227,53,13,0.28);
}

.btn-primary:hover  { background: var(--red-dark); transform: translateY(-2px); box-shadow: 0 8px 28px rgba(227,53,13,0.38); }
.btn-primary:active { transform: scale(0.97); box-shadow: none; }

.btn-secondary {
  font-family: 'Space Mono', monospace;
  font-size: 0.78rem;
  color: var(--muted);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  text-underline-offset: 3px;
  transition: color 0.15s;
}

.btn-secondary:hover { color: var(--text); }

.header-top { width: 100%; text-align: center; margin-bottom: 2.5rem; }

.date-label {
  font-size: 0.7rem;
  color: var(--red);
  letter-spacing: 3px;
  text-transform: uppercase;
  margin-bottom: 0.6rem;
  font-weight: 700;
}

.header-top h2 { font-size: clamp(1.6rem, 5vw, 2.2rem); }
.header-sub { font-size: 0.82rem; color: var(--muted); margin-top: 0.5rem; }

.grid-2x2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.75rem;
  width: 100%;
}

@media (max-width: 500px) { .grid-2x2 { gap: 0.6rem; } }

.poke-card {
  background: var(--card-bg);
  border-radius: 24px;
  border: 2px solid var(--border);
  padding: 2rem 1.2rem 1.5rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s, border-color 0.2s, background 0.3s;
  position: relative;
  overflow: hidden;
  user-select: none;
}

@media (max-width: 500px) { .poke-card { padding: 1rem 0.5rem 0.8rem; border-radius: 16px; } }

.poke-card:hover { transform: translateY(-6px); box-shadow: 0 16px 40px rgba(0,0,0,0.09); border-color: var(--text); }
.poke-card.selected { border-color: var(--accept); background: var(--accept-light); }
.poke-card.selected::after { content: '✓'; position: absolute; top: 12px; right: 16px; font-size: 1.2rem; color: var(--accept); }

.poke-card .ripple {
  position: absolute; border-radius: 50%;
  background: rgba(0,0,0,0.07); transform: scale(0);
  animation: ripple-anim 0.5s linear; pointer-events: none;
}

@keyframes ripple-anim { to { transform: scale(4); opacity: 0; } }

.poke-img-wrap { width: 110px; height: 110px; display: flex; align-items: center; justify-content: center; margin-bottom: 1rem; }
@media (max-width: 500px) { .poke-img-wrap { width: 72px; height: 72px; margin-bottom: 0.5rem; } }

.poke-img-wrap img { width: 100%; height: 100%; object-fit: contain; transition: transform 0.3s; }
.poke-card:hover .poke-img-wrap img { transform: scale(1.1) translateY(-4px); }

.poke-number { font-size: 0.68rem; color: var(--muted); letter-spacing: 1px; margin-bottom: 0.3rem; }

.poke-name {
  font-family: 'Syne', sans-serif;
  font-size: 1.15rem;
  font-weight: 800;
  margin-bottom: 0.6rem;
  text-transform: capitalize;
  text-align: center;
  word-break: break-word;
}

@media (max-width: 500px) {
  .poke-number { font-size: 0.55rem; margin-bottom: 0.2rem; }
  .poke-name   { font-size: 0.82rem; margin-bottom: 0.4rem; }
}

.type-badges { display: flex; gap: 5px; flex-wrap: wrap; justify-content: center; }

.type-badge {
  font-size: 0.62rem; padding: 3px 10px; border-radius: 100px;
  background: var(--dark); color: var(--cream);
  text-transform: uppercase; font-weight: 700; letter-spacing: 0.5px;
}

@media (max-width: 500px) { .type-badge { font-size: 0.52rem; padding: 2px 7px; } }

.type-feu      { background: #FF6B35; color: #fff; }
.type-eau      { background: #4A9EFF; color: #fff; }
.type-plante   { background: #56C450; color: #fff; }
.type-électrik { background: #F4D03F; color: #333; }
.type-glace    { background: #74D7EC; color: #333; }
.type-psy      { background: #FF8FA3; color: #fff; }
.type-dragon   { background: #7463D8; color: #fff; }
.type-ténèbres { background: #3D2B1F; color: #fff; }
.type-fée      { background: #F9A8C9; color: #333; }
.type-combat   { background: #CC4A1A; color: #fff; }
.type-poison   { background: #9B59B6; color: #fff; }
.type-sol      { background: #D4B483; color: #333; }
.type-vol      { background: #8EA8C3; color: #fff; }
.type-insecte  { background: #7DB840; color: #fff; }
.type-roche    { background: #B0A080; color: #fff; }
.type-spectre  { background: #6558A0; color: #fff; }
.type-acier    { background: #8FA3B8; color: #fff; }
.type-normal   { background: #A8A878; color: #fff; }

.loader {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--red);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin: 3rem auto;
}

@keyframes spin { to { transform: rotate(360deg); } }

#screen-voted { text-align: center; gap: 1.5rem; }

.voted-icon {
  width: 80px; height: 80px;
  background: var(--accept-light);
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 2.2rem; margin: 0 auto;
}

.voted-pokemon-info {
  background: var(--card-bg);
  border: 2px solid var(--border);
  border-radius: 16px;
  padding: 1.2rem 2rem;
  font-size: 0.85rem;
  color: var(--muted);
}

.voted-pokemon-info strong {
  color: var(--text);
  font-family: 'Syne', sans-serif;
  font-size: 1.1rem;
  text-transform: capitalize;
  display: block;
  margin-top: 0.3rem;
}

.voted-msg { text-align: center; color: var(--muted); font-size: 0.83rem; max-width: 300px; line-height: 1.7; }

.voted-lineup-label {
  font-size: 0.7rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  margin-top: 0.5rem;
}

.voted-lineup {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  width: 100%;
  max-width: 320px;
}

.lineup-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.3rem;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  padding: 0.8rem 0.6rem 0.6rem;
  opacity: 0.4;
  transition: opacity 0.2s, transform 0.2s;
}

.lineup-item--voted {
  border-color: var(--accept);
  background: var(--accept-light);
  opacity: 1;
  transform: translateY(-3px);
}

.lineup-item img { width: 56px; height: 56px; object-fit: contain; }

.lineup-item span {
  font-size: 0.65rem;
  font-family: 'Syne', sans-serif;
  font-weight: 700;
  text-transform: capitalize;
  text-align: center;
  word-break: break-word;
  line-height: 1.2;
}

.winner-card {
  width: 100%; background: var(--accept-light);
  border: 2px solid var(--accept); border-radius: 24px;
  padding: 2rem; text-align: center; margin-bottom: 2rem;
}

.winner-label { font-size: 0.7rem; letter-spacing: 3px; text-transform: uppercase; color: var(--accept); font-weight: 700; margin-bottom: 0.5rem; }

.winner-name {
  font-family: 'Syne', sans-serif;
  font-size: clamp(1.4rem, 6vw, 2.2rem);
  font-weight: 800; color: var(--accept);
  text-transform: capitalize; word-break: break-word; text-align: center;
}

.winner-pct { font-size: 0.9rem; color: var(--muted); margin-top: 0.3rem; }

.tie-card { width: 100%; background: var(--card-bg); border: 2px solid var(--border); border-radius: 24px; padding: 2rem; text-align: center; margin-bottom: 2rem; }
.tie-label { font-family: 'Syne', sans-serif; font-size: 1.4rem; font-weight: 800; margin-bottom: 0.5rem; }
.tie-sub { font-size: 0.82rem; color: var(--muted); }

.results-list { width: 100%; display: flex; flex-direction: column; gap: 1.2rem; }

.result-row {
  display: flex; align-items: center; gap: 1rem;
  background: var(--card-bg); border: 1.5px solid var(--border);
  border-radius: 16px; padding: 1rem 1.2rem;
}

.result-rank { font-family: 'Syne', sans-serif; font-size: 1.2rem; font-weight: 800; color: var(--border); width: 24px; flex-shrink: 0; text-align: center; }
.result-rank.first { color: #F0B429; }
.result-sprite { width: 48px; height: 48px; flex-shrink: 0; object-fit: contain; }
.result-info { flex: 1; display: flex; flex-direction: column; gap: 0.5rem; }
.result-labels { display: flex; justify-content: space-between; font-size: 0.82rem; font-weight: 700; text-transform: capitalize; }
.result-pct { color: var(--muted); }
.result-bar-bg { width: 100%; height: 6px; background: var(--border); border-radius: 3px; overflow: hidden; }
.result-bar-fill { height: 100%; background: var(--text); border-radius: 3px; width: 0%; transition: width 1.2s cubic-bezier(0.22,1,0.36,1); }
.result-bar-fill.first { background: var(--accept); }

.personal-msg {
  margin-top: 1.5rem; padding: 1.2rem 1.5rem;
  background: var(--card-bg); border: 1.5px solid var(--border);
  border-radius: 16px; font-size: 0.82rem; text-align: center;
  width: 100%; line-height: 1.7; color: var(--muted);
}

.personal-msg strong { color: var(--text); text-transform: capitalize; }

#screen-archives { justify-content: flex-start; padding-top: 4rem; }

.archive-grid { display: flex; flex-direction: column; gap: 0.8rem; width: 100%; margin-bottom: 2rem; }

.archive-card {
  background: var(--card-bg); border: 1.5px solid var(--border);
  border-radius: 16px; padding: 1.1rem 1.5rem;
  display: flex; justify-content: space-between; align-items: center;
  cursor: pointer; transition: transform 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.archive-card:hover { border-color: var(--text); transform: translateX(4px); box-shadow: 0 4px 16px rgba(0,0,0,0.06); }
.archive-date { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1rem; }
.archive-arrow { color: var(--muted); font-size: 0.85rem; }

#screen-stats { justify-content: flex-start; padding-top: 4rem; }

.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  width: 100%;
  margin-bottom: 2rem;
}

.stat-card {
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  padding: 1.4rem 1.2rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 0.3rem;
}

.stat-card--accent { border-color: var(--red); background: var(--red-light); }
.stat-card--full   { grid-column: 1 / -1; }
.stat-card--poke   { gap: 0.5rem; }

.stat-label    { font-size: 0.68rem; letter-spacing: 2px; text-transform: uppercase; color: var(--muted); font-weight: 700; }
.stat-value    { font-family: 'Syne', sans-serif; font-size: 2.4rem; font-weight: 800; color: var(--text); line-height: 1; }
.stat-value-md { font-family: 'Syne', sans-serif; font-size: 1.1rem; font-weight: 800; color: var(--text); }
.stat-sub      { font-size: 0.75rem; color: var(--muted); }
.stat-poke-name { font-family: 'Syne', sans-serif; font-size: 1.3rem; font-weight: 800; text-transform: capitalize; }
.stat-sprite   { width: 80px; height: 80px; object-fit: contain; }

#screen-settings { justify-content: flex-start; padding-top: 4rem; gap: 0; }

.settings-section-label {
  width: 100%;
  font-size: 0.68rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 700;
  padding: 1.4rem 0.2rem 0.5rem;
}

.settings-card {
  width: 100%;
  background: var(--card-bg);
  border: 1.5px solid var(--border);
  border-radius: 20px;
  overflow: hidden;
  margin-bottom: 0.5rem;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.5rem;
  gap: 1rem;
  border-bottom: 1px solid var(--border);
}

.settings-row:last-child { border-bottom: none; }

.settings-label { font-family: 'Syne', sans-serif; font-size: 0.9rem; font-weight: 700; }
.settings-sub   { font-size: 0.75rem; color: var(--muted); margin-top: 0.2rem; line-height: 1.5; }
.settings-value { font-size: 0.8rem; color: var(--muted); }
.settings-link  { font-size: 0.8rem; color: var(--red); text-decoration: none; }
.settings-link:hover { text-decoration: underline; }

.toggle-switch { position: relative; width: 48px; height: 26px; flex-shrink: 0; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }

.toggle-slider {
  position: absolute; inset: 0;
  background: var(--border); border-radius: 100px;
  cursor: pointer; transition: background 0.2s;
}

.toggle-slider::before {
  content: ''; position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: #fff; border-radius: 50%;
  transition: transform 0.2s;
}

.toggle-switch input:checked + .toggle-slider { background: var(--accept); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(22px); }

body.shiny img { filter: brightness(0); transition: filter 0.3s; }
