/* ========================================================
   PROCRASTINATION SIMULATOR – style.css
   Dark theme, mobile-first, max-width 480 px
   ======================================================== */

/* ── Custom properties ── */
:root {
  --bg:         #0D0D0D;
  --panel:      #1A1A2E;
  --accent:     #E94560;
  --accent-dim: rgba(233, 69, 96, 0.18);
  --text:       #FFFFFF;
  --muted:      #A0A0B0;
  --card:       #16213E;
  --border:     rgba(255,255,255,0.08);
  --success:    #4ade80;
  --warning:    #facc15;

  --radius:    14px;
  --radius-sm:  8px;
  --shadow:    0 8px 32px rgba(0,0,0,0.6);

  --font: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; }
body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  align-items: center;
  -webkit-font-smoothing: antialiased;
}
button { cursor: pointer; font-family: inherit; border: none; }
input  { font-family: inherit; }

.hidden { display: none !important; }


/* ═══════════════════════════════════════════════════════
   AUTH OVERLAY
═══════════════════════════════════════════════════════ */
.auth-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.92);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  padding: 20px;
}

.auth-box {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 36px 28px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: var(--shadow);
  animation: fade-scale-in 320ms ease-out;
}

.auth-logo   { font-size: 3rem; margin-bottom: 10px; }
.auth-title  { font-size: 1.5rem; font-weight: 800; letter-spacing: -0.5px; line-height: 1.2; margin-bottom: 6px; }
.auth-subtitle { color: var(--muted); font-size: .85rem; margin-bottom: 24px; }

.auth-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin-bottom: 20px;
}
.auth-tab {
  flex: 1;
  padding: 8px;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--muted);
  font-size: .9rem;
  font-weight: 600;
  transition: background .2s, color .2s;
}
.auth-tab.active {
  background: var(--card);
  color: var(--text);
}

.field {
  display: block;
  width: 100%;
  padding: 12px 14px;
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: .95rem;
  margin-bottom: 10px;
  outline: none;
  transition: border-color .2s;
}
.field:focus { border-color: var(--accent); }
.field::placeholder { color: var(--muted); }

.auth-error {
  color: var(--accent);
  font-size: .82rem;
  min-height: 20px;
  margin-bottom: 8px;
  text-align: left;
}


/* ═══════════════════════════════════════════════════════
   BUTTONS
═══════════════════════════════════════════════════════ */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: .95rem;
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  transition: opacity .15s, transform .1s;
}
.btn-primary:hover  { opacity: .9; }
.btn-primary:active { transform: scale(.96); }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--card);
  color: var(--text);
  font-weight: 600;
  font-size: .9rem;
  padding: 11px 24px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: background .15s, transform .1s;
}
.btn-secondary:hover  { background: var(--panel); }
.btn-secondary:active { transform: scale(.96); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  font-size: .8rem;
  padding: 6px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
  transition: color .15s, border-color .15s;
}
.btn-ghost:hover { color: var(--text); border-color: var(--muted); }

.btn-full  { width: 100%; }
.btn-block { display: block; width: 100%; text-align: center; margin-top: 12px; }
.btn-xl    { font-size: 1.1rem; padding: 16px 40px; border-radius: var(--radius); }


/* ═══════════════════════════════════════════════════════
   APP SHELL
═══════════════════════════════════════════════════════ */
#app {
  width: 100%;
  max-width: 480px;
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
  padding: 0 0 80px;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}
.app-logo     { display: flex; align-items: center; gap: 6px; font-weight: 800; font-size: .95rem; }
.app-name     { color: var(--accent); }
.header-right { display: flex; align-items: center; gap: 8px; }
.user-badge   { font-size: .8rem; color: var(--muted); }

