/* ═══════════════════════════════════════
   DOWN ROUND — PHONE EXPERIENCE
   ═══════════════════════════════════════ */

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

:root {
  --phone-width: 380px;
  --phone-height: 780px;
  --phone-radius: 50px;
  --screen-radius: 42px;
  --bezel: 12px;
  --notch-width: 160px;
  --notch-height: 34px;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #000;
  -webkit-font-smoothing: antialiased;
}

/* ── Page background ── */
#page-background {
  position: fixed;
  inset: 0;
  background: radial-gradient(ellipse at 50% 30%, #1a1a2e 0%, #0a0a0f 100%);
  z-index: 0;
}

/* ── Phone Container ── */
#phone-container {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
}

/* ── Phone Frame (Desktop) ── */
#phone-frame {
  width: var(--phone-width);
  height: var(--phone-height);
  border-radius: var(--phone-radius);
  background: #1a1a1a;
  padding: var(--bezel);
  position: relative;
  box-shadow:
    0 0 0 2px #333,
    0 0 0 4px #1a1a1a,
    0 30px 80px rgba(0, 0, 0, 0.8),
    0 0 120px rgba(100, 60, 180, 0.15),
    inset 0 0 2px rgba(255, 255, 255, 0.05);
}

/* Side buttons */
#phone-frame::before {
  content: '';
  position: absolute;
  right: -4px;
  top: 160px;
  width: 4px;
  height: 60px;
  background: #333;
  border-radius: 0 3px 3px 0;
}

#phone-frame::after {
  content: '';
  position: absolute;
  left: -4px;
  top: 140px;
  width: 4px;
  height: 35px;
  background: #333;
  border-radius: 3px 0 0 3px;
  box-shadow: 0 50px 0 #333, 0 90px 0 #333;
}

/* ── Phone Screen ── */
#phone-screen {
  width: 100%;
  height: 100%;
  border-radius: var(--screen-radius);
  background: #000;
  position: relative;
  overflow: hidden;
}

/* ── Notch ── */
#phone-notch {
  position: absolute;
  top: var(--bezel);
  left: 50%;
  transform: translateX(-50%);
  width: var(--notch-width);
  height: var(--notch-height);
  background: #1a1a1a;
  border-radius: 0 0 20px 20px;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
}

#phone-camera {
  width: 12px;
  height: 12px;
  background: #0d0d0d;
  border-radius: 50%;
  border: 2px solid #1f1f1f;
}

/* ── Wallpaper ── */
#screen-wallpaper {
  position: absolute;
  inset: 0;
  background: url('background.jpg') center center / cover no-repeat;
  z-index: 0;
}

#screen-wallpaper::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    180deg,
    rgba(0, 0, 0, 0.3) 0%,
    rgba(0, 0, 0, 0.1) 30%,
    rgba(0, 0, 0, 0.1) 60%,
    rgba(0, 0, 0, 0.5) 100%
  );
}

/* ── Status Bar ── */
#status-bar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 28px 0;
  z-index: 50;
  color: white;
  font-size: 14px;
  font-weight: 600;
}

#status-icons {
  display: flex;
  align-items: center;
  gap: 6px;
}

/* ── Screens ── */
.screen {
  position: absolute;
  inset: 0;
  z-index: 10;
  display: flex;
  flex-direction: column;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.5s ease;
}

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

/* ═══════════════════════════════════════
   INCOMING CALL SCREEN
   ═══════════════════════════════════════ */

#call-screen {
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(30px);
  -webkit-backdrop-filter: blur(30px);
  align-items: center;
  justify-content: space-between;
  padding: 80px 30px 50px;
}

#call-info {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
}

#caller-avatar {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6c5ce7, #a855f7);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
  position: relative;
  margin-bottom: 10px;
}

#avatar-ring {
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid rgba(168, 85, 247, 0.6);
  animation: ringPulse 2s ease-in-out infinite;
}

@keyframes ringPulse {
  0%, 100% { transform: scale(1); opacity: 0.6; }
  50% { transform: scale(1.15); opacity: 0; }
}

#caller-name {
  font-size: 30px;
  font-weight: 600;
  color: white;
  letter-spacing: -0.5px;
}

#call-label {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.6);
  font-weight: 400;
}

#call-status {
  font-size: 15px;
  color: rgba(255, 255, 255, 0.8);
  font-weight: 400;
  animation: statusBlink 1.5s ease-in-out infinite;
}

@keyframes statusBlink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

#call-actions {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 60px;
}

.call-btn {
  width: 70px;
  height: 70px;
  border-radius: 50%;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.call-btn:active {
  transform: scale(0.92);
}

.call-btn.decline {
  background: #ef4444;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.5);
}

.call-btn.answer {
  background: #22c55e;
  box-shadow: 0 4px 20px rgba(34, 197, 94, 0.5);
  animation: answerPulse 1.8s ease-in-out infinite;
}

@keyframes answerPulse {
  0%, 100% { box-shadow: 0 4px 20px rgba(34, 197, 94, 0.5); }
  50% { box-shadow: 0 4px 40px rgba(34, 197, 94, 0.8), 0 0 60px rgba(34, 197, 94, 0.3); }
}

#swipe-hint {
  color: rgba(255, 255, 255, 0.4);
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.5px;
}

