@import url('https://fonts.googleapis.com/css2?family=Cinzel:wght@700;900&family=Outfit:wght@400;500;600;700&family=Playfair+Display:ital,wght@0,600;0,700;1,600&display=swap');

:root {
  --color-pine: #0c2317;
  --color-pine-deep: #07170f;
  --color-crimson: #a81c2b;
  --color-crimson-dark: #6e101b;
  --color-gold: #f2cb66;
  --color-gold-bright: #ffe699;
  --color-gold-deep: #b8860b;
  --color-cream: #faf5ea;
  --color-cream-muted: #e6decb;
  --font-serif: 'Playfair Display', Georgia, serif;
  --font-display: 'Cinzel', serif;
  --font-sans: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --shadow-gold: 0 0 25px rgba(242, 203, 102, 0.45);
  --shadow-card: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 1px rgba(255, 255, 255, 0.2);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
  -webkit-user-select: none;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--color-pine-deep);
  font-family: var(--font-sans);
  color: var(--color-cream);
  touch-action: none;
}

/* Background atmosphere container on wide screens */
.app-container {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(circle at 50% 40%, #173824 0%, #07160e 100%);
  position: relative;
  overflow: hidden;
}

/* Desktop festive blur backdrop */
.app-backdrop-blur {
  position: absolute;
  top: -20px;
  left: -20px;
  right: -20px;
  bottom: -20px;
  background-image: url('assets/fireplace_bg.jpg');
  background-size: cover;
  background-position: center;
  filter: blur(35px) brightness(0.35);
  transform: scale(1.1);
  z-index: 0;
  opacity: 0.85;
}

/* Responsive Game Stage maintaining 9:16 aspect ratio up to screen bounds */
.game-viewport {
  position: relative;
  width: 100%;
  height: 100%;
  max-width: calc(100vh * (9 / 16));
  max-height: 100vh;
  aspect-ratio: 9 / 16;
  margin: auto;
  box-shadow: 0 0 80px rgba(0, 0, 0, 0.9), 0 0 2px rgba(242, 203, 102, 0.3);
  overflow: hidden;
  z-index: 1;
  background: #000;
}

/* Primary Game Canvas */
#gameCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: block;
  z-index: 2;
  cursor: grab;
}

#gameCanvas:active {
  cursor: grabbing;
}

/* UI Layer Overlay */
.ui-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 10;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: max(16px, env(safe-area-inset-top)) max(16px, env(safe-area-inset-right)) max(16px, env(safe-area-inset-bottom)) max(16px, env(safe-area-inset-left));
}

/* Top HUD */
.hud-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  width: 100%;
  pointer-events: auto;
}

.hud-pill {
  background: rgba(12, 35, 23, 0.78);
  border: 1px solid rgba(242, 203, 102, 0.35);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: 999px;
  padding: 8px 16px;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4), inset 0 1px 0 rgba(255, 255, 255, 0.15);
  display: flex;
  flex-direction: column;
  align-items: center;
}

.hud-score-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1.5px;
  color: var(--color-gold);
  font-weight: 600;
}

.hud-score-val {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: #fff;
  text-shadow: 0 0 12px rgba(242, 203, 102, 0.6);
  line-height: 1.1;
  min-width: 60px;
  text-align: center;
}

/* Throws remaining rack */
.hud-throws-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
}

.hud-throws-title {
  font-size: 10px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--color-cream-muted);
}

.hud-throws-dots {
  display: flex;
  gap: 5px;
}

