:root {
  --bg: #0d1210;
  --bg-2: #141c18;
  --panel: #1a2620;
  --panel-border: #2a3d32;
  --text: #e8f0ea;
  --muted: #8fa396;
  --accent: #7cff6b;
  --accent-dim: #3d8f34;
  --danger: #ff5c5c;
  --warn: #ffc857;
  --shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
  --radius: 14px;
  --cell: clamp(42px, 9vw, 64px);
  --font: "Nunito", system-ui, sans-serif;
  --display: "Creepster", "Nunito", cursive;
}

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

html,
body {
  margin: 0;
  min-height: 100%;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
}

body {
  position: relative;
  overflow-x: hidden;
}

.bg-fog {
  pointer-events: none;
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(80, 140, 60, 0.18), transparent 55%),
    radial-gradient(ellipse 40% 40% at 90% 80%, rgba(120, 40, 40, 0.12), transparent 50%),
    radial-gradient(ellipse 50% 30% at 10% 70%, rgba(40, 90, 50, 0.15), transparent 50%);
  z-index: 0;
}

.app {
  position: relative;
  z-index: 1;
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.25rem;
  flex-wrap: wrap;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.logo-icon {
  display: grid;
  place-items: center;
  width: 3rem;
  height: 3rem;
  font-size: 2.4rem;
  animation: bob 2.4s ease-in-out infinite;
}

@keyframes bob {
  0%, 100% { transform: translateY(0) rotate(-4deg); }
  50% { transform: translateY(-6px) rotate(4deg); }
}

.logo h1 {
  font-family: var(--display);
  font-weight: 400;
  font-size: clamp(1.8rem, 4vw, 2.6rem);
  letter-spacing: 0.04em;
  margin: 0;
  color: var(--accent);
  text-shadow: 0 0 18px rgba(124, 255, 107, 0.35);
  line-height: 1;
}

.tagline {
  margin: 0.2rem 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.hearts {
  display: flex;
  align-items: flex-end;
  gap: 0.55rem;
  user-select: none;
  min-height: 2.75rem;
}

/* ---- Zombie life eggs ---- */
.life-egg {
  position: relative;
  width: 2.35rem;
  height: 2.85rem;
  display: inline-block;
  flex-shrink: 0;
}

.egg-shell {
  position: absolute;
  inset: 0;
  display: block;
}

.egg-half {
  position: absolute;
  inset: 0;
  overflow: hidden;
  transform-origin: 50% 70%;
  transition: transform 0.15s ease;
}

.egg-left { clip-path: inset(0 50% 0 0); }
.egg-right { clip-path: inset(0 0 0 50%); }

.egg-svg {
  width: 100%;
  height: 100%;
  display: block;
  filter: drop-shadow(0 2px 3px rgba(0, 0, 0, 0.45));
}

/* Intact cracked look — slight split line */
.life-egg:not(.broken):not(.spitting) .egg-left {
  transform: translateX(-0.5px);
}
.life-egg:not(.broken):not(.spitting) .egg-right {
  transform: translateX(0.5px);
}

/* Goo / yolk hidden until spit */
.egg-yolk,
.egg-goo {
  position: absolute;
  pointer-events: none;
  opacity: 0;
}

.egg-yolk {
  left: 50%;
  top: 48%;
  width: 0.85rem;
  height: 0.85rem;
  margin: -0.4rem 0 0 -0.4rem;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #d8ff6a, #6a9a20 60%, #3d5c10);
  box-shadow: 0 0 8px rgba(140, 220, 60, 0.55);
}

.egg-goo {
  left: 50%;
  width: 0.45rem;
  height: 0.55rem;
  margin-left: -0.22rem;
  border-radius: 40% 40% 50% 50%;
  background: linear-gradient(180deg, #8fd94a, #3d6b18);
  top: 55%;
}

.egg-goo-1 { margin-left: -0.45rem; }
.egg-goo-2 { margin-left: 0.05rem; width: 0.35rem; }
.egg-goo-3 { margin-left: -0.15rem; width: 0.4rem; top: 58%; }

/* Spit open animation */
.life-egg.spitting .egg-left {
  animation: egg-spit-left 0.65s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
.life-egg.spitting .egg-right {
  animation: egg-spit-right 0.65s cubic-bezier(0.2, 0.8, 0.3, 1) forwards;
}
.life-egg.spitting .egg-yolk {
  animation: egg-yolk-burst 0.65s ease forwards;
}
.life-egg.spitting .egg-goo-1 {
  animation: egg-goo-fly 0.7s ease forwards;
  animation-delay: 0.05s;
}
.life-egg.spitting .egg-goo-2 {
  animation: egg-goo-fly 0.7s ease forwards;
  animation-delay: 0.1s;
}
.life-egg.spitting .egg-goo-3 {
  animation: egg-goo-fly 0.75s ease forwards;
  animation-delay: 0.08s;
}
.life-egg.spitting {
  animation: egg-shake 0.2s ease;
  z-index: 5;
}

@keyframes egg-shake {
  0%, 100% { transform: rotate(0); }
  25% { transform: rotate(-8deg) scale(1.08); }
  50% { transform: rotate(8deg) scale(1.12); }
  75% { transform: rotate(-4deg) scale(1.05); }
}

@keyframes egg-spit-left {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  35% { transform: translate(-6px, -4px) rotate(-18deg); }
  100% { transform: translate(-14px, 10px) rotate(-48deg); opacity: 0.35; filter: grayscale(0.4) brightness(0.7); }
}

@keyframes egg-spit-right {
  0% { transform: translate(0, 0) rotate(0); opacity: 1; }
  35% { transform: translate(6px, -4px) rotate(18deg); }
  100% { transform: translate(14px, 10px) rotate(48deg); opacity: 0.35; filter: grayscale(0.4) brightness(0.7); }
}

@keyframes egg-yolk-burst {
  0% { opacity: 0; transform: scale(0.3); }
  25% { opacity: 1; transform: scale(1.35); }
  70% { opacity: 0.9; transform: scale(1) translateY(4px); }
  100% { opacity: 0; transform: scale(0.6) translateY(14px); }
}

@keyframes egg-goo-fly {
  0% { opacity: 0; transform: translateY(0) scale(0.5); }
  20% { opacity: 1; }
  100% { opacity: 0; transform: translateY(18px) scale(0.8); }
}

/* Broken resting state */
.life-egg.broken .egg-left {
  transform: translate(-11px, 8px) rotate(-42deg);
  opacity: 0.3;
  filter: grayscale(0.5) brightness(0.65);
}
.life-egg.broken .egg-right {
  transform: translate(11px, 8px) rotate(42deg);
  opacity: 0.3;
  filter: grayscale(0.5) brightness(0.65);
}
.life-egg.broken .egg-yolk,
.life-egg.broken .egg-goo {
  opacity: 0;
  display: none;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 0.85rem 1rem;
  padding: 1rem;
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 1.25rem;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.field select {
  font: inherit;
  font-size: 0.95rem;
  font-weight: 600;
  text-transform: none;
  letter-spacing: 0;
  color: var(--text);
  background: var(--bg-2);
  border: 1px solid var(--panel-border);
  border-radius: 10px;
  padding: 0.55rem 0.75rem;
  min-width: 150px;
  cursor: pointer;
}

.modes {
  display: flex;
  gap: 0.4rem;
  background: var(--bg-2);
  padding: 0.3rem;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
}

.mode-btn {
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  color: var(--muted);
  background: transparent;
  border: none;
  border-radius: 9px;
  padding: 0.55rem 0.9rem;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

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

.mode-btn.active {
  background: var(--accent-dim);
  color: #fff;
  box-shadow: inset 0 0 0 1px rgba(124, 255, 107, 0.35);
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin-left: auto;
}

.btn {
  font: inherit;
  font-weight: 700;
  font-size: 0.9rem;
  border-radius: 10px;
  padding: 0.55rem 1rem;
  border: 1px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, background 0.15s, border-color 0.15s;
}

.btn:active { transform: scale(0.97); }

.btn.primary {
  background: linear-gradient(160deg, #6be85a, #2f8a28);
  color: #061208;
  border-color: rgba(255, 255, 255, 0.12);
}

.btn.primary:hover { filter: brightness(1.08); }

.btn.ghost {
  background: transparent;
  color: var(--text);
  border-color: var(--panel-border);
}

.btn.ghost:hover {
  background: var(--bg-2);
  border-color: var(--muted);
}

.main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(220px, 300px);
  gap: 1.25rem;
  align-items: start;
}

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

.board-wrap {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.85rem;
}

.board {
  display: grid;
  gap: 0;
  padding: 10px;
  background: #0a0f0c;
  border-radius: 16px;
  border: 2px solid #2e4638;
  box-shadow: var(--shadow), inset 0 0 30px rgba(0, 0, 0, 0.5);
  user-select: none;
  touch-action: manipulation;
}

.cell {
  width: var(--cell);
  height: var(--cell);
  position: relative;
  display: grid;
  place-items: center;
  font-size: calc(var(--cell) * 0.48);
  cursor: pointer;
  border: 1px solid rgba(0, 0, 0, 0.22);
  transition: filter 0.12s, transform 0.1s;
  outline: none;
}

.cell:hover:not(.locked) {
  filter: brightness(1.12);
  z-index: 1;
}

.cell:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: -2px;
  z-index: 2;
}

.cell.edge-t { border-top: 2.5px solid rgba(10, 14, 12, 0.85); }
.cell.edge-b { border-bottom: 2.5px solid rgba(10, 14, 12, 0.85); }
.cell.edge-l { border-left: 2.5px solid rgba(10, 14, 12, 0.85); }
.cell.edge-r { border-right: 2.5px solid rgba(10, 14, 12, 0.85); }

.cell .mark {
  line-height: 1;
  pointer-events: none;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.35);
}

.cell.chicken .mark,
.cell.chicken .mark-zombie {
  animation: place-pop 0.28s cubic-bezier(0.2, 1.4, 0.4, 1);
  display: grid;
  place-items: center;
  width: 86%;
  height: 86%;
}

.cell.chicken .zc {
  width: 100%;
  height: 100%;
  display: block;
  filter:
    drop-shadow(0 0 4px rgba(255, 40, 40, 0.45))
    drop-shadow(0 2px 2px rgba(0, 0, 0, 0.35));
}

.zc-eye {
  animation: zc-pulse 1.6s ease-in-out infinite;
}

.zc-glow {
  animation: zc-glow 1.6s ease-in-out infinite;
}

@keyframes zc-pulse {
  0%, 100% { fill: #ff1a1a; }
  50% { fill: #ff6a2a; }
}

@keyframes zc-glow {
  0%, 100% { opacity: 0.55; }
  50% { opacity: 1; }
}

.logo-icon .zc-logo {
  width: 3rem;
  height: 3rem;
  filter:
    drop-shadow(0 0 10px rgba(124, 255, 107, 0.45))
    drop-shadow(0 0 6px rgba(255, 40, 40, 0.35));
}

.mode-zc {
  display: inline-grid;
  place-items: center;
  width: 1.35rem;
  height: 1.35rem;
  vertical-align: -0.25rem;
  margin-right: 0.15rem;
}

.mode-zc .zc-mode {
  width: 1.35rem;
  height: 1.35rem;
}

.modal-icon {
  display: grid;
  place-items: center;
  min-height: 4.5rem;
  margin-bottom: 0.5rem;
}

.modal-icon .zc-lg {
  width: 4.5rem;
  height: 4.5rem;
  filter:
    drop-shadow(0 0 12px rgba(255, 40, 40, 0.5))
    drop-shadow(0 0 10px rgba(124, 255, 107, 0.3));
  animation: bob 2.4s ease-in-out infinite;
}

.cell.x-mark .mark {
  color: rgba(20, 28, 22, 0.55);
  font-weight: 800;
  font-size: calc(var(--cell) * 0.38);
}

.cell.wrong {
  animation: shake 0.4s ease;
  box-shadow: inset 0 0 0 3px var(--danger);
}

@keyframes place-pop {
  from { transform: scale(0.4); opacity: 0.5; }
  to { transform: scale(1); opacity: 1; }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  20% { transform: translateX(-4px); }
  40% { transform: translateX(4px); }
  60% { transform: translateX(-3px); }
  80% { transform: translateX(3px); }
}

.status {
  min-height: 1.4rem;
  font-weight: 700;
  color: var(--muted);
  text-align: center;
  font-size: 0.95rem;
}

.status.win {
  color: var(--accent);
  text-shadow: 0 0 12px rgba(124, 255, 107, 0.4);
}

.status.lose { color: var(--danger); }

.sidebar {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius);
  padding: 1.1rem 1.15rem;
  box-shadow: var(--shadow);
}

.panel h2 {
  margin: 0 0 0.75rem;
  font-size: 1rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--accent);
}

.rules ol {
  margin: 0;
  padding-left: 1.15rem;
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.45;
}

.rules li + li { margin-top: 0.55rem; }

.rules .tip {
  margin: 0.9rem 0 0;
  padding-top: 0.75rem;
  border-top: 1px dashed var(--panel-border);
  color: var(--muted);
  font-size: 0.85rem;
  line-height: 1.4;
}

.stats { display: grid; gap: 0.65rem; }

.stat {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  font-weight: 700;
}

.stat-label {
  color: var(--muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.overlay {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: grid;
  place-items: center;
  background: rgba(4, 8, 6, 0.72);
  backdrop-filter: blur(6px);
  padding: 1rem;
}

.overlay.hidden { display: none; }

.modal {
  background: linear-gradient(165deg, #1e2e24, #121a16);
  border: 1px solid var(--panel-border);
  border-radius: 20px;
  padding: 2rem 1.75rem;
  text-align: center;
  max-width: 360px;
  width: 100%;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
  animation: modal-in 0.35s cubic-bezier(0.2, 1.2, 0.4, 1);
}

@keyframes modal-in {
  from { transform: scale(0.85) translateY(12px); opacity: 0; }
  to { transform: scale(1) translateY(0); opacity: 1; }
}


.modal h2 {
  margin: 0 0 0.4rem;
  font-family: var(--display);
  font-size: 2rem;
  font-weight: 400;
  color: var(--accent);
}

.modal p {
  margin: 0 0 1.25rem;
  color: var(--muted);
}

.modal .btn {
  width: 100%;
  padding: 0.75rem;
  font-size: 1rem;
}

.loading .board {
  opacity: 0.5;
  pointer-events: none;
}


/* ---- Points & shop ---- */
.header-right {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  flex-wrap: wrap;
}

.points-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  font-weight: 800;
  font-size: 1.15rem;
  color: #ffe08a;
  background: linear-gradient(160deg, #3a3220, #1e1a12);
  border: 1px solid #8a7340;
  border-radius: 999px;
  padding: 0.4rem 0.85rem 0.4rem 0.65rem;
  box-shadow: 0 0 16px rgba(255, 200, 80, 0.15);
  min-width: 4.5rem;
  justify-content: center;
  user-select: none;
}

.points-icon {
  color: #ffc857;
  font-size: 0.95rem;
  text-shadow: 0 0 8px rgba(255, 200, 80, 0.6);
}

.points-badge.points-flash {
  animation: points-pop 0.55s ease;
}

@keyframes points-pop {
  0% { transform: scale(1); }
  35% { transform: scale(1.12); box-shadow: 0 0 22px rgba(255, 200, 80, 0.45); }
  100% { transform: scale(1); }
}

.shop {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
}

.btn.shop-btn {
  background: linear-gradient(160deg, #3a2e18, #241c10);
  color: #ffe8a8;
  border: 1px solid #8a7340;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
}

.btn.shop-btn:hover:not(:disabled) {
  filter: brightness(1.12);
  border-color: #c4a04a;
}

.btn.shop-btn .cost {
  font-size: 0.78rem;
  font-weight: 800;
  color: #ffc857;
  background: rgba(0, 0, 0, 0.35);
  border-radius: 6px;
  padding: 0.12rem 0.4rem;
  margin-left: 0.15rem;
}

.btn.shop-btn:disabled,
.btn.shop-btn.unaffordable:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: grayscale(0.4);
}

.cell.hint-glow {
  box-shadow: inset 0 0 0 3px #ffc857, 0 0 14px rgba(255, 200, 80, 0.55);
  z-index: 2;
  animation: hint-pulse 1s ease-in-out infinite;
}

@keyframes hint-pulse {
  0%, 100% { filter: brightness(1.05); }
  50% { filter: brightness(1.2); }
}

.cell.reveal-flash {
  animation: reveal-burst 0.7s ease;
  z-index: 3;
}

@keyframes reveal-burst {
  0% { box-shadow: inset 0 0 0 0 rgba(124, 255, 107, 0); transform: scale(1); }
  40% { box-shadow: inset 0 0 0 4px var(--accent), 0 0 20px rgba(124, 255, 107, 0.6); transform: scale(1.04); }
  100% { box-shadow: inset 0 0 0 0 transparent; transform: scale(1); }
}

.shop-info .shop-list {
  margin: 0;
  padding-left: 1.15rem;
  font-size: 0.9rem;
  line-height: 1.45;
}

.shop-info .shop-list li + li {
  margin-top: 0.45rem;
}


/* ---- Campaign level ---- */
.level-field .field-label {
  display: block;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
  margin-bottom: 0.35rem;
}

.level-badge {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  background: linear-gradient(160deg, #1e2e24, #121a16);
  border: 1px solid var(--panel-border);
  border-radius: 12px;
  padding: 0.45rem 0.85rem;
  min-width: 150px;
}

.level-name {
  font-weight: 800;
  font-size: 1.05rem;
  color: var(--accent);
  letter-spacing: 0.02em;
}

.level-meta {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--muted);
}

/* ---- Codeword gate ---- */
.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;
}

.gate-overlay {
  z-index: 100;
  background: rgba(4, 8, 6, 0.88);
}

.gate-modal {
  max-width: 400px;
}

.gate-form {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 0.5rem;
}

.gate-input {
  width: 100%;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1px solid var(--panel-border);
  background: #0e1612;
  color: var(--text);
  font-family: var(--font);
  font-size: 1.05rem;
  font-weight: 600;
  letter-spacing: 0.04em;
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.gate-input:focus {
  border-color: var(--accent-dim);
  box-shadow: 0 0 0 3px rgba(124, 255, 107, 0.18);
}

.gate-input:disabled {
  opacity: 0.55;
}

.gate-error {
  margin: 0.35rem 0 0;
  color: var(--danger);
  font-size: 0.92rem;
  font-weight: 700;
  min-height: 1.25em;
}

.gate-error[hidden] {
  display: none;
}

body.gated .app {
  filter: blur(3px);
  pointer-events: none;
  user-select: none;
}
