html, body {
  margin: 0;
  padding: 0;
  height: 100%;
  overflow: visible;
  background-color: #000;
  font-family: 'Zen Dots', monospace;
  transition: background-color 10s linear;
}

button,
input,
select,
textarea {
  font: inherit;
}

#gameCanvas {
  position: fixed;
  inset: 0;
  display: block;
  width: 100vw;
  height: 100vh;
  touch-action: none;
  background: black;
  z-index: 1;
  cursor: url("flower-cursor.svg") 24 24, crosshair;
}

#scoreContainer,
#scoreContainer button,
#settingsPanel,
#settingsPanel button,
#settingsPanel [role="button"] {
  cursor: url("flower-cursor-menu.svg") 24 24, pointer;
}

#scoreContainer {
  position: fixed;
  top: 0;
  left: 50%;
  transform: translate(-50%, calc(-100% + 12px));
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  font-family: 'Zen Dots', monospace;
  font-size: 1.2rem;
  color: #c9ffd9;
  z-index: 3000;
  text-shadow: 0 0 10px rgba(72, 255, 155, 0.35);
  background: linear-gradient(180deg, #143826 0%, #0f2f20 46%, #0a2117 100%);
  border-style: solid;
  border-color: #2f6f52;
  border-width: 0 1px 1px;
  padding: 12px 24px 14px 132px;
  min-width: min(92vw, 520px);
  border-radius: 0 0 24px 24px;
  box-shadow:
    0 8px 20px rgba(0, 0, 0, 0.35),
    inset 0 1px 0 rgba(180, 255, 217, 0.26),
    inset 0 -6px 14px rgba(0, 0, 0, 0.35);
  overflow: visible;
  pointer-events: auto;
  opacity: 0.92;
  transition:
    transform 520ms cubic-bezier(0.2, 0.82, 0.2, 1),
    box-shadow 420ms ease,
    opacity 320ms ease;
}

#scoreContainer.is-active {
  transform: translate(-50%, 0);
  opacity: 1;
  box-shadow:
    0 12px 30px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(180, 255, 217, 0.3),
    inset 0 -8px 16px rgba(0, 0, 0, 0.4);
}

#hudActions {
  position: absolute;
  left: 12px;
  top: 0;
  display: flex;
  gap: 8px;
}

.round-btn {
  width: 50px;
  height: 34px;
  border-radius: 0 0 12px 12px;
  border: 1px solid #7ec0ff;
  background: linear-gradient(180deg, #225f87 0%, #17486a 52%, #113650 100%);
  color: #e9f7ff;
  font-size: 0.95rem;
  line-height: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow:
    0 3px 10px rgba(4, 22, 38, 0.55),
    inset 0 1px 0 rgba(201, 235, 255, 0.4);
}

.round-btn:active {
  transform: translateY(1px);
}

#profileButton {
  font-weight: 700;
  position: relative;
  overflow: hidden;
  padding: 0;
}

#profileButton::before {
  content: attr(data-initial);
  position: absolute;
  inset: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

#profileButton.has-avatar::before {
  content: "";
}

#profileButtonAvatar {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#profileButton.needs-login-cue {
  animation: profile-login-cue 2200ms cubic-bezier(0.2, 0.8, 0.2, 1) 1;
}

@keyframes profile-login-cue {
  0%, 100% {
    border-color: #7ec0ff;
    box-shadow:
      0 3px 10px rgba(4, 22, 38, 0.55),
      inset 0 1px 0 rgba(201, 235, 255, 0.4);
  }
  20%, 55%, 82% {
    border-color: #ff8d8d;
    box-shadow:
      0 0 0 1px rgba(255, 141, 141, 0.18),
      0 0 18px rgba(255, 97, 97, 0.34),
      0 3px 10px rgba(4, 22, 38, 0.55),
      inset 0 1px 0 rgba(255, 215, 215, 0.42);
  }
  35%, 68% {
    border-color: #ffb0b0;
    box-shadow:
      0 0 0 2px rgba(255, 141, 141, 0.16),
      0 0 24px rgba(255, 97, 97, 0.28),
      0 3px 10px rgba(4, 22, 38, 0.55),
      inset 0 1px 0 rgba(255, 230, 230, 0.44);
  }
}