/* View tabs */
.view-tabs {
  display: flex;
  gap: 0;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
.view-tab {
  flex: 1;
  padding: 11px;
  background: transparent;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 600;
  border-bottom: 2px solid transparent;
  transition: color .2s, border-color .2s;
}
.view-tab.active { color: var(--accent); border-color: var(--accent); }

/* Screens inside game-view */
.screen { padding: 24px 16px; }


/* ═══════════════════════════════════════════════════════
   START SCREEN
═══════════════════════════════════════════════════════ */
.start-hero  { font-size: 4rem; text-align: center; margin-bottom: 16px; animation: float 3s ease-in-out infinite; }
.start-title { font-size: 1.8rem; font-weight: 800; text-align: center; margin-bottom: 10px; }
.start-desc  { color: var(--muted); text-align: center; line-height: 1.6; margin-bottom: 20px; }
.start-desc strong { color: var(--text); }

.start-tips {
  list-style: none;
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px 20px;
  margin-bottom: 28px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.start-tips li { color: var(--muted); font-size: .88rem; padding-left: 18px; position: relative; }
.start-tips li::before { content: '→'; position: absolute; left: 0; color: var(--accent); }
.start-tips strong { color: var(--text); }

#start-btn { display: block; width: 100%; }


/* ═══════════════════════════════════════════════════════
   HUD
═══════════════════════════════════════════════════════ */
.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}
.hud-item {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 12px 10px;
  text-align: center;
  border: 1px solid var(--border);
}
.hud-label  { display: block; font-size: .7rem; color: var(--muted); margin-bottom: 4px; text-transform: uppercase; letter-spacing: .5px; }
.hud-value  { display: block; font-size: 1.4rem; font-weight: 800; font-variant-numeric: tabular-nums; }

/* Timer urgency pulse when ≤ 15 s (class toggled by JS) */
.timer-urgent { color: var(--accent); animation: pulse-color 1s ease-in-out infinite; }

/* Multiplier glow when active */
#hud-multiplier.glow { animation: hud-glow 1.4s ease-in-out infinite; }
#hud-multiplier.glow .hud-value { color: var(--warning); }


/* ═══════════════════════════════════════════════════════
   PROGRESS BAR
═══════════════════════════════════════════════════════ */
.progress-wrap   { margin-bottom: 24px; }
.progress-labels { display: flex; justify-content: space-between; font-size: .82rem; color: var(--muted); margin-bottom: 6px; }
.progress-track  { height: 22px; background: var(--card); border-radius: 100px; overflow: hidden; border: 1px solid var(--border); }
.progress-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #ff7a9a);
  border-radius: 100px;
  transition: width 300ms ease-out;
}
/* Near-win glow */
.progress-bar.near-win { box-shadow: 0 0 14px rgba(233,69,96,.6); }


/* ═══════════════════════════════════════════════════════
   WORK BUTTON
═══════════════════════════════════════════════════════ */
.work-area { text-align: center; margin-bottom: 20px; }

.work-button {
  position: relative;
  overflow: hidden;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #2a2a4e, var(--card));
  border: 3px solid var(--accent);
  box-shadow: 0 0 0 6px var(--accent-dim), var(--shadow);
  color: var(--text);
  transition: transform 200ms ease, box-shadow 200ms;
}
.work-button:active { transform: scale(.92); }
.work-button:disabled {
  opacity: .4;
  cursor: not-allowed;
  transform: none;
}
.work-label {
  display: block;
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: 1px;
  pointer-events: none;
}

/* Ripple */
.ripple-container { position: absolute; inset: 0; border-radius: 50%; overflow: hidden; pointer-events: none; }
.ripple {
  position: absolute;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  width: 10px;
  height: 10px;
  transform: translate(-50%, -50%) scale(0);
  animation: ripple-expand .6s linear forwards;
  pointer-events: none;
}

.status-msg {
  margin-top: 12px;
  font-size: .82rem;
  color: var(--muted);
  min-height: 20px;
  font-style: italic;
}


/* ═══════════════════════════════════════════════════════
   TEMPTATION BUTTON
═══════════════════════════════════════════════════════ */
.temptation-button {
  display: block;
  width: 100%;
  padding: 14px;
  background: rgba(233,69,96,.12);
  border: 1px dashed var(--accent);
  border-radius: var(--radius-sm);
  color: var(--accent);
  font-size: .9rem;
  font-weight: 600;
  transition: background .2s, transform .1s;
}
.temptation-button:hover:not(:disabled)  { background: rgba(233,69,96,.22); }
.temptation-button:active:not(:disabled) { transform: scale(.98); }
.temptation-button:disabled { opacity: .45; cursor: not-allowed; }

.temptation-button.pulse-reappear { animation: tempt-reappear 900ms ease-in-out; }


/* ═══════════════════════════════════════════════════════
   END SCREEN
═══════════════════════════════════════════════════════ */
.personality-result {
  font-size: 1.4rem;
  font-weight: 800;
  text-align: center;
  padding: 20px;
  border-radius: var(--radius);
  margin-bottom: 20px;
  background: var(--card);
  border: 1px solid var(--border);
  animation: fade-scale-in 400ms ease-out;
}

