/* === RESET & BASE === */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  background: #16130f;
  font-family: 'Press Start 2P', monospace;
  color: #eae1da;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

#game-container {
  width: 100%;
  height: 100%;
  max-width: 420px;
  margin: 0 auto;
  position: relative;
  overflow: hidden;
}

/* === SCREENS === */
.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease;
}

.screen.active {
  opacity: 1;
  pointer-events: auto;
}

/* === BUTTON === */
.pixel-btn {
  font-family: 'Press Start 2P', monospace;
  font-size: 14px;
  padding: 16px 32px;
  background: #E8A04C;
  color: #16130f;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.1s, opacity 0.15s;
  position: relative;
}

.pixel-btn:active {
  transform: scale(0.96);
  opacity: 0.85;
}

.pixel-btn.pulse {
  animation: pulse 1.5s infinite;
}

@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.05); }
}

/* === INTRO SCREEN === */
#screen-intro h1 {
  font-size: 18px;
  line-height: 1.6;
  text-align: center;
  margin-bottom: 16px;
}

.highlight {
  color: #E8A04C;
}

.subtitle {
  font-family: 'Press Start 2P', monospace;
  font-size: 9px;
  line-height: 1.8;
  text-align: center;
  color: #d7c3b2;
  margin-bottom: 32px;
}

/* === PIXEL COFFEE CUP === */
.pixel-coffee-big {
  position: relative;
  margin-bottom: 32px;
}

.coffee-cup-large {
  width: 80px;
  height: 64px;
  background: #fff;
  border-radius: 0 0 12px 12px;
  position: relative;
  image-rendering: pixelated;
  box-shadow: inset 0 -20px 0 #6b4226;
}

.coffee-cup-large::after {
  content: '';
  position: absolute;
  right: -20px;
  top: 12px;
  width: 20px;
  height: 28px;
  border: 6px solid #fff;
  border-left: none;
  border-radius: 0 8px 8px 0;
}

/* Steam */
.steam {
  position: absolute;
  width: 8px;
  height: 20px;
  background: rgba(255,255,255,0.3);
  border-radius: 4px;
  top: -24px;
  animation: steam 2s infinite ease-out;
}

.steam-1 { left: 16px; animation-delay: 0s; }
.steam-2 { left: 34px; animation-delay: 0.5s; }
.steam-3 { left: 52px; animation-delay: 1s; }

@keyframes steam {
  0% { transform: translateY(0) scaleX(1); opacity: 0.6; }
  50% { transform: translateY(-16px) scaleX(1.5); opacity: 0.3; }
  100% { transform: translateY(-32px) scaleX(2); opacity: 0; }
}

/* === STEP HEADER === */
.step-header {
  text-align: center;
  margin-bottom: 24px;
}

.step-label {
  font-size: 8px;
  color: #E8A04C;
  letter-spacing: 2px;
}

.step-header h2 {
  font-size: 14px;
  margin-top: 8px;
}

/* === GAME AREA === */
.game-area {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
}

.instruction {
  font-size: 9px;
  color: #d7c3b2;
  margin: 16px 0;
  text-align: center;
  line-height: 1.6;
}

.timer {
  font-size: 24px;
  color: #E8A04C;
  margin-top: 12px;
}

/* === GRINDER (Step 1) – Comandante-Style === */
#grinder {
  width: 120px;
  height: 240px;
  position: relative;
  cursor: pointer;
}

