:root {
  --bg-main:
    radial-gradient(circle at top left, rgba(255, 255, 255, 0.8), transparent 34%),
    radial-gradient(circle at bottom right, rgba(255, 245, 179, 0.7), transparent 22%),
    linear-gradient(180deg, #ffe7f2, #d8f5ff);
  --bg-top: #ffe7f2;
  --bg-bottom: #d8f5ff;
  --card: rgba(255, 255, 255, 0.72);
  --card-border: rgba(255, 255, 255, 0.55);
  --text-main: #3f315b;
  --text-soft: #6d6190;
  --accent: #ff8cb7;
  --accent-2: #7dd3fc;
  --shadow: 0 18px 45px rgba(112, 89, 142, 0.18);
  --stage-glow: linear-gradient(135deg, #fff8b8, #ffc2dd);
  --stage-text: #8b4e76;
  --dot-fill:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.9), transparent 38%),
    linear-gradient(135deg, #ffd6e8, #fff6a9);
  --panel: rgba(255, 255, 255, 0.7);
  --toggle-bg: rgba(255, 255, 255, 0.75);
  --toggle-text: #3f315b;
}

body[data-theme="dark"] {
  --bg-main:
    radial-gradient(circle at top left, rgba(74, 222, 128, 0.12), transparent 26%),
    radial-gradient(circle at 85% 18%, rgba(125, 211, 252, 0.18), transparent 24%),
    radial-gradient(circle at bottom right, rgba(244, 114, 182, 0.18), transparent 28%),
    linear-gradient(180deg, #08111f, #111827 48%, #1f1338);
  --card: rgba(10, 18, 35, 0.72);
  --card-border: rgba(148, 163, 184, 0.18);
  --text-main: #eef2ff;
  --text-soft: #b7c2e0;
  --accent: #7dd3fc;
  --accent-2: #f9a8d4;
  --shadow: 0 24px 50px rgba(4, 10, 24, 0.38);
  --stage-glow: linear-gradient(135deg, #1f3a8a, #f472b6);
  --stage-text: #fef3c7;
  --dot-fill:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.72), transparent 38%),
    linear-gradient(135deg, #38bdf8, #f9a8d4);
  --panel: rgba(20, 28, 48, 0.76);
  --toggle-bg: rgba(15, 23, 42, 0.9);
  --toggle-text: #eef2ff;
}

* {
  box-sizing: border-box;
}

* {
  scrollbar-width: thin;
  scrollbar-color: rgba(125, 211, 252, 0.85) rgba(255, 255, 255, 0.08);
}

*::-webkit-scrollbar {
  width: 12px;
  height: 12px;
}

*::-webkit-scrollbar-track {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 999px;
}

*::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(125, 211, 252, 0.95), rgba(244, 114, 182, 0.95));
  border: 2px solid transparent;
  border-radius: 999px;
  background-clip: padding-box;
}

*::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, rgba(186, 230, 253, 1), rgba(249, 168, 212, 1));
  border: 2px solid transparent;
  background-clip: padding-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  color: var(--text-main);
  touch-action: manipulation;
}

body {
  min-height: 100%;
  overflow: hidden;
  background: var(--bg-main);
  transition:
    background 0.35s ease,
    color 0.25s ease;
}

@media (hover: hover) and (pointer: fine) {
  html,
  body {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='44' height='44' viewBox='0 0 44 44'%3E%3Cdefs%3E%3ClinearGradient id='g' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0%25' stop-color='%237dd3fc'/%3E%3Cstop offset='100%25' stop-color='%23f472b6'/%3E%3C/linearGradient%3E%3C/defs%3E%3Ccircle cx='20' cy='20' r='10' fill='url(%23g)'/%3E%3Ccircle cx='20' cy='20' r='4' fill='%23fff7ed'/%3E%3Ccircle cx='31.5' cy='11.5' r='4.5' fill='%23fde68a'/%3E%3Ccircle cx='12' cy='31' r='3.5' fill='%23bfdbfe'/%3E%3C/svg%3E") 20 20, auto;
  }

  button,
  button:hover,
  .settings-menu__action,
  .settings-menu__action:hover,
  .settings-menu__toggle,
  .settings-menu__toggle:hover,
  .start-button,
  .start-button:hover,
  .exit-button,
  .exit-button:hover,
  [role="button"],
  [role="button"]:hover {
    cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='48' height='48' viewBox='0 0 48 48'%3E%3Cdefs%3E%3ClinearGradient id='g2' x1='0' y1='0' x2='1' y2='1'%3E%3Cstop offset='0%25' stop-color='%23fde68a'/%3E%3Cstop offset='100%25' stop-color='%23fb7185'/%3E%3C/linearGradient%3E%3C/defs%3E%3Ccircle cx='24' cy='24' r='11' fill='url(%23g2)'/%3E%3Ccircle cx='19' cy='19' r='3.2' fill='%23111827'/%3E%3Ccircle cx='29' cy='19' r='3.2' fill='%23111827'/%3E%3Cellipse cx='24' cy='28' rx='6.5' ry='4.8' fill='%23fff7ed'/%3E%3Cpath d='M20 27c1.8-2.2 3.2-3.2 4-3.2s2.2 1 4 3.2' fill='%237c2d12'/%3E%3Ccircle cx='14.5' cy='14.5' r='4.5' fill='%23f59e0b'/%3E%3Ccircle cx='33.5' cy='14.5' r='4.5' fill='%23f59e0b'/%3E%3C/svg%3E") 24 24, pointer !important;
  }
}

