:root {
  color-scheme: light;
  --bg-a: #fff8e8;
  --bg-b: #eaf8ff;
  --bg-c: #eef8ef;
  --ink: #31404a;
  --muted: #687a84;
  --panel: rgba(255, 255, 255, 0.78);
  --panel-strong: rgba(255, 255, 255, 0.94);
  --line: rgba(92, 117, 130, 0.2);
  --accent: #3576d4;
  --accent-2: #e78aa7;
  --accent-3: #d7a83e;
  --mint: #6cbf9c;
  --shadow: 0 16px 38px rgba(73, 96, 112, 0.16);
  --soft-shadow: 0 8px 20px rgba(73, 96, 112, 0.12);
  --radius: 18px;
  --radius-small: 12px;
  --max: 520px;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background:
    radial-gradient(circle at 8% 0%, rgba(255, 227, 166, 0.7), transparent 28rem),
    radial-gradient(circle at 100% 6%, rgba(184, 226, 255, 0.74), transparent 28rem),
    linear-gradient(145deg, var(--bg-a), var(--bg-b) 48%, var(--bg-c));
}

body {
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  font-size: 16px;
  line-height: 1.65;
  letter-spacing: 0;
}

button,
input,
textarea {
  font: inherit;
}

button {
  min-height: 48px;
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  touch-action: manipulation;
}

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 3px solid rgba(53, 118, 212, 0.45);
  outline-offset: 3px;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

a {
  color: #265fba;
  text-decoration-thickness: 0.08em;
  text-underline-offset: 0.18em;
}

.app-shell {
  width: min(100%, var(--max));
  min-height: 100vh;
  margin: 0 auto;
  padding: 14px 12px 24px;
}

.app-header {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 8px 4px 14px;
}

.brand-mark {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(255, 255, 255, 0.96), rgba(255, 243, 212, 0.9));
  box-shadow: var(--soft-shadow);
  color: var(--accent-3);
  font-size: 24px;
  flex: 0 0 auto;
}

.eyebrow {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

h1,
h2,
h3,
p {
  overflow-wrap: anywhere;
}

h1 {
  margin: 0;
  font-size: 22px;
  line-height: 1.25;
}

h2 {
  margin: 0 0 12px;
  font-size: 24px;
  line-height: 1.3;
}

h3 {
  margin: 0 0 8px;
  font-size: 18px;
  line-height: 1.35;
}

.screen-wrap {
  display: grid;
  gap: 14px;
}

.screen {
  display: grid;
  gap: 14px;
}

.card {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--panel);
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  padding: 16px;
}

.plain-band {
  padding: 6px 2px;
}

.hero-title {
  font-size: 30px;
  line-height: 1.18;
  margin: 0 0 8px;
}

.subtitle {
  margin: 0 0 12px;
  color: #3d6580;
  font-weight: 800;
}

.lead {
  margin: 0;
  color: #50626c;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.stat {
  min-height: 74px;
  border: 1px solid rgba(255, 255, 255, 0.8);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.66);
  padding: 10px;
}

