:root {
  color-scheme: light;
  --ink: #26346c;
  --violet: #6552d9;
  --purple: #8d52e1;
  --pink: #f45f9f;
  --yellow: #ffdf62;
  --mint: #68d9bb;
  --panel: rgba(255, 255, 255, 0.9);
  --shadow: 0 18px 42px rgba(68, 61, 146, 0.18);
}

* {
  box-sizing: border-box;
}

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

body {
  color: var(--ink);
  font-family: ui-rounded, "SF Pro Rounded", "Arial Rounded MT Bold", system-ui, sans-serif;
  background:
    radial-gradient(circle at 8% 15%, rgba(255, 223, 98, 0.52) 0 7px, transparent 8px),
    radial-gradient(circle at 91% 28%, rgba(244, 95, 159, 0.34) 0 9px, transparent 10px),
    radial-gradient(circle at 9% 72%, rgba(104, 217, 187, 0.3) 0 130px, transparent 132px),
    linear-gradient(180deg, #dff6ff 0%, #f2ecff 48%, #fff8df 100%);
}

button,
select,
input {
  color: inherit;
  font: inherit;
}

button,
select,
input[type="checkbox"] {
  cursor: pointer;
}

button {
  touch-action: manipulation;
}

.game-shell {
  width: min(1160px, calc(100% - 28px));
  min-height: 100svh;
  margin: 0 auto;
  padding: clamp(14px, 2.4vw, 28px) 0 38px;
}

.topbar {
  display: grid;
  grid-template-columns: 52px minmax(0, 1fr) auto;
  align-items: center;
  gap: 14px;
  margin-bottom: 18px;
}

.title-block {
  min-width: 0;
}

.eyebrow,
h1,
h2,
p {
  margin: 0;
}

.eyebrow {
  color: #7950bd;
  font-size: clamp(0.72rem, 1.5vw, 0.9rem);
  font-weight: 950;
  text-transform: uppercase;
}

h1 {
  font-size: clamp(1.75rem, 4vw, 3.5rem);
  line-height: 0.98;
  text-shadow: 0 4px 0 white;
}

.age-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 390px;
  padding: 11px 16px;
  border: 4px solid rgba(255, 255, 255, 0.82);
  border-radius: 8px;
  color: #773e72;
  background: #fff0a8;
  box-shadow: 0 7px 0 rgba(94, 72, 121, 0.12);
  font-size: clamp(0.8rem, 1.5vw, 1rem);
}

.counter-card {
  position: relative;
  padding: clamp(24px, 4vw, 48px);
  overflow: hidden;
  border: 5px solid rgba(255, 255, 255, 0.88);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 0 13px 0 rgba(91, 77, 179, 0.12), var(--shadow);
  text-align: center;
}

.rocket {
  position: absolute;
  top: 12px;
  right: clamp(14px, 3vw, 36px);
  font-size: clamp(3rem, 7vw, 5rem);
  filter: drop-shadow(0 7px 0 rgba(56, 68, 143, 0.14));
  transform: rotate(9deg);
  animation: hover 2s ease-in-out infinite;
}

.intro {
  margin-bottom: 17px;
  color: #565f80;
  font-size: clamp(0.95rem, 2vw, 1.18rem);
  font-weight: 800;
}

.unit-toggle {
  display: flex;
  justify-content: center;
  gap: 7px;
  width: min(460px, 100%);
  margin: 0 auto 22px;
  padding: 6px;
  border: 2px solid white;
  border-radius: 8px;
  background: #eeeaff;
}

.unit-button {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  color: #615c91;
  background: transparent;
  font-weight: 900;
}

.unit-button.active {
  color: white;
  background: linear-gradient(135deg, var(--violet), var(--purple));
  box-shadow: 0 5px 0 #4936ae;
  transform: translateY(-2px);
}

.number-stage {
  width: max-content;
  max-width: 100%;
  min-height: clamp(100px, 13vw, 150px);
  margin: 0 auto 8px;
  padding-top: 8px;
}