body.is-playing .settings-menu {
  display: none;
}

.page-shell {
  position: relative;
  width: 100%;
  min-height: 100vh;
}

.settings-menu {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: max(20px, env(safe-area-inset-bottom));
  z-index: 6;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 10px;
}

.settings-menu__panel {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px;
  border: 1px solid var(--card-border);
  border-radius: 20px;
  background: rgba(10, 18, 35, 0.88);
  box-shadow: var(--shadow);
  backdrop-filter: blur(12px);
  transform: translateY(10px) scale(0.96);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.22s ease,
    transform 0.24s ease;
}

.settings-menu__panel[hidden] {
  display: none;
}

.settings-menu--open .settings-menu__panel {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: auto;
}

body[data-theme="light"] .settings-menu__panel {
  background: rgba(255, 255, 255, 0.92);
}

.settings-menu__action,
.settings-menu__toggle {
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  padding: 0;
  border: 1px solid var(--card-border);
  border-radius: 50%;
  background: var(--toggle-bg);
  color: var(--toggle-text);
  box-shadow: var(--shadow);
  cursor: pointer;
  font: inherit;
  font-weight: 700;
  transition:
    transform 0.2s ease,
    background 0.25s ease,
    color 0.25s ease,
    border-color 0.25s ease;
}

.settings-menu__action {
  grid-template-columns: 32px auto;
  justify-content: start;
  gap: 8px;
  width: auto;
  min-width: 132px;
  height: 42px;
  padding: 0 14px 0 8px;
  border-radius: 999px;
}

.settings-menu__toggle:hover {
  transform: translateY(-1px);
}

.settings-menu__toggle:disabled,
.settings-menu__action:disabled,
.exit-button:disabled,
.start-button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
}

.settings-menu__action-icon,
.settings-menu__gear {
  font-size: 1.2rem;
}

.settings-menu__action-text {
  font-size: 0.88rem;
  font-weight: 700;
}

.playground {
  display: block;
  min-height: 100vh;
}

.stage-card {
  position: relative;
  width: 100%;
  min-height: 100vh;
  background: var(--bg-main);
}

.stage {
  position: relative;
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  min-height: 100vh;
  overflow: hidden;
  background: var(--bg-main);
}

.stage__center {
  position: relative;
  z-index: 2;
  text-align: center;
  pointer-events: none;
}

.big-letter {
  display: grid;
  place-items: center;
  width: min(78vw, 360px);
  min-height: 130px;
  padding: 18px 28px;
  margin: 0 auto 14px;
  border-radius: 34px;
  background: var(--stage-glow);
  box-shadow: 0 18px 36px rgba(255, 140, 183, 0.28);
  font-size: clamp(2.8rem, 9vw, 6rem);
  font-weight: 800;
  color: var(--stage-text);
  text-transform: uppercase;
  line-height: 0.95;
  text-align: center;
  word-break: break-word;
  overflow-wrap: anywhere;
  transition:
    background 0.25s ease,
    color 0.25s ease;
}

.big-letter--wide {
  font-size: clamp(2rem, 6vw, 4rem);
}

.big-letter--xwide {
  font-size: clamp(1.4rem, 4.2vw, 2.8rem);
}

.stage__hint {
  margin: 0;
  font-size: 0.9rem;
  color: var(--text-soft);
}

.game-overlay {
  position: absolute;
  inset: 0;
  z-index: 4;
  display: grid;
  place-items: center;
  padding: 14px 24px;
  background:
    radial-gradient(circle at center, rgba(125, 211, 252, 0.12), transparent 24%),
    rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(14px);
  overflow-y: auto;
  overscroll-behavior: contain;
}

.game-overlay[hidden] {
  display: none;
}

