@font-face {
  font-family: TamilUI;
  src: url("../fonts/Nirmala.ttc");
  font-display: swap;
}

* { box-sizing: border-box; }
html, body { margin: 0; min-height: 100%; font-family: TamilUI, Latha, system-ui, sans-serif; }
body { background: #190000; color: #fff; }

.landing {
  min-height: 100vh;
  display: grid;
  place-items: center;
  position: relative;
  overflow: hidden;
  background: #220000;
}

.banner {
  width: min(100vw, 650px);
  height: 100svh;
  object-fit: cover;
  object-position: top center;
  display: block;
  filter: saturate(1.04);
}

.brand-title {
  margin: 0;
  color: #fff8c9;
  font-weight: 950;
  text-align: center;
  text-shadow:
    0 1px 0 rgba(120, 35, 0, .58),
    0 3px 10px rgba(0,0,0,.44),
    0 0 18px rgba(255,216,92,.28);
}

.landing-brand {
  position: fixed;
  top: max(20px, env(safe-area-inset-top));
  left: 50%;
  z-index: 5;
  width: clamp(300px, 32vw, 420px);
  transform: translateX(-50%);
  font-size: clamp(18px, 2vw, 30px);
  line-height: 1.03;
  letter-spacing: 0;
  pointer-events: none;
}

.landing-brand span {
  display: block;
  white-space: nowrap;
}

.form-brand {
  margin: 0 auto 14px;
  font-size: clamp(25px, 4.2vw, 42px);
  line-height: 1.03;
  width: min(760px, calc(100vw - 28px));
}

.form-brand span {
  display: block;
  white-space: nowrap;
}

.cta {
  position: fixed;
  left: 50%;
  bottom: max(26px, env(safe-area-inset-bottom));
  transform: translateX(-50%);
  text-decoration: none;
  color: #7a0000;
  background:
    linear-gradient(135deg, rgba(255,255,255,.24), rgba(255,232,132,.12)),
    rgba(255,255,255,.035);
  padding: 9px 18px;
  border-radius: 999px;
  font-size: clamp(15px, 2.8vw, 19px);
  font-weight: 800;
  border: 1px solid rgba(255,255,255,.7);
  box-shadow:
    0 10px 24px rgba(0,0,0,.16),
    inset 0 1px 0 rgba(255,255,255,.82),
    inset 0 -1px 0 rgba(120,0,0,.08);
  backdrop-filter: blur(2px) saturate(1.04);
  white-space: nowrap;
}

.counter-card {
  border: 1px solid rgba(255, 255, 255, .62);
  border-radius: 18px;
  background:
    radial-gradient(circle at 22% 18%, rgba(255,255,255,.24), transparent 34%),
    linear-gradient(135deg, rgba(255,255,255,.1), rgba(255,216,92,.045)),
    rgba(255,255,255,.025);
  box-shadow:
    0 12px 28px rgba(0,0,0,.14),
    inset 0 1px 0 rgba(255,255,255,.72),
    inset 0 -1px 0 rgba(255,255,255,.16);
  backdrop-filter: blur(2px) saturate(1.04);
  text-align: center;
}

.landing-counter {
  position: fixed;
  left: 50%;
  bottom: max(86px, calc(env(safe-area-inset-bottom) + 76px));
  transform: translateX(-50%);
  width: min(310px, calc(100vw - 36px));
  padding: 6px 14px 8px;
}

.form-counter {
  flex: 1 1 260px;
  margin: 0;
  padding: 6px 14px 8px;
}

.counter-label {
  color: rgba(255,255,255,.92);
  font-size: 16px;
  font-weight: 700;
  line-height: 1;
}

.counter-number {
  margin-top: 2px;
  color: #fff7bf;
  font: 950 44px/1 TamilUI, Latha, system-ui, sans-serif;
  text-shadow: 0 2px 8px rgba(0,0,0,.38), 0 0 14px rgba(255,216,92,.2);
  transition: transform .28s ease, color .28s ease;
}

.counter-number.pulse {
  animation: counterPulse .58s ease;
}

@keyframes counterPulse {
  0% { transform: scale(1); color: #fff7bf; }
  45% { transform: scale(1.08); color: #ffffff; }
  100% { transform: scale(1); color: #fff7bf; }
}

.form-page {
  min-height: 100vh;
  background:
    radial-gradient(circle at 20% 10%, rgba(255,220,80,.28), transparent 25rem),
    linear-gradient(135deg, #4b0000, #d00000 48%, #047ad7);
  padding: 28px 14px;
}

.shell { width: min(860px, 100%); margin: 0 auto; }
.form-topbar {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin: 0 0 12px;
}
.home-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 70px;
  min-height: 42px;
  align-self: center;
  border: 1px solid rgba(255, 238, 154, .42);
  border-radius: 999px;
  background: rgba(255,255,255,.82);
  color: #7a0000;
  font: 750 14px/1 TamilUI, Latha, system-ui, sans-serif;
  text-decoration: none;
  padding: 0 13px;
  box-shadow: 0 10px 24px rgba(0,0,0,.18);
}
.form-card {
  border: 1px solid rgba(255,255,255,.28);
  border-radius: 28px;
  background: rgba(255,255,255,.14);
  box-shadow: 0 24px 70px rgba(0,0,0,.35);
  backdrop-filter: blur(18px);
  padding: clamp(12px, 2.4vw, 18px) clamp(18px, 4vw, 34px) clamp(18px, 4vw, 32px);
}

.form-title { margin: 0 0 14px; font-size: clamp(17px, 2.55vw, 25px); line-height: 1.15; font-weight: 750; }
p { margin: 0 0 18px; color: rgba(255,255,255,.84); font-size: 15px; }
.grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 14px; }
.compact-grid { align-items: start; }
label { display: grid; gap: 7px; font-weight: 650; font-size: 15px; letter-spacing: 0; }
input,
small[contenteditable] {
  width: 100%;
  min-height: 50px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 16px;
  padding: 12px 15px;
  background: rgba(255,255,255,.92);
  color: #170000;
  font: 400 17px TamilUI, Latha, system-ui, sans-serif;
  outline: none;
}
input:focus,
small[contenteditable]:focus { box-shadow: 0 0 0 4px rgba(255,216,92,.35); border-color: #ffd85c; }
small {
  min-height: 22px;
  color: #ffe987;
  font-size: 16px;
  font-weight: 500;
}
small[contenteditable] {
  display: block;
  min-height: 42px;
  padding: 9px 13px;
  background: rgba(20,0,0,.28);
  color: #fff1a3;
  font-weight: 500;
  line-height: 1.35;
}
small[contenteditable]:empty {
  padding: 9px 13px;
  min-height: 42px;
  border-color: rgba(255,255,255,.22);
  background: rgba(20,0,0,.16);
}
.preview-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 34px;
  gap: 6px;
  align-items: center;
}
.keyboard-trigger {
  width: 34px;
  min-height: 32px;
  border: 1px solid rgba(255,255,255,.35);
  border-radius: 10px;
  background: linear-gradient(135deg, #fff8dc, #ffd85c);
  color: #7a0000;
  cursor: pointer;
  font: 850 15px/1 system-ui, sans-serif;
  box-shadow: inset 0 1px 0 #fff;
  padding: 0;
}
.keyboard-trigger:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 4px rgba(255,216,92,.35), inset 0 1px 0 #fff;
}
.tamil-keyboard {
  position: absolute;
  z-index: 40;
  width: min(368px, calc(100vw - 24px));
  padding: 12px;
  border: 1px solid rgba(255, 238, 154, .48);
  border-radius: 18px;
  background: rgba(44, 0, 0, .96);
  box-shadow: 0 22px 70px rgba(0,0,0,.46);
  backdrop-filter: blur(18px);
}
.keyboard-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 10px;
}
.keyboard-tabs {
  display: flex;
  gap: 6px;
}
.keyboard-tab,
.keyboard-close,
.keyboard-key {
  border: 0;
  cursor: pointer;
  font-family: TamilUI, Latha, system-ui, sans-serif;
  font-weight: 900;
}
.keyboard-tab {
  min-height: 34px;
  padding: 7px 12px;
  border-radius: 999px;
  background: rgba(255,255,255,.16);
  color: #fff4b5;
}
.keyboard-tab.active {
  background: #ffe45e;
  color: #7a0000;
}
.keyboard-close {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  background: rgba(255,255,255,.9);
  color: #7a0000;
  font-size: 22px;
}
.keyboard-row {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 5px;
  margin-top: 5px;
}
.keyboard-key {
  min-height: 34px;
  border-radius: 9px;
  background: rgba(255,255,255,.9);
  color: #170000;
  font-size: 15px;
}
.keyboard-key.wide-key {
  grid-column: span 3;
  font-size: 12px;
}
.wide, .photo { grid-column: 1 / -1; }
.message { min-height: 24px; margin: 12px 0 8px; color: #fff2a8; font-weight: 850; }
.submit, .download, .ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 54px;
  border: 0;
  border-radius: 16px;
  padding: 13px 22px;
  font-size: 18px;
  font-weight: 850;
  cursor: pointer;
}
.submit {
  width: 100%;
  background: linear-gradient(135deg, #ffe45e, #fff7c1);
  color: #7a0000;
}
.submit:disabled { opacity: .7; cursor: wait; }
.result {
  margin-top: 24px;
  padding: 22px;
  background: rgba(0,0,0,.25);
  border-radius: 20px;
}
.result h2 { margin: 0 0 14px; }
.download {
  margin: 6px 8px 6px 0;
  color: #fff;
  background: #0076d6;
  text-decoration: none;
}
.ghost { background: rgba(255,255,255,.9); color: #660000; }

.powered-by {
  position: fixed;
  right: max(14px, env(safe-area-inset-right));
  bottom: max(12px, env(safe-area-inset-bottom));
  z-index: 20;
  padding: 9px 14px;
  border: 1px solid rgba(255, 232, 135, .46);
  border-radius: 999px;
  background: linear-gradient(135deg, rgba(90, 0, 0, .64), rgba(255, 255, 255, .14));
  box-shadow: 0 12px 30px rgba(0, 0, 0, .32), inset 0 1px 0 rgba(255,255,255,.24);
  backdrop-filter: blur(14px);
  color: rgba(255,255,255,.82);
  font: 800 12px/1.2 system-ui, sans-serif;
  letter-spacing: .02em;
  text-shadow: 0 1px 2px rgba(0,0,0,.5);
}

.powered-by a {
  color: #ffe36b;
  text-decoration: none;
  margin-left: 4px;
}

.powered-by a:hover,
.powered-by a:focus-visible {
  color: #fff6bf;
  text-decoration: underline;
}

@media (max-width: 720px) {
  .grid { grid-template-columns: 1fr; gap: 14px; }
  .form-page { padding: 10px; }
  .form-card { border-radius: 22px; padding: 12px 16px 18px; }
  .banner { width: 100vw; height: 100svh; }
  .download, .ghost { width: 100%; margin-right: 0; }
  p { margin-bottom: 12px; }
  input { min-height: 48px; border-radius: 14px; }
  label { gap: 5px; font-size: 14px; }
  small[contenteditable] { min-height: 40px; border-radius: 14px; }
  .submit { width: 100%; min-width: 0; white-space: normal; }
  .landing-brand {
    top: max(16px, env(safe-area-inset-top));
    width: min(62vw, 340px);
    font-size: clamp(14px, 4vw, 21px);
  }
  .form-brand {
    width: min(92vw, 520px);
    font-size: clamp(21px, 6vw, 30px);
    margin-bottom: 12px;
  }
  .landing-counter { bottom: max(78px, calc(env(safe-area-inset-bottom) + 68px)); padding: 6px 14px 9px; }
  .counter-label { font-size: 15px; }
  .counter-number { font-size: 42px; }
  .form-topbar { gap: 8px; }
  .form-counter { flex-basis: 0; }
  .home-link { min-width: 72px; min-height: 38px; font-size: 13px; padding: 0 10px; }
  .form-title { font-size: 17px; margin-bottom: 12px; }
  .cta { padding: 8px 16px; font-size: clamp(14px, 3.7vw, 17px); }
  .preview-row { grid-template-columns: minmax(0, 1fr) 32px; }
  .keyboard-trigger { width: 32px; min-height: 30px; border-radius: 10px; font-size: 14px; }
  .keyboard-row { grid-template-columns: repeat(6, minmax(0, 1fr)); }
  .keyboard-key.wide-key { grid-column: span 2; }
  .tamil-keyboard {
    position: fixed;
    left: 12px !important;
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    top: auto !important;
    width: auto;
  }
  .form-page { padding-bottom: 58px; }
  .powered-by {
    right: 10px;
    bottom: 8px;
    max-width: calc(100vw - 20px);
    font-size: 11px;
  }
}

@media (max-width: 430px) {
  .landing-brand {
    width: min(56vw, 250px);
    font-size: clamp(12px, 3.45vw, 16px);
  }

  .landing-counter {
    width: min(284px, calc(100vw - 34px));
  }
}
