/* ═══════════════════════════════════════════════
   Raspadita — Game Styles
   Premium dark theme with gold accents
   ═══════════════════════════════════════════════ */

/* ── Google Fonts ── */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800;900&family=Outfit:wght@400;500;600;700;800;900&display=swap');

/* ── CSS Custom Properties (driven by config branding) ── */
:root {
  --primary: #ffd700;
  --accent: #ff6b6b;
  --bg: #0f0f23;
  --bg-card: #1a1a3e;
  --surface: #16162e;
  --text: #e8e8f0;
  --text-muted: #8888aa;
  --font: 'Inter', sans-serif;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow-glow: 0 0 30px rgba(255, 215, 0, 0.15);
}

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

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* ── App Shell ── */
.app-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  position: relative;
  overflow: hidden;
}

/* Background gradient overlay */
.app-container::before {
  content: '';
  position: absolute;
  inset: 0;
  background: 
    radial-gradient(ellipse at 30% 20%, rgba(255, 215, 0, 0.06) 0%, transparent 50%),
    radial-gradient(ellipse at 70% 80%, rgba(255, 107, 107, 0.04) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* ── Header ── */
.game-header {
  text-align: center;
  margin-bottom: 32px;
  z-index: 1;
  position: relative;
}

.game-logo {
  max-height: 60px;
  margin-bottom: 12px;
}

.game-title {
  font-family: 'Outfit', var(--font);
  font-size: 2.5rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--primary), #ffec6e, var(--primary));
  background-size: 200% 200%;
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  animation: shimmerText 3s ease-in-out infinite;
  letter-spacing: -0.02em;
}

.game-subtitle {
  font-size: 0.95rem;
  color: var(--text-muted);
  margin-top: 6px;
  font-weight: 400;
}

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

/* ── Scratch Instruction ── */
.scratch-instruction {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 100;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  padding: 14px 28px;
  border-radius: 50px;
  font-size: 1rem;
  font-weight: 600;
  color: #ffffff;
  pointer-events: none;
  animation: floatInstruction 2s ease-in-out infinite;
  transition: opacity 0.5s ease, transform 0.5s ease;
  white-space: nowrap;
}

.scratch-instruction.hidden {
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.8);
  pointer-events: none;
}

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

/* ── Game Area ── */
.game-area {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 800px;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

/* ── Zones Container — Layout Presets ── */
.zones-container {
  display: flex;
  gap: 20px;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  width: 100%;
}

.zones-container.layout-single {
  flex-direction: column;
}

.zones-container.layout-single .scratch-zone {
  width: min(580px, 90vw);
  height: min(380px, 50vh);
}

.zones-container.layout-triple {
  flex-direction: row;
}

.zones-container.layout-triple .scratch-zone {
  width: min(240px, 28vw);
  height: min(280px, 40vh);
  flex: 1;
  max-width: 260px;
}

.zones-container.layout-grid-6 {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  max-width: 700px;
}

.zones-container.layout-grid-6 .scratch-zone {
  width: 100%;
  height: min(200px, 25vh);
}

/* ── Individual Scratch Zone ── */
.scratch-zone {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  box-shadow: 
    0 4px 24px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.05);
  cursor: crosshair;
}

/* Shimmer effect on intact foil */
.scratch-zone::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(
    115deg,
    transparent 30%,
    rgba(255, 255, 255, 0.08) 45%,
    rgba(255, 255, 255, 0.12) 50%,
    rgba(255, 255, 255, 0.08) 55%,
    transparent 70%
  );
  background-size: 300% 100%;
  animation: shimmerFoil 4s ease-in-out infinite;
  pointer-events: none;
  z-index: 5;
  border-radius: inherit;
}

@keyframes shimmerFoil {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* ── Canvas Layers ── */
.scratch-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  border-radius: inherit;
}

.particle-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 4;
  pointer-events: none;
  border-radius: inherit;
}

/* ── Prize Content ── */
.prize-content {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 1;
  padding: 16px;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.3s ease;
  transform: scale(0.85);
  opacity: 0.7;
}

.prize-content.prize-revealed {
  transform: scale(1);
  opacity: 1;
  animation: prizePopIn 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

.prize-content.prize-winner {
  animation: prizeWin 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) forwards;
}

@keyframes prizePopIn {
  0% { transform: scale(0.7); opacity: 0.5; }
  60% { transform: scale(1.08); opacity: 1; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes prizeWin {
  0% { transform: scale(1); }
  30% { transform: scale(1.15); }
  60% { transform: scale(0.95); }
  100% { transform: scale(1.05); filter: drop-shadow(0 0 20px rgba(255, 215, 0, 0.6)); }
}

.prize-symbol {
  font-size: 64px;
  line-height: 1;
}

.prize-text {
  font-family: 'Outfit', var(--font);
  font-weight: 800;
  text-align: center;
  line-height: 1.1;
  text-shadow: 0 2px 12px rgba(0, 0, 0, 0.5);
}

.prize-image {
  max-width: 80%;
  max-height: 60%;
  object-fit: contain;
  border-radius: 8px;
}

.prize-label {
  display: block;
  margin-top: 8px;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  text-align: center;
}

/* ── Game Result Banner ── */
.game-result-banner {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0);
  z-index: 200;
  padding: 28px 48px;
  border-radius: 20px;
  text-align: center;
  opacity: 0;
  transition: all 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  pointer-events: none;
}

.game-result-banner.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
  pointer-events: auto;
}

