:root {
  color: #22170f;
  font-family: "Inter", "Segoe UI", -apple-system, system-ui, sans-serif;
  background: #fdfcf8;
  --accent: #d6792c;
  --accent-muted: #e8c8ac;
  --accent-soft: #f6e7da;
  --petal: #f6c78f;
  --petal-faded: #fbe9d6;
  --card: #ffffff;
  --border: #f0e4d7;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  justify-content: center;
  padding: 2rem 1rem;
  background: var(--background, #fdfcf8);
  color: inherit;
}

.app-shell {
  width: min(960px, 100%);
  background: var(--card);
  border-radius: 1.25rem;
  padding: 2rem;
  box-shadow: 0 15px 35px rgba(20, 16, 12, 0.05);
  border: 1px solid var(--border);
}

header h1 {
  margin: 0 0 0.5rem;
  font-size: clamp(2rem, 4vw, 2.6rem);
  color: var(--accent);
  font-weight: 600;
}

.instructions {
  margin: 0;
  color: #6c5a46;
  font-size: 1rem;
  line-height: 1.5;
}

.panel {
  margin-top: 1.5rem;
  border: 1px solid var(--border);
  border-radius: 1rem;
  padding: 1.5rem;
  background: #fffdfa;
}

.host-panel .primary {
  margin-top: 1rem;
}

.play-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-weight: 600;
}

.field input,
.field textarea {
  border: 1.75px solid #ffd0a0;
  border-radius: 0.85rem;
  padding: 0.8rem 1rem;
  font-size: 1rem;
}

.field textarea {
  min-height: 140px;
  resize: vertical;
  font-family: inherit;
  line-height: 1.4;
}

button,
.button,
a.primary {
  border: none;
  border-radius: 999px;
  padding: 0.6rem 1.3rem;
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease, opacity 0.15s ease;
  text-align: center;
  background: transparent;
  color: inherit;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.primary,
a.primary {
  background: var(--accent);
  color: #fff;
  text-decoration: none;
}

.ghost {
  border: 1px solid transparent;
  color: #7a6a5e;
  padding: 0.4rem 0.9rem;
}

.ghost:not(:disabled):hover {
  color: var(--accent);
}

.pill {
  background: var(--accent);
  color: #fff;
  border-radius: 0.75rem;
  border: none;
}

.pill.outline {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
}

.pill:not(:disabled):hover,
.pill.outline:not(:disabled):hover {
  opacity: 0.85;
}

.hidden {
  display: none;
}

.message {
  min-height: 1.5rem;
  color: #5f4a34;
}

.message.small {
  margin-top: 1rem;
  font-size: 0.95rem;
}

.lotus-board {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
}

.lotus {
  width: min(320px, 100%);
  height: auto;
  display: block;
  margin: 0 auto;
}

.petal {
  fill: var(--petal);
  opacity: 0.9;
  transition: opacity 0.3s ease, transform 0.3s ease;
  filter: drop-shadow(0 4px 8px rgba(214, 121, 44, 0.15));
}

.petal.faded {
  opacity: 0.12;
  transform: scale(0.9) translate(var(--petal-shift-x, 0), var(--petal-shift-y, 0));
}

.petal-ring .petal:nth-of-type(1) { --petal-shift-x: -6px; --petal-shift-y: 24px; }
.petal-ring .petal:nth-of-type(2) { --petal-shift-x: 8px; --petal-shift-y: 18px; }
.petal-ring .petal:nth-of-type(3) { --petal-shift-x: 14px; --petal-shift-y: 26px; }
.petal-ring .petal:nth-of-type(4) { --petal-shift-x: 18px; --petal-shift-y: 12px; }
.petal-ring .petal:nth-of-type(5) { --petal-shift-x: 20px; --petal-shift-y: -6px; }
.petal-ring .petal:nth-of-type(6) { --petal-shift-x: 8px; --petal-shift-y: -20px; }
.petal-ring .petal:nth-of-type(7) { --petal-shift-x: -10px; --petal-shift-y: -24px; }
.petal-ring .petal:nth-of-type(8) { --petal-shift-x: -22px; --petal-shift-y: -10px; }
.petal-ring .petal:nth-of-type(9) { --petal-shift-x: -28px; --petal-shift-y: 4px; }
.petal-ring .petal:nth-of-type(10) { --petal-shift-x: -18px; --petal-shift-y: 18px; }
.petal-ring .petal:nth-of-type(11) { --petal-shift-x: -4px; --petal-shift-y: 26px; }
.petal-ring .petal:nth-of-type(12) { --petal-shift-x: 12px; --petal-shift-y: 20px; }

.center {
  fill: #fff5ce;
  stroke: var(--accent);
  stroke-width: 3;
  filter: drop-shadow(0 3px 5px rgba(0, 0, 0, 0.1));
}

.mask-wrapper {
  text-align: center;
  margin-top: 2.5rem;
}

.masked {
  margin: 1.25rem auto 0.5rem;
  font-size: 1.8rem;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.25rem;
  max-width: 90%;
}

.mask-char {
  min-width: 1.1rem;
  text-align: center;
  font-weight: 600;
}

.mask-gap {
  width: 1.1rem;
}

.mask-fixed {
  color: #9d8876;
}

.message.subtle {
  margin-top: 0.4rem;
  font-size: 0.95rem;
  color: #a38d7b;
  min-height: 1.2rem;
}

.keyboard {
  margin: 1.5rem auto 0;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.4rem;
  max-width: 520px;
}

.keyboard button {
  min-width: 2.4rem;
  padding: 0.45rem 0.2rem;
  border-radius: 0.6rem;
  border: 1px solid #e4d9cd;
  background: #fff;
  font-weight: 600;
  color: #6b5b4e;
  transition: background 0.15s ease, color 0.15s ease;
}

.keyboard button:not(:disabled):hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.keyboard button.key-hit {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
}

.keyboard button.key-miss {
  background: #eee6de;
  color: #a19b95;
}

.keyboard button:disabled {
  opacity: 0.65;
}

.inputs {
  margin-top: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  width: min(520px, 100%);
  margin-left: auto;
  margin-right: auto;
}

.input-row label {
  font-size: 0.9rem;
  color: #7f6c5b;
  display: block;
  margin-bottom: 0.4rem;
}

.input-group {
  display: flex;
  gap: 0.5rem;
}

.input-group input {
  flex: 1;
  border: 1px solid #d9cfc5;
  border-radius: 0.7rem;
  padding: 0.65rem 0.9rem;
  font-size: 1rem;
  background: #fff;
}

.play-page #missing-panel {
  text-align: center;
}

