/* ===== Reset & Base ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  height: 100%;
  overflow: hidden;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: #0a0f0a;
  color: #f0e6d3;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

.screen {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  transition: opacity 0.5s ease;
}

.hidden {
  display: none !important;
}

/* ===== Lock Screen ===== */
#lock-screen {
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, #0a0f0a 0%, #1a1a2e 50%, #0a0f0a 100%);
  background-size: 400% 400%;
  animation: bgShift 8s ease infinite;
  overflow: hidden;
}

.lock-content {
  position: relative;
  z-index: 2;
  text-align: center;
  padding: 2rem;
}

.lock-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  animation: lockBounce 2s ease-in-out infinite;
  filter: grayscale(0.3);
}

.lock-title {
  font-size: 1.8rem;
  font-weight: 700;
  color: #d4af37;
  margin-bottom: 0.5rem;
  text-shadow: 0 0 20px rgba(212, 175, 55, 0.3);
}

.lock-message {
  font-size: 1.1rem;
  color: #a09880;
  margin-bottom: 1.5rem;
  line-height: 1.5;
}

.countdown {
  font-size: 2.5rem;
  font-weight: 700;
  color: #d4af37;
  font-variant-numeric: tabular-nums;
  text-shadow: 0 0 30px rgba(212, 175, 55, 0.4);
  letter-spacing: 0.05em;
}

/* Floating orbs background */
.bg-orbs {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
}

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(80px);
  opacity: 0.15;
}

.orb-1 {
  width: 300px;
  height: 300px;
  background: #d4af37;
  top: -100px;
  right: -80px;
  animation: orbFloat 6s ease-in-out infinite;
}

.orb-2 {
  width: 250px;
  height: 250px;
  background: #8b0000;
  bottom: -80px;
  left: -60px;
  animation: orbFloat 8s ease-in-out infinite reverse;
}

.orb-3 {
  width: 200px;
  height: 200px;
  background: #d4af37;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation: orbPulse 4s ease-in-out infinite;
}

/* ===== Active Screen ===== */
#active-screen {
  background: linear-gradient(180deg, #0a0f0a 0%, #0f1a0f 50%, #0a0f0a 100%);
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem 1.2rem;
  padding-top: max(1rem, env(safe-area-inset-top));
}

.app-title {
  font-size: 1.3rem;
  font-weight: 700;
  color: #d4af37;
  text-shadow: 0 0 15px rgba(212, 175, 55, 0.3);
}

.chip-counter {
  font-size: 1.3rem;
  font-weight: 700;
  color: #f0e6d3;
  font-variant-numeric: tabular-nums;
}

#chips-remaining {
  color: #d4af37;
  font-size: 1.5rem;
}

/* ===== Progress Bar ===== */
.progress-bar-container {
  margin: 0 1.2rem 0.5rem;
  height: 4px;
  background: rgba(212, 175, 55, 0.15);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  width: 100%;
  background: linear-gradient(90deg, #d4af37, #f0c850);
  border-radius: 2px;
  transition: width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 0 8px rgba(212, 175, 55, 0.5);
}

/* ===== Swipe Hint ===== */
.swipe-hint {
  text-align: center;
  padding: 0.5rem;
  font-size: 0.9rem;
  color: #a09880;
  animation: hintFade 3s ease-in-out infinite;
}

.swipe-hint.dismissed {
  animation: fadeOut 0.5s ease forwards;
}

.hint-arrow {
  display: inline-block;
  animation: hintSlide 1.5s ease-in-out infinite;
  font-size: 1.1rem;
}

/* ===== Chip Grid ===== */
.chip-grid {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(4, 1fr);
  gap: 0.8rem;
  padding: 0.8rem 1.2rem 1.5rem;
  align-items: center;
  justify-items: center;
}

/* ===== Poker Chip ===== */
.poker-chip {
  position: relative;
  width: min(22vw, 90px);
  height: min(22vw, 90px);
  border-radius: 50%;
  cursor: grab;
  touch-action: pan-y;
  will-change: transform;
  animation: chipEnter 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) backwards;
}