#soundButton .sound-off {
  display: none;
}

#soundButton.is-muted .sound-on {
  display: none;
}

#soundButton.is-muted .sound-off {
  display: inline;
}

#soundButton.is-muted {
  border-color: #ff9a9a;
  background: linear-gradient(180deg, #ba3f3f 0%, #8f2f2f 52%, #6b2222 100%);
  color: #ffe9e9;
}

.metric {
  white-space: nowrap;
  letter-spacing: 0.03em;
}

.metric span {
  color: #e8ffee;
}

#scoreMetric {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  font-size: 1.35rem;
  text-align: center;
}

#superMetric {
  display: none;
  font-size: 0.72rem;
  letter-spacing: 0.06em;
  color: #c5ffd8;
}

#timeBadge {
  position: absolute;
  top: 0;
  right: 12px;
  display: inline-flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-width: 146px;
  padding: 4px 8px;
  font-size: 0.95rem;
  color: #e6f5ff;
  border-radius: 0 0 12px 0;
  background: linear-gradient(180deg, #1f6c9a 0%, #134a78 52%, #0f3556 100%);
  border: 1px solid #5eb5ff;
  box-shadow:
    0 4px 12px rgba(7, 28, 47, 0.55),
    inset 0 1px 0 rgba(173, 225, 255, 0.4);
}

#settingsPanel {
  position: absolute;
  top: calc(100% + 2px);
  left: 50%;
  transform: translateX(-50%) scaleY(0.92);
  transform-origin: top center;
  width: min(84vw, 360px);
  max-height: 0;
  opacity: 1;
  overflow: hidden;
  padding: 0 14px;
  border-radius: 0 0 18px 18px;
  background: linear-gradient(180deg, #143826 0%, #0f2f20 46%, #0a2117 100%);
  border: 1px solid #2f6f52;
  border-top: none;
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  transition: max-height 280ms ease, transform 280ms ease, padding 280ms ease;
  pointer-events: auto;
  z-index: 4001;
}

#scoreContainer.settings-open #settingsPanel {
  max-height: 340px;
  transform: translateX(-50%) scaleY(1);
  padding: 10px 14px 14px;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  margin-top: 8px;
  font-size: 0.82rem;
  color: #d4ffe4;
}

#profileSummary {
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
}

#profileAvatar {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid #5eb5ff;
  background: #0f2f20;
  flex: 0 0 auto;
}

#profileMeta {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

#profileName {
  display: block;
  font-weight: 700;
  overflow-wrap: anywhere;
}

#authStatusText {
  display: block;
  font-size: 0.72rem;
  color: #bfead0;
  opacity: 0.9;
  overflow-wrap: anywhere;
}

.settings-row-right {
  justify-content: flex-end;
}

.settings-row-bottom {
  justify-content: space-between;
  margin-top: 13px;
}

#settingsAudioRow {
  gap: 8px;
  flex-wrap: nowrap;
}

#settingsSoundRow,
#settingsBeatRow {
  display: flex;
  flex: 1 1 0;
  min-width: 0;
}

.settings-btn,
.settings-link {
  border: 1px solid #5eb5ff;
  border-radius: 999px;
  background: linear-gradient(180deg, #1f6c9a 0%, #134a78 52%, #0f3556 100%);
  color: #e6f5ff;
  padding: 5px 10px;
  font-size: 0.76rem;
  font-family: 'Zen Dots', monospace;
  cursor: pointer;
  min-width: 112px;
  text-align: center;
}

#settingsAudioRow .settings-btn {
  width: 100%;
  min-width: 0;
}