.throw-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(242, 203, 102, 0.3);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.throw-dot.remaining {
  background: radial-gradient(circle at 35% 35%, #ffe699, #d49826);
  box-shadow: 0 0 8px rgba(242, 203, 102, 0.7);
  border-color: #fff;
}

.throw-dot.hit {
  background: radial-gradient(circle at 35% 35%, #7bf2a6, #168a42);
  box-shadow: 0 0 8px rgba(78, 222, 128, 0.7);
  border-color: #a7f3d0;
  transform: scale(1.15);
}

.throw-dot.miss {
  background: rgba(120, 120, 120, 0.4);
  border-color: rgba(255, 255, 255, 0.15);
  transform: scale(0.85);
}

/* Sound Button */
.btn-icon-audio {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(12, 35, 23, 0.78);
  border: 1px solid rgba(242, 203, 102, 0.4);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4);
  color: var(--color-gold);
  transition: transform 0.2s, background-color 0.2s;
  pointer-events: auto;
}

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

.btn-icon-audio svg {
  width: 22px;
  height: 22px;
  fill: currentColor;
}

/* Combo Streak Banner */
.combo-banner {
  position: absolute;
  top: 72px;
  left: 50%;
  transform: translateX(-50%) scale(0.8);
  opacity: 0;
  pointer-events: none;
  background: linear-gradient(135deg, rgba(168, 28, 43, 0.95), rgba(110, 16, 27, 0.95));
  border: 1.5px solid var(--color-gold);
  border-radius: 999px;
  padding: 6px 20px;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 8px 25px rgba(168, 28, 43, 0.6), 0 0 15px rgba(242, 203, 102, 0.5);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.combo-banner.visible {
  opacity: 1;
  transform: translateX(-50%) scale(1);
}

.combo-text {
  font-family: var(--font-display);
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  letter-spacing: 1px;
}

.combo-multiplier {
  font-size: 14px;
  font-weight: 700;
  color: var(--color-gold-bright);
  background: rgba(0, 0, 0, 0.25);
  padding: 2px 8px;
  border-radius: 999px;
}

/* Bottom Hint / Controls Guide */
.hud-bottom {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
  margin-bottom: 8px;
}

/* Animated Hand Hint for first throw */
.tutorial-hint {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  animation: pulseHint 2s infinite ease-in-out;
  transition: opacity 0.5s ease;
  pointer-events: none;
}

.tutorial-hint.hidden {
  opacity: 0;
  pointer-events: none;
}

.hand-icon {
  width: 36px;
  height: 36px;
  filter: drop-shadow(0 4px 10px rgba(0,0,0,0.7));
  animation: handDrag 2s infinite ease-in-out;
}

@keyframes handDrag {
  0% { transform: translateY(-8px) scale(1); }
  45% { transform: translateY(22px) scale(0.92); }
  60% { transform: translateY(22px) scale(0.92); }
  100% { transform: translateY(-8px) scale(1); }
}

@keyframes pulseHint {
  0%, 100% { opacity: 0.9; }
  50% { opacity: 0.45; }
}

.tutorial-text {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-gold-bright);
  text-shadow: 0 2px 6px rgba(0,0,0,0.8), 0 0 12px rgba(242, 203, 102, 0.6);
  letter-spacing: 0.5px;
  background: rgba(7, 22, 14, 0.65);
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid rgba(242, 203, 102, 0.3);
}

.item-info-tag {
  font-size: 13px;
  font-weight: 500;
  color: var(--color-cream);
  background: rgba(12, 35, 23, 0.7);
  padding: 4px 14px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(8px);
}

/* Modals (Start Screen, Results Screen, Holiday Card) */
.modal-screen {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(7, 22, 14, 0.82);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.4s ease, transform 0.4s ease;
}

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

.modal-card {
  width: 100%;
  max-width: 380px;
  background: linear-gradient(165deg, rgba(23, 56, 36, 0.95) 0%, rgba(12, 35, 23, 0.98) 100%);
  border: 2px solid var(--color-gold);
  border-radius: 28px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow-card), var(--shadow-gold);
  position: relative;
  overflow: hidden;
  transform: translateY(20px) scale(0.95);
  transition: transform 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.modal-screen.active .modal-card {
  transform: translateY(0) scale(1);
}

/* Gold decorative corner accents */
.modal-card::before, .modal-card::after {
  content: '✦';
  position: absolute;
  color: var(--color-gold);
  font-size: 16px;
  opacity: 0.8;
}
.modal-card::before { top: 12px; left: 16px; }
.modal-card::after { top: 12px; right: 16px; }

.modal-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(242, 203, 102, 0.15);
  border: 1px solid var(--color-gold);
  color: var(--color-gold-bright);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  padding: 4px 14px;
  border-radius: 999px;
  margin-bottom: 16px;
}

.modal-title {
  font-family: var(--font-serif);
  font-size: 30px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  margin-bottom: 12px;
  text-shadow: 0 2px 10px rgba(0, 0, 0, 0.7);
}

.modal-subtitle {
  font-size: 15px;
  line-height: 1.5;
  color: var(--color-cream-muted);
  margin-bottom: 24px;
}

