:root {
  --croc-ink: #f7fff9;
  --croc-muted: rgba(238, 255, 245, 0.7);
  --croc-panel: rgba(8, 41, 31, 0.72);
  --croc-line: rgba(213, 255, 226, 0.15);
  --croc-green: #3caf64;
}

.croc-page {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  color: var(--croc-ink);
  background:
    radial-gradient(circle at 50% 20%, rgba(69, 181, 108, 0.2), transparent 38%),
    linear-gradient(160deg, #123f30 0%, #08281f 55%, #061d18 100%);
  overflow: hidden;
}

.croc-page::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.2;
  background-image: radial-gradient(rgba(255,255,255,.2) .7px, transparent .7px);
  background-size: 13px 13px;
  mask-image: linear-gradient(to bottom, #000, transparent 70%);
}

.croc-app {
  width: min(100%, 560px);
  flex: 1;
  min-height: 0;
  margin: 0 auto;
  padding: env(safe-area-inset-top) 18px calc(14px + env(safe-area-inset-bottom));
  position: relative;
  display: flex;
  flex-direction: column;
}

.croc-topbar {
  position: relative;
  z-index: 40;
  min-height: 58px;
  flex: 0 0 auto;
  flex-wrap: nowrap;
  gap: 8px;
  padding-block: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.croc-topbar > .language-switcher {
  order: 2;
  flex: 0 0 auto;
  margin-inline-start: 0;
}
.croc-topbar > .croc-sound { order: 1; flex-shrink: 0; margin-inline-start: auto; }
.croc-topbar .language-switcher summary {
  color: var(--croc-muted);
  background: transparent;
  border-color: transparent;
}
.croc-topbar .language-switcher summary:hover,
.croc-topbar .language-switcher details[open] summary { background: rgba(255,255,255,.08); }
.croc-topbar .language-menu { background: #0d3328; border-color: var(--croc-line); }
.croc-topbar .language-menu a { color: var(--croc-ink); }
.croc-topbar .language-preview { color: var(--croc-muted); }
.croc-topbar .language-menu a:hover,
.croc-topbar .language-menu a[aria-current="true"] { background: rgba(255,255,255,.08); }

.croc-back {
  color: var(--croc-ink);
  text-decoration: none;
  font-size: .86rem;
  font-weight: 700;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 0 13px;
  border: 1px solid var(--croc-line);
  border-radius: 999px;
  background: rgba(255,255,255,.06);
  backdrop-filter: blur(12px);
}

.croc-back span { font-size: 1.35rem; line-height: 1; transform: translateY(-1px); }

.croc-sound {
  width: 42px;
  height: 42px;
  border: 1px solid var(--croc-line);
  border-radius: 50%;
  color: var(--croc-ink);
  background: rgba(255,255,255,.06);
  font: 800 1rem var(--font);
  cursor: pointer;
}

.croc-sound[aria-pressed="false"] { color: var(--croc-muted); }
.croc-sound[aria-pressed="false"] span { text-decoration: line-through; }

.croc-game {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  text-align: center;
}

.croc-heading { flex: 0 0 auto; padding: 2px 0 0; }

.croc-heading h1 {
  margin: 0;
  color: #fff;
  font-size: clamp(1.55rem, 6vw, 2rem);
  line-height: 1.08;
  letter-spacing: -.04em;
}

.croc-status {
  min-height: 22px;
  margin: 7px 0 0;
  color: var(--croc-muted);
  font-size: .88rem;
  font-weight: 600;
}

.croc-stage {
  flex: 1 1 auto;
  width: 100%;
  min-height: 340px;
  max-height: 570px;
  position: relative;
  display: grid;
  place-items: center;
  margin: -8px auto -13px;
  isolation: isolate;
}

.croc-glow {
  width: min(84vw, 510px);
  aspect-ratio: 1;
  position: absolute;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(98, 210, 130, .15), transparent 68%);
  filter: blur(8px);
}

.croc-character {
  width: min(100%, 520px);
  aspect-ratio: 1;
  position: relative;
  z-index: 2;
  user-select: none;
  -webkit-user-select: none;
  filter: drop-shadow(0 22px 22px rgba(0, 15, 10, .28));
}

.croc-art,
.croc-teeth-layer {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
}

.croc-art {
  object-fit: contain;
  pointer-events: none;
  transition: opacity .09s linear, transform .18s cubic-bezier(.18,.86,.25,1);
}

.croc-art-open { opacity: 1; }
.croc-art-closed { opacity: 0; transform: scale(1.18); }
.croc-teeth-layer { z-index: 3; overflow: visible; }

.croc-tooth {
  cursor: pointer;
  outline: none;
  -webkit-tap-highlight-color: transparent;
}

.croc-tooth .tooth-hit { fill: transparent; }
.croc-tooth .tooth-socket {
  fill: #971e3b;
  stroke: rgba(91, 10, 34, .72);
  stroke-width: .24;
  filter: drop-shadow(0 .35px .25px rgba(255, 133, 148, .25));
}
.croc-tooth .tooth-cap {
  transform-box: fill-box;
  transform-origin: center bottom;
  transition: transform .1s ease-out, opacity .1s ease-out;
}
.croc-tooth .tooth-body {
  fill: url(#toothFill);
  stroke: #c9bfa7;
  stroke-width: .28;
  filter: url(#toothShadow);
  transition: fill .1s ease-out, stroke .1s ease-out;
}
.croc-tooth .tooth-highlight {
  fill: none;
  stroke: rgba(255, 255, 255, .82);
  stroke-width: .34;
  stroke-linecap: round;
  pointer-events: none;
}
.croc-tooth:hover .tooth-body,
.croc-tooth:focus-visible .tooth-body { stroke: #ffe36b; stroke-width: .48; }
.croc-tooth:active .tooth-cap { transform: translateY(.8px) scaleY(.83); }
.croc-tooth.is-down { pointer-events: none; }
.croc-tooth.is-down .tooth-cap { transform: translateY(.4px) scaleY(.16); opacity: .18; }
.croc-tooth.is-down .tooth-socket { fill: #70142d; }
.croc-tooth.is-bad .tooth-body { fill: #ffd9df; stroke: #ff385c; }

.croc-page.is-editing .croc-teeth-layer { touch-action: none; }
.croc-page.is-editing .croc-tooth { cursor: grab; }
.croc-page.is-editing .croc-tooth:active { cursor: grabbing; }
.croc-page.is-editing .croc-tooth.is-selected .tooth-hit {
  fill: rgba(255, 227, 107, .14);
  stroke: #ffe36b;
  stroke-width: .45;
  stroke-dasharray: 1.1 1;
}
.croc-page.is-editing .croc-tooth.is-selected .tooth-body {
  stroke: #ffe36b;
  stroke-width: .62;
}

.croc-stage.is-biting .croc-art-open { opacity: 0; transform: scale(.97); }
.croc-stage.is-biting .croc-art-closed { opacity: 1; animation: closed-snap .52s cubic-bezier(.18,.89,.25,1.18) both; }
.croc-stage.is-biting .croc-teeth-layer { opacity: 0; transition: opacity .05s linear; }
.croc-stage.is-biting .croc-character { animation: croc-shake .48s .08s ease-in-out both; }
.croc-stage.is-biting .croc-bite-word { animation: bite-word .7s .12s cubic-bezier(.18,.89,.32,1.28) both; }

.croc-bite-word {
  position: absolute;
  z-index: 5;
  left: 50%;
  top: 49%;
  color: #fff;
  font-size: clamp(3rem, 15vw, 6.5rem);
  font-weight: 900;
  letter-spacing: -.08em;
  text-shadow: 0 7px 0 #a11635, 0 16px 30px rgba(0,0,0,.45);
  transform: translate(-50%, -50%) scale(0) rotate(-10deg);
  opacity: 0;
  pointer-events: none;
}

@keyframes closed-snap {
  0% { transform: scale(.9, 1.28); opacity: 0; }
  48% { transform: scale(1.22, 1.1); opacity: 1; }
  68% { transform: scale(1.14, 1.2); }
  100% { transform: scale(1.18); opacity: 1; }
}

@keyframes croc-shake {
  0%, 100% { translate: 0; }
  25% { translate: -7px 2px; }
  50% { translate: 7px -1px; }
  75% { translate: -4px 1px; }
}

@keyframes bite-word {
  0% { opacity: 0; transform: translate(-50%, -50%) scale(.1) rotate(-10deg); }
  32%, 75% { opacity: 1; transform: translate(-50%, -50%) scale(1) rotate(-5deg); }
  100% { opacity: 0; transform: translate(-50%, -54%) scale(1.12) rotate(-2deg); }
}

.croc-rule {
  flex: 0 0 auto;
  max-width: 430px;
  margin: 5px auto 0;
  color: rgba(230,255,238,.52);
  font-size: .72rem;
  line-height: 1.55;
}

.bite-result {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: end center;
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom));
  background: rgba(2,16,12,.58);
  backdrop-filter: blur(8px);
  cursor: pointer;
}
.bite-result[hidden] { display: none; }

.tooth-editor[hidden] { display: none; }

.tooth-editor {
  position: fixed;
  z-index: 30;
  left: 50%;
  bottom: calc(12px + env(safe-area-inset-bottom));
  width: min(calc(100% - 24px), 540px);
  padding: 13px;
  color: #f7fff9;
  background: rgba(5, 31, 24, .94);
  border: 1px solid rgba(213, 255, 226, .2);
  border-radius: 18px;
  box-shadow: 0 18px 50px rgba(0, 0, 0, .4);
  backdrop-filter: blur(18px);
  transform: translateX(-50%);
}

.tooth-editor-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  font-size: .8rem;
}

.tooth-editor-heading span {
  color: #b9ddc7;
  font-size: .68rem;
  font-variant-numeric: tabular-nums;
}

.tooth-editor > p {
  margin: 4px 0 10px;
  color: rgba(238, 255, 245, .66);
  font-size: .66rem;
}

.tooth-editor-controls {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 6px;
}

.tooth-editor button {
  min-height: 36px;
  padding: 5px 7px;
  border: 1px solid rgba(213, 255, 226, .16);
  border-radius: 10px;
  color: #f7fff9;
  background: rgba(255, 255, 255, .07);
  font: 700 .68rem var(--font);
  cursor: pointer;
}

.tooth-editor button:active { transform: translateY(1px); }
.tooth-editor .tooth-editor-done {
  grid-column: 1 / -1;
  color: #09241b;
  background: #79e39b;
}

.bite-card {
  width: min(100%, 420px);
  padding: 28px 24px 22px;
  color: #1e2521;
  background: #fff;
  border-radius: 25px;
  text-align: center;
  box-shadow: 0 28px 90px rgba(0,0,0,.35);
  animation: card-up .36s cubic-bezier(.2,.88,.3,1.15) both;
}

.bite-emoji { display: block; font-size: 2.8rem; margin-bottom: 4px; }
.bite-label { margin: 0 0 5px; color: #ff385c; font-size: .7rem; font-weight: 800; letter-spacing: .14em; }
.bite-card h2 { margin: 0; font-size: 1.7rem; letter-spacing: -.04em; }
.bite-card > p:last-of-type { margin: 9px auto 18px; color: #666; font-size: .82rem; line-height: 1.55; }
.bite-restart {
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  color: #fff;
  background: #ff385c;
  border-radius: 999px;
  font-size: .9rem;
  box-shadow: 0 7px 20px rgba(255,56,92,.2);
}
.bite-restart span { font-size: 1.2rem; }

@keyframes card-up { from { opacity: 0; transform: translateY(28px) scale(.96); } }

@media (min-width: 680px) {
  .bite-result { place-items: center; }
}

@media (max-height: 700px) {
  .croc-heading { padding-top: 0; }
  .croc-stage { min-height: 300px; margin-bottom: -14px; }
  .croc-rule { display: none; }
  .tooth-editor { bottom: 7px; padding: 10px; }
  .tooth-editor > p { display: none; }
}

@media (prefers-reduced-motion: reduce) {
  .croc-art, .croc-tooth .tooth-body { transition: none; }
  .croc-stage.is-biting .croc-character { animation: none; }
}