.menu-card {
  position: relative;
  display: flex;
  flex-direction: column;
  width: min(620px, 100%);
  max-height: 80vh;
  padding: 28px 34px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 32px;
  background:
    linear-gradient(180deg, rgba(15, 23, 42, 0.94), rgba(30, 41, 59, 0.9));
  box-shadow:
    0 24px 70px rgba(0, 0, 0, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.08);
  text-align: center;
  overflow: auto;
  scrollbar-gutter: stable;
}

body[data-theme="light"] .menu-card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.96), rgba(244, 247, 255, 0.93));
}

.menu-card__badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 124px;
  padding: 10px 18px;
  margin-bottom: 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.08);
  font-size: 1.4rem;
}

.menu-card__eyebrow {
  margin: 0 0 8px;
  color: var(--accent);
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-size: 0.78rem;
}

.menu-card__hero-title {
  width: min(100%, 460px);
  align-self: center;
  margin: 0;
  font-size: clamp(1.2rem, 2.8vw, 1.7rem);
  line-height: 1.02;
}

.menu-card__hero-text {
  width: min(100%, 460px);
  align-self: center;
  margin: 6px auto 12px;
  color: var(--text-soft);
  font-size: 0.74rem;
  line-height: 1.25;
}

.menu-card__title {
  width: min(100%, 460px);
  align-self: center;
  margin: 0;
  font-size: clamp(1.45rem, 3.8vw, 2.35rem);
}

.menu-card__text {
  width: min(100%, 460px);
  align-self: center;
  margin: 14px auto 0;
  color: var(--text-soft);
  font-size: 0.96rem;
  line-height: 1.55;
}

.menu-card__install {
  width: min(100%, 460px);
  align-self: center;
  margin: 14px auto 0;
  color: var(--text-soft);
  font-size: 0.82rem;
  line-height: 1.45;
}

.start-button,
.exit-button {
  border: 0;
  border-radius: 999px;
  cursor: pointer;
  font: inherit;
  font-weight: 800;
}

.start-button {
  align-self: center;
  width: min(100%, 460px);
  margin-top: 22px;
  padding: 16px 30px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #08111f;
  box-shadow: 0 16px 36px rgba(20, 28, 48, 0.28);
  font-size: 1rem;
}

.exit-button {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  right: max(20px, env(safe-area-inset-right));
  z-index: 3;
  padding: 10px 14px;
  border: 1px solid var(--card-border);
  background: var(--toggle-bg);
  color: var(--toggle-text);
  font-size: 0.84rem;
}

.hud {
  position: absolute;
  top: max(20px, env(safe-area-inset-top));
  left: max(20px, env(safe-area-inset-left));
  right: auto;
  z-index: 3;
  display: grid;
  gap: 10px;
}

.hud[hidden] {
  display: none;
}

.hud__item {
  min-width: 94px;
  max-width: 160px;
  padding: 9px 11px;
  border: 1px solid var(--card-border);
  border-radius: 16px;
  background: rgba(8, 14, 28, 0.62);
  box-shadow: var(--shadow);
  backdrop-filter: blur(10px);
}

body[data-theme="light"] .hud__item {
  background: rgba(255, 255, 255, 0.72);
}

.hud__label {
  display: block;
  margin-bottom: 4px;
  font-size: 0.68rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-soft);
}

.hud strong {
  display: block;
  font-size: 0.95rem;
  line-height: 1.1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#flowersfall {
  position: absolute;
  inset: 0;
  overflow: hidden;
  pointer-events: none;
}

.dot {
  position: absolute;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--dot-fill);
  opacity: 0.8;
}

.history {
  align-self: center;
  width: min(100%, 460px);
  margin-top: 26px;
  padding-top: 22px;
  border-top: 1px solid var(--card-border);
  text-align: left;
}

.history__scroll {
  max-height: 240px;
  overflow-y: auto;
  scrollbar-gutter: stable;
}

.history__title {
  margin: 0 0 12px;
  font-size: 1.05rem;
}

.history__empty {
  margin: 0;
  color: var(--text-soft);
}

.history__list {
  display: grid;
  gap: 10px;
}

.history__entry {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 16px;
  background: var(--panel);
}

.history__meta {
  color: var(--text-soft);
  font-size: 0.92rem;
}

@keyframes floatUp {
  0% {
    transform: translate(0, 0) scale(0.6) rotate(0deg);
    opacity: 0;
  }

  15% {
    opacity: 1;
  }

  100% {
    transform: translate(var(--x), var(--y)) scale(1.2) rotate(16deg);
    opacity: 0;
  }
}

