:root {
  color-scheme: light;
  --ink: #1d2433;
  --muted: #667085;
  --panel: rgba(255, 255, 255, 0.9);
  --panel-strong: rgba(255, 255, 255, 0.96);
  --line: rgba(31, 42, 68, 0.13);
  --coral: #ff6f61;
  --mint: #28c7a8;
  --sun: #ffc247;
  --sky: #5eb7ff;
  --violet: #8b6cf6;
  --shadow: 0 18px 50px rgba(37, 48, 74, 0.15);
  --app-bg:
    linear-gradient(90deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.18) 1px, transparent 1px),
    linear-gradient(135deg, #fff7df 0%, #e9fbf4 36%, #eaf3ff 68%, #fff0f4 100%);
  --brand-gradient: linear-gradient(135deg, var(--coral), var(--sun) 48%, var(--mint));
  --stage-bg:
    linear-gradient(180deg, rgba(255, 255, 255, 0.62), rgba(255, 255, 255, 0.2)),
    linear-gradient(135deg, rgba(255, 194, 71, 0.1), rgba(40, 199, 168, 0.08) 45%, rgba(94, 183, 255, 0.12));
}

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  align-items: center;
  background: var(--app-bg);
  background-size: 42px 42px, 42px 42px, auto;
  color: var(--ink);
  display: flex;
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    "Microsoft YaHei", sans-serif;
  justify-content: center;
  min-height: 100%;
  overflow: hidden;
}

