@font-face {
  font-family: "Oswald";
  src: url("/fonts/Oswald.ttf") format("truetype");
  font-weight: 200 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Comic Neue";
  src: url("/fonts/ComicNeue-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Comic Neue";
  src: url("/fonts/ComicNeue-Bold.ttf") format("truetype");
  font-weight: 700;
  font-style: normal;
  font-display: swap;
}

@font-face {
  font-family: "Permanent Marker";
  src: url("/fonts/PermanentMarker.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

:root {
  --ink: #000;
  --paper: #fff;
  --soft-ink: #222;
  --hand: "Comic Neue", "Comic Sans MS", "Chalkboard SE", cursive, sans-serif;
  --marker: "Permanent Marker", "Comic Sans MS", "Chalkboard SE", cursive, sans-serif;
  --heading: "Oswald", "Arial Narrow", "Comic Sans MS", cursive, sans-serif;
  --wobble: 255px 15px 225px 15px / 15px 225px 15px 255px;
  --wobble-small: 18px 8px 16px 10px / 10px 16px 8px 18px;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

html {
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--paper);
  color: var(--ink);
  font-family: var(--hand);
  font-size: 18px;
  line-height: 1.4;
  -webkit-text-size-adjust: 100%;
}

body.age-locked {
  overflow: hidden;
}

img {
  max-width: 100%;
  height: auto;
}

a {
  color: var(--ink);
  text-decoration: underline;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

a:hover {
  text-decoration-style: wavy;
}

button,
input {
  color: inherit;
  font: inherit;
}

button {
  cursor: pointer;
}

button:disabled {
  cursor: default;
  opacity: 0.55;
}

:focus-visible {
  outline: 3px dashed var(--ink);
  outline-offset: 3px;
}

::selection {
  background: var(--ink);
  color: var(--paper);
}

.visually-hidden {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  padding: 0 !important;
  margin: -1px !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  white-space: nowrap !important;
  border: 0 !important;
}

.skip-link {
  position: absolute;
  left: 1rem;
  top: -5rem;
  z-index: 2000;
  padding: 0.5rem 1rem;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--wobble-small);
}

.skip-link:focus {
  top: 0.8rem;
}

/* ---------------------------------------------------------------- */
/* Header and footer                                                 */
/* ---------------------------------------------------------------- */

.site-header {
  width: 100%;
  padding: 22px 16px 6px;
  text-align: center;
}

.logo {
  display: inline-block;
  text-decoration: none;
  transform: rotate(-0.7deg);
}

.logo:hover {
  text-decoration: none;
  transform: rotate(0.5deg);
}

.logo img {
  display: block;
  width: min(430px, 78vw);
  height: auto;
}

.site-footer {
  width: min(100% - 32px, 1000px);
  margin: auto auto 0;
  padding: 1.1rem 0 1.6rem;
  border-top: 2px dotted var(--ink);
  text-align: center;
  font-size: 0.95rem;
}

.site-footer p {
  margin: 0;
}

/* ---------------------------------------------------------------- */
/* Stage                                                             */
/* ---------------------------------------------------------------- */

.loop-main {
  width: 100%;
  max-width: 1032px;
  margin: 0 auto;
  padding: 6px 16px 26px;
  flex: 1;
}

.stage {
  position: relative;
  width: 100%;
  max-width: 1000px;
  aspect-ratio: 1000 / 650;
  margin: 0 auto;
  overflow: hidden;
  background: var(--ink);
  border: 2px solid var(--ink);
  border-radius: var(--wobble);
}

.player {
  position: absolute;
  inset: 0;
  z-index: 1;
  width: 100%;
  height: 100%;
  background: var(--ink);
}

.player > *,
.player ruffle-player,
ruffle-player {
  display: block;
  width: 100%;
  height: 100%;
}

.play-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  width: 100%;
  height: 100%;
  margin: 0;
  padding: 1.2rem;
  overflow: hidden;
  color: var(--ink);
  text-align: center;
  background: var(--paper);
  border: 0;
  border-radius: inherit;
}

.play-overlay-click {
  display: inline-block;
  font-family: var(--marker);
  font-size: clamp(2.8rem, 8.8vw, 6.4rem);
  line-height: 0.92;
  letter-spacing: 0.01em;
  transform: rotate(-2deg);
  border-bottom: 5px solid var(--ink);
  padding: 0 0.1em 0.02em;
}

.play-overlay-title {
  display: block;
  max-width: 90%;
  font-family: var(--marker);
  font-size: clamp(1rem, 2.7vw, 1.9rem);
  line-height: 1.15;
  overflow-wrap: anywhere;
  transform: rotate(1deg);
}

.play-overlay:hover .play-overlay-click {
  transform: rotate(-2deg) scale(1.025);
}

.play-overlay:active .play-overlay-click {
  transform: rotate(-1deg) scale(0.99);
}

.not-found {
  position: absolute;
  inset: 0;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.2rem;
  padding: 1.2rem;
  color: var(--ink);
  text-align: center;
  background: var(--paper);
}

.not-found-text {
  max-width: 90%;
  margin: 0;
  font-family: var(--marker);
  font-size: clamp(1.45rem, 4.4vw, 3.2rem);
  line-height: 1.08;
  transform: rotate(-1deg);
}

/* ---------------------------------------------------------------- */
/* Hand-drawn buttons                                                */
/* ---------------------------------------------------------------- */

.hand-button {
  display: inline-block;
  padding: 0.48rem 1rem;
  color: var(--ink);
  font-family: var(--hand);
  font-size: 1rem;
  font-weight: 700;
  line-height: 1.2;
  text-align: center;
  text-decoration: none;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--wobble-small);
  transition: transform 80ms ease;
}

.hand-button:hover {
  background: #f1f1f1;
  transform: rotate(-1deg);
  text-decoration: none;
}

.hand-button:active {
  transform: rotate(0.6deg) translateY(1px);
}

/* ---------------------------------------------------------------- */
/* Loop details                                                      */
/* ---------------------------------------------------------------- */

.loop-info {
  padding: 1.15rem 0 0;
  text-align: center;
}

.loop-info h1 {
  max-width: 1000px;
  margin: 0 auto 0.2rem;
  font-family: var(--heading);
  font-size: clamp(1.7rem, 4vw, 3rem);
  font-weight: 600;
  line-height: 1.06;
  overflow-wrap: anywhere;
}

.loop-meta {
  margin: 0.25rem 0 0.8rem;
  color: var(--soft-ink);
  font-size: 0.95rem;
}

.meta-dot {
  padding: 0 0.35rem;
}

.fullscreen-row {
  margin: 0.35rem 0 0.8rem;
}

.share-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem 0.9rem;
  margin: 0.4rem 0 0.9rem;
  font-size: 0.98rem;
}

