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

html, body {
  height: 100%;
  overflow: hidden;
}

body {
  background: #000;
  color: #fff;
  font-family: system-ui, -apple-system, sans-serif;
  display: flex;
  justify-content: center;
  align-items: center;
  text-align: center;
  -webkit-font-smoothing: antialiased;
  position: relative;
}

/* ---- TABS ---- */

#tabs {
  position: fixed;
  top: 1rem;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 0;
  z-index: 50;
  border: 1px solid #222;
  border-radius: 4px;
  overflow: hidden;
}

.tab {
  background: transparent;
  border: none;
  color: #555;
  font-size: 0.65rem;
  letter-spacing: 0.2em;
  padding: 0.5rem 1.2rem;
  cursor: pointer;
  transition: color 0.2s, background 0.2s;
  font-family: system-ui, -apple-system, sans-serif;
}

.tab:hover {
  color: #888;
}

.tab.active {
  color: #fff;
  background: #111;
}

/* ---- GAME STATE ---- */

#game {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  padding: 2rem;
  width: 100%;
  max-width: 500px;
  position: absolute;
}

#counter-label {
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  color: #555;
  text-transform: uppercase;
}

#counter {
  font-family: 'Courier New', Courier, monospace;
  font-size: clamp(3rem, 12vw, 7rem);
  font-weight: bold;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  transition: transform 0.15s ease, color 0.3s ease;
  color: #fff;
}

#counter.bump {
  transform: scale(1.15);
  color: #ff0000;
}

#input-group {
  width: 100%;
  max-width: 280px;
}

#name-input {
  width: 100%;
  padding: 0.75rem 1rem;
  font-size: 1rem;
  font-family: system-ui, -apple-system, sans-serif;
  letter-spacing: 0.1em;
  text-align: center;
  text-transform: uppercase;
  background: transparent;
  border: 1px solid #333;
  color: #fff;
  outline: none;
  transition: border-color 0.2s;
}

#name-input:focus {
  border-color: #ff0000;
}

#name-input.shake {
  animation: shake 0.4s ease;
}

/* THE BUTTON */

#the-button {
  width: min(200px, 50vw);
  height: min(200px, 50vw);
  border-radius: 50%;
  border: none;
  background: #ff0000;
  color: #fff;
  font-size: clamp(1rem, 4vw, 1.5rem);
  font-weight: 700;
  letter-spacing: 0.15em;
  cursor: pointer;
  position: relative;
  transition: transform 0.1s ease;
  animation: pulse 2s ease-in-out infinite;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#the-button:hover {
  transform: scale(1.05);
}

#the-button:active {
  transform: scale(0.95);
  animation: none;
}

#the-button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  animation: none;
}

@keyframes pulse {
  0%, 100% { box-shadow: 0 0 30px rgba(255, 0, 0, 0.4), 0 0 60px rgba(255, 0, 0, 0.1); }
  50% { box-shadow: 0 0 50px rgba(255, 0, 0, 0.6), 0 0 100px rgba(255, 0, 0, 0.2); }
}

#subtext {
  font-size: 0.8rem;
  color: #444;
  font-style: italic;
}

/* Ticker */

#ticker {
  width: 100%;
  max-width: 300px;
  max-height: 120px;
  overflow: hidden;
  font-size: 0.7rem;
  color: #333;
  font-family: 'Courier New', Courier, monospace;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.tick-entry {
  opacity: 0;
  animation: fadeIn 0.3s ease forwards;
}

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

/* ---- BREAK ANIMATION ---- */

#the-button.breaking {
  animation: buttonBreak 1.2s ease forwards;
}