.stat-label {
  display: block;
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.stat-value {
  display: block;
  margin-top: 3px;
  font-size: 20px;
  font-weight: 900;
}

.button-row,
.button-stack {
  display: grid;
  gap: 10px;
}

.button-row {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  width: 100%;
  padding: 11px 15px;
  background: var(--panel-strong);
  color: var(--ink);
  box-shadow: 0 5px 14px rgba(73, 96, 112, 0.12);
  font-weight: 850;
  text-align: center;
}

.btn.primary {
  background: linear-gradient(145deg, #3f82e6, #2f68c9);
  color: #fff;
}

.btn.warm {
  background: linear-gradient(145deg, #f4b260, #e88a9e);
  color: #fff;
}

.btn.quiet {
  background: rgba(255, 255, 255, 0.55);
  color: #4b6370;
}

.btn.danger {
  background: #fff2f2;
  color: #b53e4a;
}

.btn.small {
  min-height: 42px;
  padding: 8px 12px;
  font-size: 14px;
}

.note {
  margin: 0;
  color: var(--muted);
  font-size: 14px;
}

.theme-box,
.action-box {
  border: 1px solid rgba(215, 168, 62, 0.28);
  border-radius: 16px;
  background: linear-gradient(145deg, rgba(255, 252, 235, 0.92), rgba(255, 255, 255, 0.72));
  padding: 13px;
}

.action-box strong {
  display: block;
  margin-bottom: 4px;
  color: #8f6420;
}

.mission-box {
  border: 1px solid rgba(108, 191, 156, 0.25);
  border-radius: 16px;
  background: rgba(243, 255, 249, 0.8);
  padding: 13px;
}

.ad-slot {
  display: grid;
  place-items: center;
  min-height: 68px;
  border: 1px dashed rgba(93, 113, 126, 0.34);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.42);
  color: #7a8990;
  font-size: 13px;
  font-weight: 800;
}

.mate-row,
.mate-grid {
  display: grid;
  gap: 10px;
}

.mate-card {
  display: grid;
  grid-template-columns: 54px 1fr;
  gap: 12px;
  align-items: center;
  border: 1px solid var(--line);
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.68);
  padding: 12px;
}

.mate-card.selected {
  border-color: rgba(53, 118, 212, 0.56);
  box-shadow: 0 0 0 3px rgba(53, 118, 212, 0.12);
}

.mate-face {
  display: grid;
  place-items: center;
  width: 54px;
  height: 54px;
  border-radius: 18px;
  background: linear-gradient(145deg, #fff, #f3fbff);
  font-size: 30px;
}

.mate-name {
  margin: 0;
  font-weight: 900;
}

.mate-copy {
  margin: 2px 0 8px;
  color: var(--muted);
  font-size: 14px;
}

.level-grid {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 8px;
}

.level-btn {
  min-height: 58px;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  box-shadow: var(--soft-shadow);
  font-weight: 900;
}

.level-btn.locked {
  background: rgba(244, 246, 247, 0.66);
  color: #88979e;
  box-shadow: none;
}

.level-btn.cleared {
  border: 2px solid rgba(108, 191, 156, 0.62);
}

.level-mark {
  display: block;
  font-size: 12px;
  color: var(--muted);
}

.game-top {
  display: grid;
  gap: 10px;
}

.game-title-row {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: flex-start;
}

.game-title-row h2 {
  margin: 0;
}

.mate-bubble {
  display: grid;
  grid-template-columns: 42px 1fr;
  gap: 10px;
  align-items: center;
  padding: 10px;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.62);
}

.mate-bubble .mate-face {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  font-size: 25px;
}

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

.game-stat {
  border-radius: 13px;
  background: rgba(255, 255, 255, 0.62);
  padding: 8px;
  text-align: center;
}

.game-stat span {
  display: block;
  color: var(--muted);
  font-size: 11px;
  font-weight: 850;
}

.game-stat strong {
  display: block;
  font-size: 17px;
}

.board-card {
  overflow: hidden;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, minmax(64px, 1fr));
  gap: 12px 8px;
  justify-items: center;
  padding: 6px 0 2px;
}

.bottle-button {
  position: relative;
  display: grid;
  justify-items: center;
  width: 100%;
  min-height: 168px;
  padding: 0;
  border-radius: 18px;
  background: transparent;
  box-shadow: none;
}

.bottle {
  position: relative;
  display: flex;
  flex-direction: column-reverse;
  justify-content: flex-start;
  align-items: center;
  gap: 5px;
  width: min(68px, 21vw);
  max-width: 74px;
  height: 138px;
  padding: 14px 8px 12px;
  border: 3px solid rgba(105, 139, 155, 0.5);
  border-top: 0;
  border-radius: 0 0 24px 24px;
  background: linear-gradient(90deg, rgba(255,255,255,0.44), rgba(255,255,255,0.12), rgba(255,255,255,0.42));
  box-shadow: inset 0 -12px 18px rgba(132, 176, 190, 0.1), 0 9px 17px rgba(73, 96, 112, 0.12);
}

.bottle::before {
  content: "";
  position: absolute;
  top: -8px;
  width: 54%;
  height: 10px;
  border: 3px solid rgba(105, 139, 155, 0.5);
  border-bottom: 0;
  border-radius: 12px 12px 0 0;
  background: rgba(255, 255, 255, 0.46);
}

.bottle-label {
  margin-top: 7px;
  color: #667882;
  font-size: 12px;
  font-weight: 850;
}

.drop {
  display: grid;
  place-items: center;
  width: 42px;
  height: 25px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.65);
  color: rgba(255, 255, 255, 0.92);
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.22);
  font-size: 15px;
  font-weight: 900;
  box-shadow: inset 0 5px 9px rgba(255, 255, 255, 0.32), inset 0 -7px 10px rgba(0, 0, 0, 0.12);
}

.bottle-button.selected .bottle {
  transform: translateY(-8px);
  border-color: rgba(53, 118, 212, 0.84);
  box-shadow: 0 0 0 4px rgba(53, 118, 212, 0.12), 0 16px 24px rgba(73, 96, 112, 0.16);
}

.bottle-button.selected .drop:last-child {
  animation: floatDrop 900ms ease-in-out infinite alternate;
}

