:root {
  --bg: #f4efe6;
  --bg-accent: #e4d4b9;
  --surface: rgba(255, 251, 244, 0.82);
  --surface-strong: rgba(243, 225, 189, 0.94);
  --border: rgba(98, 71, 33, 0.16);
  --text: #2a1f17;
  --muted: #6e5a47;
  --accent: #b15d2a;
  --accent-deep: #6e3218;
  --shadow: 0 24px 60px rgba(81, 56, 31, 0.12);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Manrope", sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at top right, rgba(177, 93, 42, 0.22), transparent 25%),
    radial-gradient(circle at left center, rgba(87, 133, 104, 0.14), transparent 28%),
    linear-gradient(180deg, #f8f3ec 0%, var(--bg) 100%);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.12) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.12) 1px, transparent 1px);
  background-size: 28px 28px;
  mask-image: radial-gradient(circle at center, black 35%, transparent 82%);
}

.shell {
  width: min(1180px, calc(100vw - 2rem));
  margin: 0 auto;
  padding: 2rem 0 4rem;
}

.grid {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 1.5rem;
}

.card {
  position: relative;
  overflow: hidden;
  padding: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 28px;
  background: var(--surface);
  box-shadow: var(--shadow);
  backdrop-filter: blur(18px);
}

.card::after {
  content: "";
  position: absolute;
  inset: auto -20% -35% auto;
  width: 220px;
  height: 220px;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(177, 93, 42, 0.14), transparent 68%);
}

.hero {
  padding: 2rem;
}

.emphasis {
  background: linear-gradient(145deg, rgba(245, 234, 212, 0.95), rgba(255, 249, 241, 0.88));
}

.eyebrow {
  margin: 0 0 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.16em;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--accent);
}

h1,
h2 {
  margin: 0;
  font-family: "Fraunces", serif;
  line-height: 1.02;
}

h1 {
  font-size: clamp(2.8rem, 5vw, 4.8rem);
  max-width: 11ch;
}

h2 {
  font-size: 1.8rem;
}

.lede,
.muted,
p,
li {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--muted);
}

.lookup-form {
  display: grid;
  gap: 0.9rem;
  grid-template-columns: minmax(0, 1fr) auto;
  margin-top: 1.5rem;
}

.lookup-form input {
  width: 100%;
  min-height: 60px;
  padding: 0 1.1rem;
  border: 1px solid rgba(96, 67, 36, 0.18);
  border-radius: 18px;
  font-size: 1.1rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.75);
}

.lookup-form button,
.pill {
  border: none;
  border-radius: 18px;
  font-weight: 700;
  cursor: pointer;
}

.lookup-form button {
  padding: 0 1.35rem;
  color: #fff7f0;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
}

.helper-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
}

.pill {
  padding: 0.75rem 0.95rem;
  color: var(--accent-deep);
  background: rgba(255, 244, 233, 0.92);
  border: 1px solid rgba(177, 93, 42, 0.18);
}

.preset-select {
  min-height: 52px;
  padding: 0 1rem;
  border: 1px solid rgba(177, 93, 42, 0.18);
  border-radius: 18px;
  font-size: 0.98rem;
  font-weight: 700;
  color: var(--accent-deep);
  background: rgba(255, 244, 233, 0.92);
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 0.9rem;
  margin-top: 1.25rem;
}

.stat-card {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  padding: 0.95rem 1rem;
  border-radius: 20px;
  border: 1px solid rgba(177, 93, 42, 0.14);
  background: rgba(255, 247, 236, 0.88);
  text-decoration: none;
}

.stat-label {
  font-size: 0.76rem;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--muted);
}

.stat-card strong {
  color: var(--text);
}

.link-card:hover {
  transform: translateY(-1px);
}

.section-heading {
  margin-bottom: 1rem;
}

.heading-row {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 1rem;
}

.spin-button {
  align-self: center;
  min-width: 112px;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(177, 93, 42, 0.18);
  border-radius: 999px;
  font-size: 0.96rem;
  font-weight: 800;
  color: #fff7f0;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  cursor: pointer;
  box-shadow: 0 12px 24px rgba(109, 60, 26, 0.14);
}

.spin-button:disabled {
  cursor: default;
  opacity: 0.55;
  box-shadow: none;
}