#settingsSoundBlock {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.settings-btn.is-danger {
  border-color: #ff9a9a;
  background: linear-gradient(180deg, #ba3f3f 0%, #8f2f2f 52%, #6b2222 100%);
  color: #ffe9e9;
}

#scoreContainer.settings-open #settingsPanel {
  max-height: min(80vh, 520px);
}

#settingsPanel .settings-btn:disabled,
#settingsPanel .settings-icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  filter: saturate(0.65);
}

.gamer-name-field {
  flex: 1 1 auto;
  min-width: 0;
}

.gamer-name-field:not(.is-editing) {
  cursor: pointer;
}

.settings-input {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid rgba(94, 181, 255, 0.55);
  border-radius: 999px;
  background: rgba(11, 38, 58, 0.92);
  color: #e6f5ff;
  padding: 7px 12px;
  font-size: 0.76rem;
  font-family: 'Zen Dots', monospace;
  outline: none;
  transition: border-color 180ms ease, box-shadow 180ms ease, background 180ms ease;
}

.settings-input:disabled {
  opacity: 0.88;
  cursor: pointer;
  pointer-events: none;
}

.settings-input.is-editing {
  border-color: #a8e2ff;
  background: rgba(17, 58, 87, 0.98);
  box-shadow:
    0 0 0 1px rgba(168, 226, 255, 0.18),
    0 0 16px rgba(94, 181, 255, 0.18);
}

.settings-icon-btn {
  min-width: 42px;
  width: 42px;
  height: 42px;
  padding: 0;
  border: 1px solid #5eb5ff;
  border-radius: 999px;
  background: linear-gradient(180deg, #1f6c9a 0%, #134a78 52%, #0f3556 100%);
  color: #e6f5ff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.95rem;
  font-family: 'Zen Dots', monospace;
}

.settings-icon-btn[hidden] {
  display: none !important;
}

#settingsHighscore {
  display: none;
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid #5eb5ff;
  background: linear-gradient(180deg, #1f6c9a 0%, #134a78 52%, #0f3556 100%);
  color: #e6f5ff;
  font-size: 0.8rem;
  line-height: 1.4;
  text-align: center;
  white-space: pre-line;
}

#time {
  display: inline-block;
  width: 62px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

#timeUnit {
  display: inline-block;
  width: 24px;
  text-align: right;
}

#scoreContainer::before {
  content: "";
  position: absolute;
  top: 0;
  left: 5%;
  width: 90%;
  height: 40%;
  pointer-events: none;
}

#message {
  position: fixed;
  top: 40%;
  left: 50%;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  font-family: 'Zen Dots', monospace;
  user-select: none;
  z-index: 4000;
}

#messageTitle {
  font-size: 4rem;
  color: #ff00ff;
  text-shadow: 0 0 20px #ff00ff;
}

#messageSummary {
  display: none;
  min-width: 260px;
  padding: 10px 14px;
  border-radius: 18px;
  background: linear-gradient(180deg, #1f6c9a 0%, #134a78 52%, #0f3556 100%);
  border: 1px solid #5eb5ff;
  box-shadow:
    0 6px 16px rgba(7, 28, 47, 0.58),
    inset 0 1px 0 rgba(173, 225, 255, 0.4);
  font-size: 1.8rem;
  line-height: 1.45;
  color: #e6f5ff;
  text-shadow: 0 0 8px rgba(120, 200, 255, 0.35);
  text-align: center;
  white-space: pre-line;
}

body.auth-modal-open {
  overflow: hidden;
}

.auth-modal {
  position: fixed;
  inset: 0;
  z-index: 6500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-sizing: border-box;
}

.auth-modal[hidden],
.auth-session-card[hidden],
.auth-error-message[hidden],
.auth-secondary-btn[hidden],
#authSessionAvatar[hidden] {
  display: none !important;
}