.share-label {
  font-weight: 700;
}

.share-row a {
  text-decoration-style: dotted;
  text-underline-offset: 2px;
}

.copy-button {
  padding: 0.25rem 0.7rem;
  font-size: 0.9rem;
}

.copy-status {
  min-width: 4.5rem;
  color: var(--soft-ink);
  font-size: 0.9rem;
  font-style: italic;
}

.loop-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: clamp(1rem, 4vw, 3rem);
  margin: 0.8rem 0 1.2rem;
}

.image-button {
  display: inline-block;
  line-height: 0;
  text-decoration: none;
  transform: rotate(-0.6deg);
}

.image-button + .image-button {
  transform: rotate(0.7deg);
}

.image-button:hover {
  transform: rotate(0deg) scale(1.025);
  text-decoration: none;
}

.image-button img {
  display: block;
  width: min(250px, 40vw);
  height: auto;
}

/* ---------------------------------------------------------------- */
/* Index page                                                        */
/* ---------------------------------------------------------------- */

.index-main {
  width: 60%;
  max-width: 1000px;
  margin: 0 auto;
  padding: 1.4rem 0 2.6rem;
  flex: 1;
}

.index-main h1 {
  margin: 0 0 1.2rem;
  font-family: var(--heading);
  font-size: clamp(1.8rem, 4.2vw, 3.1rem);
  font-weight: 600;
  line-height: 1.02;
  text-align: center;
  transform: rotate(-0.6deg);
}