.floating-icon {
  position: fixed;
  pointer-events: none;
  user-select: none;
  z-index: 9999;
  animation: floatUp var(--duration) ease-out forwards;
  filter: drop-shadow(0 0 6px rgba(255, 255, 255, 0.6));
}

.cursor-trail {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 4;
}

.cursor-trail__dot {
  position: fixed;
  top: 0;
  left: 0;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 30% 30%, rgba(255, 255, 255, 0.95), transparent 42%),
    linear-gradient(135deg, rgba(125, 211, 252, 0.95), rgba(244, 114, 182, 0.95));
  box-shadow:
    0 0 22px rgba(125, 211, 252, 0.38),
    0 0 34px rgba(244, 114, 182, 0.28);
  opacity: 0;
  transform: translate3d(-50%, -50%, 0) scale(0.3);
  will-change: transform, opacity;
}

.mobile-tap-zone {
  display: none !important;
}

.key-burst {
  animation: pulseLetter 0.35s ease;
}

@keyframes pulseLetter {
  0% {
    transform: scale(0.88);
  }

  60% {
    transform: scale(1.08);
  }

  100% {
    transform: scale(1);
  }
}

@media (max-width: 900px) {
  .cursor-trail {
    display: none;
  }

  .settings-menu {
    right: max(20px, env(safe-area-inset-right));
    bottom: max(20px, env(safe-area-inset-bottom));
  }

  .settings-menu__toggle {
    width: 42px;
    height: 42px;
  }

  .settings-menu__action {
    min-width: 122px;
    height: 40px;
  }

  .game-overlay {
    padding: 12px 16px;
  }

  .menu-card {
    padding: 20px 18px;
    border-radius: 24px;
    max-height: 80dvh;
  }

  .menu-card__title {
    font-size: 1.6rem;
  }

  .menu-card__hero-title {
    font-size: 1.18rem;
  }

  .menu-card__hero-text,
  .menu-card__text {
    font-size: 0.82rem;
  }

  .big-letter {
    width: min(86vw, 300px);
    min-height: 106px;
    padding: 16px 18px;
    font-size: clamp(2rem, 12vw, 4rem);
    border-radius: 26px;
  }

  .big-letter--wide {
    font-size: clamp(1.5rem, 8vw, 2.5rem);
  }

  .big-letter--xwide {
    font-size: clamp(1.05rem, 5vw, 1.8rem);
  }

  .stage__hint {
    padding: 0 18px;
    font-size: 0.82rem;
  }

  .hud {
    left: max(20px, env(safe-area-inset-left));
    right: auto;
    top: max(20px, env(safe-area-inset-top));
    bottom: auto;
    grid-template-columns: 1fr;
  }

  .hud__item {
    max-width: none;
  }

  .exit-button {
    top: max(20px, env(safe-area-inset-top));
    right: max(20px, env(safe-area-inset-right));
    bottom: auto;
    padding: 8px 12px;
    font-size: 0.72rem;
    opacity: 0.82;
  }

  .mobile-tap-zone {
    display: none !important;
  }

  .mobile-tap-zone[hidden] {
    display: none;
  }
}

@media (orientation: landscape) and (hover: none) and (pointer: coarse) {
  .menu-card {
    width: min(720px, 100%);
    max-height: 80dvh;
    padding: 16px 18px 16px;
  }

  .menu-card__badge {
    margin-bottom: 8px;
    font-size: 1.1rem;
  }

  .menu-card__title {
    font-size: 1.28rem;
  }

  .menu-card__hero-title {
    font-size: 1.02rem;
  }

  .menu-card__hero-text,
  .menu-card__text,
  .menu-card__install {
    font-size: 0.82rem;
  }

  .start-button {
    margin-top: 16px;
    padding: 12px 24px;
    font-size: 0.92rem;
  }

  .history {
    margin-top: 18px;
    padding-top: 16px;
    max-height: 120px;
  }

  .history__list {
    gap: 8px;
  }

  .history__entry {
    padding: 10px 12px;
  }

  .big-letter {
    width: min(58vw, 260px);
    min-height: 90px;
    font-size: clamp(1.8rem, 7vw, 3.2rem);
  }

  .big-letter--wide {
    font-size: clamp(1.3rem, 5vw, 2.2rem);
  }

  .big-letter--xwide {
    font-size: clamp(1rem, 3.5vw, 1.7rem);
  }

  .stage__hint {
    font-size: 0.76rem;
  }

  .hud__item {
    min-width: 84px;
  }

  .exit-button {
    top: max(20px, env(safe-area-inset-top));
    left: auto;
    right: max(20px, env(safe-area-inset-right));
    bottom: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
  }

  .mobile-tap-zone {
    display: none !important;
  }
}
