@import url('https://fonts.googleapis.com/css2?family=Fredoka:wght@400;600;700&family=Caveat:wght@400;600;700&family=Poppins:wght@400;600;700&display=swap');

:root {
  --ui-scale: 1;
}

@media (max-width: 1600px) {
  :root { --ui-scale: 0.95; }
}

@media (max-width: 1400px) {
  :root { --ui-scale: 0.9; }
}

@media (max-width: 1200px) {
  :root { --ui-scale: 0.85; }
}

@media (max-width: 1000px) {
  :root { --ui-scale: 0.8; }
}

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

html, body {
  pointer-events: auto;
  overflow-x: hidden;
  overflow-y: auto;
  font-family: 'Poppins', sans-serif;
  font-size: calc(16px * var(--ui-scale));
  background: #f5e6d3;
  min-height: 100vh;
  position: relative;
  align-content: center;
  justify-content: center;
  background-image: 
    url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23d4a574' fill-opacity='0.1'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

body {
  padding: 1rem;
  transform: scale(var(--ui-scale));
  transform-origin: top center;
  width: calc(100% / var(--ui-scale));
  height: calc(100% / var(--ui-scale));
}

.falling-leaves {
  position: fixed;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 100;
  top: 0;
  left: 0;
}
.leaf img,
.coffee img,
.pencil img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}
.leaf-fall {
  position: absolute;
  font-size: 40px;
  animation: fall 12s infinite ease-in-out;
  opacity: 0;
}

@keyframes fall {
  0% { top: -10%; opacity: 0; transform: translateX(0) rotate(0deg); }
  10% { opacity: 1; }
  50% { transform: translateX(100px) rotate(180deg); }
  90% { opacity: 1; }
  100% { top: 110%; opacity: 0; transform: translateX(-50px) rotate(360deg); }
}

.coffee {
  position: absolute;
  width: 6vw;
  height: 6vh;
  animation: float 15s infinite ease-in-out;
  opacity: 0.6;
  pointer-events: none;
  z-index: 9999;
}

.pencil {
  position: absolute;
  width: 6vw;
  height: 6vh;
  animation: float 15s infinite ease-in-out;
  opacity: 0.6;
  pointer-events: none;
  z-index: 9999;
}

@keyframes float {
  0%, 100% { transform: translateY(0px) rotate(0deg); }
  25% { transform: translateY(-20px) rotate(10deg); }
  50% { transform: translateY(-10px) rotate(-5deg); }
  75% { transform: translateY(-15px) rotate(5deg); }
}
.titlebar {
  -webkit-app-region: drag;
}

/* Headers */
h1 {
  font-family: 'Caveat', cursive;
  font-size: clamp(3rem, 7vw, 5rem);
  color: #d17842;
  text-shadow: 
    3px 3px 0 #8b5a3c,
    6px 6px 0 rgba(0,0,0,0.1);
  font-weight: 700;
  text-align: center;
  margin-bottom: 2rem;
}

h2 {
  font-family: 'Caveat', cursive;
  color: #d17842;
  text-align: center;
  font-size: clamp(1.5rem, 7vw, 3rem);
  font-weight: 700;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.05);
  margin-bottom: 2rem;
}

h3 {
  font-family: 'Caveat', cursive;
  color: #d17842;
  text-align: center;
  font-size: clamp(0.7rem, 7vw, 1.5rem);
  font-weight: 700;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.05);
}

/* Container and scrapbook page styles */
.container {
  max-width: 1400px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
  width: 100%;
}

.scrapbook-page {
  background: #fffef7;
  padding: 1.5rem;
  box-shadow: 
    0 2px 8px rgba(0,0,0,0.1),
    inset 0 0 0 1px rgba(139,90,60,0.1),
    8px 8px 0 rgba(209,120,66,0.15);
  border: 2px solid #e6d5c3;
  position: relative;
  animation: pflip 1s ease-out backwards;
  margin-bottom: 1rem;
}

@keyframes pflip {
  0% { transform: perspective(1000px) rotateY(-90deg); opacity: 0; }
  100% { transform: perspective(1000px) rotateY(0deg); opacity: 1; }
}

/* Washi tape decoration */
.scrapbook-page::before {
  content: '';
  position: absolute;
  top: -15px;
  left: 15%;
  width: 120px;
  height: 30px;
  background: repeating-linear-gradient(
    45deg,
    rgba(209,120,66,0.8),
    rgba(209,120,66,0.8) 10px,
    rgba(255,157,92,0.8) 10px,
    rgba(255,157,92,0.8) 20px
  );
  border-radius: 3px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.2);
  transform: rotate(-3deg);
}

/* Stats and cards */
.cumulative-stats {
  position: absolute;
  top: 1vh;
  left: 2vw;
  background: #fffef7;
  border: 3px solid #d17842;
  border-radius: 12px;
  padding: 0.5rem 1rem;
  font-weight: 600;
  font-size: clamp(0.3rem, 1vw, 0.5rem);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  text-align: left;
  max-width: 90vw;
  z-index: 20;
  font-family: 'Caveat', cursive;
  color: #6b4423;
}

