@import url('https://fonts.googleapis.com/css2?family=DM+Mono:wght@400;500&family=DM+Sans:wght@400;500&display=swap');

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

:root {
  --bg:             #0f0f0f;
  --bg-secondary:   #1a1a1a;
  --bg-hover:       #222222;
  --border:         #2a2a2a;
  --border-focus:   #555555;
  --text-primary:   #f0ede8;
  --text-secondary: #888880;
  --text-tertiary:  #707070;
  --accent:         #F59E0B;
  --accent-red:     #E84057;
  --radius-sm:      6px;
  --radius-md:      10px;
  --radius-lg:      14px;
  --font-sans:      'DM Sans', system-ui, sans-serif;
  --font-mono:      'DM Mono', monospace;
}

body.light {
  --bg:             #f5f3ef;
  --bg-secondary:   #ece9e3;
  --bg-hover:       #e2dfd8;
  --border:         #d4d0c8;
  --border-focus:   #999890;
  --text-primary:   #1a1a18;
  --text-secondary: #6b6960;
  --text-tertiary:  #9b9890;
}

*, *::before, *::after {
  transition: background-color 0.35s ease, border-color 0.35s ease, color 0.35s ease;
}

html, body {
  background: var(--bg);
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 16px;
  line-height: 1.5;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ── Load animations ── */
@keyframes fadeUp {
  from {
    opacity: 0;
    transform: translateY(14px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

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

.header {
  animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.05s;
}

.inputs {
  animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.15s;
}

.games-label {
  animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.25s;
}

.game-list {
  animation: fadeUp 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.30s;
}

/* Stagger each row inside the list */
.group-header,
.game-row {
  animation: fadeIn 0.35s ease both;
}

.game-list > *:nth-child(1)  { animation-delay: 0.38s; }
.game-list > *:nth-child(2)  { animation-delay: 0.44s; }
.game-list > *:nth-child(3)  { animation-delay: 0.50s; }
.game-list > *:nth-child(4)  { animation-delay: 0.56s; }
.game-list > *:nth-child(5)  { animation-delay: 0.62s; }
.game-list > *:nth-child(6)  { animation-delay: 0.68s; }
.game-list > *:nth-child(7)  { animation-delay: 0.74s; }
.game-list > *:nth-child(8)  { animation-delay: 0.80s; }

.page {
  max-width: 540px;
  margin: 0 auto;
  padding: 3rem 1.5rem 4rem;
}

/* Header */
.header {
  margin-bottom: 2.5rem;
}

.header h1 {
  font-size: 11px;
  font-weight: 500;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--text-secondary);
}

/* Top inputs */
.inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 2rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 7px;
}

.field label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.field input {
  font-family: var(--font-mono);
  font-size: 24px;
  font-weight: 500;
  color: var(--text-primary);
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  width: 100%;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}

.field input::-webkit-outer-spin-button,
.field input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.field input:focus {
  border-color: var(--border-focus);
}

.field input::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
  font-size: 20px;
}

.field input.derived {
  color: var(--text-secondary);
}

/* Games label */
.games-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 8px;
}

/* Game list */
.game-list {
  display: flex;
  flex-direction: column;
  gap: 1px;
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--border);
}

.group-header {
  background: var(--bg-secondary);
  padding: 7px 16px;
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.game-row {
  display: flex;
  align-items: center;
  background: var(--bg);
  padding: 11px 16px 11px 24px;
  gap: 12px;
  transition: background 0.1s;
}

.game-row:hover {
  background: var(--bg-hover);
}

.game-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.game-name {
  font-size: 14px;
  font-weight: 500;
  color: var(--text-primary);
  flex: 1;
}

.game-sens-input {
  font-family: var(--font-mono);
  font-size: 15px;
  font-weight: 500;
  color: var(--text-primary);
  width: 100px;
  text-align: right;
  background: transparent;
  border: none;
  border-bottom: 1px solid var(--border);
  border-radius: 0;
  padding: 4px 2px;
  outline: none;
  transition: border-color 0.15s;
  -moz-appearance: textfield;
}

.game-sens-input::-webkit-outer-spin-button,
.game-sens-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.game-sens-input:focus {
  border-bottom-color: var(--border-focus);
}

.game-sens-input::placeholder {
  color: var(--text-tertiary);
  font-weight: 400;
  font-size: 13px;
}

.game-sens-input.derived {
  color: var(--text-secondary);
}


/* ── Theme toggle button ── */
.theme-btn {
  animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.35s;
}

.theme-btn {
  position: fixed;
  bottom: 24px;
  right: 72px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  z-index: 100;
  font-size: 16px;
  line-height: 1;
}

.theme-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
  transform: scale(1.07);
}

/* ── Help button ── */
.help-btn {
  animation: fadeUp 0.5s cubic-bezier(0.22, 1, 0.36, 1) both;
  animation-delay: 0.35s;
}

.help-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 1px solid var(--border);
  background: var(--bg-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background 0.15s, border-color 0.15s, transform 0.15s;
  z-index: 100;
}

.help-btn img {
  width: 20px;
  height: 20px;
  opacity: 0.5;
  transition: opacity 0.15s;
}

.help-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-focus);
  transform: scale(1.07);
}

.help-btn:hover img {
  opacity: 0.85;
}

/* ── Help overlay & modal ── */
.help-overlay {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.help-overlay.active {
  opacity: 1;
  pointer-events: all;
}

/* Backdrop blur on the page content */
body.help-open .page,
body.help-open .help-btn {
  filter: blur(4px);
  transition: filter 0.25s ease;
}

body:not(.help-open) .page,
body:not(.help-open) .help-btn {
  filter: blur(0);
  transition: filter 0.25s ease;
}

/* Dark scrim */
.help-overlay::before {
  content: '';
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: -1;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.help-overlay.active::before {
  opacity: 1;
}

.help-modal {
  width: calc(100% - 3rem);
  max-width: 480px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transform: scale(0.95) translateY(8px);
  transition: transform 0.3s cubic-bezier(0.22, 1, 0.36, 1);
}

.help-overlay.active .help-modal {
  transform: scale(1) translateY(0);
}

.help-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px 14px 20px;
  border-bottom: 1px solid var(--border);
}

.help-modal-title {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--text-tertiary);
}

.help-close-btn {
  background: none;
  border: none;
  color: var(--text-tertiary);
  font-size: 14px;
  cursor: pointer;
  line-height: 1;
  padding: 2px 4px;
  border-radius: 4px;
  transition: color 0.15s, background 0.15s;
}

.help-close-btn:hover {
  color: var(--text-primary);
  background: var(--bg-hover);
}

.help-modal-body {
  padding: 18px 20px 22px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.help-section {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.help-section-label {
  font-size: 10px;
  font-weight: 500;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-tertiary);
  margin-bottom: 2px;
}

.help-section p {
  font-size: 13px;
  color: var(--text-secondary);
  line-height: 1.6;
}

.help-section p strong {
  color: var(--text-primary);
  font-weight: 500;
}
