html, body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: sans-serif;
  position: relative;
}

/* Ensure default text color follows theme variable */
body {
  color: var(--text-default);
}

/* Theme variables (defaults) */
:root {
  --top-bg: #3498db;
  --bottom-bg: #bdc3c7;
  --progress-fill: rgba(255, 255, 255, 0.8);
  --kbd-bg: rgba(255,255,255,0.12);
  --text-on-primary: #ffffff;
  --text-default: #111827; /* default body/text color */
  --modal-bg: #ffffff;
  --no-button-color: #4aa3ff; /* lighter blue for the "I don't press" link */
  --settings-btn-bg-start: rgba(255,255,255,0.06);
  --settings-btn-bg-end: rgba(255,255,255,0.02);
}

/* Dark theme */
body.theme-dark {
  --top-bg: #07080a; /* very very dark gray (near-black) */
  --bottom-bg: #1a1c1f; /* slightly lighter dark gray for improved separation */
  --progress-fill: #60a5fa;
  --kbd-bg: rgba(255,255,255,0.06);
  --text-on-primary: #ffffff; /* pure white for highest contrast */
  --settings-btn-bg-start: rgba(255,255,255,0.03);
  --settings-btn-bg-end: rgba(255,255,255,0.01);
  --text-default: #ffffff;
  --modal-bg: #0b0d10; /* dark modal background for dark theme */
  --no-button-color: #7fbfff; /* slightly brighter in dark mode for legibility */
}

/* (Removed Colorful and Retro themes — keeping Default and Dark) */

/* Top and bottom sections fill half screen each */
.top-section, .bottom-section {
  height: 50%;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.top-section {
  background: var(--top-bg);
}

.bottom-section {
  background: var(--bottom-bg);
}

/* Progress bar */
.progress-bar {
  width: 100%;
  height: 8px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  position: relative;
  margin-bottom: 20px;
  overflow: hidden;
  padding: 0 20px;
  box-sizing: border-box;
}

.progress-fill {
  height: 100%;
  background-color: var(--progress-fill);
  width: 10%;
  border-radius: 4px;
  transition: width 0.3s ease;
}

.progress-text {
  position: absolute;
  top: 18px;
  right: 20px;
  font-size: 0.9rem;
  color: var(--text-on-primary);
  font-weight: 600;
}

.keyboard-hint {
  margin-top: 6px;
  color: var(--text-on-primary);
  font-size: 0.9rem;
}

.settings {
  margin-top: 8px;
}

.setting-item {
  color: var(--text-on-primary);
  font-size: 0.85rem;
}

.setting-item input[type="checkbox"] {
  margin-right: 8px;
  transform: translateY(-1px);
}

.settings-btn {
  position: fixed;
  left: 16px;
  bottom: 16px;
  width: 52px;
  height: 52px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--text-on-primary);
  padding: 6px;
  border-radius: 12px; /* rounded pill for modern feel */
  cursor: pointer;
  box-shadow: 0 8px 30px rgba(21, 38, 71, 0.28);
  z-index: 11000;
  opacity: 1;
  transition: transform 0.14s ease, box-shadow 0.14s ease, background 0.12s ease;
  will-change: transform;
  /* glassy gradient using variables */
  background: linear-gradient(135deg, var(--settings-btn-bg-start), var(--settings-btn-bg-end));
  border: 1px solid rgba(255,255,255,0.08);
  backdrop-filter: blur(6px) saturate(1.05);
  min-width: 48px;
  /* larger emoji/icon */
  font-size: 22px;
  line-height: 1;
}

.settings-btn:hover {
  transform: translateY(-4px) scale(1.03);
  box-shadow: 0 14px 36px rgba(21, 38, 71, 0.36);
}

/* subtle periodic pulse to draw attention without being obnoxious */
.settings-btn.pulse {
  animation: confettiPulse 4.5s ease-in-out infinite;
}

@keyframes confettiPulse {
  0% { transform: translateY(0) scale(1); }
  50% { transform: translateY(-3px) scale(1.02); }
  100% { transform: translateY(0) scale(1); }
}

/* Tooltip using data-tooltip attr */
.settings-btn::after {
  content: attr(data-tooltip);
  position: absolute;
  left: 50%;
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(6px);
  background: rgba(0,0,0,0.85);
  color: #fff;
  padding: 6px 10px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.12s ease, transform 0.12s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.28);
}

.settings-btn:hover::after,
.settings-btn:focus::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

@media (max-width: 520px) {
  .settings-btn { left: 10px; bottom: 10px; width: 48px; height: 48px; }
  .settings-btn::after { display: none; } /* hide tooltip on small screens */
}

/* Modal for settings */
.modal {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,0.45);
  z-index: 10000;
  visibility: hidden;
  opacity: 0;
  transition: opacity 0.18s ease;
}
.modal.show {
  visibility: visible;
  opacity: 1;
}
.modal-content {
  background: var(--modal-bg);
  color: var(--text-default);
  padding: 18px;
  border-radius: 10px;
  width: 92%;
  max-width: 420px;
  box-sizing: border-box;
}
.modal-row { margin-top: 10px; }
.modal-actions { margin-top: 14px; text-align: right; }
.modal .btn { padding: 8px 12px; border-radius: 6px; border: none; cursor: pointer; }
#celebrationLevel { width: 100%; }

kbd {
  background: var(--kbd-bg);
  border-radius: 4px;
  padding: 2px 6px;
  font-weight: 700;
  color: var(--text-on-primary);
}

/* Heading at the top with padding */
.top-section h1 {
  margin: 20px 0 0 0;
  text-align: center;
  width: 100%;
  padding: 0 20px;
  box-sizing: border-box;
}

/* Good thing container vertically centered with slight nudge up */
.good-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 0 20px;
  text-align: center;
  margin-top: -10px; /* move slightly up */
  transition: transform 0.18s ease; /* smooth shift when toggled */
}

/* When keyboard hint is visible on wider screens, gently raise the good text to avoid overlap */
@media (min-width: 801px) {
  .good-container.hint-visible-shift {
    transform: translateY(-36px);
  }
}

/* Bad thing container vertically centered in gray section */
.bad-container {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  padding: 0 20px;
  text-align: center;
}

/* Button container overlaid between sections */
.button-container {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  pointer-events: none; /* container ignores clicks */
}

/* Red button */
.red-button {
  width: 120px !important;
  height: 120px !important;
  cursor: pointer;
  pointer-events: auto;
  margin-bottom: 10px;
  touch-action: manipulation; /* improve tap responsiveness */
  -webkit-user-drag: none; /* disable image drag on mobile */
  user-select: none;
}

/* Visual feedback for keyboard-triggered button press */
.red-button.press-anim {
  transform: scale(0.94);
  transition: transform 0.12s ease;
}

/* "I don't press the button" link */
.no-button {
  background: none;
  border: none;
  color: var(--no-button-color);
  text-decoration: underline;
  cursor: pointer;
  font-size: 16px;
  pointer-events: auto;
}

.no-button.press-anim {
  transform: translateY(2px);
  opacity: 0.85;
  transition: transform 0.12s ease, opacity 0.12s ease;
}

.fade {
  opacity: 0;
  transition: opacity 0.4s ease;
}

.fade.show {
  opacity: 1;
}

/* Simple inline spinner for loading stats */
.spinner {
  display: inline-block;
  width: 18px;
  height: 18px;
  border: 2px solid rgba(0,0,0,0.08);
  border-top-color: rgba(0,0,0,0.35);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  vertical-align: middle;
  margin-left: 8px;
}

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

/* Confetti canvas overlay */
#confettiCanvas {
  position: fixed;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 9999;
}
