/* =========================================================
   SINHALA & TAMIL NEW YEAR — SUNRISE GOLD & CRIMSON THEME
   ========================================================= */
:root {
  --bg-maroon: #360708;
  --bg-crimson: #7c1412;
  --sunrise-orange: #d95d16;
  --gold-bright: #ffe07d;
  --gold-main: #f4bd3c;
  --ivory: #fff8ea;
  --muted: rgba(255, 244, 219, 0.78);

  --card-bg: linear-gradient(160deg, rgba(124, 20, 18, 0.8), rgba(54, 7, 8, 0.92));
  --card-border: rgba(244, 189, 60, 0.56);

  --font-display: "Cinzel", Georgia, serif;
  --font-serif: "Abhaya Libre", Georgia, serif;
  --font-ui: "Poppins", system-ui, sans-serif;
}

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

html, body {
  height: 100%;
  width: 100%;
  overflow-x: hidden;
  background: radial-gradient(circle at 50% 18%, #b84214 0%, var(--bg-crimson) 42%, var(--bg-maroon) 100%);
  color: var(--ivory);
  font-family: var(--font-ui);
  -webkit-font-smoothing: antialiased;
  user-select: none;
}

body {
  min-height: 100dvh;
  display: grid;
  place-items: center;
  position: relative;
  cursor: pointer;
}

#bg-canvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  pointer-events: none;
}

.avurudu-scene {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  overflow: hidden;
}

.sunrise-rays {
  position: absolute;
  top: -32vh;
  left: 50%;
  width: 160vmax;
  height: 160vmax;
  transform: translateX(-50%);
  background: repeating-conic-gradient(
    from 0deg,
    rgba(255, 214, 102, 0.1) 0deg 10deg,
    transparent 10deg 24deg
  );
  animation: sunSpin 110s linear infinite;
}

@keyframes sunSpin {
  from { transform: translateX(-50%) rotate(0deg); }
  to { transform: translateX(-50%) rotate(360deg); }
}

.kolam-backdrop {
  position: absolute;
  top: 50%;
  left: 50%;
  width: min(86vmin, 660px);
  height: min(86vmin, 660px);
  transform: translate(-50%, -50%);
}

.kokis-motif {
  position: absolute;
  bottom: 18px;
  width: clamp(72px, 11vw, 130px);
  animation: kokisTurn 45s linear infinite;
}
.kokis-motif.left { left: clamp(12px, 4vw, 48px); }
.kokis-motif.right { right: clamp(12px, 4vw, 48px); animation-direction: reverse; }

@keyframes kokisTurn {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Controls */
.controls {
  position: fixed;
  top: clamp(14px, 2.5vw, 24px);
  right: clamp(14px, 2.5vw, 24px);
  z-index: 25;
  display: flex;
  gap: 8px;
}

.ctrl-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1.5px solid var(--card-border);
  background: rgba(62, 10, 10, 0.78);
  color: var(--gold-bright);
  display: grid;
  place-items: center;
  cursor: pointer;
  transition: transform 0.2s ease, background 0.2s ease;
}
.ctrl-btn svg { width: 18px; height: 18px; }
.ctrl-btn:hover, .ctrl-btn:focus-visible {
  transform: translateY(-2px);
  background: rgba(244, 189, 60, 0.25);
  outline: none;
}
.ctrl-btn[aria-pressed="true"] { background: var(--gold-main); color: #360708; }

#sound-btn .icon-on { display: none; }
#sound-btn[aria-pressed="true"] .icon-on { display: block; }
#sound-btn[aria-pressed="true"] .icon-off { display: none; }
#fullscreen-btn .icon-compress { display: none; }
body.is-fullscreen #fullscreen-btn .icon-compress { display: block; }
body.is-fullscreen #fullscreen-btn .icon-expand { display: none; }

.toast {
  position: fixed;
  top: 70px;
  right: clamp(14px, 2.5vw, 24px);
  z-index: 30;
  padding: 8px 16px;
  border-radius: 999px;
  background: rgba(66, 10, 10, 0.95);
  border: 1px solid var(--gold-main);
  color: var(--gold-bright);
  font-size: 0.82rem;
  opacity: 0;
  transform: translateY(-6px);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}
.toast.show { opacity: 1; transform: translateY(0); }

/* Stage */
.stage {
  position: relative;
  z-index: 10;
  width: min(920px, 92vw);
  padding: clamp(24px, 4vh, 48px) 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: clamp(14px, 2.5vh, 26px);
}

.pahana-emblem {
  width: clamp(68px, 9vw, 94px);
  filter: drop-shadow(0 0 24px rgba(255, 210, 82, 0.6));
}

.lamp-flame {
  transform-origin: center bottom;
  animation: lampFlicker 1.5s ease-in-out infinite alternate;
}
@keyframes lampFlicker {
  0% { transform: scaleY(0.92); opacity: 0.88; }
  100% { transform: scaleY(1.1); opacity: 1; }
}

.eyebrow {
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.26em;
  text-transform: uppercase;
  color: var(--gold-bright);
}

.title {
  font-family: var(--font-display);
  font-size: clamp(2.1rem, 6.2vw, 4.4rem);
  font-weight: 800;
  line-height: 1.08;
  background: linear-gradient(180deg, #fffdf2 0%, #ffe07d 56%, #e89b24 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 6px 24px rgba(0, 0, 0, 0.55));
}

.milestone-badge {
  margin-top: 4px;
  padding: 6px 18px;
  border-radius: 999px;
  background: rgba(244, 189, 60, 0.2);
  border: 1px solid var(--gold-bright);
  color: #fff;
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

/* Festive Avurudu Cards */
.countdown {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: clamp(12px, 2.2vw, 22px);
  width: 100%;
}

.avurudu-card {
  position: relative;
  padding: clamp(22px, 3.4vw, 34px) 10px clamp(16px, 2.4vw, 22px);
  border-radius: 18px;
  background: var(--card-bg);
  border: 1.5px solid var(--card-border);
  box-shadow: 0 20px 42px rgba(24, 3, 4, 0.62), inset 0 0 26px rgba(244, 189, 60, 0.12);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  transition: transform 0.28s ease, border-color 0.28s ease;
}

.avurudu-card::after {
  content: "❖";
  position: absolute;
  top: 6px;
  font-size: 0.72rem;
  color: var(--gold-main);
  opacity: 0.7;
}

.avurudu-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold-bright);
}

body.final-ten .avurudu-card[data-unit="seconds"] {
  transform: scale(1.09);
  border-color: #fff;
  box-shadow: 0 0 48px rgba(255, 224, 125, 0.7);
}

.digits {
  display: inline-flex;
  justify-content: center;
  font-family: var(--font-serif);
  font-size: clamp(2.4rem, 6.6vw, 5rem);
  font-weight: 800;
  line-height: 1;
  color: #fffdf5;
  text-shadow: 0 2px 18px rgba(244, 189, 60, 0.45);
}

.digit-slot {
  position: relative;
  display: inline-block;
  width: 0.6em;
  height: 1.12em;
  overflow: hidden;
}

.digit-char {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
}

.digit-char.enter { transform: translateY(75%); opacity: 0; }
.digit-char.active {
  transform: translateY(0%);
  opacity: 1;
  transition: transform 0.36s cubic-bezier(0.22, 1, 0.36, 1), opacity 0.3s ease;
}
.digit-char.exit {
  transform: translateY(-75%);
  opacity: 0;
  transition: transform 0.3s ease, opacity 0.24s ease;
}

.unit-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.24em;
  text-transform: uppercase;
  color: var(--gold-bright);
}

