@font-face {
  font-family: "Fredoka One";
  src: url("./FredokaOne-Regular.ttf") format("truetype");
  font-weight: 400;
  font-style: normal;
  font-display: swap;
}

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

@font-face {
  font-family: "Milky";
  src: url("./fonts/Milky-Regular.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Bitshow";
  src: url("./fonts/Bitshow.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Starborn";
  src: url("./fonts/Starborn.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Panic";
  src: url("./fonts/Panic.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Singsong";
  src: url("./fonts/Singsong.otf") format("opentype");
  font-display: swap;
}

@font-face {
  font-family: "Minecraft";
  src: url("./fonts/Minecraft.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Simply Olive";
  src: url("./fonts/SimplyOlive.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Catfiles";
  src: url("./fonts/Catfiles.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Catuct";
  src: url("./fonts/Catcut.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "California";
  src: url("./fonts/California.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Angel War";
  src: url("./fonts/AngelicWar.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Cocogoose";
  src: url("./fonts/Cocogoose-Regular.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Cotton Cloud";
  src: url("./fonts/CottonCloud.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Daydream";
  src: url("./fonts/Daydream.ttf") format("truetype");
  font-display: swap;
}

@font-face {
  font-family: "Adelia";
  src: url("./fonts/Adelia.otf") format("opentype");
  font-display: swap;
}

@font-face {
  font-family: "Lemon Milk";
  src: url("./fonts/LemonMilk-Regular.otf") format("opentype");
  font-display: swap;
}

@font-face {
  font-family: "Gothic War";
  src: url("./fonts/GothicWar.otf") format("opentype");
  font-display: swap;
}

@font-face {
  font-family: "New Romantics";
  src: url("./fonts/NewRomantics.ttf") format("truetype");
  font-display: swap;
}

:root {
  --ink: #1c1c1e;
  --muted: rgba(28, 28, 30, 0.62);
  --ui: "Fredoka One", system-ui, sans-serif;
  --ease: cubic-bezier(0.22, 1, 0.36, 1);
  --glass: rgba(255, 255, 255, 0.34);
  --glass-border: rgba(255, 255, 255, 0.5);
  --shadow: 0 12px 32px rgba(0, 0, 0, 0.1), inset 0 1px 0 rgba(255, 255, 255, 0.7);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 18 18'%3E%3Ccircle cx='9' cy='9' r='4' fill='%23ffffff' stroke='%23111111' stroke-width='1.5'/%3E%3C/svg%3E") 9 9, none !important;
}

*::before,
*::after {
  cursor: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 18 18'%3E%3Ccircle cx='9' cy='9' r='4' fill='%23ffffff' stroke='%23111111' stroke-width='1.5'/%3E%3C/svg%3E") 9 9, none !important;
}

body {
  min-height: 100vh;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 55% at 15% 10%, #fff 0%, transparent 55%),
    radial-gradient(ellipse 70% 50% at 90% 90%, #bdbdbd 0%, transparent 50%),
    linear-gradient(165deg, #ececec, #d6d6d6);
  padding: 1.25rem;
}

body.editor-page {
  padding: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

.logo-wobble {
  display: inline-flex;
  align-items: baseline;
  justify-content: center;
}

.logo-letter {
  display: inline-block;
  animation: wobble 2.4s ease-in-out infinite;
  transform-origin: center bottom;
  font-family: inherit;
}

.home-header .logo-letter {
  font-family: var(--ui);
}

.logo-letter.space {
  width: 0.35em;
}

@keyframes wobble {
  0%, 100% { transform: translateY(0) rotate(0deg); }
  25% { transform: translateY(-3px) rotate(-4deg); }
  50% { transform: translateY(1px) rotate(3deg); }
  75% { transform: translateY(-2px) rotate(-2deg); }
}

.glass {
  background: var(--glass);
  border: 1px solid var(--glass-border);
  border-radius: 1.35rem;
  box-shadow: var(--shadow);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: var(--ui);
  font-size: 1rem;
  border: 1px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
  padding: 0.75rem 1.25rem;
  background: rgba(255, 255, 255, 0.42);
  color: var(--ink);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08), inset 0 1px 0 rgba(255, 255, 255, 0.75);
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
}

.btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 255, 255, 0.58);
}

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

.btn:disabled {
  opacity: 0.4;
  transform: none;
}

.btn.dark {
  color: #fff;
  background: rgba(40, 40, 40, 0.78);
  border-color: rgba(255, 255, 255, 0.18);
}

.btn.dark:hover {
  background: rgba(50, 50, 50, 0.88);
}

/* Home */
.home {
  max-width: 52rem;
  margin: 0 auto;
  text-align: center;
}

.home-header {
  margin: 0.5rem 0 1.5rem;
}

.home-header h1 {
  font-size: clamp(2.4rem, 8vw, 3.4rem);
  letter-spacing: 0.02em;
  line-height: 1.05;
  color: #111;
}

.home-header p {
  margin-top: 0.45rem;
  color: var(--muted);
}

.section-title {
  font-family: var(--ui);
  font-size: 1.15rem;
  margin: 1.5rem 0 0.85rem;
  text-align: left;
}

.font-row,
.tool-list {
  display: grid;
  gap: 0.85rem;
}

.font-row {
  grid-template-columns: repeat(auto-fill, minmax(11.5rem, 1fr));
  align-items: start;
}

.font-card {
  padding: 1.15rem 1rem;
  display: grid;
  grid-template-rows: 2.75rem auto;
  gap: 0.75rem;
  justify-items: center;
  align-items: center;
}

.font-card h2 {
  font-size: clamp(1.15rem, 2.8vw, 1.55rem);
  line-height: 1;
  font-family: inherit;
  margin: 0;
  padding: 0;
  height: 100%;
  width: 100%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  white-space: nowrap;
}

.font-card.fredoka { font-family: "Fredoka One", system-ui, sans-serif; }
.font-card.porkys { font-family: "Porkys", system-ui, sans-serif; }
.font-card.milky { font-family: "Milky", system-ui, sans-serif; }
.font-card.milky h2 {
  transform: scale(3);
  transform-origin: center center;
}
.font-card.bitshow { font-family: "Bitshow", system-ui, sans-serif; }
.font-card.starborn { font-family: "Starborn", system-ui, sans-serif; }
.font-card.panic { font-family: "Panic", system-ui, sans-serif; }
.font-card.singsong { font-family: "Singsong", system-ui, sans-serif; }
.font-card.minecraft { font-family: "Minecraft", system-ui, sans-serif; }
.font-card.simply-olive { font-family: "Simply Olive", system-ui, sans-serif; }
.font-card.catfiles { font-family: "Catfiles", system-ui, sans-serif; }
.font-card.catuct { font-family: "Catuct", system-ui, sans-serif; }
.font-card.california { font-family: "California", system-ui, sans-serif; }
.font-card.california h2 {
  transform: scale(1.55);
  transform-origin: center center;
}
.font-card.angel-war { font-family: "Angel War", system-ui, sans-serif; }
.font-card.cocogoose { font-family: "Cocogoose", system-ui, sans-serif; }
.font-card.cotton-cloud { font-family: "Cotton Cloud", system-ui, sans-serif; }
.font-card.cotton-cloud h2 { transform: translateX(-0.2em); }
.font-card.daydream { font-family: "Daydream", system-ui, sans-serif; }
.font-card.adelia { font-family: "Adelia", system-ui, sans-serif; }
.font-card.lemon-milk { font-family: "Lemon Milk", system-ui, sans-serif; }
.font-card.gothic-war { font-family: "Gothic War", system-ui, sans-serif; }
.font-card.gothic-war h2 {
  transform: scale(1.55);
  transform-origin: center center;
}
.font-card.new-romantics { font-family: "New Romantics", system-ui, sans-serif; }

.tool-card {
  display: grid;
  grid-template-columns: 7.5rem 1fr auto;
  gap: 1rem;
  align-items: center;
  padding: 0.85rem;
  text-align: left;
  transition: transform 0.2s var(--ease), background 0.2s var(--ease);
  color: inherit;
}

.tool-card:hover {
  transform: translateY(-2px);
  background: rgba(255, 255, 255, 0.45);
}

.tool-preview {
  width: 7.5rem;
  height: 5.5rem;
  border-radius: 0.9rem;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.55);
  background:
    linear-gradient(45deg, #d0d0d0 25%, transparent 25%),
    linear-gradient(-45deg, #d0d0d0 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d0d0d0 75%),
    linear-gradient(-45deg, transparent 75%, #d0d0d0 75%),
    #eee;
  background-size: 12px 12px;
  background-position: 0 0, 0 6px, 6px -6px, -6px 0;
  position: relative;
}

.tool-preview canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.tool-copy h3 {
  font-family: var(--ui);
  font-size: 1.2rem;
  margin-bottom: 0;
}

.tool-go {
  font-family: var(--ui);
  font-size: 0.95rem;
  opacity: 0.7;
  white-space: nowrap;
}

.size-preview {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  z-index: 6;
}

.size-preview[hidden] {
  display: none !important;
}

.size-preview-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(40, 40, 40, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.95);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
  opacity: 0;
  transition: opacity 0.5s ease;
}

.size-preview-dot.visible {
  opacity: 1;
  transition: none;
}

.size-preview-dot.corner {
  border-radius: 0;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255, 255, 255, 0.95);
  position: relative;
}

@media (max-width: 640px) {
  .font-row {
    grid-template-columns: 1fr;
  }

  .tool-card {
    grid-template-columns: 5.5rem 1fr;
  }

  .tool-go {
    display: none;
  }

  .tool-preview {
    width: 5.5rem;
    height: 4.4rem;
  }
}

/* Fullscreen editor shell */
.editor-page {
  min-height: 100vh;
  padding: 0;
  display: flex;
  flex-direction: column;
}

.editor-top {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.85rem 1rem;
  background: rgba(255, 255, 255, 0.35);
  border-bottom: 1px solid rgba(255, 255, 255, 0.45);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
}

.editor-top h1 {
  font-family: var(--ui);
  font-size: 1.2rem;
}

.editor-body {
  flex: 1;
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 0.85rem;
  padding: 1rem;
  max-width: 72rem;
  width: 100%;
  margin: 0 auto;
}

.toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: end;
  padding: 0.85rem;
}

.toolbar .control {
  display: grid;
  gap: 0.3rem;
  min-width: 8rem;
  flex: 1;
}

.toolbar label {
  font-size: 0.8rem;
  font-weight: 700;
  color: var(--muted);
}

.toolbar input[type="color"] {
  width: 100%;
  height: 2.4rem;
  border: 1px solid rgba(255, 255, 255, 0.5);
  border-radius: 0.7rem;
  background: rgba(255, 255, 255, 0.5);
}

.toolbar input[type="range"] {
  width: 100%;
  accent-color: #555;
}

.toolbar output {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
}

.stage {
  position: relative;
  min-height: 55vh;
  display: grid;
  place-items: center;
  padding: 1rem;
  overflow: auto;
}

.stage canvas {
  max-width: 100%;
  max-height: calc(100vh - 14rem);
  height: auto;
  border-radius: 0.75rem;
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.12);
  background:
    linear-gradient(45deg, #d2d2d2 25%, transparent 25%),
    linear-gradient(-45deg, #d2d2d2 25%, transparent 25%),
    linear-gradient(45deg, transparent 75%, #d2d2d2 75%),
    linear-gradient(-45deg, transparent 75%, #d2d2d2 75%),
    #eee;
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0;
}

.stage.empty {
  color: var(--muted);
  font-weight: 600;
}

.dropzone {
  border: 1px dashed rgba(80, 80, 80, 0.35);
  border-radius: 1rem;
  padding: 1rem;
  text-align: center;
  background: rgba(255, 255, 255, 0.25);
  transition: background 0.2s var(--ease), border-color 0.2s var(--ease);
}

.dropzone:hover,
.dropzone.dragover {
  background: rgba(255, 255, 255, 0.45);
  border-color: rgba(40, 40, 40, 0.5);
}

.dropzone strong {
  font-family: var(--ui);
  display: block;
}

.dropzone span {
  color: var(--muted);
  font-size: 0.9rem;
}

.actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  justify-content: flex-end;
}

.tool-pills {
  display: inline-flex;
  gap: 0.35rem;
  padding: 0.25rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.4);
}

.tool-pills button {
  border: 0;
  background: transparent;
  font-family: var(--ui);
  padding: 0.45rem 0.9rem;
  border-radius: 999px;
}

.tool-pills button.active {
  background: rgba(255, 255, 255, 0.7);
}

.meta {
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--muted);
}

#fileInput,
#drawFileInput,
#cropFileInput {
  display: none;
}