/* Metal cap on top */
.grinder-top {
  width: 56px;
  height: 14px;
  background: linear-gradient(to bottom, #ccc, #999);
  border-radius: 4px 4px 0 0;
  position: absolute;
  top: 28px;
  left: 32px;
  z-index: 2;
}

/* Wooden cylinder body */
.grinder-body {
  width: 56px;
  height: 140px;
  background: linear-gradient(135deg, #8B6914 0%, #6B4F1D 30%, #54381A 60%, #6B4F1D 100%);
  border-radius: 6px;
  position: absolute;
  top: 42px;
  left: 32px;
  box-shadow:
    inset -8px 0 12px rgba(0,0,0,0.25),
    inset 8px 0 12px rgba(255,255,255,0.08),
    2px 4px 8px rgba(0,0,0,0.3);
}

/* Wood grain texture */
.grinder-body::before {
  content: '';
  position: absolute;
  inset: 8px 10px;
  background: repeating-linear-gradient(
    180deg,
    transparent,
    transparent 6px,
    rgba(0,0,0,0.06) 6px,
    rgba(0,0,0,0.06) 7px
  );
  border-radius: 3px;
}

/* Brand text area */
.grinder-body::after {
  content: '';
  position: absolute;
  top: 30px;
  left: 12px;
  width: 32px;
  height: 60px;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 2px;
}

/* Glass catch cup at bottom */
.grinder-glass {
  width: 52px;
  height: 55px;
  background: linear-gradient(to bottom,
    rgba(200,200,210,0.25),
    rgba(180,180,190,0.15));
  border: 2px solid rgba(200,200,210,0.3);
  border-radius: 0 0 6px 6px;
  position: absolute;
  top: 180px;
  left: 34px;
  overflow: hidden;
}

/* Ground coffee in glass */
.grinder-glass::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 0%;
  background: linear-gradient(to bottom, #5C3A1E, #3E2512);
  border-radius: 0 0 4px 4px;
  transition: height 0.3s ease;
}

.grinder-glass.filling-1::after { height: 14%; }
.grinder-glass.filling-2::after { height: 28%; }
.grinder-glass.filling-3::after { height: 42%; }
.grinder-glass.filling-4::after { height: 57%; }
.grinder-glass.filling-5::after { height: 71%; }
.grinder-glass.filling-6::after { height: 85%; }
.grinder-glass.filling-7::after { height: 100%; }

/* Metal ring between body and glass */
.grinder-ring {
  width: 60px;
  height: 6px;
  background: linear-gradient(to bottom, #bbb, #888);
  border-radius: 2px;
  position: absolute;
  top: 178px;
  left: 30px;
  z-index: 2;
}

/* Crank assembly */
.grinder-crank {
  position: absolute;
  top: 0;
  left: 50%;
  transform-origin: 50% 30px;
  width: 0;
  height: 0;
  transition: transform 0.3s ease;
  z-index: 3;
}

.crank-arm {
  width: 70px;
  height: 5px;
  background: linear-gradient(to right, #bbb, #ddd, #bbb);
  border-radius: 3px;
  position: absolute;
  top: 0;
  left: -35px;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3);
}

/* Bend at the end */
.crank-arm::after {
  content: '';
  position: absolute;
  right: -2px;
  top: -8px;
  width: 5px;
  height: 20px;
  background: linear-gradient(to right, #bbb, #ddd);
  border-radius: 3px;
}

.crank-knob {
  width: 12px;
  height: 18px;
  background: linear-gradient(to right, #666, #888, #666);
  border-radius: 6px;
  position: absolute;
  top: -16px;
  left: 28px;
  box-shadow: 0 2px 3px rgba(0,0,0,0.3);
}

.beans-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  overflow: hidden;
}

.bean {
  position: absolute;
  width: 8px;
  height: 6px;
  background: #3e1f0d;
  border-radius: 50%;
  animation: bean-fall 0.6s ease-in forwards;
}

@keyframes bean-fall {
  0% { transform: translateY(0) rotate(0); opacity: 1; }
  100% { transform: translateY(140px) rotate(360deg); opacity: 0; }
}

.grind-dots {
  display: flex;
  gap: 12px;
  margin-top: 24px;
}

.grind-dot {
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #231f1b;
  transition: background 0.3s, transform 0.3s;
}

.grind-dot.filled {
  background: #E8A04C;
  transform: scale(1.3);
}

/* === MILK (Step 2) – Motta-Style Pitcher === */
#milk-container {
  width: 140px;
  height: 220px;
  position: relative;
}

.pitcher {
  position: absolute;
  bottom: 0;
  left: 20px;
  width: 90px;
  height: 180px;
  overflow: hidden;
  background: transparent;
}

/* Pitcher body – tapered shape */
.pitcher::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 5px;
  width: 80px;
  height: 160px;
  background: rgba(60, 60, 70, 0.45);
  border: 2px solid rgba(120, 120, 130, 0.5);
  border-radius: 0 0 20px 20px;
  /* Taper: wider at top, narrower at bottom */
  clip-path: polygon(5% 0%, 95% 0%, 85% 100%, 15% 100%);
  box-shadow:
    inset -6px 0 10px rgba(255,255,255,0.06),
    inset 6px 0 10px rgba(0,0,0,0.15);
}

/* Spout */
.pitcher::after {
  content: '';
  position: absolute;
  top: 8px;
  left: 20px;
  width: 24px;
  height: 16px;
  background: rgba(60, 60, 70, 0.45);
  border: 2px solid rgba(120, 120, 130, 0.4);
  border-bottom: none;
  border-radius: 6px 6px 0 0;
  transform: rotate(-8deg);
}

/* Handle */
.pitcher-handle {
  position: absolute;
  right: 8px;
  top: 30px;
  width: 18px;
  height: 90px;
  border: 4px solid rgba(100, 100, 110, 0.7);
  border-left: none;
  border-radius: 0 14px 14px 0;
}

/* Milk inside pitcher */
.milk-level {
  position: absolute;
  bottom: 4px;
  left: 32px;
  width: 66px;
  height: 15%;
  background: linear-gradient(to top, #f0ead6, #f5f0dc);
  border-radius: 0 0 14px 14px;
  transition: height 0.15s;
  /* Match taper */
  clip-path: polygon(8% 0%, 92% 0%, 82% 100%, 18% 100%);
}

/* Foam on top of milk */
.milk-foam {
  position: absolute;
  bottom: 4px;
  left: 32px;
  width: 66px;
  height: 0;
  background: rgba(255, 255, 255, 0.85);
  border-radius: 6px 6px 0 0;
  transition: height 0.15s;
  pointer-events: none;
  clip-path: polygon(8% 0%, 92% 0%, 82% 100%, 18% 100%);
}

.milk-rub-zone {
  width: 240px;
  height: 60px;
  background: #231f1b;
  border-radius: 30px;
  margin-top: 24px;
  position: relative;
  overflow: hidden;
  touch-action: none;
  cursor: pointer;
}

.milk-rub-indicator {
  width: 48px;
  height: 48px;
  background: #E8A04C;
  border-radius: 50%;
  position: absolute;
  top: 6px;
  left: 6px;
  box-shadow: 0 0 12px rgba(217,119,6,0.4);
  transition: left 0.05s;
  pointer-events: none;
}

.milk-rub-zone::after {
  content: '\2194';
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 24px;
  color: rgba(255,255,255,0.15);
  font-family: sans-serif;
  pointer-events: none;
}

/* === LATTE ART (Step 3) === */
#art-area {
  position: relative;
  width: 240px;
  height: 240px;
  background: #3e1f0d;
  border-radius: 50%;
  overflow: hidden;
  box-shadow:
    0 0 0 6px #d7c3b2,
    0 0 0 8px #524437,
    0 4px 16px rgba(0,0,0,0.4);
}

#art-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  cursor: crosshair;
  touch-action: none;
}

.art-target {
  position: absolute;
  inset: 0;
  pointer-events: none;
  opacity: 0.15;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 120px;
}

.art-target::after {
  content: '\2665';
  color: #fff;
}

.art-done-btn {
  font-size: 9px;
  padding: 10px 20px;
  margin-top: 12px;
  background: transparent;
  border: 1px solid #524437;
  color: #d7c3b2;
}

/* === SCORE SCREEN === */
#score-content {
  text-align: center;
}