body[data-theme="candy"] {
  --coral: #ff73a6;
  --mint: #67d8c3;
  --sun: #ffd166;
  --sky: #8cc8ff;
  --violet: #b388ff;
  --app-bg:
    linear-gradient(90deg, rgba(255, 255, 255, 0.2) 1px, transparent 1px),
    linear-gradient(180deg, rgba(255, 255, 255, 0.2) 1px, transparent 1px),
    linear-gradient(135deg, #fff0f7 0%, #fff7d6 34%, #ddfff6 66%, #eef0ff 100%);
  --brand-gradient: linear-gradient(135deg, #ff73a6, #ffd166 48%, #67d8c3);
  --stage-bg:
    linear-gradient(180deg, rgba(255, 255, 255, 0.7), rgba(255, 244, 252, 0.28)),
    linear-gradient(135deg, rgba(255, 115, 166, 0.12), rgba(255, 209, 102, 0.1) 45%, rgba(103, 216, 195, 0.13));
}

body[data-theme="night"] {
  --ink: #eef4ff;
  --muted: #aebbd1;
  --panel: rgba(20, 28, 44, 0.86);
  --panel-strong: rgba(24, 34, 54, 0.95);
  --line: rgba(210, 225, 255, 0.18);
  --coral: #ff8c91;
  --mint: #45e3c5;
  --sun: #ffd36e;
  --sky: #7fc7ff;
  --violet: #a892ff;
  --shadow: 0 18px 50px rgba(3, 8, 20, 0.36);
  --app-bg:
    linear-gradient(90deg, rgba(127, 199, 255, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(127, 199, 255, 0.08) 1px, transparent 1px),
    linear-gradient(135deg, #111827 0%, #172033 40%, #101c2a 70%, #23182d 100%);
  --brand-gradient: linear-gradient(135deg, #ff8c91, #ffd36e 44%, #45e3c5);
  --stage-bg:
    linear-gradient(180deg, rgba(18, 28, 48, 0.84), rgba(18, 28, 48, 0.36)),
    linear-gradient(135deg, rgba(69, 227, 197, 0.1), rgba(127, 199, 255, 0.14) 48%, rgba(168, 146, 255, 0.12));
}

body[data-theme="festival"] {
  --ink: #171923;
  --muted: #4a5568;
  --panel: rgba(255, 255, 255, 0.94);
  --panel-strong: rgba(255, 255, 255, 0.98);
  --line: rgba(23, 25, 35, 0.18);
  --coral: #ff3d6e;
  --mint: #00b894;
  --sun: #ffbe0b;
  --sky: #2f80ed;
  --violet: #8338ec;
  --app-bg:
    linear-gradient(90deg, rgba(23, 25, 35, 0.08) 1px, transparent 1px),
    linear-gradient(180deg, rgba(23, 25, 35, 0.08) 1px, transparent 1px),
    linear-gradient(135deg, #fff8d7 0%, #dffbf2 32%, #dfeaff 66%, #ffe4ee 100%);
  --brand-gradient: linear-gradient(135deg, #ff3d6e, #ffbe0b 42%, #00b894 68%, #2f80ed);
  --stage-bg:
    linear-gradient(180deg, rgba(255, 255, 255, 0.72), rgba(255, 255, 255, 0.26)),
    linear-gradient(135deg, rgba(255, 61, 110, 0.11), rgba(255, 190, 11, 0.12) 36%, rgba(47, 128, 237, 0.13));
}

body[data-theme="night"] .stats div,
body[data-theme="night"] .result-stat,
body[data-theme="night"] .theme-card,
body[data-theme="night"] .setting-row,
body[data-theme="night"] .achievement-item,
body[data-theme="night"] .task-item,
body[data-theme="night"] .recent-list li,
body[data-theme="night"] .rank-list li,
body[data-theme="night"] .summary-tile,
body[data-theme="night"] .guide-item {
  background: rgba(255, 255, 255, 0.08);
}

body[data-theme="night"] .secondary-button,
body[data-theme="night"] #closeRankBtn,
body[data-theme="night"] #clearRankBtn,
body[data-theme="night"] #closeGuideBtn,
body[data-theme="night"] #closeTasksBtn,
body[data-theme="night"] #closeShareBtn,
body[data-theme="night"] #closeSettingsBtn,
body[data-theme="night"] #copyShareBtn {
  background: rgba(255, 255, 255, 0.1);
  color: var(--ink);
}

button {
  border: 0;
  cursor: pointer;
  font: inherit;
}

button:focus-visible,
canvas:focus-visible {
  outline: 3px solid rgba(94, 183, 255, 0.68);
  outline-offset: 3px;
}

.game-shell {
  display: grid;
  gap: 14px;
  grid-template-rows: auto minmax(0, 1fr) auto;
  height: min(100vh, 900px);
  padding: max(14px, env(safe-area-inset-top)) max(14px, env(safe-area-inset-right)) max(14px, env(safe-area-inset-bottom)) max(14px, env(safe-area-inset-left));
  width: min(100vw, 1180px);
}

.hud,
.controls {
  align-items: center;
  backdrop-filter: blur(22px);
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: space-between;
}

.hud {
  min-height: 86px;
  padding: 14px 18px;
}

.brand {
  align-items: center;
  display: flex;
  gap: 12px;
  min-width: 0;
}

.logo-dot {
  background:
    radial-gradient(circle at 34% 28%, #ffffff 0 16%, transparent 17%),
    var(--brand-gradient);
  border-radius: 50%;
  box-shadow: 0 8px 22px rgba(255, 111, 97, 0.32), inset 0 -6px 14px rgba(255, 255, 255, 0.32);
  flex: 0 0 auto;
  height: 46px;
  width: 46px;
}

h1,
h2,
p {
  margin: 0;
}

h1 {
  font-size: clamp(1.22rem, 2.4vw, 1.82rem);
  font-weight: 900;
  letter-spacing: 0;
  line-height: 1.1;
}

.brand p,
#message {
  color: var(--muted);
  line-height: 1.5;
}

.network-badge {
  background: rgba(233, 251, 244, 0.9);
  border: 1px solid rgba(40, 199, 168, 0.34);
  border-radius: 999px;
  color: #14786d;
  flex: 0 0 auto;
  font-size: 0.72rem;
  font-weight: 900;
  padding: 5px 9px;
}

.stats {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(68px, 1fr));
  min-width: min(54vw, 440px);
}

.stats div {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 58px;
  padding: 8px 10px;
  text-align: center;
}

.score-meter,
.combo-meter,
.best-meter {
  background: rgba(31, 42, 68, 0.09);
  border-radius: 999px;
  height: 4px;
  margin-top: 4px;
  overflow: hidden;
  transform: translateZ(0);
}

.score-meter i,
.combo-meter i,
.best-meter i {
  border-radius: inherit;
  display: block;
  height: 100%;
  transform: scaleX(0);
  transform-origin: left center;
  transition: transform 90ms linear, background 120ms ease;
}

.score-meter i {
  background: linear-gradient(90deg, var(--sky), var(--violet));
}

.score-meter.is-complete i {
  background: linear-gradient(90deg, var(--sun), var(--coral));
}

.combo-meter i {
  background: linear-gradient(90deg, var(--mint), var(--sun));
}

.best-meter i {
  background: linear-gradient(90deg, var(--violet), var(--sun));
}

.best-meter.is-complete i {
  background: linear-gradient(90deg, var(--sun), var(--coral));
}

.combo-meter.is-warning i {
  background: linear-gradient(90deg, var(--sun), var(--coral));
}

.best-meter:not(.is-active),
.combo-meter:not(.is-active) {
  opacity: 0.42;
}

.stats div.is-low-time {
  background: rgba(255, 240, 244, 0.88);
  border-color: rgba(255, 111, 97, 0.48);
  box-shadow: inset 0 0 0 1px rgba(255, 111, 97, 0.16), 0 8px 20px rgba(255, 111, 97, 0.14);
}

.stats div.is-low-time span,
.stats div.is-low-time strong {
  color: #b33a2f;
}

.stats span {
  color: var(--muted);
  display: block;
  font-size: 0.76rem;
}

.stats strong {
  display: block;
  font-size: clamp(1.1rem, 2.4vw, 1.58rem);
  line-height: 1.2;
  min-height: 1.2em;
}

.stage-wrap {
  border: 1px solid rgba(255, 255, 255, 0.72);
  border-radius: 8px;
  box-shadow: 0 22px 70px rgba(37, 48, 74, 0.16), inset 0 0 0 1px rgba(31, 42, 68, 0.08);
  min-height: 300px;
  overflow: hidden;
  position: relative;
}

canvas {
  background: var(--stage-bg);
  display: block;
  height: 100%;
  touch-action: manipulation;
  width: 100%;
}

.goal-strip {
  backdrop-filter: blur(16px);
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid var(--line);
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(30, 35, 48, 0.12);
  color: var(--ink);
  font-size: 0.82rem;
  font-weight: 900;
  left: 12px;
  line-height: 1.2;
  max-width: min(520px, calc(100% - 24px));
  overflow: hidden;
  padding: 8px 12px;
  pointer-events: none;
  position: absolute;
  text-overflow: ellipsis;
  top: 12px;
  white-space: nowrap;
  z-index: 2;
}

.goal-strip[data-tone="daily"] {
  background: rgba(255, 246, 206, 0.88);
  color: #7b5600;
}

.goal-strip[data-tone="complete"] {
  background: rgba(233, 251, 244, 0.9);
  color: #14786d;
}

.goal-strip[data-tone="pause"] {
  background: rgba(234, 243, 255, 0.92);
  color: #24537a;
}

.daily-rule-strip {
  backdrop-filter: blur(16px);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(255, 194, 71, 0.34);
  border-radius: 999px;
  box-shadow: 0 10px 24px rgba(30, 35, 48, 0.1);
  color: #7b5600;
  font-size: 0.76rem;
  font-weight: 900;
  left: 12px;
  line-height: 1.2;
  max-width: min(560px, calc(100% - 24px));
  overflow: hidden;
  padding: 7px 11px;
  pointer-events: none;
  position: absolute;
  text-overflow: ellipsis;
  top: 54px;
  white-space: nowrap;
  z-index: 2;
}

.coach-tip {
  backdrop-filter: blur(16px);
  background: rgba(29, 36, 51, 0.82);
  border: 1px solid rgba(255, 255, 255, 0.28);
  border-radius: 999px;
  bottom: 14px;
  box-shadow: 0 12px 28px rgba(30, 35, 48, 0.18);
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 900;
  left: 50%;
  line-height: 1.25;
  max-width: min(560px, calc(100% - 28px));
  overflow: hidden;
  padding: 9px 14px;
  pointer-events: none;
  position: absolute;
  text-align: center;
  text-overflow: ellipsis;
  transform: translateX(-50%);
  white-space: nowrap;
  z-index: 2;
}

.coach-tip[data-tone="time"] {
  background: rgba(20, 120, 109, 0.88);
}

.coach-tip[data-tone="danger"] {
  background: rgba(179, 58, 47, 0.9);
}

.coach-tip[data-tone="combo"] {
  background: rgba(91, 68, 188, 0.88);
}

.coach-tip[data-tone="score"] {
  background: rgba(47, 128, 237, 0.88);
}

.overlay {
  align-items: center;
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  inset: 0;
  justify-content: center;
  opacity: 1;
  padding: 20px;
  pointer-events: auto;
  position: absolute;
  transition: opacity 180ms ease, visibility 180ms ease;
  visibility: visible;
}

.overlay.is-hidden {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

.result-card {
  backdrop-filter: blur(20px);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 72px rgba(32, 43, 66, 0.24);
  max-width: 520px;
  padding: clamp(20px, 4vw, 34px);
  text-align: center;
}

.kicker {
  color: var(--coral);
  font-size: 0.8rem;
  font-weight: 800;
  margin-bottom: 8px;
  text-transform: uppercase;
}

h2 {
  font-size: clamp(1.6rem, 4vw, 3rem);
  letter-spacing: 0;
  line-height: 1.02;
  margin-bottom: 12px;
}

#startBtn,
.recommend-button,
.secondary-button {
  background: linear-gradient(135deg, var(--ink), #35445e);
  border-radius: 8px;
  box-shadow: 0 12px 28px rgba(30, 35, 48, 0.22);
  color: #fff;
  font-weight: 800;
  min-height: 46px;
  min-width: 128px;
  padding: 0 22px;
}

.recommend-button {
  background: linear-gradient(135deg, var(--mint), #1ea989);
}

.mode-preview {
  display: grid;
  gap: 10px;
  margin: 16px auto 0;
  max-width: 440px;
}

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

.mode-chip {
  background: rgba(255, 255, 255, 0.74);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  font-size: 0.78rem;
  font-weight: 900;
  line-height: 1.25;
  min-height: 42px;
  padding: 10px 8px;
}

.mode-meters {
  background: rgba(255, 255, 255, 0.58);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  padding: 10px 12px;
}

.mode-meter {
  align-items: center;
  display: grid;
  gap: 10px;
  grid-template-columns: 38px minmax(0, 1fr);
  text-align: left;
}

.mode-meter strong {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.mode-meter i {
  background: rgba(31, 42, 68, 0.1);
  border-radius: 999px;
  display: block;
  height: 7px;
  overflow: hidden;
  position: relative;
}

.mode-meter i::before {
  background: linear-gradient(90deg, var(--mint), var(--sun), var(--coral));
  border-radius: inherit;
  content: "";
  display: block;
  height: 100%;
  width: calc(var(--level) * 20%);
}

.result-goal {
  background: rgba(255, 247, 223, 0.82);
  border: 1px solid rgba(255, 194, 71, 0.34);
  border-radius: 8px;
  color: #6f5420;
  font-size: 0.92rem;
  font-weight: 800;
  line-height: 1.45;
  margin: 14px auto 0;
  max-width: 420px;
  padding: 10px 12px;
}

.result-review {
  background: rgba(233, 251, 244, 0.84);
  border: 1px solid rgba(40, 199, 168, 0.28);
  border-radius: 8px;
  color: #176b61;
  font-size: 0.9rem;
  font-weight: 800;
  line-height: 1.45;
  margin: 14px auto 0;
  max-width: 440px;
  padding: 10px 12px;
}

.result-stats {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  margin: 16px auto 0;
  max-width: 460px;
}

.result-stat {
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid rgba(31, 42, 68, 0.12);
  border-radius: 8px;
  min-height: 62px;
  padding: 8px 6px;
}

.result-stat span {
  color: var(--muted);
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
  line-height: 1.2;
}

.result-stat strong {
  color: var(--ink);
  display: block;
  font-size: 1.18rem;
  font-weight: 900;
  line-height: 1.35;
}

.result-actions {
  align-items: center;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  margin-top: 20px;
}

.result-shortcut {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.35;
  margin-top: 10px;
}

.secondary-button {
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  box-shadow: none;
  color: var(--ink);
}

.is-hidden {
  display: none !important;
}

.app-toast {
  background: rgba(29, 36, 51, 0.9);
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 8px;
  bottom: 18px;
  box-shadow: 0 16px 38px rgba(30, 35, 48, 0.22);
  color: #ffffff;
  font-size: 0.86rem;
  font-weight: 800;
  left: 50%;
  line-height: 1.35;
  max-width: min(420px, calc(100% - 28px));
  padding: 11px 14px;
  position: fixed;
  text-align: center;
  transform: translateX(-50%);
  z-index: 30;
}

.controls {
  gap: 8px;
  justify-content: center;
  min-height: 58px;
  padding: 8px;
}

.rank-panel,
.guide-panel,
.about-panel,
.tasks-panel,
.share-panel,
.settings-panel {
  align-items: center;
  background: rgba(30, 35, 48, 0.42);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 18px;
  position: fixed;
  z-index: 20;
}

.rank-dialog,
.guide-dialog,
.about-dialog,
.tasks-dialog,
.share-dialog,
.settings-dialog {
  backdrop-filter: blur(20px);
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 72px rgba(30, 35, 48, 0.26);
  display: grid;
  gap: 12px;
  max-height: min(82vh, 640px);
  overflow: auto;
  padding: 18px;
  width: min(720px, 100%);
}

.share-dialog {
  max-height: min(92vh, 780px);
  width: min(420px, 100%);
}

.leaderboard-head {
  align-items: center;
  display: flex;
  gap: 12px;
  justify-content: space-between;
}

.leaderboard-head h2 {
  font-size: 1rem;
  font-weight: 900;
  line-height: 1.1;
  margin: 0;
}

.leaderboard-head p {
  color: var(--muted);
  font-size: 0.78rem;
  margin-top: 2px;
}

.leaderboard-actions {
  display: flex;
  gap: 8px;
}

#toggleRankBtn,
#closeRankBtn,
#clearRankBtn,
#closeGuideBtn,
#closeAboutBtn,
#closeTasksBtn,
#closeShareBtn,
#closeSettingsBtn,
#nativeShareBtn,
#copyShareBtn {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 800;
  min-height: 32px;
  padding: 0 12px;
}

#shareCard {
  aspect-ratio: 3 / 4;
  background: #fffaf0;
  border: 1px solid rgba(31, 42, 68, 0.12);
  border-radius: 8px;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.66), 0 16px 38px rgba(30, 35, 48, 0.16);
  display: block;
  height: auto;
  justify-self: center;
  max-width: min(320px, 100%);
  width: 100%;
}

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

#nativeShareBtn {
  background: linear-gradient(135deg, var(--ink), #35445e);
  color: #fff;
}

.guide-button {
  background: rgba(255, 255, 255, 0.82);
  color: var(--ink);
}

.daily-button {
  background: rgba(255, 246, 206, 0.9);
  color: #7b5600;
}

.settings-button {
  background: rgba(234, 243, 255, 0.92);
  color: #24537a;
}

.install-button {
  background: rgba(255, 246, 206, 0.92);
  color: #7b5600;
}

.tasks-button {
  background: rgba(233, 251, 244, 0.92);
  color: #14786d;
}

.about-button {
  background: rgba(244, 240, 255, 0.92);
  color: #5b44bc;
}

.settings-list {
  display: grid;
  gap: 8px;
}

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

.about-grid article {
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 116px;
  padding: 12px;
}

.about-grid strong,
.about-grid small {
  display: block;
}

.about-grid strong {
  color: var(--ink);
  font-size: 0.9rem;
  font-weight: 900;
}

.about-grid small {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
  line-height: 1.45;
  margin-top: 6px;
}

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

.backup-actions .setting-row {
  min-height: 92px;
}

.backup-file {
  display: none;
}

.backup-status {
  background: rgba(255, 255, 255, 0.64);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 800;
  line-height: 1.4;
  padding: 10px 12px;
}

.backup-status[data-tone="success"] {
  background: rgba(233, 251, 244, 0.86);
  border-color: rgba(40, 199, 168, 0.32);
  color: #14786d;
}

.backup-status[data-tone="error"] {
  background: rgba(255, 240, 244, 0.9);
  border-color: rgba(255, 111, 97, 0.38);
  color: #b33a2f;
}

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

.theme-card {
  align-items: center;
  background: rgba(255, 255, 255, 0.7);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: grid;
  gap: 9px;
  grid-template-columns: 34px minmax(0, 1fr) auto;
  min-height: 68px;
  padding: 9px 10px;
  text-align: left;
}

.theme-card.is-active {
  border-color: rgba(40, 199, 168, 0.55);
  box-shadow: inset 0 0 0 1px rgba(40, 199, 168, 0.22);
}

.theme-card.is-locked {
  cursor: not-allowed;
  opacity: 0.62;
}

.theme-card em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 900;
}

.theme-copy strong,
.theme-copy small {
  display: block;
}

.theme-copy strong {
  font-size: 0.88rem;
}

.theme-copy small {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.28;
  margin-top: 2px;
}

.theme-swatch {
  border: 2px solid rgba(255, 255, 255, 0.8);
  border-radius: 50%;
  box-shadow: 0 6px 15px rgba(31, 42, 68, 0.18);
  height: 30px;
  width: 30px;
}

.theme-swatch[data-theme="fresh"] {
  background: linear-gradient(135deg, #ff6f61, #ffc247 48%, #28c7a8);
}

.theme-swatch[data-theme="candy"] {
  background: linear-gradient(135deg, #ff73a6, #ffd166 48%, #67d8c3);
}

.theme-swatch[data-theme="night"] {
  background: linear-gradient(135deg, #111827, #45e3c5 48%, #a892ff);
}

.theme-swatch[data-theme="festival"] {
  background: linear-gradient(135deg, #ff3d6e, #ffbe0b 42%, #00b894 68%, #2f80ed);
}

.setting-row {
  align-items: center;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--ink);
  display: flex;
  gap: 12px;
  justify-content: space-between;
  min-height: 74px;
  padding: 12px;
  text-align: left;
}

.setting-row strong,
.setting-row small {
  display: block;
}

.setting-row small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.35;
  margin-top: 3px;
}

.setting-row em {
  align-items: center;
  background: rgba(31, 42, 68, 0.08);
  border-radius: 999px;
  color: var(--muted);
  display: inline-flex;
  flex: 0 0 auto;
  font-size: 0.74rem;
  font-style: normal;
  font-weight: 900;
  justify-content: center;
  min-width: 42px;
  padding: 5px 10px;
}

.setting-row[aria-pressed="true"] {
  border-color: rgba(40, 199, 168, 0.46);
  box-shadow: inset 0 0 0 1px rgba(40, 199, 168, 0.2);
}

.setting-row[aria-pressed="true"] em {
  background: rgba(40, 199, 168, 0.16);
  color: #14786d;
}

.version-card,
.highlight-card,
.release-card,
.privacy-card {
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
  border-radius: 8px;
  color: var(--muted);
  display: grid;
  gap: 3px;
  padding: 12px;
}

.version-card strong,
.highlight-card strong,
.release-card strong,
.privacy-card strong {
  color: var(--ink);
  font-size: 0.84rem;
  font-weight: 900;
}

.version-card span {
  color: #14786d;
  font-size: 0.78rem;
  font-weight: 900;
}

.version-card small,
.highlight-card small,
.release-card small,
.privacy-card small {
  font-size: 0.75rem;
  line-height: 1.35;
}

.highlight-list {
  display: grid;
  gap: 8px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.highlight-list li {
  background: rgba(255, 255, 255, 0.66);
  border: 1px solid rgba(31, 42, 68, 0.08);
  border-radius: 8px;
  display: grid;
  gap: 2px;
  padding: 10px;
}

.highlight-list span {
  color: var(--muted);
  font-size: 0.75rem;
  font-weight: 800;
  line-height: 1.35;
}

.release-head {
  align-items: center;
  display: flex;
  justify-content: space-between;
}

.release-head span {
  background: rgba(40, 199, 168, 0.14);
  border-radius: 999px;
  color: #14786d;
  font-size: 0.72rem;
  font-weight: 900;
  padding: 4px 8px;
}

.release-note {
  background: rgba(233, 251, 244, 0.72);
  border: 1px solid rgba(40, 199, 168, 0.22);
  border-radius: 8px;
  color: #14786d;
  font-size: 0.76rem;
  font-weight: 800;
  line-height: 1.4;
  margin-top: 6px;
  padding: 9px 10px;
}

.release-list {
  display: grid;
  gap: 7px;
  margin-top: 6px;
}

.release-actions {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  margin-top: 6px;
}

.release-item {
  align-items: center;
  display: grid;
  gap: 9px;
  grid-template-columns: 24px minmax(0, 1fr);
  text-align: left;
}

.release-item > span {
  align-items: center;
  background: rgba(31, 42, 68, 0.08);
  border-radius: 50%;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.72rem;
  font-weight: 900;
  height: 24px;
  justify-content: center;
  width: 24px;
}

.release-item.is-ready > span {
  background: rgba(40, 199, 168, 0.16);
  color: #14786d;
}

.release-item strong,
.release-item small {
  display: block;
}

.privacy-card {
  gap: 5px;
}

.text-link,
.policy-back {
  color: #14786d;
  font-size: 0.78rem;
  font-weight: 900;
  text-decoration: none;
}

.text-link:hover,
.policy-back:hover {
  text-decoration: underline;
}

.policy-page {
  align-items: center;
  display: flex;
  min-height: 100svh;
  padding: 24px;
}

.policy-card {
  background: var(--panel-strong);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: 0 24px 72px rgba(32, 43, 66, 0.18);
  margin: 0 auto;
  max-width: 760px;
  padding: clamp(22px, 5vw, 40px);
}

.policy-card h1 {
  color: var(--ink);
  font-size: clamp(2rem, 5vw, 3.4rem);
  letter-spacing: 0;
  line-height: 1;
  margin: 8px 0 18px;
}

.policy-card h2 {
  color: var(--ink);
  font-size: 1rem;
  line-height: 1.2;
  margin: 22px 0 8px;
}

.policy-card p {
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.7;
}

.health-card {
  display: grid;
  gap: 12px;
}

.health-summary {
  background: rgba(255, 247, 223, 0.86);
  border: 1px solid rgba(255, 194, 71, 0.34);
  border-radius: 8px;
  color: #6f5420;
  font-size: 0.92rem;
  font-weight: 900;
  padding: 10px 12px;
}

.health-summary[data-tone="ready"] {
  background: rgba(233, 251, 244, 0.82);
  border-color: rgba(40, 199, 168, 0.3);
  color: #14786d;
}

.health-summary[data-tone="warn"] {
  background: rgba(255, 240, 244, 0.82);
  border-color: rgba(255, 111, 97, 0.3);
  color: #b33a2f;
}

.danger-setting {
  border-color: rgba(255, 111, 97, 0.28);
}

.danger-setting em {
  background: rgba(255, 111, 97, 0.12);
  color: #b33a2f;
}

.danger-setting.is-confirming {
  background: rgba(255, 240, 244, 0.86);
  border-color: rgba(255, 111, 97, 0.55);
}

body.is-high-contrast canvas {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.86), rgba(255, 255, 255, 0.38)),
    linear-gradient(135deg, rgba(255, 194, 71, 0.14), rgba(40, 199, 168, 0.12) 45%, rgba(94, 183, 255, 0.18));
}

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

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

.rank-filter {
  background: rgba(31, 42, 68, 0.06);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  padding: 5px;
}

.rank-filter button {
  background: transparent;
  border-radius: 6px;
  color: var(--muted);
  font-size: 0.8rem;
  font-weight: 900;
  min-height: 34px;
}

.rank-filter button.is-active {
  background: rgba(255, 255, 255, 0.86);
  box-shadow: 0 6px 16px rgba(31, 42, 68, 0.1);
  color: var(--ink);
}

.mode-best-list {
  display: grid;
  gap: 8px;
  grid-template-columns: repeat(4, minmax(0, 1fr));
}

.mode-best-card {
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 78px;
  padding: 9px 10px;
}

.mode-best-card.is-current {
  border-color: rgba(47, 128, 237, 0.38);
  box-shadow: inset 0 0 0 1px rgba(47, 128, 237, 0.16);
}

.mode-best-card.is-empty {
  opacity: 0.72;
}

.mode-best-card span,
.mode-best-card small {
  display: block;
}

.mode-best-card span {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
}

.mode-best-card strong {
  color: var(--ink);
  display: block;
  font-size: 1.28rem;
  font-weight: 900;
  line-height: 1.2;
  margin-top: 4px;
}

.mode-best-card small {
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 800;
  line-height: 1.2;
  margin-top: 3px;
}

.summary-tile {
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 62px;
  padding: 9px 10px;
}

.summary-tile span {
  color: var(--muted);
  display: block;
  font-size: 0.72rem;
  font-weight: 800;
}

.summary-tile strong {
  color: var(--ink);
  display: block;
  font-size: 1.2rem;
  font-weight: 900;
  line-height: 1.25;
  margin-top: 3px;
}

.section-label {
  color: var(--muted);
  font-size: 0.72rem;
  font-weight: 900;
  margin: 2px 0 8px;
}

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

.recent-list {
  display: grid;
  gap: 6px;
  list-style: none;
  margin: 0;
  padding: 0;
}

.recent-list li {
  align-items: center;
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: flex;
  gap: 10px;
  justify-content: space-between;
  min-height: 54px;
  padding: 9px 11px;
}

.recent-list li.is-latest {
  border-color: rgba(40, 199, 168, 0.5);
  box-shadow: inset 0 0 0 1px rgba(40, 199, 168, 0.16);
}

.recent-list strong {
  color: var(--ink);
  display: block;
  font-size: 1.08rem;
  font-weight: 900;
  line-height: 1.15;
}

.recent-list span,
.recent-list em {
  color: var(--muted);
  font-size: 0.72rem;
  font-style: normal;
  font-weight: 800;
}

.recent-list em {
  flex: 0 0 auto;
}

.achievement-item {
  align-items: center;
  background: rgba(255, 255, 255, 0.62);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 38px minmax(0, 1fr);
  min-height: 70px;
  opacity: 0.58;
  padding: 9px 10px;
}

.achievement-item.is-unlocked {
  background: rgba(255, 246, 206, 0.8);
  border-color: rgba(255, 194, 71, 0.52);
  box-shadow: inset 0 0 0 1px rgba(255, 194, 71, 0.22);
  opacity: 1;
}

.achievement-icon {
  align-items: center;
  background: rgba(31, 42, 68, 0.08);
  border-radius: 50%;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.78rem;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.achievement-item.is-unlocked .achievement-icon {
  background: rgba(255, 194, 71, 0.22);
  color: #7b5600;
}

.achievement-title {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.achievement-title em {
  background: rgba(31, 42, 68, 0.08);
  border-radius: 999px;
  color: var(--muted);
  flex: 0 0 auto;
  font-size: 0.68rem;
  font-style: normal;
  font-weight: 900;
  padding: 4px 7px;
}

.achievement-item.is-unlocked .achievement-title em {
  background: rgba(255, 194, 71, 0.2);
  color: #7b5600;
}

.achievement-copy strong,
.achievement-copy small {
  display: block;
}

.achievement-copy strong {
  font-size: 0.88rem;
}

.achievement-copy small {
  color: var(--muted);
  font-size: 0.74rem;
  line-height: 1.34;
  margin-top: 2px;
}

.task-item {
  align-items: center;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 38px minmax(0, 1fr);
  min-height: 74px;
  padding: 10px;
}

.task-check {
  align-items: center;
  background: rgba(31, 42, 68, 0.08);
  border-radius: 50%;
  color: var(--muted);
  display: inline-flex;
  font-size: 0.86rem;
  font-weight: 900;
  height: 34px;
  justify-content: center;
  width: 34px;
}

.task-item.is-complete {
  border-color: rgba(40, 199, 168, 0.48);
  box-shadow: inset 0 0 0 1px rgba(40, 199, 168, 0.18);
}

.task-item.is-complete .task-check {
  background: rgba(40, 199, 168, 0.18);
  color: #14786d;
}

.task-copy strong,
.task-copy small {
  display: block;
}

.task-copy small {
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.38;
  margin-top: 3px;
}

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

.guide-item {
  align-items: center;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 8px;
  grid-template-columns: 48px minmax(0, 1fr);
  min-height: 74px;
  padding: 10px;
}

.guide-item.is-risk {
  background: rgba(255, 240, 244, 0.86);
  border-color: rgba(179, 58, 47, 0.28);
}

.guide-item.is-risk .guide-bubble {
  box-shadow: inset 0 -8px 18px rgba(255, 255, 255, 0.16), 0 8px 20px rgba(179, 58, 47, 0.18);
}

.guide-item.is-risk .guide-tag {
  background: rgba(179, 58, 47, 0.13);
  color: #b33a2f;
}

.guide-bubble {
  align-items: center;
  border: 2px solid rgba(255, 255, 255, 0.78);
  border-radius: 50%;
  box-shadow: inset 0 -8px 18px rgba(255, 255, 255, 0.28), 0 8px 20px rgba(31, 42, 68, 0.12);
  color: #fff;
  display: flex;
  font-size: 0.88rem;
  font-weight: 900;
  height: 42px;
  justify-content: center;
  text-align: center;
  width: 42px;
}

.guide-copy {
  min-width: 0;
}

.guide-title {
  align-items: center;
  display: flex;
  gap: 8px;
  justify-content: space-between;
}

.guide-title strong {
  font-size: 0.96rem;
}

.guide-tag {
  background: rgba(31, 42, 68, 0.08);
  border-radius: 8px;
  color: var(--muted);
  font-size: 0.7rem;
  font-weight: 900;
  padding: 3px 7px;
}

.guide-copy p {
  color: var(--muted);
  font-size: 0.8rem;
  line-height: 1.42;
  margin-top: 3px;
}

.rank-list {
  display: grid;
  gap: 6px;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  list-style: none;
  margin: 0;
  padding: 0;
}

.rank-list li {
  align-items: center;
  background: rgba(255, 255, 255, 0.76);
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 2px;
  min-height: 48px;
  padding: 8px 10px;
}

.rank-list li.is-latest {
  border-color: rgba(255, 111, 97, 0.55);
  box-shadow: inset 0 0 0 1px rgba(255, 111, 97, 0.18);
}

.rank-list .empty-rank {
  color: var(--muted);
  grid-column: 1 / -1;
  justify-content: center;
  text-align: center;
}

.recent-list .empty-rank {
  color: var(--muted);
  justify-content: center;
  text-align: center;
}

.rank-main {
  align-items: center;
  display: flex;
  gap: 6px;
  justify-content: space-between;
  min-width: 0;
}

.rank-place {
  color: var(--coral);
  font-size: 0.78rem;
  font-weight: 900;
}

.rank-score {
  font-size: 1rem;
  font-weight: 900;
}

.rank-meta {
  color: var(--muted);
  font-size: 0.72rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.icon-button,
.mode-button {
  border: 1px solid var(--line);
  border-radius: 8px;
  min-height: 42px;
  transition: transform 140ms ease, background 140ms ease, color 140ms ease, box-shadow 140ms ease;
}

.icon-button {
  align-items: center;
  background: rgba(255, 255, 255, 0.78);
  color: var(--ink);
  display: inline-flex;
  font-size: 1.15rem;
  font-weight: 900;
  justify-content: center;
  width: 46px;
}

#pauseBtn[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--mint), #1ea989);
  color: #fff;
}

.mode-button {
  background: rgba(255, 255, 255, 0.72);
  color: var(--muted);
  font-weight: 800;
  padding: 0 16px;
}

.mode-button[data-mode] {
  align-content: center;
  display: grid;
  gap: 1px;
  line-height: 1.15;
  min-height: 56px;
  min-width: 98px;
  padding: 6px 12px;
}

.mode-button[data-mode] span,
.mode-button[data-mode] small,
.mode-button[data-mode] em {
  display: block;
}

.mode-button[data-mode] span {
  color: inherit;
  font-size: 0.9rem;
  font-weight: 900;
}

.mode-button[data-mode] small {
  color: currentColor;
  font-size: 0.68rem;
  font-weight: 800;
  opacity: 0.68;
}

.mode-button[data-mode] em {
  color: currentColor;
  font-size: 0.64rem;
  font-style: normal;
  font-weight: 900;
  opacity: 0.82;
}

.mode-button.is-active,
.icon-button[aria-pressed="true"] {
  background: linear-gradient(135deg, var(--ink), #34445d);
  box-shadow: 0 8px 18px rgba(30, 35, 48, 0.16);
  color: #fff;
}

button:active {
  transform: scale(0.96);
}

@media (max-width: 720px) {
  body {
    overflow: auto;
  }

  .game-shell {
    height: 100svh;
    padding: 10px;
  }

  .hud {
    align-items: stretch;
    flex-direction: column;
    gap: 12px;
  }

  .stats {
    min-width: 0;
    width: 100%;
  }

  .brand p {
    font-size: 0.9rem;
  }

  .network-badge {
    margin-left: auto;
  }

  .goal-strip {
    font-size: 0.76rem;
    left: 10px;
    max-width: calc(100% - 20px);
    padding: 7px 10px;
    top: 10px;
  }

  .coach-tip {
    bottom: 10px;
    font-size: 0.76rem;
    max-width: calc(100% - 20px);
    padding: 8px 10px;
  }

  .controls {
    flex-wrap: wrap;
  }

  .rank-list {
    grid-template-columns: 1fr;
  }

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

  .mode-best-list {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .achievement-list {
    grid-template-columns: 1fr;
  }

  .recent-list li {
    align-items: flex-start;
    flex-direction: column;
    gap: 4px;
  }

  .guide-list {
    grid-template-columns: 1fr;
  }

  .tasks-list {
    grid-template-columns: 1fr;
  }

  .about-grid {
    grid-template-columns: 1fr;
  }

  .about-grid article {
    min-height: auto;
  }

  .setting-row {
    align-items: flex-start;
  }

  .theme-list {
    grid-template-columns: 1fr;
  }

  .backup-actions {
    grid-template-columns: 1fr;
  }

  .mode-button {
    flex: 1 1 28%;
    min-width: 82px;
    padding: 0 10px;
  }

  .mode-button[data-mode] {
    min-width: 94px;
    padding: 6px 8px;
  }
}

@media (max-width: 420px) {
  .stats {
    gap: 6px;
  }

  .stats div {
    min-height: 54px;
    padding: 7px 6px;
  }

  .result-card {
    padding: 20px 18px;
  }

  .mode-preview {
    gap: 8px;
  }

  .mode-chips {
    grid-template-columns: 1fr;
  }

  .mode-chip {
    min-height: 36px;
  }

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

  #startBtn,
  .secondary-button {
    flex: 1 1 100%;
  }
}

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