.auth-backdrop {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(circle at top, rgba(69, 148, 255, 0.18), transparent 40%),
    rgba(1, 8, 15, 0.8);
  backdrop-filter: blur(18px);
}

.auth-dialog {
  position: relative;
  width: min(100%, 430px);
  padding: 26px 24px 22px;
  border-radius: 26px;
  border: 1px solid rgba(94, 181, 255, 0.35);
  background:
    linear-gradient(180deg, rgba(23, 53, 76, 0.96) 0%, rgba(16, 34, 54, 0.98) 100%);
  box-shadow:
    0 28px 80px rgba(0, 0, 0, 0.55),
    inset 0 1px 0 rgba(228, 245, 255, 0.22);
  color: #eef8ff;
  font-family: 'Zen Dots', monospace;
  z-index: 1;
}

.auth-dialog button,
.auth-dialog input,
.auth-dialog select,
.auth-dialog textarea {
  font-family: inherit;
}

.auth-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 44px;
  height: 44px;
  border: 1px solid rgba(94, 181, 255, 0.35);
  border-radius: 999px;
  background: rgba(11, 24, 37, 0.9);
  color: #ecf7ff;
  font-size: 1.6rem;
  line-height: 1;
  cursor: pointer;
}

.auth-brand {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.auth-brand-mark {
  width: 52px;
  height: 52px;
  border-radius: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(180deg, rgba(240, 215, 102, 0.14) 0%, rgba(80, 34, 104, 0.12) 100%);
  box-shadow: inset 0 1px 0 rgba(255, 245, 206, 0.18);
  flex: 0 0 auto;
}

.auth-brand-mark img {
  width: 34px;
  height: 34px;
  display: block;
}

.auth-brand-copy {
  min-width: 0;
}

.auth-eyebrow {
  font-size: 0.72rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: #9dd2ff;
  margin-bottom: 6px;
}

#authTitle {
  margin: 0;
  font-size: 1.55rem;
  line-height: 1.15;
}

#authDescription {
  margin: 10px 0 0;
  font-size: 0.95rem;
  line-height: 1.5;
  color: #d3e8f7;
}

.auth-session-card {
  margin-top: 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  border-radius: 18px;
  border: 1px solid rgba(94, 181, 255, 0.28);
  background: rgba(13, 28, 45, 0.72);
}

#authSessionAvatar {
  width: 42px;
  height: 42px;
  border-radius: 999px;
  object-fit: cover;
  border: 1px solid rgba(94, 181, 255, 0.45);
  background: #0f2f20;
  flex: 0 0 auto;
}

.auth-session-copy {
  min-width: 0;
}

.auth-session-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: #f5fbff;
  overflow-wrap: anywhere;
}

.auth-session-email {
  margin-top: 2px;
  font-size: 0.8rem;
  color: #a9cee8;
  overflow-wrap: anywhere;
}

.auth-status-message {
  min-height: 22px;
  margin-top: 18px;
  font-size: 0.88rem;
  color: #bfdcf1;
}

.auth-error-message {
  margin-top: 8px;
  padding: 10px 12px;
  border-radius: 14px;
  border: 1px solid rgba(255, 154, 154, 0.4);
  background: rgba(113, 28, 33, 0.72);
  color: #ffe5e5;
  font-size: 0.88rem;
  line-height: 1.45;
}

.auth-google-shell {
  min-height: 56px;
  margin-top: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 18px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px dashed rgba(94, 181, 255, 0.18);
  padding: 10px;
}

.auth-google-button {
  width: 100%;
  display: flex;
  justify-content: center;
}

