:root {
  --purple: #7357ff;
  --purple-dark: #5540d7;
  --pink: #ff5fa2;
  --yellow: #ffd84d;
  --green: #45d483;
  --blue: #42b7ff;
  --orange: #ff9c4a;
  --ink: #302a4b;
  --muted: #736d8c;
  --surface: rgba(255, 255, 255, 0.92);
  --shadow: 0 18px 45px rgba(75, 57, 146, 0.18);
  --radius-xl: 32px;
  --radius-lg: 24px;
  --radius-md: 18px;
}

* { box-sizing: border-box; }

html, body { min-height: 100%; }

body {
  margin: 0;
  font-family: "Trebuchet MS", "Arial Rounded MT Bold", system-ui, sans-serif;
  color: var(--ink);
  background: linear-gradient(145deg, #fff7dc 0%, #f5ecff 45%, #e7f8ff 100%);
  overflow-x: hidden;
}

button { font: inherit; }
button:focus-visible { outline: 5px solid rgba(115, 87, 255, 0.3); outline-offset: 4px; }

.background-shapes { position: fixed; inset: 0; pointer-events: none; overflow: hidden; }
.blob { position: absolute; border-radius: 50%; filter: blur(2px); opacity: .35; animation: float 7s ease-in-out infinite; }
.blob-1 { width: 280px; height: 280px; background: #ffd84d; top: -80px; left: -90px; }
.blob-2 { width: 360px; height: 360px; background: #a997ff; right: -150px; top: 25%; animation-delay: -2s; }
.blob-3 { width: 240px; height: 240px; background: #63dff0; left: 18%; bottom: -110px; animation-delay: -4s; }

@keyframes float { 50% { transform: translateY(18px) scale(1.04); } }

.app-shell {
  position: relative;
  width: min(1080px, calc(100% - 28px));
  margin: 0 auto;
  padding: 20px 0 40px;
}

.topbar {
  display: grid;
  grid-template-columns: 58px 1fr 58px;
  align-items: center;
  gap: 14px;
  margin-bottom: 22px;
}

.brand { display: flex; align-items: center; justify-content: center; min-width: 0; }
.brand-logo {
  display: block;
  width: min(410px, 100%);
  max-height: 112px;
  object-fit: contain;
  border-radius: 22px;
  mix-blend-mode: multiply;
}

.icon-button {
  width: 58px; height: 58px; border: 0; border-radius: 20px; background: var(--surface);
  box-shadow: 0 9px 22px rgba(75,57,146,.14); cursor: pointer; font-size: 1.5rem;
  transition: transform .18s ease, box-shadow .18s ease;
}
.icon-button:hover { transform: translateY(-3px) rotate(-2deg); box-shadow: 0 14px 25px rgba(75,57,146,.2); }

.screen { display: none; animation: fadeIn .35s ease; }
.screen.active { display: block; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(10px); } }

.hero-card {
  display: flex; align-items: center; gap: 22px; padding: 26px 30px; margin-bottom: 22px;
  border-radius: var(--radius-xl); background: linear-gradient(120deg, #7357ff, #9a7eff);
  color: white; box-shadow: var(--shadow); overflow: hidden; position: relative;
}
.hero-card::after { content: ""; position: absolute; width: 210px; height: 210px; border: 30px solid rgba(255,255,255,.13); border-radius: 50%; right: -65px; top: -85px; }
.mascot { font-size: clamp(4rem, 10vw, 6.5rem); filter: drop-shadow(0 10px 9px rgba(0,0,0,.14)); animation: mascotBounce 2.4s ease-in-out infinite; }
@keyframes mascotBounce { 50% { transform: translateY(-8px) rotate(3deg); } }
.eyebrow { display: inline-block; padding: 6px 11px; background: rgba(255,255,255,.2); border-radius: 999px; font-size: .78rem; font-weight: 800; text-transform: uppercase; letter-spacing: .08em; }
.hero-card h2 { margin: 10px 0 4px; font-size: clamp(1.55rem, 4vw, 2.45rem); }
.hero-card p { margin: 0; font-size: clamp(1rem, 2.5vw, 1.2rem); opacity: .9; }


.player-card {
  display: grid;
  grid-template-columns: 76px minmax(0, 1fr);
  gap: 18px;
  align-items: center;
  margin: 0 0 22px;
  padding: 20px 24px;
  background: var(--surface);
  border: 3px solid rgba(115, 87, 255, .12);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
}
.player-icon {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  border-radius: 23px;
  background: linear-gradient(145deg, #fff3b8, #ffe08b);
  font-size: 2.8rem;
  box-shadow: inset 0 0 0 4px rgba(255,255,255,.6), 0 9px 18px rgba(75,57,146,.12);
}
.player-copy label {
  display: block;
  margin-bottom: 4px;
  color: var(--purple-dark);
  font-size: clamp(1.2rem, 3vw, 1.55rem);
  font-weight: 900;
}
.player-copy p { margin: 0 0 12px; color: var(--muted); line-height: 1.4; }
.name-field-wrap { position: relative; }
.name-field-wrap input {
  width: 100%;
  min-height: 56px;
  padding: 13px 52px 13px 17px;
  border: 3px solid #ded6ff;
  border-radius: 18px;
  background: #fff;
  color: var(--ink);
  font: inherit;
  font-size: 1.12rem;
  font-weight: 800;
  outline: none;
  transition: border-color .18s ease, box-shadow .18s ease, transform .18s ease;
}
.name-field-wrap input:focus {
  border-color: var(--purple);
  box-shadow: 0 0 0 5px rgba(115,87,255,.12);
  transform: translateY(-1px);
}
.name-field-wrap input.invalid { border-color: #ff6378; animation: shake .4s ease; }
.name-pencil { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); font-size: 1.35rem; pointer-events: none; }
.player-copy small { display: block; margin-top: 8px; color: var(--muted); line-height: 1.35; }
.name-error { display: block; min-height: 1.2em; margin-top: 5px; color: #d83d55; font-size: .9rem; }

.mode-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.mode-card {
  position: relative; min-height: 172px; padding: 22px; border: 0; border-radius: var(--radius-lg); text-align: left;
  display: grid; grid-template-columns: 80px 1fr; gap: 18px; align-items: center; cursor: pointer; color: var(--ink);
  box-shadow: var(--shadow); transition: transform .18s ease, box-shadow .18s ease;
}
.mode-card:hover { transform: translateY(-6px) scale(1.01); box-shadow: 0 22px 48px rgba(75,57,146,.24); }
.mode-card:active { transform: scale(.98); }
.shape-theme { background: linear-gradient(135deg, #fff, #fff0f7); }
.color-theme { background: linear-gradient(135deg, #fff, #eefaff); }
.number-theme { background: linear-gradient(135deg, #fff, #fff8db); }
.mix-theme { background: linear-gradient(135deg, #fff, #effff4); }
.mode-illustration { display: grid; place-items: center; width: 80px; height: 80px; border-radius: 25px; background: rgba(255,255,255,.85); font-size: 3.3rem; box-shadow: inset 0 0 0 4px rgba(255,255,255,.55), 0 10px 24px rgba(47,40,81,.1); }
.mode-copy { display: flex; flex-direction: column; gap: 7px; }
.mode-copy strong { font-size: clamp(1.25rem, 3vw, 1.65rem); }
.mode-copy small { color: var(--muted); font-size: .94rem; line-height: 1.35; }
.play-badge { position: absolute; right: 18px; bottom: 16px; background: var(--purple); color: white; padding: 7px 13px; border-radius: 999px; font-size: .84rem; font-weight: 900; }

.progress-card { margin-top: 20px; padding: 20px 24px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow); }
.progress-card > div:first-child { display: flex; justify-content: space-between; align-items: center; }
.progress-label { color: var(--muted); font-weight: 800; }
.progress-card strong { font-size: 1.35rem; }
.trophy-track { height: 15px; margin: 13px 0 8px; border-radius: 999px; background: #eeeaf7; overflow: hidden; }
.trophy-progress { height: 100%; width: 0%; border-radius: inherit; background: linear-gradient(90deg, #ffd84d, #ff9c4a); transition: width .5s ease; }
.trophy-text { color: var(--muted); font-size: .9rem; }

.game-hud { display: flex; justify-content: center; gap: 12px; flex-wrap: wrap; margin-bottom: 17px; }
.hud-pill { min-width: 88px; display: flex; justify-content: center; gap: 8px; align-items: center; padding: 10px 16px; border-radius: 999px; background: var(--surface); box-shadow: 0 9px 20px rgba(75,57,146,.12); font-size: 1.08rem; }
.level-pill { background: linear-gradient(135deg, #7357ff, #9b84ff); color: white; }
.level-pill span { font-size: .84rem; text-transform: uppercase; letter-spacing: .06em; }

.question-card { text-align: center; background: var(--surface); border-radius: var(--radius-xl); padding: 25px 22px; box-shadow: var(--shadow); margin-bottom: 20px; }
.mode-tag { display: inline-block; padding: 6px 13px; border-radius: 999px; background: #ece7ff; color: var(--purple-dark); font-weight: 900; font-size: .82rem; text-transform: uppercase; letter-spacing: .07em; }
.question-card h2 { font-size: clamp(1.7rem, 5vw, 2.8rem); margin: 14px 0 16px; }
.repeat-button { border: 0; border-radius: 999px; background: #f2efff; color: var(--purple-dark); padding: 10px 18px; font-weight: 900; cursor: pointer; }

.answers-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 18px; }
.answer-card {
  min-height: 190px; border: 5px solid transparent; border-radius: var(--radius-xl); background: white; box-shadow: var(--shadow);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 12px; cursor: pointer;
  transition: transform .15s ease, border-color .15s ease, filter .15s ease; position: relative; overflow: hidden;
}
.answer-card::after { content: ""; position: absolute; inset: auto -30px -55px auto; width: 120px; height: 120px; border-radius: 50%; background: rgba(115,87,255,.06); }
.answer-card:hover { transform: translateY(-5px); }
.answer-card:active { transform: scale(.97); }
.answer-card.correct { border-color: var(--green); animation: correctPulse .55s ease; }
.answer-card.wrong { border-color: #ff6a7d; animation: shake .4s ease; }
.answer-visual { min-height: 105px; display: grid; place-items: center; font-size: 5.2rem; line-height: 1; }
.answer-label { font-size: 1.15rem; font-weight: 900; color: var(--ink); }

.geo-shape { width: 96px; height: 96px; display: block; filter: drop-shadow(0 8px 8px rgba(0,0,0,.12)); }
.geo-circle { border-radius: 50%; }
.geo-square { border-radius: 12px; }
.geo-triangle { width: 0; height: 0; border-left: 52px solid transparent; border-right: 52px solid transparent; border-bottom: 96px solid currentColor; filter: drop-shadow(0 8px 8px rgba(0,0,0,.12)); }
.geo-rectangle { width: 125px; height: 78px; border-radius: 12px; }
.geo-oval { width: 130px; height: 82px; border-radius: 50%; }
.geo-star { width: auto; height: auto; font-size: 6rem; }

.color-swatch { width: 112px; height: 112px; border-radius: 28px; box-shadow: inset 0 0 0 8px rgba(255,255,255,.32), 0 10px 18px rgba(0,0,0,.12); }
.number-visual { display: flex; flex-direction: column; align-items: center; gap: 8px; }
.big-number { font-size: 5.3rem; color: var(--purple); text-shadow: 0 7px 0 #e8e1ff; }
.count-dots { max-width: 180px; display: flex; flex-wrap: wrap; justify-content: center; gap: 5px; font-size: 1.2rem; }

@keyframes correctPulse { 50% { transform: scale(1.05); } }
@keyframes shake { 25%,75% { transform: translateX(-8px); } 50% { transform: translateX(8px); } }

.round-progress { height: 15px; margin: 22px auto 7px; max-width: 600px; background: rgba(255,255,255,.75); border-radius: 999px; overflow: hidden; box-shadow: inset 0 2px 5px rgba(75,57,146,.1); }
.round-progress-bar { height: 100%; width: 12.5%; background: linear-gradient(90deg, #7357ff, #ff5fa2); border-radius: inherit; transition: width .35s ease; }
.round-text { text-align: center; margin: 0; color: var(--muted); font-weight: 800; }

.result-card { max-width: 650px; margin: 20px auto; text-align: center; padding: 34px; background: var(--surface); border-radius: 38px; box-shadow: var(--shadow); }
.result-medal { font-size: 6rem; animation: medalPop .8s cubic-bezier(.17,.67,.35,1.4); }
@keyframes medalPop { from { transform: scale(.2) rotate(-18deg); opacity: 0; } }
.result-card h2 { font-size: clamp(2rem, 6vw, 3.2rem); margin: 12px 0 4px; }
.result-card > p { color: var(--muted); font-size: 1.1rem; }
.result-score { display: flex; flex-direction: column; gap: 7px; margin: 24px auto; padding: 20px; max-width: 360px; border-radius: 22px; background: #fff6cf; }
.result-score span { color: #8d6c00; font-weight: 800; }
.result-score strong { font-size: 2rem; }
.badge-row { display: flex; justify-content: center; flex-wrap: wrap; gap: 10px; margin-bottom: 25px; }
.badge { padding: 9px 13px; border-radius: 999px; background: #eeeaff; color: var(--purple-dark); font-weight: 900; }
.result-actions { display: grid; gap: 12px; }
.primary-button, .secondary-button { border: 0; border-radius: 18px; padding: 15px 20px; font-weight: 900; font-size: 1.05rem; cursor: pointer; }
.primary-button { background: linear-gradient(135deg, var(--purple), #9278ff); color: white; box-shadow: 0 12px 23px rgba(115,87,255,.3); }
.secondary-button { background: #f0edf8; color: var(--ink); }

.feedback-overlay { position: fixed; inset: 0; z-index: 30; display: grid; place-items: center; pointer-events: none; opacity: 0; transition: opacity .18s ease; background: rgba(47,40,81,.08); }
.feedback-overlay.show { opacity: 1; }
.feedback-bubble { min-width: 230px; padding: 24px 28px; text-align: center; border-radius: 30px; background: white; box-shadow: 0 22px 70px rgba(47,40,81,.28); transform: scale(.75); transition: transform .25s cubic-bezier(.17,.67,.35,1.4); }
.feedback-overlay.show .feedback-bubble { transform: scale(1); }
.feedback-bubble span { display: block; font-size: 4rem; }
.feedback-bubble strong { display: block; font-size: 1.65rem; margin: 5px 0; }
.feedback-bubble small { color: var(--muted); font-size: 1rem; }

.confetti-container { position: fixed; inset: 0; pointer-events: none; z-index: 40; overflow: hidden; }
.confetti { position: absolute; top: -24px; width: 12px; height: 22px; border-radius: 4px; animation: confettiFall 1.7s linear forwards; }
@keyframes confettiFall { to { transform: translate3d(var(--drift), 110vh, 0) rotate(720deg); opacity: .9; } }

@media (max-width: 720px) {
  .app-shell { width: min(100% - 18px, 680px); padding-top: 10px; }
  .topbar { grid-template-columns: 48px 1fr 48px; gap: 7px; }
  .icon-button { width: 48px; height: 48px; border-radius: 16px; }
  .brand-logo { max-height: 82px; border-radius: 15px; }
  .hero-card { padding: 20px; gap: 14px; }
  .player-card { grid-template-columns: 58px minmax(0, 1fr); padding: 16px; gap: 12px; }
  .player-icon { width: 56px; height: 56px; border-radius: 18px; font-size: 2rem; }
  .player-copy p { font-size: .9rem; }
  .name-field-wrap input { min-height: 52px; font-size: 1rem; }
  .mascot { font-size: 4rem; }
  .mode-grid { grid-template-columns: 1fr; gap: 13px; }
  .mode-card { min-height: 135px; grid-template-columns: 65px 1fr; padding: 17px; }
  .mode-illustration { width: 65px; height: 65px; border-radius: 20px; font-size: 2.6rem; }
  .answers-grid { gap: 12px; }
  .answer-card { min-height: 160px; border-width: 4px; border-radius: 25px; }
  .answer-visual { min-height: 90px; font-size: 4rem; }
  .geo-shape { width: 78px; height: 78px; }
  .geo-triangle { border-left-width: 43px; border-right-width: 43px; border-bottom-width: 78px; }
  .geo-rectangle { width: 102px; height: 62px; }
  .geo-oval { width: 106px; height: 67px; }
  .color-swatch { width: 88px; height: 88px; }
  .big-number { font-size: 4.2rem; }
}

@media (max-width: 390px) {
  .answers-grid { grid-template-columns: 1fr 1fr; gap: 9px; }
  .answer-card { min-height: 145px; }
  .answer-label { font-size: 1rem; }
  .question-card { padding: 19px 14px; }
  .question-card h2 { margin: 10px 0 12px; }
}

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