:root {
  --orange: #FF8A3D;
  --orange-deep: #E86A17;
  --orange-dark: #C95A0F;
  --orange-soft: #FFF2E6;
  --blue: #2F7CE0;
  --blue-deep: #1A5CA9;
  --ink: #173B57;
  --muted: #68849A;
  --line: #DCEAF6;
  --white: #FFFFFF;
  --shadow: 0 18px 40px rgba(15, 78, 132, 0.22);
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: #74C3FF;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100dvh;
  overflow-x: hidden;
  color: var(--ink);
  background: #74C3FF;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
  text-size-adjust: 100%;
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

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

[hidden] {
  display: none !important;
}

/* ---------- sky background ---------- */

.sky {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
  background:
    radial-gradient(92% 42% at 50% 0%, #3E95FD 0%, #55AFFF 44%, rgba(85, 175, 255, 0) 100%),
    radial-gradient(60% 34% at 50% 32%, rgba(255, 255, 255, 0.3) 0%, rgba(255, 255, 255, 0) 72%),
    linear-gradient(180deg, #63B7FF 0%, #8ED4FF 46%, #D9F4FF 100%);
}

.sky::before {
  content: "";
  position: absolute;
  right: -16%;
  bottom: -14%;
  left: -16%;
  height: 48%;
  opacity: 0.82;
  background:
    radial-gradient(ellipse 38% 58% at 22% 68%, rgba(255, 255, 255, 0.9) 0%, rgba(255, 255, 255, 0) 72%),
    radial-gradient(ellipse 44% 64% at 58% 78%, rgba(255, 255, 255, 0.82) 0%, rgba(255, 255, 255, 0) 74%),
    radial-gradient(ellipse 34% 52% at 86% 62%, rgba(255, 255, 255, 0.76) 0%, rgba(255, 255, 255, 0) 72%);
  filter: blur(7px);
  pointer-events: none;
}

.sky::after {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.22;
  background-image:
    radial-gradient(circle at 22% 18%, #FFFFFF 0 1.4px, transparent 1.8px),
    radial-gradient(circle at 76% 11%, #FFFFFF 0 1.1px, transparent 1.5px),
    radial-gradient(circle at 64% 34%, #FFFFFF 0 1.3px, transparent 1.7px),
    radial-gradient(circle at 12% 62%, #FFFFFF 0 1.2px, transparent 1.6px),
    radial-gradient(circle at 87% 71%, #FFFFFF 0 1.5px, transparent 1.9px);
  background-size: 190px 190px, 240px 240px, 210px 210px, 260px 260px, 280px 280px;
}

.bubble {
  position: absolute;
  display: block;
  border-radius: 50%;
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: radial-gradient(
    circle at 32% 28%,
    rgba(255, 255, 255, 0.58) 0%,
    rgba(255, 255, 255, 0.16) 44%,
    rgba(255, 255, 255, 0) 72%
  );
  box-shadow: inset 0 0 30px rgba(255, 255, 255, 0.12);
  animation: drift 9s ease-in-out infinite alternate;
}

.bubble-a {
  width: 170px;
  height: 170px;
  top: 7%;
  left: -78px;
}

.bubble-b {
  width: 128px;
  height: 128px;
  top: 25%;
  right: -62px;
  animation-delay: -3s;
  animation-duration: 11s;
}

.bubble-c {
  width: 92px;
  height: 92px;
  bottom: 18%;
  left: -34px;
  animation-delay: -5s;
  animation-duration: 10s;
}

.bubble-d {
  width: 190px;
  height: 190px;
  right: -88px;
  bottom: 5%;
  opacity: 0.7;
  animation-delay: -2s;
  animation-duration: 12s;
}

.bubble-e {
  width: 56px;
  height: 56px;
  top: 12%;
  right: 8%;
  opacity: 0.55;
  animation-delay: -6s;
}

/* ---------- layout ---------- */

.app {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  min-height: 100dvh;
  padding-top: max(9px, env(safe-area-inset-top));
  padding-bottom: max(16px, env(safe-area-inset-bottom));
}

.shell {
  display: flex;
  flex: 1 0 auto;
  flex-direction: column;
  width: 100%;
  max-width: 460px;
  margin: 0 auto;
  padding: 0 16px;
}

.brand {
  padding: 0 4px;
  animation: brandIn 0.65s cubic-bezier(0.2, 0.9, 0.28, 1.15) both;
}

.brand-art {
  width: 100%;
  height: clamp(50px, 16.7vw, 78px);
  background-image: url("images/gen/title.png");
  background-repeat: no-repeat;
  background-position: center top;
  background-size: contain;
  filter: drop-shadow(0 7px 9px rgba(16, 70, 130, 0.16));
}

.board {
  position: relative;
  margin-top: 10px;
  padding: 14px;
  border: 1px solid rgba(255, 255, 255, 0.92);
  border-radius: 28px;
  background: linear-gradient(180deg, #FFFFFF 0%, #F7FCFF 100%);
  box-shadow: var(--shadow), inset 0 1px 0 rgba(255, 255, 255, 0.95);
  animation: boardIn 0.6s cubic-bezier(0.2, 0.9, 0.3, 1.05) 0.05s both;
}

/* ---------- rules ---------- */

.rules {
  display: flex;
  gap: 12px;
  padding: 12px;
  border: 1px solid #D8EDFF;
  border-radius: 18px;
  background: #ECF7FF;
}

.rules-icon {
  display: grid;
  flex: 0 0 42px;
  width: 42px;
  height: 42px;
  place-items: center;
  border-radius: 13px;
  color: #FFFFFF;
  background: linear-gradient(180deg, #5CA9FF 0%, #2F79DB 100%);
  box-shadow: 0 5px 10px rgba(47, 124, 224, 0.28), inset 0 1px 0 rgba(255, 255, 255, 0.4);
}

.rules-icon .mp-icon {
  width: 25px;
  height: 25px;
}

.rules-copy {
  flex: 1 1 auto;
  min-width: 0;
}

.rules-copy h2 {
  margin: 0 0 4px;
  color: #1B63AE;
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.2px;
  line-height: 1.25;
}

.rules-copy ol {
  margin: 0;
  padding-left: 16px;
  color: #4D6F8A;
  font-size: 12.5px;
  font-weight: 500;
  line-height: 1.55;
}

.rules-copy li {
  padding-left: 1px;
}

.rules-copy li + li {
  margin-top: 2px;
}

.rules-copy li::marker {
  color: var(--orange);
  font-weight: 800;
}

/* ---------- hud ---------- */

.hud {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin: 12px 2px 10px;
}

.stat {
  display: flex;
  align-items: center;
  gap: 7px;
  min-height: 42px;
  padding: 8px 12px;
  border: 1px solid #D2E8FF;
  border-radius: 14px;
  background: #E9F4FF;
}

.stat .mp-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
  color: var(--blue);
}

.stat-label {
  color: #3B6688;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
}

.stat-value {
  min-width: 20px;
  color: #F97316;
  font-size: 22px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.stat-value.bump {
  animation: bump 0.36s cubic-bezier(0.2, 0.9, 0.3, 1.4);
}

.range-chip {
  padding: 7px 10px;
  border: 1px solid #FFE0C2;
  border-radius: 999px;
  color: #A34A08;
  background: #FFF3E6;
  font-size: 11.5px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

/* ---------- input + guess ---------- */

.guess-form {
  display: flex;
  align-items: stretch;
  gap: 10px;
}

.guess-input {
  flex: 1 1 auto;
  width: 100%;
  min-width: 0;
  height: 56px;
  padding: 0 14px;
  border: 2px solid var(--line);
  border-radius: 16px;
  outline: none;
  color: #17415F;
  background: #FFFFFF;
  box-shadow: inset 0 2px 4px rgba(31, 84, 130, 0.05);
  font-size: 18px;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
  -moz-appearance: textfield;
}

.guess-input::placeholder {
  color: #6B8194;
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0;
}

.guess-input:focus {
  border-color: #FF9A55;
  box-shadow: 0 0 0 4px rgba(255, 138, 61, 0.16), inset 0 2px 4px rgba(31, 84, 130, 0.04);
}

.guess-input::-webkit-outer-spin-button,
.guess-input::-webkit-inner-spin-button {
  margin: 0;
  -webkit-appearance: none;
}

.guess-input.shake {
  animation: shake 0.4s ease;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  border-radius: 16px;
  color: #FFFFFF;
  font-weight: 800;
  letter-spacing: 0.4px;
  cursor: pointer;
  user-select: none;
  transition: transform 0.12s ease, box-shadow 0.12s ease, filter 0.12s ease;
}

.btn:active {
  transform: translateY(4px);
}

.btn:focus-visible {
  outline: 3px solid rgba(255, 138, 61, 0.5);
  outline-offset: 2px;
}

.btn-guess {
  flex: 0 0 128px;
  height: 56px;
  padding: 0 10px;
  background: linear-gradient(180deg, #FFA85B 0%, #F97818 100%);
  box-shadow: 0 5px 0 var(--orange-dark), 0 10px 18px rgba(235, 100, 18, 0.32);
  text-shadow: 0 1px 0 rgba(160, 60, 0, 0.24);
  font-size: 16px;
}

.btn-guess .mp-icon {
  width: 20px;
  height: 20px;
  flex: 0 0 20px;
}

.btn-guess:active {
  box-shadow: 0 1px 0 var(--orange-dark), 0 4px 8px rgba(235, 100, 18, 0.24);
}

.btn-again {
  width: 100%;
  height: 56px;
  margin-top: 22px;
  border-radius: 17px;
  background: linear-gradient(180deg, #FFA85B 0%, #F97818 100%);
  box-shadow: 0 5px 0 var(--orange-dark), 0 10px 18px rgba(235, 100, 18, 0.3);
  font-size: 16px;
  text-shadow: 0 1px 0 rgba(160, 60, 0, 0.24);
}

.btn-again .mp-icon {
  width: 21px;
  height: 21px;
}

.btn-again:active {
  box-shadow: 0 1px 0 var(--orange-dark), 0 4px 8px rgba(235, 100, 18, 0.24);
}

/* ---------- feedback ---------- */

.feedback {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: 64px;
  margin-top: 12px;
  padding: 11px 14px;
  border: 1px solid #FFE5A8;
  border-radius: 18px;
  color: #8A4B00;
  background: #FFF6DC;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7);
  transition: background 0.2s ease, border-color 0.2s ease, color 0.2s ease;
}

.feedback.pop {
  animation: feedbackPop 0.33s cubic-bezier(0.2, 0.9, 0.3, 1.2);
}

.feedback-icon {
  width: 27px;
  height: 27px;
  flex: 0 0 27px;
  color: #F2A000;
}

.feedback-copy {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.feedback-copy strong {
  font-size: 15px;
  font-weight: 800;
  line-height: 1.32;
}

.feedback-copy span {
  color: #8A5A17;
  font-size: 11.5px;
  font-weight: 600;
  line-height: 1.35;
}

.feedback[data-tone="low"] {
  border-color: #C9E9FF;
  color: #0E5F96;
  background: #E9F6FF;
}

.feedback[data-tone="low"] .feedback-icon {
  color: #2F7CE0;
}

.feedback[data-tone="low"] .feedback-copy span {
  color: #396E8E;
}

.feedback[data-tone="high"] {
  border-color: #FFD8BC;
  color: #B14A00;
  background: #FFF0E5;
}

.feedback[data-tone="high"] .feedback-icon {
  color: #F0761B;
}

.feedback[data-tone="high"] .feedback-copy span {
  color: #8A5427;
}

.feedback[data-tone="error"] {
  border-color: #FFD1D1;
  color: #B52F2F;
  background: #FFF0F0;
}

.feedback[data-tone="error"] .feedback-icon {
  color: #E34D4D;
}

.feedback[data-tone="error"] .feedback-copy span {
  color: #9A4A4A;
}

/* ---------- win ---------- */

.win-panel {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 402px;
  overflow: hidden;
  padding: 10px;
  border: 1px solid #FFF0C8;
  border-radius: 22px;
  background:
    radial-gradient(95% 62% at 50% 8%, #FFFDF0 0%, #FFFFFF 54%, #F3FAFF 100%);
}

.win-panel::before {
  content: "";
  position: absolute;
  inset: 0;
  opacity: 0.09;
  background: url("images/gen/gptimg_1795233348_look.png") center 76% / 170% auto no-repeat;
  filter: blur(2px);
  pointer-events: none;
}

.win-panel.is-shown {
  animation: winIn 0.48s cubic-bezier(0.2, 0.9, 0.3, 1.12) both;
}

.confetti {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.confetti span {
  position: absolute;
  top: -22px;
  display: block;
  animation-name: confettiFall;
  animation-timing-function: linear;
  animation-fill-mode: forwards;
  will-change: transform, opacity;
}

.win-content {
  position: relative;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  padding: 16px 8px 8px;
  text-align: center;
}

.trophy-wrap {
  position: relative;
  width: 214px;
  max-width: 100%;
  animation: trophyIn 0.62s cubic-bezier(0.2, 1.05, 0.3, 1.25) 0.05s both;
}

.trophy-wrap::before {
  content: "";
  position: absolute;
  inset: 16% 10% 6%;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle, rgba(255, 205, 80, 0.5) 0%, rgba(255, 205, 80, 0) 70%);
  filter: blur(8px);
}

.trophy-art {
  display: block;
  width: 100%;
  height: auto;
  mix-blend-mode: multiply;
  filter: drop-shadow(0 7px 12px rgba(247, 166, 0, 0.18));
}

.win-ribbon {
  position: relative;
  z-index: 2;
  margin-top: 20px;
  padding: 10px 24px;
  border-radius: 9px;
  background: linear-gradient(180deg, #FFED8C 0%, #FFD23F 100%);
  box-shadow: 0 5px 0 #E8A400, 0 10px 18px rgba(232, 164, 0, 0.24);
}

.win-ribbon::before,
.win-ribbon::after {
  content: "";
  position: absolute;
  top: 12px;
  z-index: -1;
  width: 16px;
  height: 24px;
  background: #F0B400;
}

.win-ribbon::before {
  left: -11px;
  clip-path: polygon(100% 0, 100% 100%, 0 50%);
}

.win-ribbon::after {
  right: -11px;
  clip-path: polygon(0 0, 0 100%, 100% 50%);
}

.win-ribbon h2 {
  margin: 0;
  color: #9A4A00;
  font-size: 23px;
  font-weight: 900;
  line-height: 1.2;
  letter-spacing: 0.3px;
  text-shadow: 0 1px 0 rgba(255, 255, 255, 0.55);
  white-space: nowrap;
}

.win-answer {
  margin: 20px 0 0;
  color: #54708A;
  font-size: 15px;
  font-weight: 700;
}

.win-answer strong {
  display: inline-block;
  margin-left: 6px;
  color: #F97316;
  font-size: 38px;
  font-weight: 900;
  line-height: 1;
  text-shadow: 0 2px 0 #FFE1C7;
  vertical-align: -3px;
  font-variant-numeric: tabular-nums;
}

.win-count {
  margin: 10px 0 0;
  color: #6A8398;
  font-size: 14px;
  font-weight: 600;
}

.win-count strong {
  margin: 0 3px;
  color: var(--blue);
  font-size: 20px;
  font-weight: 900;
}

/* ---------- footer ---------- */

.footnote {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  margin: auto 0 0;
  padding-top: 14px;
  color: #3E6B8C;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.footnote .mp-icon {
  width: 15px;
  height: 15px;
  color: #537FA0;
}

/* ---------- motion ---------- */

@keyframes brandIn {
  from {
    opacity: 0;
    transform: translateY(-10px) scale(0.97);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes boardIn {
  from {
    opacity: 0;
    transform: translateY(18px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@keyframes drift {
  from {
    transform: translate3d(0, -6px, 0) scale(1);
  }
  to {
    transform: translate3d(8px, 12px, 0) scale(1.04);
  }
}

@keyframes bump {
  0% {
    transform: scale(1);
  }
  42% {
    transform: scale(1.36);
  }
  100% {
    transform: scale(1);
  }
}

@keyframes feedbackPop {
  0% {
    transform: scale(0.975);
  }
  62% {
    transform: scale(1.018);
  }
  100% {
    transform: scale(1);
  }
}

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

@keyframes winIn {
  0% {
    opacity: 0;
    transform: scale(0.94) translateY(12px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes trophyIn {
  0% {
    opacity: 0;
    transform: scale(0.5) rotate(-12deg);
  }
  70% {
    opacity: 1;
    transform: scale(1.08) rotate(3deg);
  }
  100% {
    opacity: 1;
    transform: scale(1) rotate(0);
  }
}

@keyframes confettiFall {
  0% {
    opacity: 0;
    transform: translate3d(0, -24px, 0) rotate(0deg);
  }
  9% {
    opacity: 1;
  }
  100% {
    opacity: 0;
    transform: translate3d(var(--drift, 20px), var(--fall, 460px), 0) rotate(760deg);
  }
}

@media (max-width: 359px) {
  .shell {
    padding-right: 12px;
    padding-left: 12px;
  }

  .board {
    padding: 12px;
    border-radius: 24px;
  }

  .rules {
    gap: 9px;
    padding: 10px;
  }

  .rules-copy ol {
    font-size: 12px;
  }

  .btn-guess {
    flex-basis: 112px;
    font-size: 14px;
  }

  .btn-guess .mp-icon {
    display: none;
  }

  .guess-input {
    font-size: 16px;
  }

  .guess-input::placeholder {
    font-size: 13px;
  }

  .range-chip {
    padding-right: 8px;
    padding-left: 8px;
    font-size: 10.5px;
  }

  .win-ribbon h2 {
    font-size: 20px;
  }
}

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