.game-result-banner.winner {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  border: 2px solid var(--primary);
  box-shadow: 
    0 0 40px rgba(255, 215, 0, 0.3),
    0 20px 60px rgba(0, 0, 0, 0.5);
}

.game-result-banner.loser {
  background: linear-gradient(135deg, #1a1a2e 0%, #2d1b2e 100%);
  border: 2px solid rgba(255, 107, 107, 0.4);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.result-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 8px;
}

.result-text {
  font-family: 'Outfit', var(--font);
  font-size: 2rem;
  font-weight: 800;
}

.winner .result-text {
  background: linear-gradient(135deg, var(--primary), #ffec6e);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.loser .result-text {
  color: var(--text-muted);
}

/* ── Confetti ── */
.confetti-container {
  position: fixed;
  inset: 0;
  z-index: 300;
  pointer-events: none;
  overflow: hidden;
}

.confetti-piece {
  position: absolute;
  top: -20px;
  left: var(--x);
  width: var(--size);
  height: var(--size);
  background: var(--color);
  border-radius: 2px;
  animation: confettiFall 2.5s cubic-bezier(0.25, 0.46, 0.45, 0.94) forwards;
  animation-delay: var(--delay);
  transform: rotate(var(--rotation));
}

@keyframes confettiFall {
  0% {
    transform: translateY(0) rotate(0deg) scale(1);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg) scale(0.5);
    opacity: 0;
  }
}

/* ── Controls Bar ── */
.controls-bar {
  display: flex;
  gap: 12px;
  align-items: center;
  justify-content: center;
  margin-top: 28px;
  z-index: 10;
  position: relative;
}

.admin-hotspot {
  position: fixed;
  right: 0;
  bottom: 0;
  width: 96px;
  height: 96px;
  z-index: 500;
  border: 0;
  background: transparent;
  opacity: 0;
  cursor: default;
  touch-action: none;
}

.admin-pin-overlay {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: rgba(4, 4, 12, 0.78);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
}

.admin-pin-form {
  width: min(320px, 100%);
  display: grid;
  gap: 12px;
  padding: 22px;
  border-radius: 12px;
  background: #151528;
  border: 1px solid rgba(255, 255, 255, 0.14);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.45);
}

.admin-pin-title {
  font-size: 1rem;
  font-weight: 800;
  color: var(--text);
}

.admin-pin-input {
  width: 100%;
  height: 48px;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
  color: var(--text);
  font: inherit;
  font-size: 1.2rem;
  padding: 0 14px;
  outline: none;
}

.admin-pin-input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(255, 215, 0, 0.18);
}

.admin-pin-error {
  min-height: 18px;
  color: #ff6b6b;
  font-size: 0.82rem;
}

.admin-pin-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.admin-pin-cancel,
.admin-pin-submit {
  min-height: 40px;
  border: 0;
  border-radius: 8px;
  padding: 0 16px;
  font: inherit;
  font-weight: 700;
  cursor: pointer;
}

.admin-pin-cancel {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
}

.admin-pin-submit {
  background: var(--primary);
  color: #151528;
}

.admin-pin-shake .admin-pin-form {
  animation: adminPinShake 0.22s ease;
}

@keyframes adminPinShake {
  0%, 100% { transform: translateX(0); }
  30% { transform: translateX(-8px); }
  70% { transform: translateX(8px); }
}

.btn {
  padding: 12px 28px;
  border: none;
  border-radius: 50px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  outline: none;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.96);
}

.btn-primary {
  background: linear-gradient(135deg, var(--primary), #ffb800);
  color: #1a1a2e;
  box-shadow: 0 4px 16px rgba(255, 215, 0, 0.25);
}

.btn-primary:hover {
  box-shadow: 0 6px 24px rgba(255, 215, 0, 0.4);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid rgba(255, 255, 255, 0.1);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
}

/* ── Responsive ── */
@media (max-width: 600px) {
  .game-title {
    font-size: 1.8rem;
  }
  
  .zones-container.layout-triple {
    flex-direction: column;
  }
  
  .zones-container.layout-triple .scratch-zone {
    width: 80vw;
    max-width: none;
    height: min(200px, 25vh);
  }
  
  .zones-container.layout-grid-6 {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* ── Kiosk Mode (1080×1920 portrait) ── */
@media (min-height: 1400px) and (max-width: 1200px) {
  .game-title {
    font-size: 3.2rem;
  }
  
  .game-subtitle {
    font-size: 1.2rem;
  }
  
  .zones-container {
    gap: 28px;
  }
  
  .zones-container.layout-single .scratch-zone {
    width: min(700px, 85vw);
    height: min(460px, 30vh);
  }
  
  .zones-container.layout-triple .scratch-zone {
    width: min(300px, 30vw);
    height: min(360px, 22vh);
  }
  
  .btn {
    padding: 16px 36px;
    font-size: 1.1rem;
  }
  
  .scratch-instruction {
    font-size: 1.2rem;
    padding: 18px 36px;
  }
}