/* ═══════════════════════════════════════
   PLAYER SCREEN
   ═══════════════════════════════════════ */

#player-screen {
  background: rgba(0, 0, 0, 0.6);
  backdrop-filter: blur(40px);
  -webkit-backdrop-filter: blur(40px);
}

#player-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 70px 24px 30px;
  height: 100%;
  justify-content: center;
  gap: 16px;
}

#episode-art {
  width: 240px;
  height: 240px;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.5);
  flex-shrink: 0;
}

#album-art-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

#episode-info {
  text-align: center;
  width: 100%;
}

#episode-title {
  font-size: 20px;
  font-weight: 600;
  color: white;
  letter-spacing: -0.3px;
  margin-bottom: 4px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#episode-show {
  font-size: 14px;
  color: rgba(255, 255, 255, 0.5);
  font-weight: 400;
}

/* Progress bar */
#progress-container {
  width: 100%;
}

#progress-bar {
  width: 100%;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

#progress-fill {
  height: 100%;
  background: white;
  border-radius: 2px;
  width: 0%;
  transition: width 0.1s linear;
}

#progress-knob {
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 0%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.2s;
}

#progress-container:hover #progress-knob {
  opacity: 1;
}

#progress-times {
  display: flex;
  justify-content: space-between;
  margin-top: 6px;
  font-size: 11px;
  color: rgba(255, 255, 255, 0.4);
  font-weight: 500;
  font-variant-numeric: tabular-nums;
}

/* Controls */
#player-controls {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 36px;
}

.control-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  border-radius: 50%;
  transition: background 0.15s, transform 0.1s;
}

.control-btn:hover {
  background: rgba(255, 255, 255, 0.1);
}

.control-btn:active {
  transform: scale(0.9);
}

.play-btn {
  width: 64px;
  height: 64px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 50%;
}

.play-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

/* Volume */
#volume-container {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
}

#volume-bar {
  flex: 1;
  height: 4px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 2px;
  position: relative;
  cursor: pointer;
}

#volume-fill {
  height: 100%;
  background: white;
  border-radius: 2px;
  width: 70%;
}

#volume-knob {
  width: 12px;
  height: 12px;
  background: white;
  border-radius: 50%;
  position: absolute;
  top: 50%;
  left: 70%;
  transform: translate(-50%, -50%);
  box-shadow: 0 0 6px rgba(0, 0, 0, 0.3);
  opacity: 0;
  transition: opacity 0.2s;
}

#volume-container:hover #volume-knob {
  opacity: 1;
}

/* Hangup button */
.hangup-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  background: #ef4444;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
  transition: transform 0.15s, box-shadow 0.15s;
  margin-top: 4px;
  flex-shrink: 0;
}

.hangup-btn:active {
  transform: scale(0.9);
}

/* ═══════════════════════════════════════
   BONZI BUDDY
   ═══════════════════════════════════════ */

#bonzi-container {
  position: absolute;
  bottom: 70px;
  right: 8px;
  z-index: 200;
  display: flex;
  flex-direction: column;
  align-items: center;
  animation: bonziBounce 3s ease-in-out infinite;
}

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

#bonzi-speech {
  background: #ffffcc;
  border: 2px solid #333;
  border-radius: 12px;
  padding: 8px 12px;
  font-size: 11px;
  font-weight: 700;
  color: #333;
  position: relative;
  max-width: 130px;
  text-align: center;
  box-shadow: 2px 2px 6px rgba(0, 0, 0, 0.3);
  font-family: 'Comic Sans MS', 'Chalkboard SE', cursive;
  margin-bottom: 6px;
}

#bonzi-speech-arrow {
  position: absolute;
  bottom: -8px;
  left: 50%;
  transform: translateX(-50%);
  width: 0;
  height: 0;
  border-left: 8px solid transparent;
  border-right: 8px solid transparent;
  border-top: 8px solid #ffffcc;
}

#bonzi-speech-arrow::before {
  content: '';
  position: absolute;
  top: -11px;
  left: -10px;
  width: 0;
  height: 0;
  border-left: 10px solid transparent;
  border-right: 10px solid transparent;
  border-top: 10px solid #333;
  z-index: -1;
}

#bonzi-link {
  display: block;
  transition: transform 0.15s;
}

#bonzi-link:hover {
  transform: scale(1.1);
}

#bonzi-img {
  width: 70px;
  height: auto;
  filter: drop-shadow(2px 2px 4px rgba(0, 0, 0, 0.4));
}

/* ═══════════════════════════════════════
   WINDOWS ERROR POPUPS
   ═══════════════════════════════════════ */