.auth-secondary-btn {
  margin-top: 14px;
  width: 100%;
  border: 1px solid #5eb5ff;
  border-radius: 999px;
  background: linear-gradient(180deg, #1f6c9a 0%, #134a78 52%, #0f3556 100%);
  color: #e6f5ff;
  padding: 12px 16px;
  font-size: 0.95rem;
  font-family: 'Zen Dots', monospace;
  cursor: pointer;
}

.auth-privacy-note {
  margin: 14px 0 0;
  font-size: 0.76rem;
  line-height: 1.5;
  color: #a8c6da;
}

@media (max-width: 768px) {
  #scoreContainer {
    --hud-side-space: 172px;
    width: 100vw;
    min-width: 100vw;
    max-width: 100vw;
    padding: 16px var(--hud-side-space) 18px var(--hud-side-space);
    border-radius: 0 0 28px 28px;
    box-sizing: border-box;
  }

  #hudActions {
    left: 14px;
    top: 0;
    gap: 10px;
  }

  .round-btn {
    width: 50px;
    height: 60px;
    font-size: 2.1rem;
  }

  #message {
    min-width: 450px;
  }

  #scoreMetric {
    font-size: 2.6rem;
  }

  #superMetric {
    font-size: 1.2rem;
  }

  #timeBadge {
    top: 0;
    right: 12px;
    min-width: 200px;
    padding: 6px 10px;
    font-size: 1.15rem;
  }

  #time {
    width: 88px;
  }

  #timeUnit {
    width: 34px;
  }

  #settingsPanel {
    width: min(96vw, 420px);
  }

  .settings-row {
    font-size: 1.18rem;
    align-items: flex-start;
  }

  .settings-btn,
  .settings-link {
    min-width: 172px;
    padding: 10px 16px;
    font-size: 1.14rem;
  }

  #settingsHighscore {
    line-height: 1.18;
    padding: 14px 16px;
  }

  #profileSummary {
    gap: 12px;
  }

  #profileAvatar {
    width: 42px;
    height: 42px;
  }

  #authStatusText {
    font-size: 0.88rem;
  }

  .auth-modal {
    align-items: flex-end;
    padding: 16px 12px calc(12px + env(safe-area-inset-bottom));
  }

  .auth-dialog {
    width: min(100%, 100vw - 24px);
    padding: 22px 18px calc(18px + env(safe-area-inset-bottom));
    border-radius: 24px 24px 18px 18px;
  }

  .auth-brand {
    gap: 12px;
  }

  .auth-brand-mark {
    width: 48px;
    height: 48px;
  }

  #authTitle {
    font-size: 1.34rem;
  }

  #authDescription {
    font-size: 0.9rem;
  }

  .auth-status-message,
  .auth-error-message,
  .auth-secondary-btn {
    font-size: 0.92rem;
  }
}

@media (pointer: coarse) and (orientation: portrait) {
  #scoreContainer {
    --hud-side-space: 206px;
    width: 100vw;
    min-width: 100vw;
    max-width: 100vw;
    padding: 22px var(--hud-side-space) 24px var(--hud-side-space);
    border-radius: 0 0 32px 32px;
    box-sizing: border-box;
  }

  #hudActions {
    left: 14px;
    top: 0;
    gap: 12px;
  }

  .round-btn {
    width: 40px;
    height: 60px;
    font-size: 2.1rem;
  }

  #message {
    min-width: 450px;
  }

  #scoreMetric {
    font-size: 3.2rem;
    gap: 6px;
  }

  #superMetric {
    font-size: 1.45rem;
  }

  #timeBadge {
    top: 0;
    min-width: 216px;
    padding: 7px 11px;
    font-size: 1.28rem;
  }

  #time {
    width: 94px;
  }

  #timeUnit {
    width: 36px;
  }

  #settingsPanel {
    width: min(98vw, 460px);
  }

  .settings-row {
    font-size: 1.32rem;
    align-items: flex-start;
  }

  .settings-btn,
  .settings-link {
    min-width: 196px;
    padding: 12px 18px;
    font-size: 1.28rem;
  }

  #settingsHighscore {
    font-size: 4rem;
    line-height: 1.18;
    padding: 16px 18px;
  }

  #profileAvatar {
    width: 46px;
    height: 46px;
  }

  #authStatusText {
    font-size: 0.92rem;
  }
}
