:root {
  --paper: #fff7e9;
  --cream: #f7ead7;
  --marigold: #e19a32;
  --terracotta: #a84932;
  --deep: #2b1913;
  --muted: #725b4e;
  --line: rgba(96, 48, 35, 0.16);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--cream);
  color: var(--deep);
  font-family: Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  min-height: 100svh;
  overflow-x: hidden;
}

button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 750;
  min-height: 48px;
  padding: 0 24px;
}

.app-shell {
  min-height: 100svh;
  display: grid;
  place-items: center;
  padding: max(14px, env(safe-area-inset-top)) 14px max(16px, env(safe-area-inset-bottom));
  background:
    radial-gradient(circle at 18% 18%, rgba(225, 154, 50, 0.16), transparent 22rem),
    radial-gradient(circle at 90% 82%, rgba(168, 73, 50, 0.13), transparent 20rem),
    linear-gradient(150deg, #fffaf0, #f2d9bd);
}

.game-card {
  position: relative;
  width: min(100%, 440px);
  min-height: min(820px, calc(100svh - 28px));
  overflow: hidden;
  border: 1px solid rgba(100, 55, 40, 0.18);
  border-radius: 28px;
  background: rgba(255, 248, 236, 0.9);
  box-shadow: 0 20px 70px rgba(60, 32, 22, 0.19);
}

.screen {
  position: relative;
  z-index: 1;
  min-height: min(820px, calc(100svh - 28px));
}

.play-screen {
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 10px;
  padding: 12px;
}

.result-screen {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: 34px 26px;
  text-align: center;
}

.eyebrow,
.brand-mark {
  margin: 0 0 12px;
  color: var(--terracotta);
  font-size: 0.72rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

h1, h2 {
  margin: 0;
  font-family: Georgia, "Times New Roman", serif;
  font-weight: 600;
  letter-spacing: 0;
}

h1 {
  font-size: clamp(2.45rem, 13vw, 4.1rem);
  line-height: 0.96;
}

h2 {
  font-size: clamp(2rem, 9vw, 3.35rem);
  line-height: 1;
}

.hint {
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 0.94rem;
}

.primary-button {
  background: var(--terracotta);
  color: white;
  box-shadow: 0 10px 24px rgba(168, 73, 50, 0.25);
}

.secondary-button {
  background: rgba(255, 255, 255, 0.78);
  color: var(--deep);
  border: 1px solid var(--line);
}

.hud {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.hud > div {
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
  padding: 10px;
}

.hud span {
  display: block;
  color: var(--muted);
  font-size: 0.68rem;
  font-weight: 750;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.hud strong {
  display: block;
  margin-top: 2px;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.58rem;
}

.canvas-wrap {
  position: relative;
  min-height: 430px;
  overflow: hidden;
  border: 1px solid rgba(126, 69, 44, 0.16);
  border-radius: 22px;
  touch-action: none;
  user-select: none;
  background: #fff4df;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.start-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 24px;
  text-align: center;
  background:
    linear-gradient(180deg, rgba(255, 248, 235, 0.94), rgba(255, 248, 235, 0.38));
}

.start-brand {
  margin: 0 0 8px;
  color: var(--terracotta);
  font-size: 0.74rem;
  font-weight: 850;
  letter-spacing: 0.14em;
  text-transform: uppercase;
}

.start-title {
  margin: 0 0 18px;
  max-width: 8ch;
  color: var(--deep);
  font-size: clamp(2.35rem, 13vw, 4rem);
  line-height: 0.92;
  text-align: center;
}

.start-button {
  min-width: 190px;
  min-height: 68px;
  margin-top: 4px;
  padding: 0 34px;
  border: 3px solid rgba(255, 246, 222, 0.88);
  background: var(--terracotta);
  color: white;
  font-size: 1.25rem;
  box-shadow: 0 18px 42px rgba(168, 73, 50, 0.34);
}

.start-hint {
  margin: 16px 0 0;
  max-width: 24ch;
  line-height: 1.4;
}

.canvas-wrap.time-urgent {
  border-color: rgba(168, 73, 50, 0.43);
  box-shadow: inset 0 0 0 2px rgba(225, 154, 50, 0.2);
}

.canvas-wrap.festive-glow {
  box-shadow:
    inset 0 0 0 1px rgba(255, 214, 109, 0.45),
    0 0 25px rgba(255, 214, 109, 0.35);
}

.flash {
  pointer-events: none;
  position: absolute;
  inset: 0;
  opacity: 0;
  background: rgba(255, 249, 226, 0.72);
}

.flash.pop {
  animation: flash 520ms ease-out;
}

.toast {
  position: absolute;
  left: 50%;
  top: 22px;
  transform: translateX(-50%);
  white-space: nowrap;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 999px;
  background: rgba(43, 25, 19, 0.78);
  color: white;
  padding: 10px 16px;
  font-size: 0.9rem;
  font-weight: 800;
  box-shadow: 0 12px 30px rgba(43, 25, 19, 0.18);
}

.toast.pop {
  animation: toast 820ms ease both;
}

.floating-score {
  position: absolute;
  margin-left: -16px;
  color: #8e442d;
  font-size: 1.02rem;
  font-weight: 700;
  font-family: Georgia, "Times New Roman", serif;
  transform: translateY(0);
  pointer-events: none;
  animation: floatScore 680ms ease-out;
}

.progress-lights,
.result-lights {
  display: grid;
  grid-auto-flow: column;
  grid-auto-columns: 1fr;
  gap: 8px;
  padding: 4px 1px 5px;
}

.result-lights {
  width: min(260px, 100%);
  margin: 26px auto 18px;
}

.diya-light {
  position: relative;
  min-height: 42px;
  border: 1px solid rgba(43, 25, 19, 0.16);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.5);
}

.diya-light::before {
  content: "";
  position: absolute;
  left: 50%;
  bottom: 9px;
  width: 28px;
  height: 12px;
  border-radius: 50%;
  background: rgba(120, 82, 63, 0.26);
  transform: translateX(-50%);
}

.diya-light::after {
  content: "";
  position: absolute;
  left: 50%;
  top: 9px;
  width: 9px;
  height: 17px;
  opacity: 0;
  border-radius: 50% 50% 50% 0;
  background: #ffd66d;
  box-shadow: 0 0 16px rgba(255, 195, 78, 0.65);
  transform: translateX(-50%) rotate(45deg);
}

.diya-light.lit {
  background: rgba(255, 250, 233, 0.76);
}

.diya-light.lit::before {
  background: var(--terracotta);
}

.diya-light.lit::after {
  opacity: 1;
}

.result-lights .diya-light {
  min-height: 48px;
}

.closing-copy {
  margin: 6px auto 0;
  max-width: 31ch;
  color: var(--muted);
  line-height: 1.55;
}

.morya {
  margin: 16px 0 0;
  font-family: Georgia, "Times New Roman", serif;
  font-size: 1.45rem;
  font-weight: 700;
}

.signature {
  margin: 6px 0 24px;
  color: var(--muted);
}

.actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.share-status {
  min-height: 22px;
  margin: 14px 0 0;
  color: var(--muted);
  font-size: 0.82rem;
  overflow-wrap: anywhere;
}

#timeText.urgent,
#timeText.urgent-1,
#timeText.urgent-2,
#timeText.urgent-3 {
  transition: color 250ms ease;
}

#timeText.urgent {
  color: #a84932;
}

#timeText.urgent-1,
#timeText.urgent-2,
#timeText.urgent-3 {
  color: #7c2616;
}