#popups-container {
  position: absolute;
  inset: 0;
  z-index: 300;
  pointer-events: none;
}

#popups-container.active {
  pointer-events: all;
}

.win-error {
  position: absolute;
  background: #ECE9D8;
  border: 2px solid #0054E3;
  border-radius: 8px 8px 0 0;
  box-shadow: 3px 3px 10px rgba(0, 0, 0, 0.5), inset 0 0 0 1px #fff;
  min-width: 220px;
  max-width: 280px;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  animation: popupAppear 0.15s ease-out;
  cursor: default;
  user-select: none;
}

@keyframes popupAppear {
  0% { transform: scale(0.5); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

.win-error-titlebar {
  background: linear-gradient(180deg, #0A246A 0%, #3A6EA5 8%, #0054E3 40%, #0054E3 88%, #0A246A 100%);
  color: white;
  font-size: 12px;
  font-weight: 700;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-radius: 6px 6px 0 0;
}

.win-error-titlebar span {
  display: flex;
  align-items: center;
  gap: 4px;
}

.win-error-titlebar span::before {
  content: '';
  display: inline-block;
  width: 16px;
  height: 16px;
  background: radial-gradient(circle at 30% 30%, #ff6b6b, #cc0000);
  border-radius: 50%;
  font-size: 10px;
  line-height: 16px;
  text-align: center;
}

.win-error-close {
  width: 20px;
  height: 20px;
  background: linear-gradient(180deg, #c46148 0%, #d28e78 50%, #c46148 100%);
  border: 1px solid #7e3828;
  border-radius: 3px;
  color: white;
  font-size: 11px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  cursor: pointer;
}

.win-error-close:hover {
  background: linear-gradient(180deg, #e07050 0%, #e8a898 50%, #e07050 100%);
}

.win-error-body {
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
}

.win-error-body .error-content {
  display: flex;
  align-items: flex-start;
  gap: 12px;
}

.win-error-icon {
  font-size: 28px;
  flex-shrink: 0;
}

.win-error-message {
  font-size: 12px;
  color: #000;
  line-height: 1.4;
}

.win-error-ok {
  background: linear-gradient(180deg, #fff 0%, #ECE9D8 100%);
  border: 1px solid #003C74;
  border-radius: 3px;
  padding: 4px 28px;
  font-size: 12px;
  font-weight: 400;
  cursor: pointer;
  color: #000;
  box-shadow: 1px 1px 2px rgba(0,0,0,0.15);
  outline: 1px dotted transparent;
  font-family: 'Segoe UI', Tahoma, sans-serif;
}

.win-error-ok:hover {
  background: linear-gradient(180deg, #fff 0%, #d0cfc0 100%);
}

.win-error-ok:active {
  background: #c0c0b0;
}

.win-error-ok:focus {
  outline: 1px dotted #000;
  outline-offset: -4px;
}

/* ═══════════════════════════════════════
   MOBILE RESPONSIVE — Just the screen
   ═══════════════════════════════════════ */

@media (max-width: 500px) {
  :root {
    --phone-width: 100vw;
    --phone-height: 100vh;
    --phone-radius: 0;
    --screen-radius: 0;
    --bezel: 0;
  }

  #page-background {
    display: none;
  }

  #phone-frame {
    width: 100vw;
    height: 100vh;
    border-radius: 0;
    padding: 0;
    box-shadow: none;
    background: #000;
  }

  #phone-frame::before,
  #phone-frame::after {
    display: none;
  }

  #phone-notch {
    display: none;
  }

  #phone-screen {
    border-radius: 0;
  }

  #status-bar {
    padding: 16px 24px 0;
    /* Account for iPhone notch */
    padding-top: max(16px, env(safe-area-inset-top));
  }

  #call-screen {
    padding-top: max(100px, calc(env(safe-area-inset-top) + 60px));
    padding-bottom: max(40px, calc(env(safe-area-inset-bottom) + 20px));
  }

  #player-content {
    padding-top: max(70px, calc(env(safe-area-inset-top) + 40px));
    padding-bottom: max(30px, calc(env(safe-area-inset-bottom) + 10px));
  }

  #bonzi-container {
    bottom: max(70px, calc(env(safe-area-inset-bottom) + 50px));
  }

  #episode-art {
    width: 260px;
    height: 260px;
  }
}

/* Slightly larger phones */
@media (max-width: 500px) and (min-height: 750px) {
  #episode-art {
    width: 280px;
    height: 280px;
  }
}

/* Very tall phones / large desktops */
@media (min-width: 501px) and (min-height: 900px) {
  :root {
    --phone-width: 400px;
    --phone-height: 840px;
  }

  #episode-art {
    width: 260px;
    height: 260px;
  }
}

/* Really large screens */
@media (min-width: 1200px) {
  :root {
    --phone-width: 420px;
    --phone-height: 880px;
  }
}