.mapping-table,
.chunk-grid,
.phrase-list,
.index-results {
  display: grid;
  gap: 0.9rem;
}

.mapping-row,
.chunk-card,
.phrase-card,
.index-card {
  position: relative;
  padding: 1rem;
  border-radius: 20px;
  border: 1px solid rgba(111, 80, 44, 0.12);
  background: rgba(255, 255, 255, 0.68);
}

.mapping-row {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr);
  align-items: center;
}

.digit-badge {
  display: inline-grid;
  place-items: center;
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-weight: 800;
  color: #fff;
  background: linear-gradient(135deg, #ba6a36, #88441f);
}

.phrase-card strong,
.index-card strong {
  display: block;
  font-size: 1.15rem;
  color: var(--text);
}

.dictionary-filter {
  width: 100%;
  min-height: 56px;
  padding: 0 1rem;
  margin-top: 0.5rem;
  border: 1px solid rgba(96, 67, 36, 0.18);
  border-radius: 18px;
  font-size: 1rem;
  color: var(--text);
  background: rgba(255, 255, 255, 0.78);
}

.dictionary-results {
  max-height: 760px;
  overflow: auto;
  padding-right: 0.25rem;
}

.chunk-grid {
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
}

.chunk-label {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 56px;
  padding: 0.4rem 0.7rem;
  border-radius: 999px;
  font-weight: 800;
  color: var(--accent-deep);
  background: rgba(225, 195, 159, 0.42);
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.9rem;
}

.word-chip {
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.42rem 0.72rem;
  border-radius: 999px;
  color: var(--text);
  background: rgba(247, 238, 225, 0.92);
  border: 1px solid rgba(177, 93, 42, 0.16);
}

.word-chip.compact {
  padding: 0.36rem 0.6rem;
}

.word-thumb {
  width: 28px;
  height: 28px;
  border-radius: 10px;
  object-fit: cover;
  box-shadow: 0 8px 16px rgba(63, 40, 24, 0.15);
}

.word-thumb.compact {
  width: 24px;
  height: 24px;
  border-radius: 8px;
}

.word-thumb.large {
  width: 72px;
  height: 72px;
  border-radius: 20px;
}

.sound-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-top: 1rem;
}

.sound-card {
  display: flex;
  align-items: center;
  gap: 0.9rem;
  min-width: 220px;
  padding: 0.8rem 0.95rem;
  border-radius: 22px;
  background: rgba(250, 243, 230, 0.9);
  border: 1px solid rgba(177, 93, 42, 0.16);
}

.sound-body {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.sound-word {
  display: inline-flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 0.02rem;
  padding-top: 1.35rem;
  font-size: 2rem;
  font-weight: 800;
  line-height: 1;
  color: var(--text);
}

.sound-plain {
  opacity: 0.82;
}

.sound-match {
  position: relative;
  display: inline-flex;
  align-items: flex-end;
}

.sound-digit {
  position: absolute;
  left: 50%;
  top: -1.28rem;
  transform: translateX(-50%);
  min-width: 1.3rem;
  padding: 0.08rem 0.32rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.1;
  color: #fff7f0;
  background: linear-gradient(135deg, var(--accent), var(--accent-deep));
  box-shadow: 0 8px 16px rgba(96, 59, 30, 0.14);
}

.sound-letter {
  color: #6d3bc1;
  text-decoration: underline wavy #c24a34;
  text-underline-offset: 0.12em;
}

.sound-chunk {
  display: inline-flex;
  align-self: flex-start;
  padding: 0.24rem 0.55rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--accent-deep);
  background: rgba(225, 195, 159, 0.4);
}

.index-header {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 0.75rem;
}

.index-count {
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
}

.index-phrases {
  display: grid;
  gap: 0.55rem;
  margin-top: 0.9rem;
}

.index-option {
  padding: 0.75rem 0.85rem;
  border-radius: 16px;
  background: rgba(250, 243, 230, 0.76);
  border: 1px solid rgba(177, 93, 42, 0.12);
}

.index-option span,
.index-option small {
  display: block;
}

.index-option small {
  margin-top: 0.2rem;
  color: var(--muted);
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  .grid {
    grid-template-columns: 1fr;
  }

  .lookup-form {
    grid-template-columns: 1fr;
  }

  .stats-row {
    grid-template-columns: 1fr;
  }

  .sound-card {
    width: 100%;
  }
}