#timeText.urgent-3,
#timeText.urgent-2,
#timeText.urgent-1 {
  animation: pulseUrgent 900ms infinite;
}

#timeText.urgent-2 {
  animation-duration: 700ms;
}

#timeText.urgent-1 {
  animation-duration: 500ms;
}

.rangoli-one,
.rangoli-two {
  position: absolute;
  z-index: 0;
  width: 220px;
  height: 220px;
  border: 1px solid rgba(168, 73, 50, 0.13);
  border-radius: 50%;
  opacity: 0.55;
  pointer-events: none;
}

.rangoli-one {
  left: -90px;
  top: -88px;
}

.rangoli-two {
  right: -120px;
  bottom: -95px;
}

.rangoli-one::before,
.rangoli-two::before {
  content: "";
  position: absolute;
  inset: 35px;
  border: 1px dashed rgba(225, 154, 50, 0.55);
  border-radius: 50%;
}

[hidden] { display: none !important; }

@keyframes flash {
  0% { opacity: 0; }
  20% { opacity: 1; }
  100% { opacity: 0; }
}

@keyframes toast {
  0% { opacity: 0; transform: translate(-50%, -8px) scale(0.96); }
  18% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  82% { opacity: 1; transform: translate(-50%, 0) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -6px) scale(0.98); }
}

@keyframes floatScore {
  0% { opacity: 0; transform: translateY(14px); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(-22px); }
}

@keyframes pulseUrgent {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@media (min-width: 760px) {
  .game-card,
  .screen {
    min-height: 800px;
  }

  .app-shell {
    padding: 28px;
  }
}

@media (max-height: 720px) {
  .game-card,
  .screen {
    min-height: calc(100svh - 18px);
  }

  .result-screen {
    padding: 24px 20px;
  }

  .canvas-wrap {
    min-height: 360px;
  }

  .start-button {
    min-height: 60px;
  }
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 1ms !important;
    scroll-behavior: auto !important;
    transition-duration: 1ms !important;
  }
}