/* Treats preview showcase */
.treats-showcase {
  display: flex;
  justify-content: center;
  gap: 10px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.treat-icon-bubble {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(242, 203, 102, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  transition: transform 0.2s;
}

.treat-icon-bubble img {
  width: 78%;
  height: 78%;
  object-fit: contain;
}

/* Primary Festive CTA Button */
.btn-primary {
  width: 100%;
  padding: 16px 24px;
  background: linear-gradient(135deg, #e6b840 0%, #b8860b 50%, #996515 100%);
  color: #241400;
  border: 1px solid #ffecb3;
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 18px;
  font-weight: 700;
  letter-spacing: 0.5px;
  cursor: pointer;
  box-shadow: 0 8px 24px rgba(184, 134, 11, 0.5), inset 0 2px 0 rgba(255, 255, 255, 0.4);
  position: relative;
  overflow: hidden;
  transition: all 0.25s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.btn-primary::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -60%;
  width: 40%;
  height: 200%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.45), transparent);
  transform: rotate(25deg);
  animation: buttonShine 3.5s infinite;
}

@keyframes buttonShine {
  0% { left: -60%; }
  25% { left: 140%; }
  100% { left: 140%; }
}

.btn-primary:active {
  transform: scale(0.97);
  box-shadow: 0 4px 12px rgba(184, 134, 11, 0.4);
}

/* Secondary Button */
.btn-secondary {
  width: 100%;
  margin-top: 12px;
  padding: 13px 20px;
  background: rgba(255, 255, 255, 0.1);
  color: var(--color-cream);
  border: 1px solid rgba(242, 203, 102, 0.5);
  border-radius: 999px;
  font-family: var(--font-sans);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  backdrop-filter: blur(8px);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.btn-secondary:active {
  background: rgba(255, 255, 255, 0.2);
  transform: scale(0.97);
}

/* Results Screen Specifics */
.results-stars {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin: 12px 0 18px 0;
}

.result-star {
  font-size: 36px;
  color: rgba(255, 255, 255, 0.2);
  transform: scale(0.5);
  transition: all 0.4s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.result-star.lit {
  color: var(--color-gold);
  text-shadow: 0 0 16px rgba(242, 203, 102, 0.9);
  transform: scale(1);
}

.results-stats-box {
  background: rgba(0, 0, 0, 0.3);
  border: 1px solid rgba(242, 203, 102, 0.2);
  border-radius: 18px;
  padding: 14px 18px;
  margin-bottom: 20px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--color-cream-muted);
  margin-bottom: 4px;
}

.stat-val {
  font-family: var(--font-display);
  font-size: 22px;
  font-weight: 700;
  color: var(--color-gold-bright);
}

.results-praise {
  font-size: 15px;
  font-weight: 500;
  color: var(--color-cream);
  margin-bottom: 22px;
  font-style: italic;
}

/* Holiday Greeting Card Modal */
.card-modal-content {
  background: #fbf8f0;
  color: #2b1f14;
  border-radius: 24px;
  padding: 34px 26px 26px 26px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.75), 0 0 0 8px rgba(184, 134, 11, 0.25);
  border: 2px solid #c99e32;
  position: relative;
  max-width: 360px;
  text-align: center;
}

.card-decor-header {
  font-size: 32px;
  margin-bottom: 10px;
}

.card-title {
  font-family: var(--font-serif);
  font-size: 26px;
  font-weight: 700;
  color: var(--color-crimson);
  margin-bottom: 14px;
}

.card-text {
  font-family: var(--font-serif);
  font-size: 16px;
  line-height: 1.6;
  color: #3d2f21;
  margin-bottom: 22px;
  font-style: italic;
}

.card-signature {
  font-family: var(--font-display);
  font-size: 13px;
  letter-spacing: 1px;
  color: var(--color-gold-deep);
  margin-bottom: 24px;
  text-transform: uppercase;
}

.card-copy-btn {
  background: var(--color-crimson);
  color: #fff;
  border: none;
  padding: 12px 20px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 6px 18px rgba(168, 28, 43, 0.4);
  transition: all 0.2s;
  width: 100%;
  justify-content: center;
}

.card-copy-btn:active {
  transform: scale(0.97);
  background: var(--color-crimson-dark);
}

.card-close-btn {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.08);
  border: none;
  color: #666;
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.copy-toast {
  position: absolute;
  bottom: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: rgba(12, 35, 23, 0.95);
  color: var(--color-gold);
  padding: 8px 18px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  border: 1px solid var(--color-gold);
  box-shadow: 0 8px 20px rgba(0,0,0,0.5);
  opacity: 0;
  pointer-events: none;
  transition: all 0.3s ease;
  z-index: 100;
}

.copy-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