.pixel-coffee-result {
  display: flex;
  justify-content: center;
  margin-bottom: 24px;
}

.stars {
  font-size: 24px;
  margin-bottom: 16px;
  letter-spacing: 8px;
}

#score-title {
  font-size: 14px;
  margin-bottom: 12px;
  color: #E8A04C;
}

.score-comment {
  font-size: 9px;
  line-height: 1.8;
  color: #d7c3b2;
  margin-bottom: 32px;
  max-width: 300px;
}

/* === PARTY REVEAL === */
#screen-party {
  background: #16130f;
  z-index: 10;
  overflow-y: auto;
  justify-content: flex-start;
  padding-top: 40px;
  padding-bottom: 40px;
}

#confetti-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 0;
}

.party-content {
  position: relative;
  z-index: 1;
  text-align: center;
}

.party-title {
  font-size: 20px;
  line-height: 1.8;
  margin-bottom: 32px;
}

.big-number {
  font-size: 64px;
  color: #E8A04C;
  display: block;
  line-height: 1.2;
  text-shadow: 0 4px 0 #A85F04;
}

.party-details {
  background: #1f1b17;
  padding: 20px;
  margin-bottom: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-row {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  font-size: 10px;
  text-align: left;
}

.detail-icon {
  width: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.party-note {
  font-size: 9px;
  line-height: 1.8;
  color: #d7c3b2;
  margin-bottom: 32px;
}

/* === CERTIFICATE / URKUNDE === */
.certificate-frame {
  background: #1f1b17;
  border: 1px solid #524437;
  padding: 12px;
  margin-bottom: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

.cert-label {
  font-size: 8px;
  color: #E8A04C;
  letter-spacing: 3px;
}

#cert-canvas {
  width: 100px;
  height: 100px;
  border-radius: 50%;
  background: #3e1f0d;
  border: 2px solid #524437;
}

.cert-rating {
  font-size: 16px;
  letter-spacing: 4px;
}

.cert-comment {
  font-size: 8px;
  color: #d7c3b2;
  line-height: 1.6;
  text-align: center;
  max-width: 240px;
}

.share-cta {
  font-size: 9px;
  line-height: 1.8;
  color: #d7c3b2;
  text-align: center;
  margin-bottom: 12px;
}

/* Share & Replay Buttons */
.share-btn {
  font-size: 9px;
  padding: 14px 24px;
  margin-bottom: 12px;
}

.replay-btn {
  font-size: 10px;
  padding: 12px 24px;
  background: transparent;
  border: 1px solid #524437;
  color: #d7c3b2;
}

/* === SCREEN TRANSITIONS === */
.screen.slide-out {
  animation: slideOut 0.4s ease forwards;
}

.screen.slide-in {
  animation: slideIn 0.4s ease forwards;
}

@keyframes slideOut {
  0% { transform: translateX(0); opacity: 1; }
  100% { transform: translateX(-100%); opacity: 0; }
}

@keyframes slideIn {
  0% { transform: translateX(100%); opacity: 0; }
  100% { transform: translateX(0); opacity: 1; }
}

/* === SHAKE === */
.shake {
  animation: shake 0.1s ease;
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-4px); }
  75% { transform: translateX(4px); }
}

/* === RESPONSIVE === */
@media (max-height: 640px) {
  .pixel-coffee-big { margin-bottom: 16px; }
  .coffee-cup-large { width: 60px; height: 48px; }
  #screen-intro h1 { font-size: 14px; }
  .timer { font-size: 18px; }
  .big-number { font-size: 48px; }
  .party-title { font-size: 16px; }
}