.end-stats {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 16px;
}
.stat-card {
  background: var(--card);
  border-radius: var(--radius-sm);
  padding: 16px 12px;
  text-align: center;
  border: 1px solid var(--border);
}
.stat-value { display: block; font-size: 1.6rem; font-weight: 800; }
.stat-label { display: block; font-size: .75rem; color: var(--muted); margin-top: 4px; text-transform: uppercase; letter-spacing: .4px; }

.personal-best {
  text-align: center;
  font-size: .88rem;
  color: var(--muted);
  margin-bottom: 20px;
  min-height: 22px;
}
.personal-best.new-best { color: var(--success); font-weight: 700; font-size: .95rem; }

.end-actions {
  display: flex;
  gap: 10px;
}
.end-actions .btn-primary,
.end-actions .btn-secondary { flex: 1; }


/* ═══════════════════════════════════════════════════════
   LEADERBOARD
═══════════════════════════════════════════════════════ */
#leaderboard-view { padding: 0 16px 16px; }

.lb-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg);
  border-radius: var(--radius-sm);
  padding: 4px;
  margin: 16px 0;
}
.lb-tab {
  flex: 1;
  padding: 9px;
  border-radius: calc(var(--radius-sm) - 2px);
  background: transparent;
  color: var(--muted);
  font-size: .88rem;
  font-weight: 600;
  transition: background .2s, color .2s;
}
.lb-tab.active { background: var(--card); color: var(--text); }

.lb-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .88rem;
}
.lb-table th {
  color: var(--muted);
  text-align: left;
  padding: 8px 10px;
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 1px solid var(--border);
}
.lb-table td {
  padding: 10px;
  border-bottom: 1px solid var(--border);
}
.lb-table tr:last-child td { border-bottom: none; }
.lb-table tr.current-user td { color: var(--accent); font-weight: 700; }
.lb-table tr:hover td { background: rgba(255,255,255,.03); }

.lb-loading { text-align: center; color: var(--muted); padding: 24px; }

.personal-stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-bottom: 12px;
}


/* ═══════════════════════════════════════════════════════
   DISTRACTION OVERLAYS
═══════════════════════════════════════════════════════ */
.distraction-overlay {
  position: fixed;
  inset: 0;
  z-index: 900;
  background: rgba(0,0,0,.65);
  opacity: 0;
  pointer-events: none;
  transition: opacity 250ms ease-out;
}
.distraction-overlay.active {
  opacity: 1;
  pointer-events: all;
}
.distraction-overlay.bottom  { display: flex; align-items: flex-end; justify-content: center; }
.distraction-overlay.center  { display: flex; align-items: center;   justify-content: center; }

/* Bottom-slide panels */
.distraction-panel-bottom {
  width: 100%;
  max-width: 480px;
  transform: translateY(100%);
  transition: transform 250ms ease-out;
}
.distraction-overlay.active .distraction-panel-bottom { transform: translateY(0); }

/* Center-scale panels */
.distraction-panel-center {
  width: 90%;
  max-width: 380px;
  transform: scale(.85);
  opacity: 0;
  transition: transform 250ms ease-out, opacity 250ms ease-out;
}
.distraction-overlay.active .distraction-panel-center { transform: scale(1); opacity: 1; }

/* Shared action buttons inside distractions */
.distraction-actions { display: flex; gap: 10px; padding: 16px; }
.distraction-actions .btn-resist,
.distraction-actions .btn-distract { flex: 1; padding: 12px; border-radius: var(--radius-sm); font-size: .9rem; font-weight: 700; transition: opacity .15s, transform .1s; }
.distraction-actions button:active { transform: scale(.96); }

.btn-resist   { background: var(--card); color: var(--text); border: 1px solid var(--border); }
.btn-resist:hover { background: var(--panel); }

