:root {
  --bg-cream: #fff8f1;
  --bg-petal: #ffeef5;
  --bg-mint: #edf8f2;
  --bg-sky: #edf6ff;
  --ink: #46395f;
  --muted: #766a8a;
  --line: rgba(140, 117, 163, 0.18);
  --panel: rgba(255, 255, 255, 0.82);
  --panel-strong: rgba(255, 255, 255, 0.92);
  --mint: #bfeee3;
  --sky: #99dff1;
  --blush: #ffd6e2;
  --butter: #ffe8ad;
  --leaf: #8cc5ab;
  --lavender: #d9c8f8;
  --shadow: 0 22px 56px rgba(104, 79, 128, 0.12);
  --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", "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 14%, rgba(255, 232, 173, 0.48), transparent 28%),
    radial-gradient(circle at 82% 10%, rgba(255, 214, 226, 0.8), transparent 30%),
    radial-gradient(circle at 16% 92%, rgba(191, 238, 227, 0.72), transparent 26%),
    linear-gradient(135deg, var(--bg-cream) 0%, var(--bg-petal) 34%, var(--bg-sky) 66%, var(--bg-mint) 100%);
}
button, input, select { font: inherit; }
button {
  border: none;
  cursor: pointer;
  transition: transform 160ms ease, box-shadow 160ms ease, opacity 160ms ease;
}
button:hover { transform: translateY(-1px); }
button:disabled { opacity: 0.5; cursor: default; transform: none; }
img { display: block; }
.hidden { display: none !important; }

.app-shell {
  min-height: 100vh;
}
.screen {
  min-height: 100vh;
}

.screen-login {
  display: grid;
  place-items: center;
  padding: 32px 20px;
}
.login-frame {
  width: min(1080px, 100%);
  display: grid;
  grid-template-columns: minmax(0, 1.05fr) minmax(340px, 420px);
  gap: 28px;
  align-items: center;
}
.brand-block,
.login-card,
.dashboard-hero,
.stat-card,
.stats-chart-card,
.stats-history-card,
.game-tile,
.profile-badge {
  border: 1px solid var(--line);
  background: linear-gradient(145deg, rgba(255,255,255,0.92), rgba(255,255,255,0.72));
  box-shadow: var(--shadow);
}
.brand-block {
  padding: 40px;
  border-radius: 40px;
}
.brand-flower {
  width: 124px;
  height: 124px;
  margin-bottom: 18px;
  image-rendering: pixelated;
}
.brand-kicker,
.dashboard-kicker,
.stat-label,
.field-label,
.flower-preview-label {
  margin: 0 0 10px;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--muted);
  font-weight: 800;
}
.brand-block h1,
.dashboard-hero h1 {
  margin: 0;
  font-size: clamp(2.8rem, 5vw, 5.4rem);
  line-height: 0.95;
  letter-spacing: -0.04em;
}
.brand-copy,
.dashboard-copy,
.auth-panel p,
.section-head p {
  margin: 14px 0 0;
  color: var(--muted);
  line-height: 1.6;
}
.login-card {
  border-radius: 34px;
  padding: 24px;
}
.auth-panel h2,
.section-head h3,
.game-tile-copy h3,
.profile-badge-name,
.stats-profile h2 {
  margin: 0;
}
.auth-panel {
  display: grid;
  gap: 14px;
}
.profile-select,
#create-profile select,
#create-profile input {
  width: 100%;
  min-height: 56px;
  border-radius: 18px;
  border: 1px solid rgba(140, 117, 163, 0.22);
  background: rgba(255,255,255,0.95);
  color: var(--ink);
  padding: 0 16px;
}
.auth-actions {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
}
.primary,
.secondary,
.ghost-btn {
  min-height: 52px;
  padding: 0 18px;
  border-radius: 18px;
  font-weight: 800;
}
.primary {
  background: linear-gradient(135deg, var(--sky), var(--mint));
  color: #22414d;
  box-shadow: 0 14px 30px rgba(115, 184, 204, 0.22);
}
.secondary {
  background: linear-gradient(135deg, var(--butter), var(--blush));
  color: #604d55;
  box-shadow: 0 14px 30px rgba(218, 171, 183, 0.18);
}
.ghost-btn {
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(140, 117, 163, 0.2);
  color: var(--ink);
  box-shadow: 0 10px 24px rgba(104, 79, 128, 0.08);
}
.subtle-action {
  justify-self: start;
  background: transparent;
  color: #92667b;
  text-decoration: underline;
  text-underline-offset: 4px;
  padding: 4px 0;
}
.flower-preview-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255,255,255,0.72);
  border: 1px solid rgba(140, 117, 163, 0.14);
}
.flower-preview {
  width: 72px;
  height: 72px;
  image-rendering: pixelated;
}