.search-row {
  display: flex;
  justify-content: center;
}

#search {
  width: 100%;
  padding: 0.55rem 0.8rem;
  color: var(--ink);
  font-family: var(--hand);
  font-size: 1rem;
  background: var(--paper);
  border: 2px solid var(--ink);
  border-radius: var(--wobble-small);
  outline-offset: 3px;
}

#search::placeholder {
  color: #555;
  opacity: 1;
}

.loop-count {
  margin: 0.65rem 0 0.55rem;
  font-size: 0.95rem;
  text-align: right;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

.loops-table {
  width: 100%;
  border-collapse: collapse;
  table-layout: auto;
}

.loops-table th {
  padding: 0.35rem 0.35rem 0.45rem;
  font-family: var(--heading);
  font-size: 1.05rem;
  font-weight: 600;
  text-align: left;
  white-space: nowrap;
  border-bottom: 2px solid var(--ink);
}

.loops-table th.num {
  text-align: right;
}

.loops-table td {
  padding: 0.55rem 0.35rem;
  border-bottom: 2px dotted var(--ink);
  vertical-align: top;
}

.loops-table td.num {
  text-align: right;
  white-space: nowrap;
}

.loops-table tbody a {
  font-weight: 700;
}

.loops-table tbody a:hover {
  text-decoration-style: wavy;
}

.sort-button {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0;
  font-family: inherit;
  font-size: inherit;
  font-weight: inherit;
  line-height: inherit;
  text-align: inherit;
  background: none;
  border: 0;
}

.sort-button:hover {
  text-decoration: underline wavy;
  text-underline-offset: 3px;
}

th.num .sort-button {
  justify-content: flex-end;
}

.sort-arrow {
  display: inline-block;
  min-width: 0.9em;
  font-family: var(--hand);
  font-size: 0.85em;
  line-height: 1;
}

.empty-row td {
  padding: 1.8rem 0.5rem;
  text-align: center;
  font-style: italic;
  border-bottom: 0;
}

/* ---------------------------------------------------------------- */
/* Age gate                                                          */
/* ---------------------------------------------------------------- */

.age-gate {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  overflow-y: auto;
  background: var(--paper);
}

.age-box {
  width: 100%;
  max-width: 560px;
  padding: 1.4rem 1.4rem 1.5rem;
  text-align: center;
  background: var(--paper);
  border: 3px solid var(--ink);
  border-radius: var(--wobble);
  transform: rotate(-0.5deg);
}

.age-box h2 {
  margin: 0 0 0.55rem;
  font-family: var(--heading);
  font-size: clamp(1.6rem, 4.5vw, 2.4rem);
  font-weight: 600;
  line-height: 1.05;
}

.age-box p {
  margin: 0.5rem 0;
}

.age-warning {
  font-size: 0.95rem;
}

.age-actions {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.8rem;
  margin-top: 1.05rem !important;
}

.age-actions .hand-button {
  min-width: 7rem;
}

/* ---------------------------------------------------------------- */
/* Responsive                                                        */
/* ---------------------------------------------------------------- */

@media (max-width: 900px) {
  .index-main {
    width: 100%;
    padding: 1.2rem 16px 2.4rem;
  }
}

@media (max-width: 620px) {
  body {
    font-size: 17px;
  }

  .site-header {
    padding-top: 15px;
  }

  .stage {
    border-radius: 40px 10px 34px 12px / 12px 34px 10px 40px;
  }

  .play-overlay-click {
    border-bottom-width: 3px;
  }

  .loop-nav {
    gap: 0.6rem;
  }

  .image-button img {
    width: min(250px, 43vw);
  }

  .loop-info h1 {
    font-size: clamp(1.5rem, 7vw, 2.2rem);
  }

  .loops-table th,
  .loops-table td {
    padding-left: 0.2rem;
    padding-right: 0.2rem;
  }
}

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