.stat-card {
  background: white;
  padding: 1rem;
  box-shadow: 
    0 4px 12px rgba(0,0,0,0.15),
    inset 0 0 0 1px rgba(0,0,0,0.05);
  border: 1px solid #e0e0e0;
  transform: rotate(-1deg);
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  position: relative;
  animation: appear 0.6s ease-out backwards;
}

@keyframes appear {
  0% { opacity: 0; transform: rotate(-1deg) translateY(30px); }
  100% { opacity: 1; transform: rotate(-1deg) translateY(0); }
}

.stat-card:nth-child(even) {
  transform: rotate(1deg);
}

.stat-card:hover {
  transform: rotate(0deg) translateY(-10px) scale(1.05);
  box-shadow: 
    0 15px 30px rgba(0,0,0,0.25),
    0 0 15px rgba(255,157,92,0.3);
  z-index: 10;
}

.stat-card::before {
  content: '';
  position: absolute;
  top: -8px;
  right: 20px;
  font-size: 1rem;
  transform: rotate(45deg);
  filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
}

.stat-label {
  font-family: 'Caveat', cursive;
  font-size: 0.8rem;
  color: #8b5a3c;
  margin-bottom: 0.5rem;
  font-weight: 600;
}

.stat-value {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.6rem;
  font-weight: bold;
  color: #d17842;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.1);
}

/* Timer */
.timer-wrapper {
  width: min(50vw, 250px);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
}

.timer-ring {
  width: 100%;
  height: 100%;
}

.ring-bg {
  fill: none;
  stroke: #e6d5c3;
  stroke-width: 8;
}

.ring-progress {
  fill: none;
  stroke: url(#fox-gradient);
  stroke-width: 9;
  stroke-linecap: round;
  transform: rotate(-90deg);
  transform-origin: 50% 50%;
  transition: stroke-dashoffset 0.5s ease;
}

#timer {
  font-family: 'Fredoka', sans-serif;
  font-size: 1.5rem;
  fill: #d17842;
  font-weight: 600;
  text-align: center;
  align-items: center;
}

/* Input fields */
#sessionName, input[type="text"] {
  width: 90%;
  max-width: 300px;
  padding: 0.8rem 1.1rem;
  border: 3px solid #d17842;
  border-radius: 15px;
  font-size: 1rem;
  font-family: 'Caveat', cursive;
  font-weight: 600;
  outline: none;
  background: white;
  box-shadow: 0 4px 8px rgba(0,0,0,0.1);
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  margin-bottom: 0.5rem;
}

#sessionName:focus, input[type="text"]:focus {
  border-color: #ff9d5c;
  transform: translateY(-5px) scale(1.02);
  box-shadow: 
    0 15px 30px rgba(255,157,92,0.4),
    0 0 20px rgba(255,157,92,0.3);
}

#sessionName::placeholder, input[type="text"]::placeholder {
  color: #c4a07a;
}

/* Buttons */
.buttons {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 1rem;
}

button, .btn, .back-btn, .nav-btn {
  padding: 1.2rem 2.5rem;
  border: none;
  border-radius: 50px;
  font-size: 1.2rem;
  font-weight: 700;
  font-family: 'Fredoka', sans-serif;
  cursor: pointer;
  background: #ffb366;
  color: white;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
  box-shadow: 0 8px 0 rgba(0,0,0,0.2), 0 8px 20px rgba(0,0,0,0.15);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border: 3px solid rgba(255,255,255,0.3);
  margin: 0.5rem;
}

button:hover, .btn:hover, .back-btn:hover {
  transform: translateY(-8px) scale(1.05);
  box-shadow: 0 16px 0 rgba(0,0,0,0.2), 0 16px 30px rgba(0,0,0,0.2);
}

button:active, .btn:active, .back-btn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.2), 0 2px 10px rgba(0,0,0,0.1);
}

button:disabled, .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: translateY(0) !important;
}

button.back-btn, .back-btn {
  display: block;
  margin: 3rem auto 0;
  background: #e89563;
  width: auto;
  max-width: 300px;
  padding: 1.2rem 2.5rem;
  border: none;
  border-radius: 50px;
  font-size: 1.2rem;
  font-weight: 700;
  font-family: 'Fredoka', sans-serif;
  cursor: pointer;
  color: white;
  text-shadow: 2px 2px 0 rgba(0,0,0,0.2);
  box-shadow: 0 8px 0 rgba(0,0,0,0.2), 0 8px 20px rgba(0,0,0,0.15);
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  border: 3px solid rgba(255,255,255,0.3);
}

button.back-btn:hover, .back-btn:hover {
  transform: translateY(-8px) scale(1.05);
  box-shadow: 0 16px 0 rgba(0,0,0,0.2), 0 16px 30px rgba(0,0,0,0.2);
}