.btn-distract { background: var(--accent); color: #fff; }
.btn-distract:hover { opacity: .9; }


/* ── Phone Lockscreen ── */
.phone-lockscreen {
  background: linear-gradient(160deg, #0f0f2a 0%, #1a1a3e 100%);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  padding-bottom: 8px;
  overflow: hidden;
}
.phone-status-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 20px 4px;
  font-size: .75rem;
  color: rgba(255,255,255,.6);
}
.phone-icons { letter-spacing: 2px; }
.phone-notification {
  display: flex;
  align-items: center;
  gap: 12px;
  background: rgba(255,255,255,.08);
  backdrop-filter: blur(8px);
  margin: 8px 12px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255,255,255,.1);
}
.notif-icon-wrap { font-size: 1.8rem; }
.notif-app   { font-size: .72rem; color: rgba(255,255,255,.5); margin-bottom: 3px; text-transform: uppercase; letter-spacing: .5px; }
.notif-text  { font-size: .9rem; font-weight: 600; }
.phone-hint  { text-align: center; color: rgba(255,255,255,.3); font-size: .78rem; padding: 10px 0 4px; }


/* ── Social Media Panel ── */
.social-panel {
  background: var(--panel);
  border-top-left-radius: var(--radius);
  border-top-right-radius: var(--radius);
  max-height: 78vh;
  display: flex;
  flex-direction: column;
}
.social-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.social-logo { font-size: .95rem; font-weight: 800; color: #4a90d9; }
.close-btn {
  background: var(--card);
  color: var(--muted);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 30px;
  height: 30px;
  font-size: .8rem;
  display: flex;
  align-items: center;
  justify-content: center;
}
.social-feed { overflow-y: auto; flex: 1; padding: 8px 0; }

.post {
  display: flex;
  gap: 10px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.post:last-child { border-bottom: none; }
.post-avatar { font-size: 1.8rem; flex-shrink: 0; }
.post-meta   { font-size: .75rem; color: var(--muted); margin-bottom: 4px; }
.post-meta strong { color: var(--text); }
.post-text   { font-size: .88rem; line-height: 1.45; margin-bottom: 8px; }
.post-actions { display: flex; gap: 16px; font-size: .8rem; color: var(--muted); }


/* ── Fatigue Popup ── */
.popup-panel {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  text-align: center;
  padding-top: 28px;
  overflow: hidden;
}
.popup-emoji { font-size: 3.5rem; margin-bottom: 12px; }
.popup-title { font-size: 1.15rem; font-weight: 800; margin-bottom: 8px; }
.popup-desc  { color: var(--muted); font-size: .85rem; line-height: 1.5; padding: 0 16px 16px; }


/* ── Buffering Overlay ── */
.buffering-panel {
  background: var(--panel);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 36px 28px;
  text-align: center;
  box-shadow: var(--shadow);
}
.buffering-spinner {
  width: 52px;
  height: 52px;
  border: 4px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  margin: 0 auto 18px;
  animation: spin 1s linear infinite;
}
.buffering-text { font-weight: 700; margin-bottom: 16px; }
.buffering-track {
  height: 8px;
  background: var(--card);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 8px;
}
.buffering-bar {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent), #ff7a9a);
  border-radius: 100px;
}
.buffering-sub { font-size: .78rem; color: var(--muted); }


/* ═══════════════════════════════════════════════════════
   KEYFRAME ANIMATIONS
═══════════════════════════════════════════════════════ */
@keyframes fade-scale-in {
  from { opacity: 0; transform: scale(.9); }
  to   { opacity: 1; transform: scale(1);  }
}

@keyframes ripple-expand {
  from { transform: translate(-50%,-50%) scale(0); opacity: 1; }
  to   { transform: translate(-50%,-50%) scale(28); opacity: 0; }
}

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

@keyframes float {
  0%, 100% { transform: translateY(0);    }
  50%       { transform: translateY(-8px); }
}

@keyframes pulse-color {
  0%, 100% { color: var(--accent); }
  50%       { color: #ff7a9a;       }
}

@keyframes hud-glow {
  0%, 100% { box-shadow: 0 0 6px  var(--accent-dim); }
  50%       { box-shadow: 0 0 22px rgba(233,69,96,.45); }
}

@keyframes tempt-reappear {
  0%   { transform: scale(1);    }
  15%  { transform: scale(1.10); }
  30%  { transform: scale(1);    }
  50%  { transform: scale(1.07); }
  65%  { transform: scale(1);    }
  80%  { transform: scale(1.04); }
  100% { transform: scale(1);    }
}

@keyframes multiplier-pop {
  0%   { transform: scale(1);   }
  40%  { transform: scale(1.5); }
  100% { transform: scale(1);   }
}

.multiplier-pop { animation: multiplier-pop 400ms ease-out; }
