:root {
  --cf-blue: #1769ff;
  --cf-green: #14985d;
  --cf-deep-green: #0d6f46;
  --cf-ink: #13304c;
  --cf-muted: #587086;
  --cf-border: #cfe1ee;
}

.cf-game,
.cf-game * { box-sizing: border-box; }

.cf-game {
  width: 100%;
  overflow: hidden;
  border: 1px solid var(--cf-border);
  border-radius: 28px;
  background: #f7fcff;
  color: var(--cf-ink);
  box-shadow: 0 22px 54px rgba(19, 65, 91, .13);
  font-family: Inter, ui-rounded, "Segoe UI", Arial, sans-serif;
}

.cf-game-head {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  padding: 18px 20px;
  border-bottom: 1px solid #d9eaf2;
  background:
    radial-gradient(circle at 89% 22%, rgba(253, 224, 71, .31), transparent 19%),
    linear-gradient(135deg, #f8fdff, #edfaff 58%, #fffde9);
}

.cf-game-title { display: flex; gap: 14px; align-items: center; min-width: 0; }
.cf-game-logo {
  flex: 0 0 62px;
  display: grid;
  place-items: center;
  width: 62px;
  height: 62px;
  border: 1px solid #bfe5d0;
  border-radius: 20px;
  background: linear-gradient(145deg, #e7ffe9, #bdeed0);
  font-size: 36px;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .55);
}
.cf-game-eyebrow { margin: 0; color: var(--cf-green); font-size: 10px; font-weight: 900; letter-spacing: .13em; }
.cf-game-title h2 { margin: 3px 0 2px; color: #102f59; font: 900 clamp(24px, 3vw, 34px)/1.05 Poppins, Inter, sans-serif; letter-spacing: -.025em; }
.cf-game-best { display: block; overflow: hidden; color: #4f6e82; font-size: 12px; text-overflow: ellipsis; white-space: nowrap; }

.cf-mode-field {
  display: grid;
  grid-template-columns: 38px minmax(150px, 1fr);
  gap: 9px;
  align-items: center;
  min-width: 220px;
  padding: 9px 11px;
  border: 1px solid #cce1ed;
  border-radius: 16px;
  background: rgba(255, 255, 255, .85);
}
.cf-mode-field > span { grid-row: 1 / 3; display: grid; place-items: center; width: 36px; height: 36px; border-radius: 12px; background: #e7f7ee; font-size: 20px; }
.cf-mode-field label { color: #5b7185; font-size: 9px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.cf-mode-field select { width: 100%; min-height: 32px; padding: 4px 26px 4px 8px; border: 1px solid #c7dce9; border-radius: 9px; background: #fff; color: #183b59; font: 800 12px Inter, sans-serif; }

.cf-stats {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 8px;
  padding: 10px 12px;
  background: #f5fbfd;
}
.cf-stat {
  display: grid;
  grid-template-columns: auto 1fr;
  grid-template-rows: auto auto;
  gap: 1px 7px;
  align-items: center;
  min-width: 0;
  padding: 8px 9px;
  border: 1px solid #d7e7ef;
  border-radius: 14px;
  background: #fff;
}
.cf-stat > span { grid-row: 1 / 3; font-size: 22px; }
.cf-stat small { overflow: hidden; color: #718397; font-size: 8px; font-weight: 900; letter-spacing: .06em; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.cf-stat strong { overflow: hidden; color: #153e68; font: 900 17px/1.1 Poppins, Inter, sans-serif; text-overflow: ellipsis; white-space: nowrap; }
.cf-stat:nth-child(1) { background: #eaf5ff; }
.cf-stat:nth-child(2) { background: #eafaf0; }
.cf-stat:nth-child(3) { background: #f3edff; }
.cf-stat:nth-child(4) { background: #fff5dc; }
.cf-stat:nth-child(5) { background: #ffebef; }
.cf-stat:nth-child(6) { background: #edfafa; }
.cf-stat [data-cf-lives] { color: #e11d48; font-size: 15px; letter-spacing: 1px; }

.cf-stage {
  position: relative;
  min-height: 500px;
  overflow: hidden;
  outline: none;
  background:
    linear-gradient(180deg, rgba(30, 132, 184, .02), rgba(10, 82, 47, .10)),
    url("curious-forest-background.png") center / cover no-repeat,
    #71c878;
  box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .30);
}
.cf-stage:focus-visible { box-shadow: inset 0 0 0 4px rgba(255, 255, 255, .9), inset 0 0 0 8px rgba(23, 105, 255, .55); }

.cf-scenery { position: absolute; inset: 0; overflow: hidden; pointer-events: none; }
.cf-forest-friend { position: absolute; z-index: 4; bottom: 72px; font-size: 38px; }
.cf-forest-friend.rabbit { left: 5%; }
.cf-forest-friend.owl { right: 6%; bottom: 148px; }

.cf-stage-progress {
  position: absolute;
  top: 13px;
  right: 13px;
  left: 13px;
  z-index: 8;
  display: grid;
  grid-template-columns: auto minmax(90px, 240px);
  gap: 10px;
  justify-content: end;
  align-items: center;
  pointer-events: none;
}
.cf-stage-progress strong { padding: 6px 9px; border-radius: 999px; background: rgba(15, 73, 105, .80); color: #fff; font-size: 10px; letter-spacing: .05em; }
.cf-progress-track { height: 10px; overflow: hidden; border: 2px solid rgba(255, 255, 255, .62); border-radius: 999px; background: rgba(15, 73, 105, .34); }
.cf-progress-track i { display: block; width: 0; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #fde047, #f59e0b); transition: width .25s ease; }

.cf-target-card {
  --cf-target-x: 50%;
  --cf-target-y: 34%;
  position: absolute;
  top: var(--cf-target-y);
  left: var(--cf-target-x);
  z-index: 10;
  width: min(460px, calc(100% - 190px));
  padding: 14px 16px 13px;
  overflow: hidden;
  border: 3px solid rgba(255, 255, 255, .88);
  border-radius: 22px;
  background: rgba(255, 255, 255, .94);
  box-shadow: 0 18px 35px rgba(18, 75, 86, .22), inset 0 0 0 1px #c7e6d4;
  text-align: center;
  transform: translate(-50%, -28%);
  transition: top .25s ease, left .25s ease;
  backdrop-filter: blur(6px);
}
.cf-target-card[hidden] { display: none; }
.cf-target-icon { display: block; margin-bottom: 1px; font-size: 43px; filter: drop-shadow(0 5px 6px rgba(14, 72, 43, .16)); }
.cf-target-hint { display: block; margin-bottom: 7px; color: #4f7180; font-size: 10px; font-weight: 900; letter-spacing: .08em; text-transform: uppercase; }
.cf-target-text { display: flex; justify-content: center; flex-wrap: wrap; gap: 2px; min-height: 51px; }
.cf-target-text span { display: inline-grid; place-items: center; min-width: .72em; border-radius: 8px; color: #6b7f8c; font: 900 clamp(28px, 4.7vw, 46px)/1.1 Poppins, Inter, sans-serif; }
.cf-target-text .done { color: #15915b; }
.cf-target-text .current { padding: 0 5px; background: var(--cf-blue); color: #fff; box-shadow: 0 0 0 4px rgba(23, 105, 255, .16); }
.cf-target-text .idle { color: #1769ff; font-size: clamp(23px, 4vw, 36px); letter-spacing: .03em; }
.cf-countdown-track { height: 8px; margin-top: 11px; overflow: hidden; border-radius: 999px; background: #e5edf0; }
.cf-countdown-track i { display: block; width: 100%; height: 100%; border-radius: inherit; background: linear-gradient(90deg, #ef4444 0 18%, #f59e0b 38%, #22c55e 72%); }
.cf-target-card.is-wrong { animation: cfShake .23s ease; }
.cf-target-card.is-correct { animation: cfSuccess .25s ease; }
.cf-target-card.is-missed { animation: cfFade .2s ease; }

.cf-trail { position: absolute; z-index: 5; right: 4%; bottom: 48px; left: 4%; height: 44px; border-radius: 48% 52% 12px 12px; background: linear-gradient(180deg, #dec18b, #b98a52); box-shadow: inset 0 7px 0 rgba(255, 238, 186, .52); }
.cf-trail::after { content: "•  •  •  •  •  •  •  •  •  •  •  •"; position: absolute; inset: 5px 12px; overflow: hidden; color: rgba(111, 72, 37, .45); font-size: 21px; letter-spacing: 24px; white-space: nowrap; }
.cf-explorer { position: absolute; z-index: 7; bottom: 72px; left: 6%; font-size: 50px; filter: drop-shadow(0 7px 6px rgba(34, 65, 42, .22)); transform: translateX(-50%); transition: left .28s ease; }

.cf-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid #d8e8ed;
  background: #f8fcfd;
}
.cf-button {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  min-height: 42px;
  padding: 10px 13px;
  border: 1px solid #c9dce7;
  border-radius: 12px;
  background: #ecf5fb;
  color: #173b5c;
  box-shadow: none;
  font: 800 12px/1.15 Inter, sans-serif;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
}
.cf-button:hover { border-color: #9bbfd2; background: #e1eff8; }
.cf-button:focus-visible { outline: 3px solid rgba(23, 105, 255, .28); outline-offset: 2px; }
.cf-button.primary { border-color: #1769ff; background: #1769ff; color: #fff; box-shadow: 0 7px 16px rgba(23, 105, 255, .22); }
.cf-button.primary:hover { background: #0f58dc; }
.cf-button.green { border-color: #14985d; background: #14985d; color: #fff; box-shadow: 0 7px 16px rgba(20, 152, 93, .20); }
.cf-button.green:hover { background: #0e7f4d; }
.cf-button.light { background: #fff; color: #1769ff; }
.cf-button:disabled { opacity: .52; cursor: not-allowed; }
.cf-button[hidden] { display: none; }
.cf-start { min-width: 132px; }
.cf-mobile-keyboard { display: none; }
.cf-mobile-input { position: fixed; left: 50%; bottom: 0; width: 1px; height: 1px; opacity: .01; pointer-events: none; }
.cf-message { min-height: 42px; margin: 0; padding: 11px 14px; border-top: 1px solid #d5e8f0; background: #eef8ff; color: #17558b; font-size: 12px; font-weight: 800; text-align: center; }

.cf-game.is-paused .cf-stage::after {
  content: "Adventure paused\A Press Resume when you are ready";
  position: absolute;
  inset: 0;
  z-index: 18;
  display: grid;
  place-items: center;
  padding: 20px;
  background: rgba(15, 47, 67, .62);
  color: #fff;
  font: 900 clamp(22px, 4vw, 34px)/1.5 Poppins, Inter, sans-serif;
  text-align: center;
  white-space: pre-line;
  backdrop-filter: blur(3px);
}

.cf-results {
  position: absolute;
  inset: 0;
  z-index: 24;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(222, 247, 237, .69);
  backdrop-filter: blur(3px);
}
.cf-results[hidden] { display: none; }
.cf-result-card {
  width: min(720px, calc(100% - 12px));
  padding: 20px;
  border: 1px solid rgba(178, 214, 197, .95);
  border-radius: 24px;
  background: rgba(255, 255, 255, .97);
  color: var(--cf-ink);
  box-shadow: 0 22px 50px rgba(12, 64, 44, .22), inset 0 0 0 1px #fff;
  text-align: center;
  animation: cfResultIn .3s ease-out both;
}
.cf-result-card:focus { outline: none; }
.cf-result-stars { color: #f59e0b; font-size: 35px; letter-spacing: 4px; }
.cf-result-kicker { margin: 3px 0 0 !important; color: #14985d !important; font-size: 9px !important; font-weight: 900 !important; letter-spacing: .14em; }
.cf-result-card h2 { margin: 4px 0; color: #12482f; font: 900 clamp(26px, 4vw, 36px)/1.08 Poppins, Inter, sans-serif; }
.cf-result-card > p { margin: 0; color: #537063; font-size: 13px; font-weight: 700; line-height: 1.45; }
.cf-result-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 8px; margin: 13px 0 10px; }
.cf-result-grid > div { display: grid; grid-template-columns: auto 1fr; grid-template-rows: auto auto; gap: 1px 7px; align-items: center; min-width: 0; padding: 9px; border: 1px solid #d7e9df; border-radius: 14px; background: #edf9f1; text-align: left; }
.cf-result-grid > div:nth-child(2) { background: #edf5ff; }
.cf-result-grid > div:nth-child(3) { background: #fff5de; }
.cf-result-grid > div:nth-child(4) { background: #f4efff; }
.cf-result-grid span { grid-row: 1 / 3; font-size: 22px; }
.cf-result-grid small { overflow: hidden; color: #6e8078; font-size: 8px; font-weight: 900; text-overflow: ellipsis; text-transform: uppercase; white-space: nowrap; }
.cf-result-grid strong { color: #164e35; font: 900 17px/1.1 Poppins, Inter, sans-serif; }
.cf-result-best { display: inline-block; margin-bottom: 11px !important; padding: 6px 12px; border-radius: 999px; background: #fff3bd; color: #86520c !important; font-size: 11px !important; }
.cf-result-actions { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; }
.cf-result-actions .cf-button { min-width: 0; }
.cf-game.is-finished .cf-controls,
.cf-game.is-finished .cf-message { display: none; }

.cf-game:fullscreen { overflow: auto; width: 100%; height: 100%; padding: 12px; border: 0; border-radius: 0; background: #eaf9f0; }
.cf-game:fullscreen .cf-stage { min-height: min(66vh, 700px); }

.cf-offline-page {
  min-height: 100vh;
  margin: 0;
  padding: 18px;
  background:
    radial-gradient(circle at top left, rgba(147, 224, 255, .45), transparent 28%),
    radial-gradient(circle at top right, rgba(253, 224, 71, .20), transparent 24%),
    #eef9f4;
  color: var(--cf-ink);
  font-family: Inter, ui-rounded, "Segoe UI", Arial, sans-serif;
}
.cf-offline-shell { width: min(1180px, 100%); margin: 0 auto; }
.cf-offline-brand { display: flex; justify-content: space-between; gap: 18px; align-items: center; margin-bottom: 12px; }
.cf-offline-brand-main { display: flex; gap: 18px; align-items: center; min-width: 0; }
.cf-offline-logo { flex: 0 0 auto; display: inline-flex; padding: 5px 8px; border: 1px solid #cfe1ee; border-radius: 13px; background: #fff; box-shadow: 0 7px 18px rgba(23, 105, 255, .10); }
.cf-offline-logo img { display: block; width: 210px; height: auto; }
.cf-offline-logo:focus-visible { outline: 3px solid rgba(23, 105, 255, .30); outline-offset: 2px; }
.cf-offline-brand h1 { margin: 0; color: #123f2c; font: 900 clamp(25px, 4vw, 38px)/1.1 Poppins, Inter, sans-serif; }
.cf-offline-brand p { margin: 4px 0 0; color: #587064; }
.cf-offline-badge { flex: 0 0 auto; padding: 8px 11px; border: 1px solid #b8dbc6; border-radius: 999px; background: #fff; color: #18744c; font-size: 11px; font-weight: 900; }
.cf-offline-footer { padding: 13px 6px 0; color: #60786b; font-size: 11px; text-align: center; }
.cf-offline-footer a { color: #1769ff; font-weight: 800; }

@keyframes cfShake { 25% { transform: translate(calc(-50% - 7px), -28%); } 70% { transform: translate(calc(-50% + 7px), -28%); } }
@keyframes cfSuccess { 50% { transform: translate(-50%, -28%) scale(1.045); filter: brightness(1.08); } }
@keyframes cfFade { 60% { opacity: .46; transform: translate(-50%, -20%); } }
@keyframes cfResultIn { from { opacity: 0; transform: translateY(10px) scale(.98); } to { opacity: 1; transform: translateY(0) scale(1); } }

@media (max-width: 900px) {
  .cf-stats { grid-template-columns: repeat(3, minmax(0, 1fr)); }
  .cf-target-card { width: min(500px, calc(100% - 110px)); }
}

@media (max-width: 650px) {
  .cf-game-head { grid-template-columns: 1fr; padding: 14px; }
  .cf-mode-field { width: 100%; min-width: 0; }
  .cf-game-logo { flex-basis: 52px; width: 52px; height: 52px; border-radius: 16px; font-size: 30px; }
  .cf-stage { min-height: 480px; }
  .cf-target-card { left: 50% !important; width: calc(100% - 34px); transform: translate(-50%, -25%); }
  .cf-forest-friend.owl { display: none; }
  .cf-result-actions { grid-template-columns: 1fr 1fr; }
  .cf-result-actions .light { grid-column: 1 / -1; }
  .cf-offline-page { padding: 8px; }
  .cf-offline-brand { display: block; padding: 6px 4px; }
  .cf-offline-brand-main { display: grid; gap: 10px; }
  .cf-offline-logo { width: fit-content; }
  .cf-offline-logo img { width: min(230px, 70vw); }
  .cf-offline-badge { display: inline-block; margin-top: 8px; }
}

@media (max-width: 430px) {
  .cf-stats { grid-template-columns: repeat(2, minmax(0, 1fr)); padding: 8px; }
  .cf-stage { min-height: 450px; }
  .cf-target-text span { font-size: clamp(25px, 9.5vw, 39px); }
  .cf-controls { display: grid; grid-template-columns: 1fr 1fr; }
  .cf-controls .cf-start { grid-column: 1 / -1; }
  .cf-results { align-items: start; overflow: auto; padding: 8px; }
  .cf-result-card { width: 100%; padding: 14px 11px; }
  .cf-result-grid { grid-template-columns: 1fr 1fr; }
  .cf-result-actions { grid-template-columns: 1fr; }
  .cf-result-actions .light { grid-column: auto; }
}

@media (pointer: coarse) {
  .cf-mobile-keyboard { display: inline-flex; }
}

@media (prefers-reduced-motion: reduce) {
  .cf-target-card,
  .cf-explorer,
  .cf-progress-track i,
  .cf-result-card { animation: none !important; transition: none !important; }
}

@media (prefers-color-scheme: dark) {
  .cf-offline-page { background: #0c1d18; color: #e9fff2; }
  .cf-offline-brand h1 { color: #f2fff7; }
  .cf-offline-brand p,
  .cf-offline-footer { color: #b7cfc1; }
  .cf-offline-badge { border-color: #345f4b; background: #132d24; color: #9aebbc; }
}