button.back-btn:active, .back-btn:active {
  transform: translateY(6px);
  box-shadow: 0 2px 0 rgba(0,0,0,0.2), 0 2px 10px rgba(0,0,0,0.1);
}

.nav-btn {
  background: white;
  border: 3px solid #d17842;
  color: #d17842;
  padding: 1.2rem;
  border-radius: 12px;
  font-size: 1.1rem;
  transform: rotate(-1deg);
  box-shadow: 4px 4px 0 rgba(209,120,66,0.2);
  overflow: hidden;
  position: relative;
  width: 100%;
  margin-bottom: 1rem;
}

.nav-btn::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 0;
  height: 0;
  border-radius: 50%;
  background: rgba(255,157,92,0.3);
  transform: translate(-50%, -50%);
  transition: width 0.6s, height 0.6s;
}

.nav-btn:hover::after {
  width: 300px;
  height: 300px;
}

.nav-btn:hover {
  background: linear-gradient(135deg, #ff9d5c, #ffb366);
  color: white;
  transform: rotate(0deg) scale(1.05) translateX(10px);
  box-shadow: 8px 8px 0 rgba(209,120,66,0.3);
}
.nav-btn::before {
  content: '→';
  margin-right: 0.7rem;
  font-size: 1.4rem;
  position: relative;
  z-index: 1;
}

#roast {
  background: #fffacd;
  padding: 3.5rem;
  border-radius: 0;
  position: relative;
  font-family: 'Caveat', cursive;
  font-size: 2rem;
  color: #d17842;
  min-height: 150px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 
    0 6px 12px rgba(0,0,0,0.2),
    inset 0 -2px 4px rgba(0,0,0,0.05);
  transform: rotate(-1deg);
  font-weight: 700;
  border-bottom: 3px solid rgba(0,0,0,0.05);
  text-align: center;
  line-height: 1.4;
  margin-top: 2rem;
  max-width: 90vw;
}

#roast::before {
  content: '📎';
  position: absolute;
  top: -8px;
  left: 20px;
  font-size: 2rem;
  transform: rotate(-15deg);
}

/*milestones*/

#milestoneList {
  list-style: none;
}

#milestoneList li {
  background: white;
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: 
    0 4px 12px rgba(0,0,0,0.15),
    inset 0 0 0 1px rgba(0,0,0,0.05);
  border: 1px solid #e0e0e0;
  position: relative;
  transform: rotate(-1deg);
  transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  animation: milestone-appear 0.6s ease-out backwards;
  border-radius: 0;
  font-family: 'Caveat', cursive;
  font-size: 1.4rem;
  color: #6b4423;
  font-weight: 600;
}

@keyframes milestone-appear {
  0% {
    opacity: 0;
    transform: rotate(-1deg) translateY(30px);
  }
  100% {
    opacity: 1;
    transform: rotate(-1deg) translateY(0);
  }
}

#milestoneList li:nth-child(even) {
  transform: rotate(1deg);
}

#milestoneList li:hover {
  transform: rotate(0deg) translateY(-10px) scale(1.03);
  box-shadow: 
    0 15px 30px rgba(0,0,0,0.25),
    0 0 15px rgba(255,157,92,0.3);
  z-index: 10;
}

#milestoneList li::before {
  content: '🏆';
  position: absolute;
  top: -10px;
  right: 20px;
  font-size: 2rem;
  filter: drop-shadow(2px 2px 4px rgba(0,0,0,0.3));
}

/* Charts page specific */
.charts-wrapper {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(500px, 1fr));
  gap: 2rem;
  margin-bottom: 2rem;
  width: 100%;
}
.chart-container {
  background: white;
  border-radius: 15px;
  padding: 1.5rem;
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

canvas {
  width: 100% !important;
  height: 400px !important;
  max-height: 500px;
}

@media (max-width: 1100px) {
  .charts-wrapper {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 600px) {
  .chart-container {
    padding: 1rem;
  }
  
  canvas {
    height: 300px !important;
  }
}

#avatar {
  width: clamp(100px, 20vw, 180px);
  height: clamp(100px, 20vw, 180px);
}

@media (max-width: 770px) {
  body {
    padding: 1rem;
  }
  .container, .scrapbook-page {
    padding: 1.5rem;
  }
  
  h1 {
    font-size: clamp(2rem, 8vw, 3rem);
  }

  h2 {
    font-size: 2rem;
  }

  #roast {
    font-size: 1.5rem;
    padding: 1.5rem;
    min-height: 120px;
  }

  button, .btn, .back-btn {
    padding: 1rem 2rem;
    font-size: 1rem;
    width: 100%;
    max-width: 100%;
  }
}

@media (max-width: 600px) {
  .buttons {
    flex-direction: column;
    width: 100%;
  }
  
  button, .btn {
    width: 100%;
  }
  
  .back-btn {
    width: 100%;
    max-width: 100%;
  }
}