:root {
  --bg: #050a07;
  --panel: #0d1410;
  --line: #1b2a21;
  --text: #e8f0ea;
  --muted: #7d8f84;
  --accent: #1ed76f;
  --accent-text: #04120a;
  --glow: #0f2a1b;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html,
body {
  margin: 0;
}

html {
  min-height: 100%;
}

body {
  min-height: 100vh;
  min-height: 100dvh;
  isolation: isolate;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  padding: 16px;
  background-color: var(--bg);
  background-image: linear-gradient(100deg, transparent 30%, var(--glow) 50%, transparent 70%);
  color: var(--text);
  font-family: "Poppins", system-ui, sans-serif;
}

h1 {
  margin: 0;
  color: var(--accent);
  font-size: clamp(32px, 6vw, 52px);
  font-style: italic;
  font-weight: 800;
  letter-spacing: -1px;
}

.goal {
  width: min(92vw, 560px);
  margin: 0;
  color: var(--muted);
  font-size: 15px;
  font-weight: 500;
  text-align: center;
}

.goal-rules {
  margin-top: -8px;
  font-size: 13px;
  font-weight: 400;
}

.goal-rules .key {
  color: #ff3b3b;
  font-size: 1.5em;
  font-weight: 700;
  text-decoration: underline;
  text-underline-offset: 3px;
}

.player {
  display: flex;
  flex-direction: column;
  gap: 6px;
  width: min(92vw, 560px);
  padding: 8px 12px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 14px;
  color: var(--muted);
  font-size: 12px;
}

.track-title {
  margin: 0;
  overflow: hidden;
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-controls {
  display: flex;
  align-items: center;
  gap: 10px;
}

.player-btn {
  display: grid;
  flex: none;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  background: var(--accent);
  border: 0;
  border-radius: 50%;
  color: var(--accent-text);
  cursor: pointer;
}

.player-btn#mute,
.player-btn#loop {
  background: transparent;
  color: var(--muted);
}

.player-btn#mute {
  color: var(--text);
}

.player-btn#loop.is-active {
  background: var(--glow);
  color: var(--accent);
  box-shadow: inset 0 0 0 1px var(--accent);
}

.player input[type="range"] {
  flex: 1 1 auto;
  min-width: 0;
  height: 18px;
  margin: 0;
  accent-color: var(--accent);
  cursor: pointer;
}

.player input[type="range"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.player .volume {
  flex: 0 0 64px;
}

.time {
  flex: none;
  min-width: 34px;
  font-variant-numeric: tabular-nums;
  text-align: center;
}

@media (max-width: 420px) {
  .player .volume {
    display: none;
  }
}

.progress {
  display: flex;
  align-items: center;
  gap: 10px;
  width: min(92vw, 560px);
}

.progress-track {
  flex: 1 1 auto;
  height: 10px;
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 999px;
}

.progress-fill {
  width: 0;
  height: 100%;
  background: var(--accent);
  border-radius: inherit;
  transition: width 0.4s ease;
}

.progress-label {
  flex: none;
  min-width: 48px;
  color: var(--muted);
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  text-align: right;
}

.stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: min(92vw, 560px);
  height: min(52vh, 460px);
  height: min(52dvh, 460px);
  overflow: hidden;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
}

.stage img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.empty {
  padding: 24px;
  color: var(--muted);
  font-size: 14px;
  text-align: center;
}

.empty strong {
  display: block;
  margin-bottom: 6px;
  color: var(--text);
  font-size: 18px;
}

.grades {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  width: min(92vw, 560px);
}

.grades button {
  flex: 1 1 44px;
  max-width: 56px;
  height: 48px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: 600 18px "Poppins", sans-serif;
  cursor: pointer;
}

.grades button:hover {
  border-color: var(--accent);
}

.grades button.selected {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
}

.btn {
  height: 48px;
  padding: 0 18px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--text);
  font: 600 14px "Poppins", sans-serif;
  cursor: pointer;
}

.btn.main {
  width: min(92vw, 560px);
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-text);
  font-size: 16px;
}

.btn.small {
  height: 34px;
  font-size: 12px;
}

.btn:disabled,
.grades button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

button:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.nav {
  display: flex;
  gap: 8px;
  width: min(92vw, 560px);
}

.nav .btn.main {
  flex: 1 1 auto;
  width: auto;
}

.modal {
  width: min(92vw, 480px);
  max-height: 90vh;
  max-height: 90dvh;
  overflow-y: auto;
  padding: 24px;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 18px;
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
}