.play-page #missing-panel a {
  display: inline-block;
  margin-top: 1rem;
}

.celebration {
  position: fixed;
  inset: 0;
  background: rgba(253, 252, 248, 0.92);
  backdrop-filter: blur(3px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 999;
}

.celebration.hidden {
  display: none;
}

.celebration-card {
  position: relative;
  background: #fffefa;
  border-radius: 1rem;
  padding: 1.5rem;
  text-align: center;
  border: 1px solid var(--border);
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-width: 360px;
}

.celebration-photo {
  width: 100%;
  border-radius: 0.75rem;
  object-fit: cover;
  max-height: 220px;
}

.celebration-card h2 {
  margin: 0;
  font-size: 1.8rem;
  color: var(--accent);
}

.petal-confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.petal-confetti span {
  position: absolute;
  font-size: 1.5rem;
  animation: fall 4s linear infinite;
  opacity: 0.7;
}

.petal-confetti span:nth-child(1) { left: 10%; animation-delay: 0s; }
.petal-confetti span:nth-child(2) { left: 25%; animation-delay: 0.4s; }
.petal-confetti span:nth-child(3) { left: 40%; animation-delay: 0.8s; }
.petal-confetti span:nth-child(4) { left: 55%; animation-delay: 1.2s; }
.petal-confetti span:nth-child(5) { left: 70%; animation-delay: 1.6s; }
.petal-confetti span:nth-child(6) { left: 85%; animation-delay: 2s; }
.petal-confetti span:nth-child(7) { left: 15%; animation-delay: 2.4s; }
.petal-confetti span:nth-child(8) { left: 35%; animation-delay: 2.8s; }
.petal-confetti span:nth-child(9) { left: 65%; animation-delay: 3.2s; }
.petal-confetti span:nth-child(10) { left: 80%; animation-delay: 3.6s; }

@keyframes fall {
  0% {
    transform: translateY(-20vh) rotate(0deg);
  }
  100% {
    transform: translateY(120vh) rotate(360deg);
  }
}

.top-bar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.lotus {
  overflow: visible;
}

@media (max-width: 640px) {
  .app-shell {
    padding: 1.5rem 1.25rem;
  }

  .masked {
    font-size: 1.3rem;
  }

  .input-group {
    flex-direction: column;
  }

  .input-group input,
  .input-group button {
    width: 100%;
  }
}