.final-pulse {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: clamp(10rem, 30vw, 24rem);
  color: rgba(255, 224, 125, 0.18);
  pointer-events: none;
  z-index: 4;
  opacity: 0;
}
.final-pulse.pop { animation: dawnPop 0.9s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes dawnPop {
  0% { opacity: 0; transform: scale(0.7); }
  25% { opacity: 1; transform: scale(1.05); }
  100% { opacity: 0; transform: scale(1.24); }
}

/* Progress */
.progress-wrap {
  width: min(580px, 100%);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.progress-meta {
  display: flex;
  justify-content: space-between;
  font-size: 0.82rem;
  color: var(--muted);
}

#progress-percent { color: var(--gold-bright); font-weight: 600; }

.progress-track {
  height: 9px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(244, 189, 60, 0.45);
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #b81d18, var(--sunrise-orange), var(--gold-bright));
  transition: width 0.8s ease;
}

.fact-line {
  max-width: 58ch;
  min-height: 2.8em;
  font-size: clamp(0.94rem, 1.65vw, 1.12rem);
  line-height: 1.55;
  color: rgba(255, 246, 226, 0.92);
  transition: opacity 0.4s ease, transform 0.4s ease;
}
.fact-line.fading { opacity: 0; transform: translateY(5px); }

/* Celebration */
.celebration {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 24px;
  background: radial-gradient(circle at center, rgba(217, 93, 22, 0.44), rgba(54, 7, 8, 0.9));
  backdrop-filter: blur(8px);
}
.celebration[hidden] { display: none; }

.celebration-card {
  max-width: 680px;
  padding: clamp(32px, 6vw, 56px) clamp(24px, 5vw, 48px);
  border-radius: 26px;
  background: rgba(84, 14, 12, 0.94);
  border: 2px solid var(--gold-main);
  box-shadow: 0 0 75px rgba(244, 189, 60, 0.42);
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.celebration-greeting {
  font-size: clamp(0.84rem, 1.4vw, 1rem);
  font-weight: 600;
  letter-spacing: 0.08em;
  color: var(--gold-bright);
}

.celebration-title {
  font-family: var(--font-display);
  font-size: clamp(2.5rem, 7vw, 4.5rem);
  color: #fffdf5;
}

.celebration-sub {
  font-size: clamp(1rem, 1.8vw, 1.18rem);
  color: var(--muted);
  max-width: 40ch;
}

.celebration-hint {
  margin-top: 6px;
  font-size: 0.78rem;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: var(--gold-main);
}

@media (max-width: 680px) {
  .countdown { grid-template-columns: repeat(2, minmax(0, 1fr)); max-width: 380px; }
  .kokis-motif { opacity: 0.25; }
}

@media (prefers-reduced-motion: reduce) {
  .sunrise-rays, .kokis-motif, .lamp-flame, .final-pulse.pop { animation: none !important; }
  .digit-char.active, .digit-char.exit, .fact-line, .progress-fill { transition: none !important; }
}
