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

:root {
  --bg: #f8f6f2;
  --text: #2c3e50;
  --seb-primary: #4a90d9;
  --seb-light: #e8f1fb;
  --isla-primary: #d94a9a;
  --isla-light: #fbe8f3;
  --reward-bg: #ffffff;
  --penalty-bg: #fff0f0;
  --penalty-text: #c0392b;
  --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  --radius: 12px;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}

.hidden {
  display: none !important;
}

/* ─── Login Screen ────────────────────────────────────────── */

.login-screen {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  background: linear-gradient(135deg, var(--seb-primary), var(--isla-primary));
  padding: 20px;
}

.login-card {
  background: white;
  border-radius: 20px;
  padding: 40px 32px;
  max-width: 380px;
  width: 100%;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
}

.login-card h1 {
  font-size: 1.8rem;
  margin-bottom: 4px;
  color: var(--text);
}

.login-subtitle {
  color: #888;
  font-size: 1rem;
  margin-bottom: 28px;
}

.login-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.15s ease;
  font-family: inherit;
}

.login-btn:active {
  transform: scale(0.97);
}

.login-btn--google {
  background: white;
  color: #333;
  border: 2px solid #ddd;
}

.login-btn--google:hover {
  border-color: #4285F4;
  background: #f8f9ff;
}

.login-btn--pin {
  background: var(--seb-primary);
  color: white;
  min-width: 70px;
}

.login-divider {
  display: flex;
  align-items: center;
  margin: 20px 0;
  color: #aaa;
  font-size: 0.85rem;
}

.login-divider::before,
.login-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: #ddd;
}

.login-divider span {
  padding: 0 12px;
}

.pin-login {
  display: flex;
  gap: 8px;
}

.pin-login input {
  flex: 1;
  padding: 14px 16px;
  border: 2px solid #ddd;
  border-radius: 10px;
  font-size: 1.1rem;
  text-align: center;
  letter-spacing: 4px;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}

.pin-login input:focus {
  border-color: var(--seb-primary);
}

.pin-error {
  color: var(--penalty-text);
  font-size: 0.85rem;
  margin-top: 8px;
  min-height: 1.2em;
}

/* ─── Header ──────────────────────────────────────────────── */

header {
  text-align: center;
  padding: 12px 16px;
  background: linear-gradient(135deg, var(--seb-primary), var(--isla-primary));
  color: white;
  box-shadow: var(--shadow);
  position: relative;
  z-index: 1;
}

header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: 0.5px;
}

.settings-btn {
  position: absolute;
  right: 12px;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  font-size: 1.4rem;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
  opacity: 0.8;
}

.settings-btn:hover {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
}

/* ─── Settings Panel ──────────────────────────────────────── */

.settings-panel {
  background: white;
  padding: 12px 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
  z-index: 1;
  position: relative;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 0;
  font-size: 0.95rem;
}

.settings-row input[type="checkbox"] {
  width: 20px;
  height: 20px;
  cursor: pointer;
}

.settings-row code {
  background: #f0f0f0;
  padding: 4px 12px;
  border-radius: 6px;
  font-size: 1.1rem;
  font-weight: 700;
  letter-spacing: 3px;
  color: var(--text);
}

/* ─── Main Layout ─────────────────────────────────────────── */

main {
  display: flex;
  height: calc(100% - 56px);
  overflow: hidden;
}

.child-column {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px;
  overflow: hidden;
}

.divider {
  width: 3px;
  background: linear-gradient(to bottom, var(--seb-primary), var(--isla-primary));
  flex-shrink: 0;
}

/* ─── Balance Cards ───────────────────────────────────────── */

.balance-card {
  border-radius: var(--radius);
  padding: 12px 16px;
  text-align: center;
  color: white;
  box-shadow: var(--shadow);
  flex-shrink: 0;
  margin-bottom: 10px;
}

.balance-card--seb {
  background: linear-gradient(135deg, var(--seb-primary), #357abd);
}

.balance-card--isla {
  background: linear-gradient(135deg, var(--isla-primary), #b5347e);
}

.balance-card h2 {
  font-size: 1.3rem;
  margin-bottom: 2px;
  font-weight: 600;
}

.balance-amount {
  font-size: 2.8rem;
  font-weight: 800;
  line-height: 1.1;
  margin-bottom: 6px;
  transition: transform 0.2s ease;
}

.balance-amount.negative {
  color: #ffcccc;
}

.balance-buttons {
  display: flex;
  gap: 10px;
  justify-content: center;
}

.btn-adjust {
  border: 2px solid rgba(255, 255, 255, 0.6);
  background: rgba(255, 255, 255, 0.15);
  color: white;
  font-size: 1rem;
  font-weight: 700;
  padding: 6px 20px;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s ease;
  min-height: 40px;
}

.btn-adjust:active {
  transform: scale(0.93);
  background: rgba(255, 255, 255, 0.3);
}

.btn-adjust--minus {
  border-color: rgba(255, 150, 150, 0.6);
}

.btn-adjust--plus {
  border-color: rgba(150, 255, 150, 0.6);
}

/* ─── Reward List ─────────────────────────────────────────── */

.reward-list {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding-right: 4px;
  -webkit-overflow-scrolling: touch;
}

.reward-list::-webkit-scrollbar {
  width: 4px;
}

.reward-list::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.reward-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--reward-bg);
  border: 2px solid transparent;
  border-radius: var(--radius);
  padding: 10px 14px;
  cursor: pointer;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
  transition: all 0.15s ease;
  min-height: 54px;
  width: 100%;
  text-align: left;
  font-family: inherit;
}

.child-column[data-child="seb"] .reward-btn {
  border-color: var(--seb-light);
}

.child-column[data-child="isla"] .reward-btn {
  border-color: var(--isla-light);
}

.reward-btn:active {
  transform: scale(0.96);
}

.child-column[data-child="seb"] .reward-btn:active {
  background: var(--seb-light);
}

.child-column[data-child="isla"] .reward-btn:active {
  background: var(--isla-light);
}

.reward-btn.penalty {
  background: var(--penalty-bg);
  border-color: #ffdddd;
}

.reward-btn.penalty:active {
  background: #ffe0e0;
}

.reward-emoji {
  font-size: 1.6rem;
  flex-shrink: 0;
  width: 36px;
  text-align: center;
}

.reward-label {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
  color: var(--text);
  line-height: 1.2;
}

.reward-amount {
  font-size: 1rem;
  font-weight: 700;
  flex-shrink: 0;
  padding: 4px 10px;
  border-radius: 20px;
  min-width: 50px;
  text-align: center;
}

.reward-amount.positive {
  background: #e8f5e9;
  color: #2e7d32;
}

.reward-amount.negative {
  background: #ffebee;
  color: var(--penalty-text);
}

/* ─── Animations ──────────────────────────────────────────── */

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

@keyframes flash-red {
  0% { filter: brightness(1); }
  30% { filter: brightness(0.7) saturate(2); background: #c0392b; }
  100% { filter: brightness(1); }
}

@keyframes pop {
  0% { transform: scale(1); }
  50% { transform: scale(1.08); }
  100% { transform: scale(1); }
}

.shake {
  animation: shake 0.5s ease;
}

.flash-red {
  animation: flash-red 0.5s ease;
}

.pop {
  animation: pop 0.3s ease;
}

/* ─── Debounce visual feedback ────────────────────────────── */

.reward-btn:disabled,
.btn-adjust:disabled {
  opacity: 0.6;
  pointer-events: none;
}