.screen-dashboard,
.screen-stats {
  padding: 28px 22px 40px;
}
.dashboard-topbar,
.stats-topbar {
  width: min(1180px, 100%);
  margin: 0 auto 22px;
  display: flex;
  justify-content: space-between;
  gap: 16px;
  align-items: center;
  flex-wrap: wrap;
}
.profile-badge,
.stats-profile {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 16px;
  border-radius: 24px;
}
.profile-badge-art {
  width: 62px;
  height: 62px;
  image-rendering: pixelated;
}
.profile-badge-label,
.profile-badge-id,
.today-title,
.today-msg {
  margin: 0;
  color: var(--muted);
}
.profile-badge-name { font-size: 1.35rem; }
.dashboard-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.dashboard-hero,
.game-grid,
.stats-overview,
.stats-chart-card,
.stats-history-card {
  width: min(1180px, 100%);
  margin: 0 auto;
}
.dashboard-hero {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 320px;
  gap: 18px;
  padding: 26px;
  border-radius: 32px;
  margin-bottom: 18px;
}
.compact {
  padding: 18px;
  border-radius: 24px;
  background: linear-gradient(145deg, rgba(255,255,255,0.9), rgba(246,255,251,0.82));
  border: 1px solid rgba(140, 117, 163, 0.16);
}
.today-score {
  margin: 6px 0;
  font-size: 2.8rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  gap: 10px;
}
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 18px;
}
.game-tile {
  position: relative;
  min-height: 320px;
  padding: 20px;
  border-radius: 32px;
  text-align: left;
  overflow: hidden;
}
.game-tile-art {
  height: 168px;
  border-radius: 24px;
  margin-bottom: 18px;
}
.game-mozzie .game-tile-art {
  background:
    radial-gradient(circle at 18% 20%, rgba(255, 232, 173, 0.78), transparent 20%),
    radial-gradient(circle at 80% 24%, rgba(255, 214, 226, 0.75), transparent 16%),
    radial-gradient(circle at 70% 70%, rgba(191, 238, 227, 0.9), transparent 22%),
    linear-gradient(145deg, #fff8f1, #f0fbf5);
}
.game-clean .game-tile-art {
  background:
    linear-gradient(180deg, rgba(255,255,255,0.1), rgba(255,255,255,0.02)),
    linear-gradient(0deg, #8d5933 0 34%, transparent 34%),
    radial-gradient(circle at 25% 25%, rgba(191, 238, 227, 0.82), transparent 18%),
    radial-gradient(circle at 80% 25%, rgba(255, 232, 173, 0.82), transparent 14%),
    linear-gradient(145deg, #fff6f8, #eef7ff);
}
.game-drums .game-tile-art {
  background:
    radial-gradient(circle at 18% 24%, #ffd6e2 0 12%, transparent 13%),
    radial-gradient(circle at 42% 24%, #bfeee3 0 12%, transparent 13%),
    radial-gradient(circle at 66% 24%, #ffe8ad 0 12%, transparent 13%),
    radial-gradient(circle at 90% 24%, #99dff1 0 12%, transparent 13%),
    linear-gradient(145deg, #fff8f3, #eef7ff);
}
.game-tile-copy p {
  margin: 8px 0 0;
  color: var(--muted);
  line-height: 1.5;
}

.stats-overview {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-bottom: 18px;
}
.game-stats-sections {
  display: grid;
  gap: 16px;
}
.game-stat-section {
  border-radius: 22px;
  padding: 18px;
  background: rgba(255,255,255,0.62);
  border: 1px solid rgba(140, 117, 163, 0.14);
}
.game-stat-head {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.game-stat-title {
  margin: 0;
  font-size: 1.1rem;
}
.game-stat-note {
  margin: 4px 0 0;
  color: var(--muted);
  font-size: 0.92rem;
}
.game-stat-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 12px;
  margin-bottom: 14px;
}
.scale-toggle {
  display: flex;
  gap: 8px;
}
.stats-controls {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.toggle-btn.active {
  background: linear-gradient(135deg, var(--sky), var(--mint));
  color: #22414d;
  box-shadow: 0 14px 30px rgba(115, 184, 204, 0.16);
}
.mini-stat {
  border-radius: 18px;
  padding: 14px;
  background: rgba(255,255,255,0.74);
  border: 1px solid rgba(140, 117, 163, 0.12);
}
.mini-stat-label {
  margin: 0 0 6px;
  color: var(--muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
}
.mini-stat-value {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 900;
}
.mini-chart {
  min-height: 150px;
  display: grid;
  place-items: center;
  border-radius: 18px;
  background: rgba(255,255,255,0.52);
}
.mini-chart-empty {
  color: var(--muted);
  font-size: 0.92rem;
}
.trend-table-wrap {
  overflow-x: auto;
}
.trend-table {
  width: 100%;
  border-collapse: collapse;
  min-width: 560px;
}
.trend-table th,
.trend-table td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid rgba(140, 117, 163, 0.12);
  vertical-align: top;
}
.trend-table th {
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}
.trend-table td:first-child {
  font-weight: 800;
  color: var(--ink);
  min-width: 120px;
}
.trend-value {
  font-weight: 800;
}
.trend-shift {
  display: block;
  margin-top: 4px;
  font-size: 0.82rem;
  font-weight: 800;
}
.trend-shift.up {
  color: #2f8f68;
}
.trend-shift.down {
  color: #b55d70;
}
.attempt-list {
  display: grid;
  gap: 10px;
}
.attempt-row {
  display: grid;
  grid-template-columns: 90px 150px 1fr 110px;
  gap: 12px;
  align-items: center;
  padding: 12px 14px;
  border-radius: 18px;
  background: rgba(255,255,255,0.66);
  border: 1px solid rgba(140, 117, 163, 0.12);
}
.attempt-status {
  font-weight: 900;
}
.attempt-status.success {
  color: #2f8f68;
}
.attempt-status.fail {
  color: #b55d70;
}
.stat-card,
.stats-chart-card,
.stats-history-card {
  border-radius: 28px;
  padding: 20px;
}
.stat-value {
  margin: 0;
  font-size: 2rem;
  font-weight: 900;
}
.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 16px;
}
.stats-chart-empty {
  min-height: 180px;
  display: grid;
  place-items: center;
  color: var(--muted);
  border-radius: 22px;
  background: rgba(255,255,255,0.56);
}
.stats-chart-svg {
  width: 100%;
  height: 220px;
  display: block;
}
.chart-caption {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  margin-top: 10px;
  color: var(--muted);
  font-size: 0.88rem;
}
.session-list {
  display: grid;
  gap: 10px;
}
.session-row {
  display: grid;
  grid-template-columns: 100px 160px 1fr 110px;
  gap: 12px;
  align-items: center;
  padding: 14px;
  border-radius: 20px;
  background: rgba(255,255,255,0.68);
  border: 1px solid rgba(140, 117, 163, 0.12);
}
.session-mode { font-weight: 900; }
.session-metric { color: var(--muted); line-height: 1.4; }
.session-empty { margin: 0; color: var(--muted); }

#game-screen {
  position: fixed;
  inset: 0;
  z-index: 20;
  background: linear-gradient(180deg, #141228 0%, #191731 100%);
}
.game-shell,
.stage {
  width: 100%;
  height: 100%;
}
.stage {
  position: relative;
  min-height: 100vh;
  overflow: hidden;
}
#video,
#game {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
#video {
  transform: scaleX(-1);
  opacity: 0.4;
  filter: saturate(1.06) contrast(1.04);
}
#game { pointer-events: none; }
.pause-menu {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: none;
}
.top-left,
.top-right,
.pause-actions,
.pause-stats,
.gesture-hint { pointer-events: auto; }
.top-left { position: absolute; left: 16px; top: 16px; }
.top-right { position: absolute; right: 16px; top: 16px; }
.pause-actions {
  position: absolute;
  left: 50%;
  top: 50%;
  transform: translate(-50%, -50%);
}
.ghost-dark {
  background: rgba(22, 19, 43, 0.46);
  border-color: rgba(255,255,255,0.14);
  color: #fffdf7;
  backdrop-filter: blur(10px);
}
.icon-btn {
  width: 56px;
  min-width: 56px;
  padding: 0;
  border-radius: 999px;
  display: grid;
  place-items: center;
}
.start-big {
  width: 214px;
  height: 214px;
  border-radius: 999px;
  display: inline-flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 14px;
  border: 4px solid rgba(255,255,255,0.88);
  background:
    radial-gradient(circle at 30% 24%, rgba(255,255,255,0.82), transparent 30%),
    linear-gradient(145deg, var(--sky), var(--mint) 58%, var(--butter));
  box-shadow:
    0 0 0 14px rgba(255,255,255,0.08),
    0 24px 44px rgba(91, 189, 219, 0.26),
    inset 0 -14px 24px rgba(0,0,0,0.08);
}
.play-icon {
  width: 0;
  height: 0;
  border-left: 18px solid #173343;
  border-top: 11px solid transparent;
  border-bottom: 11px solid transparent;
  margin-left: 3px;
}
.pause-stats {
  position: absolute;
  left: 50%;
  top: calc(50% + 154px);
  transform: translateX(-50%);
  min-width: 230px;
  border-radius: 24px;
  padding: 16px 18px;
  background: rgba(25, 22, 42, 0.46);
  border: 1px solid rgba(255,255,255,0.14);
  color: #fffdf7;
  font-weight: 700;
  line-height: 1.8;
  text-align: center;
  backdrop-filter: blur(16px);
}
.permission-modal {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 18px;
  background: rgba(30, 24, 44, 0.42);
  z-index: 14;
}
.permission-card {
  width: min(430px, 100%);
  padding: 24px;
  border-radius: 28px;
  border: 1px solid rgba(255,255,255,0.12);
  background: linear-gradient(145deg, rgba(255,255,255,0.94), rgba(250,255,252,0.86));
  text-align: center;
}
.permission-card p { color: var(--muted); line-height: 1.5; }
.permission-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
  flex-wrap: wrap;
}
.gesture-hint {
  position: absolute;
  right: 14px;
  bottom: 14px;
  padding: 10px 14px;
  border-radius: 999px;
  background: rgba(255,255,255,0.8);
  border: 1px solid rgba(255,255,255,0.16);
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 700;
}

@media (max-width: 960px) {
  .login-frame,
  .dashboard-hero {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 760px) {
  .screen-login,
  .screen-dashboard,
  .screen-stats { padding: 18px 12px 24px; }
  .brand-block,
  .login-card,
  .dashboard-hero,
  .stat-card,
  .stats-chart-card,
  .stats-history-card,
  .game-tile { border-radius: 24px; }
  .brand-block { padding: 24px; }
  .brand-flower { width: 96px; height: 96px; }
  .auth-actions,
  .dashboard-actions,
  .stats-topbar,
  .dashboard-topbar { align-items: stretch; }
  .auth-actions > *,
  .dashboard-actions > *,
  .stats-topbar > .ghost-btn,
  .dashboard-topbar > .ghost-btn { width: 100%; }
  .session-row {
    grid-template-columns: 1fr;
  }
  .attempt-row {
    grid-template-columns: 1fr;
  }
  .start-big { width: 180px; height: 180px; }
  .pause-stats { top: calc(50% + 128px); }
}