.count-number {
  color: #5145c5;
  font-family: ui-monospace, "SFMono-Regular", Consolas, monospace;
  font-size: clamp(2.2rem, 7.3vw, 6.2rem);
  font-weight: 1000;
  font-variant-numeric: tabular-nums;
  letter-spacing: -0.07em;
  line-height: 1;
  text-shadow: 0 5px 0 #ddd8fa;
  white-space: nowrap;
}

.place-labels {
  position: relative;
  width: 100%;
  height: 24px;
  margin-top: 11px;
}

.place-label {
  position: absolute;
  top: 0;
  width: max-content;
  color: #85609f;
  font-family: system-ui, sans-serif;
  font-size: clamp(0.54rem, 1.15vw, 0.78rem);
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  transform: translateX(-50%);
}

.unit-label {
  display: inline-block;
  padding: 9px 19px;
  border-radius: 999px;
  color: #a53c75;
  background: #ffe2ef;
  font-size: clamp(0.88rem, 1.7vw, 1.1rem);
  font-weight: 950;
  letter-spacing: 0.12em;
}

.birthday-panel {
  width: min(780px, 100%);
  margin: 24px auto 0;
  font-family: system-ui, sans-serif;
}

.birthday-summary {
  display: grid;
  grid-template-columns: auto 1fr auto;
  align-items: center;
  gap: 13px;
  padding: 13px 15px;
  border: 3px solid #e1dcfa;
  border-radius: 8px;
  background: #f7f5ff;
  text-align: left;
}

.cake-icon {
  display: grid;
  place-items: center;
  width: 48px;
  height: 48px;
  border-radius: 8px;
  background: white;
  font-size: 1.8rem;
}

.birthday-copy {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 2px 7px;
  min-width: 0;
}

.birthday-copy small {
  width: 100%;
  color: #747a96;
  font-weight: 800;
}

.birthday-copy strong {
  color: #344194;
  font-size: 1.05rem;
}

.birthday-copy span {
  color: #69708b;
}

.edit-button,
.save-button,
.close-picker {
  border: 0;
  font-weight: 900;
}

.edit-button {
  min-height: 44px;
  padding: 8px 15px;
  border: 3px solid #cfc8f6;
  border-radius: 8px;
  color: #5b48c7;
  background: white;
}

.birthday-form {
  margin-top: 10px;
  padding: 18px;
  border: 3px solid #d8d0fa;
  border-radius: 8px;
  background: #f1edff;
  text-align: left;
}

.birthday-form.hidden,
.time-field.hidden,
.form-error.hidden {
  display: none;
}

.picker-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
  color: #443c91;
}

.picker-heading > div {
  display: flex;
  align-items: center;
  gap: 8px;
}

.close-picker {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  color: #766e9d;
  background: white;
  font-size: 1.5rem;
}

.picker-grid {
  display: grid;
  grid-template-columns: 1.5fr 0.75fr 1fr;
  gap: 10px;
}

.picker-field {
  min-width: 0;
  color: #64698a;
  font-size: 0.74rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.picker-field span {
  display: block;
  margin: 0 0 6px 3px;
}

.picker-field select,
.time-field input {
  width: 100%;
  min-height: 48px;
  padding: 10px 12px;
  border: 3px solid #cfc7f5;
  border-radius: 8px;
  color: #313776;
  background: white;
  font-size: 1rem;
  font-weight: 800;
}

.time-choice {
  display: flex;
  align-items: center;
  gap: 9px;
  margin: 14px 2px 10px;
  color: #545b82;
  font-weight: 800;
}

.time-choice input {
  width: 20px;
  height: 20px;
  accent-color: var(--violet);
}

.time-field {
  display: block;
  max-width: 230px;
  margin: 0 0 14px;
  color: #64698a;
  font-size: 0.8rem;
  font-weight: 800;
}

.time-field input {
  display: block;
  margin-top: 6px;
}

.form-error {
  margin: 10px 0;
  padding: 9px 12px;
  border-radius: 8px;
  color: #9b285a;
  background: #ffe0ed;
  font-size: 0.88rem;
  font-weight: 800;
}

.save-button {
  width: 100%;
  min-height: 48px;
  padding: 12px 18px;
  border-radius: 8px;
  color: white;
  background: var(--pink);
  box-shadow: 0 5px 0 #b73670;
}

.fact-section {
  margin-top: 48px;
}

.fact-heading {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 13px;
  margin-bottom: 18px;
  text-align: left;
}

.fact-heading > span {
  font-size: 3.2rem;
}

.fact-heading p {
  color: var(--pink);
  font-weight: 950;
}

.fact-heading h2 {
  font-size: clamp(1.45rem, 3vw, 2.2rem);
}

.fact-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
}