.poker-chip .chip-body {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%,
    #e84040 0%,
    #c62828 40%,
    #8b0000 100%
  );
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.25),
    inset 0 -2px 4px rgba(0, 0, 0, 0.4),
    0 4px 12px rgba(0, 0, 0, 0.5),
    0 0 20px rgba(212, 175, 55, 0.1);
  animation: chipGlow 3s ease-in-out infinite;
}

/* Chip edge dashes */
.poker-chip .chip-edge {
  position: absolute;
  inset: 3px;
  border-radius: 50%;
  border: 3px dashed rgba(255, 255, 255, 0.5);
}

/* Inner ring */
.poker-chip .chip-inner-ring {
  position: absolute;
  inset: 15%;
  border-radius: 50%;
  border: 2px solid rgba(212, 175, 55, 0.6);
  background: radial-gradient(circle at 35% 35%,
    #d63030 0%,
    #b71c1c 100%
  );
}

/* Chip number */
.poker-chip .chip-number {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: min(5vw, 22px);
  font-weight: 800;
  color: #fff;
  text-shadow:
    0 1px 2px rgba(0, 0, 0, 0.5),
    0 0 10px rgba(212, 175, 55, 0.3);
  z-index: 1;
}

/* Swiping state */
.poker-chip.swiping {
  cursor: grabbing;
  z-index: 10;
}

.poker-chip.swiping .chip-body {
  animation: none;
  box-shadow:
    inset 0 2px 4px rgba(255, 255, 255, 0.25),
    inset 0 -2px 4px rgba(0, 0, 0, 0.4),
    0 8px 24px rgba(0, 0, 0, 0.6),
    0 0 30px rgba(212, 175, 55, 0.2);
}

/* Swipe out animation */
.poker-chip.swipe-out {
  animation: chipSwipeOut 0.5s cubic-bezier(0.4, 0, 1, 1) forwards;
  pointer-events: none;
}

/* ===== Keyframe Animations ===== */

@keyframes bgShift {
  0%, 100% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
}

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

@keyframes orbFloat {
  0%, 100% { transform: translate(0, 0); }
  50% { transform: translate(30px, -30px); }
}

@keyframes orbPulse {
  0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.1; }
  50% { transform: translate(-50%, -50%) scale(1.3); opacity: 0.2; }
}

@keyframes chipEnter {
  0% {
    opacity: 0;
    transform: scale(0) rotate(-180deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

@keyframes chipGlow {
  0%, 100% {
    box-shadow:
      inset 0 2px 4px rgba(255, 255, 255, 0.25),
      inset 0 -2px 4px rgba(0, 0, 0, 0.4),
      0 4px 12px rgba(0, 0, 0, 0.5),
      0 0 15px rgba(212, 175, 55, 0.1);
  }
  50% {
    box-shadow:
      inset 0 2px 4px rgba(255, 255, 255, 0.25),
      inset 0 -2px 4px rgba(0, 0, 0, 0.4),
      0 4px 12px rgba(0, 0, 0, 0.5),
      0 0 25px rgba(212, 175, 55, 0.25);
  }
}

@keyframes chipSwipeOut {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translateX(-150vw) rotate(-45deg);
  }
}

@keyframes hintFade {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}

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

@keyframes fadeOut {
  to { opacity: 0; height: 0; padding: 0; overflow: hidden; }
}

@keyframes screenFadeIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

/* Screen transition */
#active-screen:not(.hidden) {
  animation: screenFadeIn 0.6s ease;
}

/* ===== Responsive ===== */
@media (min-width: 500px) {
  .chip-grid {
    max-width: 400px;
    margin: 0 auto;
  }
}

@media (max-height: 600px) {
  .poker-chip {
    width: min(18vw, 70px);
    height: min(18vw, 70px);
  }

  .chip-grid {
    gap: 0.4rem;
    padding: 0.4rem 1rem 1rem;
  }

  .app-header {
    padding: 0.5rem 1rem;
  }
}
