:root {
  --paper: #faf6f3;
  --paper-warm: #f6eee9;
  --cream: #fffaf7;
  --ink: #3a2c2e;
  --ink-soft: #6d5a5c;
  --line: #e8d5d0;
  --accent: #b56e7a;
  --accent-hover: #9a5562;
  --gold: #c9a66b;
  --gold-soft: #e8d5a8;
  --gold-deep: #8a7040;
  --shadow: 0 10px 24px rgba(58, 44, 46, 0.08);
  --serif: "Cormorant Garamond", "Times New Roman", serif;
  --sans: "Source Sans 3", "Segoe UI", sans-serif;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
}

body {
  color: var(--ink);
  background:
    radial-gradient(900px 480px at 50% -8%, var(--paper-warm), transparent 55%),
    var(--paper);
  font-family: var(--sans);
  font-size: 1rem;
  line-height: 1.5;
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: min(26.5rem, calc(100% - 1.5rem));
  margin: 0 auto;
  padding: max(0.8rem, env(safe-area-inset-top)) 0 max(1rem, env(safe-area-inset-bottom));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.top {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.mark {
  width: 2.55rem;
  height: 2.55rem;
  border-radius: 0.5rem;
  object-fit: cover;
  flex-shrink: 0;
  box-shadow: 0 0 0 1px rgba(58, 44, 46, 0.08);
}

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

h1,
h2 {
  font-family: var(--serif);
  font-weight: 600;
  line-height: 1.1;
  letter-spacing: -0.01em;
  margin: 0;
}

h1 {
  font-size: 1.65rem;
}

h2 {
  font-size: clamp(1.8rem, 6vw, 2.3rem);
  margin: 0 0 0.65rem;
}

.bar {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.45rem 0.75rem;
  margin-bottom: 0.8rem;
}

.new-game {
  margin-left: auto;
  color: var(--gold-deep);
  font-size: 0.88rem;
  font-weight: 600;
  text-decoration: none;
}

.lead,
.foot,
.win-copy,
.win-note,
.win-stat {
  color: var(--ink-soft);
}

.lead,
.moves,
.lives {
  margin: 0;
  font-size: 0.92rem;
}

.moves,
.lives {
  font-weight: 600;
  color: var(--ink);
  white-space: nowrap;
}

.moves strong,
.lives strong {
  font-family: var(--serif);
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--accent);
}

.lives strong {
  letter-spacing: 0.08em;
}

.field {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  flex: 0 0 auto;
  overflow: hidden;
  border: 1px solid rgba(201, 166, 107, 0.55);
  border-radius: 0.5rem;
  background:
    linear-gradient(180deg, transparent 86%, rgba(181, 110, 122, 0.12) 100%),
    var(--cream);
  box-shadow: var(--shadow);
}

.slots {
  position: absolute;
  inset: 0.38rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  grid-template-rows: repeat(6, minmax(0, 1fr));
  gap: 0.38rem;
  pointer-events: none;
}

.slot {
  border: 1px solid rgba(201, 166, 107, 0.28);
  border-radius: 0.45rem;
  background: radial-gradient(80% 80% at 50% 38%, rgba(75, 56, 59, 0.06) 0%, transparent 72%);
}

.slot:nth-child(even) {
  border-color: rgba(181, 110, 122, 0.22);
}

.drops {
  position: absolute;
  inset: 0.38rem;
}

.drop {
  position: absolute;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.15rem;
  padding: 0.28rem 0.4rem;
  border: 1px solid rgba(201, 166, 107, 0.7);
  border-radius: 0.5rem;
  background: radial-gradient(80% 70% at 50% 38%, #fff 0%, var(--cream) 72%);
  box-shadow: var(--shadow);
  font-family: var(--serif);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--ink);
  text-align: center;
  pointer-events: none;
  transition: top 0.42s linear, opacity 0.22s ease, transform 0.22s ease, border-color 0.16s ease;
  will-change: top;
}

.drop.is-target {
  border-color: var(--accent);
  box-shadow: 0 0 0 1px var(--accent), var(--shadow);
}

.drop .hit {
  color: var(--accent);
}

.drop.is-caught {
  border-color: var(--gold);
  box-shadow: 0 0 0 1px var(--gold-soft), var(--shadow);
  transform: scale(1.06);
  opacity: 0;
}

.drop.is-miss {
  border-color: var(--ink-soft);
  opacity: 0;
  transform: translateY(12px);
}

.type-wrap {
  margin-top: 0.7rem;
  position: sticky;
  bottom: 0;
  z-index: 5;
  padding: 0.15rem 0 0.2rem;
  background: linear-gradient(180deg, transparent, var(--paper) 28%);
}

.type-label {
  position: absolute;
  width: 1px;
  height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
}

.type-input {
  display: block;
  width: 100%;
  min-height: 3.2rem;
  padding: 0.8rem 1rem;
  border: 1px solid rgba(201, 166, 107, 0.7);
  border-radius: 0.5rem;
  background: var(--cream);
  color: var(--ink);
  font-family: var(--serif);
  font-size: 1.35rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  line-height: 1.2;
  text-align: center;
  appearance: none;
  -webkit-appearance: none;
  box-shadow: var(--shadow);
}

.type-input::placeholder {
  color: var(--ink-soft);
  font-weight: 500;
  letter-spacing: 0.02em;
}

.type-input:focus {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
  border-color: var(--accent);
}

.foot {
  margin: auto 0 0;
  padding-top: 0.85rem;
  text-align: center;
  font-size: 0.82rem;
}

.foot a {
  color: var(--gold-deep);
  font-weight: 600;
  text-decoration: none;
}

.foot a:hover { color: var(--ink); }

.win {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 1.1rem;
  background: rgba(58, 44, 46, 0.28);
  backdrop-filter: blur(6px);
}

.win[hidden] {
  display: none;
}

.win-card {
  width: min(26rem, 100%);
  max-height: calc(100dvh - 2rem);
  overflow: auto;
  background: var(--paper);
  border: 1px solid var(--line);
  box-shadow: var(--shadow);
  padding: 1.35rem 1.2rem 1.25rem;
  text-align: center;
}

.win-logo {
  display: block;
  width: min(7.5rem, 42%);
  height: auto;
  margin: 0 auto 0.5rem;
}

.win-copy {
  margin: 0 0 0.85rem;
  font-size: 0.98rem;
}

.win-stat {
  margin: 0 0 1.05rem;
  font-size: 0.92rem;
}

.win-stat strong {
  color: var(--accent);
  font-family: var(--serif);
  font-size: 1.15rem;
}

.win-actions {
  display: grid;
  gap: 0.55rem;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 2.85rem;
  padding: 0.7rem 1.15rem;
  border-radius: 4px;
  border: 1px solid transparent;
  font-family: var(--sans);
  font-size: 0.98rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.btn-primary {
  background: var(--accent);
  color: #fffaf7;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #fffaf7;
}

.btn-ghost {
  background: transparent;
  color: var(--ink);
  border-color: var(--line);
}

.btn-ghost:hover {
  background: var(--cream);
}

.btn-text {
  background: transparent;
  color: var(--gold-deep);
  border: 0;
  min-height: 2.4rem;
}

.btn-text:hover {
  color: var(--ink);
}

.win-note {
  margin: 1rem 0 0;
  font-size: 0.78rem;
}

.home-link {
  color: inherit;
  text-decoration: none;
}
.home-link:hover {
  color: var(--accent);
}

.sound-btn {
  margin-left: 0.35rem;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--gold-deep);
  font: inherit;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
}

.age-banner {
  position: sticky;
  top: 0;
  z-index: 40;
  margin: 0;
  padding: 0.65rem 1rem;
  background: #3a2c2e;
  color: #fffaf7;
  text-align: center;
  font-family: var(--sans);
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.14em;
}

@media (min-width: 520px) {
  .app {
    width: min(26rem, calc(100% - 2.5rem));
    padding-top: 1.35rem;
  }

  .slots {
    gap: 0.45rem;
  }
}

@media (max-height: 700px) {
  h1 {
    font-size: 1.4rem;
  }

  .app {
    padding-top: 0.55rem;
  }

  .field {
    aspect-ratio: 2 / 2.55;
  }

  .foot {
    margin-top: 0.6rem;
  }
}