.modal::backdrop {
  background: rgba(0, 0, 0, 0.6);
}

.modal h2 {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 22px;
  font-weight: 700;
}

.modal .intro {
  margin: 0 0 8px;
}

.modal ol {
  margin: 0 0 12px;
  padding-left: 20px;
}

.modal li + li {
  margin-top: 8px;
}

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

.modal .btn.main {
  width: 100%;
}

.modal .btn.secondary {
  width: 100%;
  margin-top: 8px;
}


.meta {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: var(--muted);
  font-size: 13px;
}

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

.footer {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 6px 10px;
  width: min(92vw, 560px);
  padding-top: 12px;
  border-top: 1px solid var(--line);
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

.floatingchat-container-wrap, .floating-chat-kofi-popup-iframe {
  left: auto !important;
  right: 16px !important;
}

.favicon-visitor {
  position: fixed;
  left: 8px;
  bottom: 8px;
  z-index: 2147483647;
  width: 40px;
  height: 40px;
  padding: 0;
  overflow: hidden;
  background: transparent;
  border: 0;
  opacity: 0;
  pointer-events: none;
  cursor: pointer;
  transition: opacity 0.6s ease;
  transform: scaleX(-1);
}

.favicon-visitor.is-visible {
  opacity: 1;
  pointer-events: auto;
}

.favicon-visitor img {
  display: block;
  width: 100%;
  height: 100%;
}

.favicon-background {
  position: fixed;
  top: 50%;
  left: 0;
  z-index: -1;
  width: clamp(180px, 36vw, 420px);
  opacity: 0.35;
  pointer-events: none;
  animation: favicon-crossing 26s linear infinite;
}

.favicon-background-image {
  display: block;
  width: 100%;
  height: auto;
  animation: favicon-flip 26s steps(1, end) infinite;
}

@keyframes favicon-crossing {
  0% {
    transform: translate(-100%, -50%);
  }
  38.5%, 50% {
    transform: translate(100vw, -50%);
  }
  88.5%, 100% {
    transform: translate(-100%, -50%);
  }
}

@keyframes favicon-flip {
  0%, 49% {
    transform: scaleX(-1);
  }
  50%, 99% {
    transform: scaleX(1);
  }
  100% {
    transform: scaleX(-1);
  }
}

@media (prefers-reduced-motion: reduce) {
  .favicon-visitor {
    transition: none;
  }

  .favicon-background {
    top: 50%;
    left: 50%;
    animation: none;
    transform: translate(-50%, -50%);
  }

  .favicon-background-image {
    animation: none;
  }
}

#image-id {
  margin: 0;
  color: var(--muted);
  font-size: 12px;
  text-align: center;
}

@media (max-width: 720px) {
  body {
    gap: 14px;
    padding: 14px 12px;
  }
}

@media (max-width: 480px) {
  body {
    gap: 12px;
    padding: 12px 10px 20px;
  }

  .goal {
    font-size: 14px;
  }

  .goal-rules {
    font-size: 12px;
  }

  .goal-rules .key {
    font-size: 1.25em;
  }

  .player {
    padding: 8px 10px;
  }

  .player-controls {
    gap: 6px;
  }

  body {
    justify-content: flex-start;
    height: 100vh;
    height: 100dvh;
  }

  body > * {
    flex-shrink: 0;
  }

  .stage {
    flex: 1 1 0;
    height: auto;
    min-height: 140px;
    max-height: 420px;
    border-radius: 14px;
  }

  .grades {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 6px;
  }

  .grades button {
    max-width: none;
    height: 52px;
  }

  .nav .btn {
    height: 52px;
  }

  .meta {
    gap: 8px 12px;
    font-size: 12px;
  }

  .modal {
    padding: 18px;
  }

  .modal h2 {
    font-size: 20px;
  }
}

@media (max-width: 360px) {
  .player-controls {
    gap: 4px;
  }

  .player-btn {
    width: 30px;
    height: 30px;
  }

  .time {
    min-width: 30px;
    font-size: 11px;
  }

  .nav .btn {
    padding: 0 12px;
  }
}

@media (max-height: 560px) {
  body {
    justify-content: flex-start;
    gap: 10px;
  }

  h1 {
    font-size: 28px;
  }

  .stage {
    height: 60dvh;
    min-height: 200px;
  }
}

@media (hover: none) and (pointer: coarse) {
  .hint {
    display: none;
  }

  .grades button:hover {
    border-color: var(--line);
  }

  .grades button.selected:hover {
    border-color: var(--accent);
  }
}