@keyframes buttonBreak {
  0% { transform: translate(0, 0) scale(1); }
  10% { transform: translate(-4px, 2px) scale(1); }
  20% { transform: translate(4px, -2px) scale(1); }
  30% { transform: translate(-6px, -4px) scale(1.02); }
  40% { transform: translate(6px, 4px) scale(1.02); }
  50% { transform: translate(-8px, 2px) scale(1.05); background: #cc0000; }
  60% { transform: translate(8px, -2px) scale(1.05); }
  70% { transform: translate(0, 0) scale(1.1); background: #ff3333; }
  80% { transform: scale(1.3); background: #fff; box-shadow: 0 0 100px #fff; }
  100% { transform: scale(0); opacity: 0; }
}

/* Flash overlay */

#flash-overlay {
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0;
  z-index: 100;
}

#flash-overlay.flash {
  animation: screenFlash 2s ease forwards;
}

@keyframes screenFlash {
  0% { background: #fff; opacity: 0; }
  10% { opacity: 1; }
  30% { background: #ff0000; opacity: 0.8; }
  60% { background: #000; opacity: 1; }
  100% { background: #000; opacity: 0; }
}

/* Game fade out */

#game.fading {
  animation: fadeOut 0.5s ease forwards;
}

@keyframes fadeOut {
  to { opacity: 0; }
}

/* ---- MEMORIAL ---- */

#memorial {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.5rem;
  padding: 2rem;
  opacity: 0;
  width: 100%;
  position: absolute;
}

#memorial.revealed {
  animation: revealMemorial 3s ease forwards;
}

@keyframes revealMemorial {
  0% { opacity: 0; transform: translateY(20px); }
  100% { opacity: 1; transform: translateY(0); }
}

#memorial-label {
  font-size: 0.75rem;
  letter-spacing: 0.4em;
  color: #555;
}

#winner-name {
  font-size: clamp(2.5rem, 10vw, 6rem);
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  animation: eternalPulse 3s ease-in-out infinite;
}

@keyframes eternalPulse {
  0%, 100% { opacity: 0.7; }
  50% { opacity: 1; }
}

#winner-click {
  font-family: 'Courier New', Courier, monospace;
  font-size: 1.2rem;
  color: #ff0000;
}

#memorial-sub {
  font-size: 0.8rem;
  color: #333;
  max-width: 300px;
  line-height: 1.5;
}

/* ---- LEADERBOARD ---- */

#leaderboard {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1rem;
  padding: 2rem;
  width: 100%;
  max-width: 400px;
  position: absolute;
  max-height: 80vh;
}

#lb-title {
  font-size: 0.75rem;
  letter-spacing: 0.3em;
  color: #555;
  text-transform: uppercase;
}

#lb-list {
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0;
  overflow-y: auto;
  max-height: 60vh;
}

.lb-row {
  display: flex;
  align-items: center;
  padding: 0.6rem 0.8rem;
  border-bottom: 1px solid #111;
  font-size: 0.85rem;
}

.lb-rank {
  width: 2rem;
  font-family: 'Courier New', Courier, monospace;
  color: #555;
  font-weight: bold;
  flex-shrink: 0;
}

.lb-row:nth-child(1) .lb-rank { color: #ff0000; }
.lb-row:nth-child(2) .lb-rank { color: #cc3333; }
.lb-row:nth-child(3) .lb-rank { color: #993333; }

.lb-name {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.lb-clicks {
  font-family: 'Courier New', Courier, monospace;
  color: #ff0000;
  font-weight: bold;
  flex-shrink: 0;
  margin-left: 1rem;
}

.lb-empty {
  color: #333;
  font-style: italic;
  font-size: 0.85rem;
  padding: 2rem 0;
}

/* Hidden attribute override (display:flex overrides [hidden]) */

#game[hidden],
#leaderboard[hidden],
#memorial[hidden] {
  display: none;
}

/* ---- UTILITIES ---- */

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-8px); }
  40% { transform: translateX(8px); }
  60% { transform: translateX(-6px); }
  80% { transform: translateX(6px); }
}

/* Responsive tweaks */
@media (max-height: 600px) {
  #game { gap: 1rem; }
  #ticker { display: none; }
}