.bottle-button.suggested .bottle {
  border-color: rgba(215, 168, 62, 0.86);
  box-shadow: 0 0 0 4px rgba(215, 168, 62, 0.15), 0 12px 22px rgba(73, 96, 112, 0.13);
}

.bottle-button.shake .bottle {
  animation: shake 300ms ease-in-out;
}

.move-flash {
  animation: softFlash 360ms ease-out;
}

.hint-text {
  min-height: 26px;
  margin: 0;
  color: #4d6977;
  font-weight: 800;
}

.clear-hero {
  position: relative;
  overflow: hidden;
  text-align: center;
}

.clear-hero .big {
  margin: 8px 0 0;
  font-size: 34px;
  font-weight: 950;
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  background:
    radial-gradient(circle, #f8c24e 0 3px, transparent 4px) 12% 18% / 58px 58px,
    radial-gradient(circle, #60b7ef 0 3px, transparent 4px) 86% 28% / 62px 62px,
    radial-gradient(circle, #e88aa8 0 3px, transparent 4px) 44% 10% / 46px 46px,
    radial-gradient(circle, #74cfa7 0 3px, transparent 4px) 30% 70% / 52px 52px;
  animation: confettiFall 1200ms ease-out both;
}

.sparkle {
  color: #c78b1f;
  animation: sparkle 900ms ease-in-out 2;
}

.record-table {
  width: 100%;
  border-collapse: collapse;
  overflow: hidden;
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.56);
  font-size: 14px;
}

.record-table th,
.record-table td {
  padding: 9px 7px;
  border-bottom: 1px solid rgba(92, 117, 130, 0.14);
  text-align: left;
}

.record-table th {
  color: #4f6672;
  font-size: 12px;
}

.settings-row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  min-height: 54px;
  padding: 10px 0;
  border-bottom: 1px solid rgba(92, 117, 130, 0.12);
}

.switch {
  position: relative;
  width: 58px;
  height: 32px;
  flex: 0 0 auto;
}

.switch input {
  position: absolute;
  opacity: 0;
}

.switch span {
  position: absolute;
  inset: 0;
  border-radius: 999px;
  background: #cfd9df;
  transition: background 180ms ease;
}

.switch span::after {
  content: "";
  position: absolute;
  top: 4px;
  left: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.18);
  transition: transform 180ms ease;
}

.switch input:checked + span {
  background: var(--accent);
}

.switch input:checked + span::after {
  transform: translateX(26px);
}

.share-fallback {
  width: 100%;
  min-height: 94px;
  margin-top: 10px;
  border: 1px solid var(--line);
  border-radius: 12px;
  padding: 10px;
  resize: vertical;
}

.modal-root {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(37, 50, 58, 0.38);
}

.modal-root[hidden],
[hidden] {
  display: none !important;
}

.modal {
  width: min(100%, 440px);
  border: 1px solid rgba(255, 255, 255, 0.76);
  border-radius: 20px;
  background: rgba(255, 255, 255, 0.96);
  box-shadow: 0 24px 60px rgba(31, 47, 58, 0.28);
  padding: 18px;
}

.footer {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 18px 0 0;
  color: var(--muted);
  font-size: 13px;
}

.legal-page {
  width: min(100%, 760px);
  margin: 0 auto;
  padding: 22px 14px 34px;
}

.legal-page .card {
  margin-top: 14px;
}

.legal-page ul {
  padding-left: 1.2em;
}

.hidden {
  display: none !important;
}

@keyframes floatDrop {
  from { transform: translateY(0); }
  to { transform: translateY(-5px); }
}

@keyframes shake {
  0%, 100% { transform: translateX(0); }
  25% { transform: translateX(-5px); }
  75% { transform: translateX(5px); }
}

@keyframes softFlash {
  0% { transform: scale(1); }
  50% { transform: scale(1.04); }
  100% { transform: scale(1); }
}

@keyframes confettiFall {
  from { opacity: 0; transform: translateY(-14px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes sparkle {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

@media (max-width: 360px) {
  .app-shell {
    padding-inline: 8px;
  }

  .hero-title {
    font-size: 27px;
  }

  .board {
    gap: 10px 4px;
  }

  .bottle-button {
    min-height: 158px;
  }

  .bottle {
    width: 62px;
    height: 130px;
    padding-inline: 7px;
  }

  .drop {
    width: 39px;
  }

  .level-grid {
    gap: 6px;
  }
}

@media (min-width: 700px) {
  .app-shell {
    padding-top: 24px;
  }
}

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

body.reduce-motion *,
body.reduce-motion *::before,
body.reduce-motion *::after {
  animation-duration: 0.001ms !important;
  animation-iteration-count: 1 !important;
  transition-duration: 0.001ms !important;
}
