:root {
  --saffron: #ff7a00;
  --marigold: #ffc300;
  --crimson: #c0162c;
  --plum: #3d1356;
  --night: #160a33;
  --cream: #fff6e0;
  --ink: #2a0f1f;
  --green: #1f8a3c;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  /* pinned so the on-screen keyboard can't leave the page scrolled */
  position: fixed;
  inset: 0;
  width: 100%;
  background: var(--night);
  color: var(--cream);
  font-family: "Poppins", system-ui, -apple-system, "Segoe UI", sans-serif;
  -webkit-tap-highlight-color: transparent;
  /* no double-tap zoom, pull-to-refresh, long-press callouts or accidental text selection */
  touch-action: manipulation;
  overscroll-behavior: none;
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  -webkit-text-size-adjust: 100%;
}
input { -webkit-user-select: text; user-select: text; }

.deva { font-family: "Yatra One", "Poppins", serif; }

#game {
  position: fixed;
  inset: 0;
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  display: block;
  touch-action: none;
  cursor: crosshair;
}

/* HUD */
.hud {
  position: fixed;
  top: 0; left: 0; right: 0;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: calc(8px + env(safe-area-inset-top)) 16px 8px;
  pointer-events: none;
}
.hud-title {
  font-weight: 700;
  font-size: 15px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, .6);
}
.hud-title .deva { color: var(--marigold); font-size: 20px; margin-right: 6px; }
.hud-stats { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.chip {
  background: rgba(22, 10, 51, .72);
  border: 1px solid rgba(255, 195, 0, .45);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 13px;
  white-space: nowrap;
  max-width: 46vw;
  overflow: hidden;
  text-overflow: ellipsis;
}
.chip b { color: var(--marigold); }
.icon-btn {
  pointer-events: auto;
  background: rgba(22, 10, 51, .72);
  border: 1px solid rgba(255, 195, 0, .45);
  color: var(--cream);
  border-radius: 999px;
  width: 34px; height: 30px;
  font-size: 15px;
  cursor: pointer;
}

.hint {
  position: fixed;
  left: 50%;
  bottom: calc(16px + env(safe-area-inset-bottom));
  transform: translateX(-50%);
  max-width: calc(100vw - 32px);
  background: rgba(22, 10, 51, .82);
  border: 1px solid var(--marigold);
  border-radius: 12px;
  padding: 8px 14px;
  font-size: 14px;
  text-align: center;
  pointer-events: none;
  transition: opacity .6s;
}
.hint.fade { opacity: 0; }

.banner {
  position: fixed;
  left: 50%;
  top: 22%;
  transform: translate(-50%, -50%) scale(.6);
  max-width: calc(100vw - 32px);
  font-family: "Yatra One", "Poppins", serif;
  font-size: clamp(20px, min(5vw, 7vh), 46px);
  text-align: center;
  color: var(--marigold);
  text-shadow: 0 0 18px rgba(255, 122, 0, .9), 0 3px 0 var(--crimson), 0 6px 18px rgba(0, 0, 0, .7);
  opacity: 0;
  pointer-events: none;
}
.banner.show { animation: banner 2.8s ease-out forwards; }
@keyframes banner {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.6); }
  12% { opacity: 1; transform: translate(-50%, -50%) scale(1.06); }
  20% { transform: translate(-50%, -50%) scale(1); }
  80% { opacity: 1; }
  100% { opacity: 0; transform: translate(-50%, -60%) scale(1); }
}

/* Overlays */
.overlay {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: radial-gradient(ellipse at center, rgba(22, 10, 51, .35), rgba(22, 10, 51, .78));
  overflow-y: auto;
}
.card {
  width: min(440px, 100%);
  background: linear-gradient(160deg, #fff6e0 0%, #ffe3b0 100%);
  color: var(--ink);
  border-radius: 20px;
  padding: 24px 22px 18px;
  border: 3px solid var(--marigold);
  box-shadow: 0 0 0 6px rgba(192, 22, 44, .85), 0 18px 60px rgba(0, 0, 0, .55);
  text-align: center;
  position: relative;
}
.card::before, .card::after {
  content: "🪔";
  position: absolute;
  top: -18px;
  font-size: 28px;
}
.card::before { left: 18px; }
.card::after { right: 18px; }
.kicker { margin: 0; color: var(--crimson); font-size: 20px; }
.card h1, .card h2 {
  margin: 4px 0 6px;
  font-family: "Yatra One", "Poppins", serif;
  font-weight: 400;
  font-size: clamp(32px, 8vw, 44px);
  color: var(--saffron);
  text-shadow: 0 2px 0 var(--crimson);
  line-height: 1.1;
}
.card h2 { font-size: clamp(26px, 6vw, 36px); overflow-wrap: anywhere; }
.lead { margin: 0 0 14px; font-size: 15px; line-height: 1.45; }

.field-label {
  display: block;
  text-align: left;
  font-weight: 600;
  font-size: 13px;
  margin: 10px 0 6px;
  color: var(--plum);
  padding: 0;
}
#name {
  width: 100%;
  font: inherit;
  font-size: 17px;
  padding: 11px 14px;
  border-radius: 12px;
  border: 2px solid #e0a040;
  background: #fffdf6;
  color: var(--ink);
}
#name:focus { outline: 3px solid rgba(255, 122, 0, .45); border-color: var(--saffron); }

.bows { border: 0; margin: 4px 0 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.bow-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px 4px;
  border: 2px solid #e8c78a;
  border-radius: 12px;
  background: #fffaf0;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
}
.bow-opt input { position: absolute; opacity: 0; pointer-events: none; }
.bow-opt:has(input:checked) { border-color: var(--crimson); background: #ffe9c2; box-shadow: 0 0 0 2px rgba(192, 22, 44, .25); }
.bow-opt:has(input:focus-visible) { outline: 3px solid rgba(255, 122, 0, .6); }
.swatch {
  width: 34px; height: 34px;
  border-radius: 50% 50% 50% 50% / 60% 60% 40% 40%;
  border: 4px solid;
  border-left-color: transparent;
  transform: rotate(-45deg);
}
.swatch.golden { border-color: #f2b632; border-left-color: transparent; }
.swatch.bamboo { border-color: #c9a35a; border-left-color: transparent; }
.swatch.saffron { border-color: #ff7a00; border-left-color: transparent; }

.error { min-height: 1.2em; margin: 8px 0 4px; color: var(--crimson); font-size: 13px; font-weight: 600; }
.cta {
  width: 100%;
  font: inherit;
  font-weight: 700;
  font-size: 17px;
  padding: 12px 16px;
  border: 0;
  border-radius: 14px;
  color: #fff;
  background: linear-gradient(180deg, #ff8a1c, #e0400a);
  box-shadow: 0 4px 0 #9a2a05, 0 8px 18px rgba(224, 64, 10, .45);
  cursor: pointer;
}
.cta:active { transform: translateY(2px); box-shadow: 0 2px 0 #9a2a05; }
.cta:focus-visible { outline: 3px solid var(--plum); outline-offset: 2px; }
.fine { margin: 10px 0 0; font-size: 11px; color: #7a5a4a; }

.noscript { position: fixed; inset: 0; display: grid; place-items: center; padding: 16px; text-align: center; }

@media (max-width: 520px) {
  .hud-title { font-size: 12px; }
  .hud-title .deva { font-size: 16px; }
  .chip { font-size: 11px; padding: 3px 8px; }
}