.fact-card {
  min-width: 0;
  padding: 23px 15px;
  border: 5px solid white;
  border-radius: 8px;
  box-shadow: 0 9px 0 rgba(62, 67, 143, 0.12);
  text-align: center;
}

.fact-card.yellow { background: #fff1a9; }
.fact-card.pink { background: #ffd8e9; }
.fact-card.blue { background: #ccefff; }
.fact-icon { display: block; font-size: 2.8rem; }

.fact-card p {
  min-height: 2.8em;
  margin: 9px 0 6px;
  color: #566078;
  font-family: system-ui, sans-serif;
  font-weight: 750;
}

.fact-card strong {
  display: block;
  color: #3d3a9e;
  font-size: clamp(1.3rem, 3vw, 2.05rem);
  line-height: 1.1;
  overflow-wrap: anywhere;
}

.fact-card > span:last-child {
  display: block;
  margin-top: 3px;
  color: #6a4d82;
  font-weight: 800;
}

.count-challenge {
  display: flex;
  align-items: center;
  gap: 17px;
  width: min(760px, 100%);
  margin: 38px auto 0;
  padding: 18px 24px;
  border: 4px solid white;
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.78);
  box-shadow: 0 8px 0 rgba(68, 80, 160, 0.1);
}

.count-challenge > span {
  font-size: 4rem;
}

.count-challenge h2 {
  color: #5751bc;
  font-size: clamp(1.15rem, 2.4vw, 1.55rem);
}

.count-challenge p {
  margin-top: 5px;
  color: #606980;
  font-family: system-ui, sans-serif;
}

button:hover {
  filter: saturate(1.08);
  transform: translateY(-1px);
}

button:focus-visible,
select:focus-visible,
input:focus-visible {
  outline: 4px solid #2fb6c8;
  outline-offset: 3px;
}

.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;
}

@keyframes hover {
  50% { transform: translateY(-9px) rotate(5deg); }
}

@media (max-width: 760px) {
  .topbar {
    grid-template-columns: 46px minmax(0, 1fr);
  }

  .age-badge {
    grid-column: 1 / -1;
    justify-content: center;
    max-width: none;
  }

  .counter-card {
    padding: 28px 16px;
  }

  .rocket {
    top: 8px;
    right: 10px;
  }

  .fact-grid {
    grid-template-columns: 1fr;
    width: min(470px, 100%);
    margin: 0 auto;
  }

  .fact-card p {
    min-height: auto;
  }
}

@media (max-width: 470px) {
  .game-shell {
    width: min(100% - 20px, 1160px);
  }

  .title-block h1 {
    font-size: 1.75rem;
  }

  .intro {
    max-width: 255px;
    margin-right: auto;
    margin-left: auto;
  }

  .unit-button {
    min-height: 44px;
    padding: 7px 3px;
    font-size: 0.77rem;
  }

  .number-stage {
    min-height: 108px;
  }

  .place-labels {
    height: 38px;
  }

  .place-label:nth-child(even) {
    top: 16px;
  }

  .birthday-summary {
    grid-template-columns: auto 1fr;
  }

  .edit-button {
    grid-column: 1 / -1;
    width: 100%;
  }

  .picker-grid {
    grid-template-columns: 1fr 1fr;
  }

  .month-field {
    grid-column: 1 / -1;
  }

  .count-challenge {
    padding: 15px;
  }

  .count-challenge > span {
    font-size: 3.2rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    scroll-behavior: auto !important;
  }
}
