@import url('https://fonts.googleapis.com/css2?family=Anton&family=Bangers&family=Permanent+Marker&display=swap');

:root {
  --yellow: #ffdc3e;
  --cream: #fff7e5;
  --pink: #ff5570;
  --mint: #65d9a5;
  --black: #111111;
  --border: 3px solid var(--black);
  --shadow: 4px 4px 0 var(--black);
}

* {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  color: var(--black);
  background-color: var(--cream);
  background-image: radial-gradient(#eadfca 1px, transparent 1px);
  background-size: 13px 13px;
  font-family: Arial, Helvetica, sans-serif;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.site-header {
  background: var(--yellow);
  border-bottom: var(--border);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  min-height: 76px;
  padding: 0 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--black);
  text-decoration: none;
  font-family: Impact, Anton, sans-serif;
  font-size: 20px;
}

.brand-icon {
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 2px solid var(--black);
  border-radius: 8px;
  background: var(--pink);
  color: white;
  font-size: 20px;
}

nav {
  display: flex;
  align-items: center;
  gap: 22px;
  font-weight: bold;
}

nav a {
  color: var(--black);
  text-decoration: none;
}

.nav-create {
  border: 0;
  border-radius: 18px;
  padding: 8px 17px;
  background: var(--black);
  color: var(--yellow);
  font-size: 13px;
  font-weight: bold;
}

main {
  max-width: 900px;
  margin: 0 auto;
  padding: 0 18px 80px;
}

.hero {
  padding: 38px 0 31px;
}

.eyebrow {
  display: inline-block;
  padding: 4px 9px;
  background: var(--pink);
  border: 2px solid var(--black);
  border-radius: 5px;
  transform: rotate(-2deg);
  color: white;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: .5px;
}

.hero h1 {
  margin: 12px 0 5px;
  max-width: 700px;
  font-family: Impact, Anton, sans-serif;
  font-size: clamp(42px, 7vw, 68px);
  line-height: .95;
  letter-spacing: 1px;
}

.hero h1 span {
  color: var(--pink);
  -webkit-text-stroke: 1px var(--black);
}

.hero p {
  max-width: 620px;
  margin: 0;
  color: #4c463c;
  font-size: 15px;
  line-height: 1.55;
}

.workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.45fr) minmax(300px, .95fr);
  gap: 16px;
  align-items: start;
}

.preview-column {
  min-width: 0;
}

.canvas-frame {
  overflow: hidden;
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 430px;
  padding: 0;
  border: var(--border);
  border-radius: 11px;
  background: #ddd;
  box-shadow: var(--shadow);
}

#memeCanvas {
  display: block;
  max-width: 100%;
  height: auto;
  cursor: grab;
}

#memeCanvas:active {
  cursor: grabbing;
}

.canvas-tip {
  margin: 8px 0 13px;
  color: #887d6d;
  text-align: center;
  font-size: 11px;
}

.action-buttons {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.action-btn {
  min-height: 39px;
  padding: 6px;
  border: 2px solid var(--black);
  border-radius: 9px;
  background: white;
  box-shadow: 2px 2px 0 var(--black);
  font-size: 13px;
  font-weight: bold;
}

.action-btn:active,
.control-card button:active {
  transform: translate(2px, 2px);
  box-shadow: none;
}

.download-btn {
  background: var(--yellow);
}

.share-btn {
  background: var(--pink);
  color: white;
}

.controls {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.control-card {
  padding: 14px;
  border: var(--border);
  border-radius: 11px;
  background: white;
  box-shadow: var(--shadow);
}

.control-card h2 {
  margin: 0 0 12px;
  font-family: Impact, Anton, sans-serif;
  font-size: 18px;
  letter-spacing: .3px;
}

.template-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 7px;
}

.template-thumb {
  width: 100%;
  aspect-ratio: 1 / .75;
  object-fit: cover;
  border: 2px solid var(--black);
  border-radius: 8px;
  cursor: pointer;
  background: #eee;
}

.template-thumb.active {
  outline: 3px solid var(--pink);
  outline-offset: -3px;
}

.upload-strip {
  width: 100%;
  margin-top: 10px;
  padding: 8px;
  border: 1px dashed #777;
  border-radius: 8px;
  background: white;
  font-size: 12px;
}

.card-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.add-text-btn {
  padding: 5px 9px;
  border: 2px solid var(--black);
  border-radius: 7px;
  background: var(--mint);
  font-size: 12px;
  font-weight: bold;
}

.caption-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 8px;
  padding: 7px;
  border: 1px solid #ddd;
  border-radius: 7px;
  background: #fffaf0;
}

.caption-row.selected {
  border: 2px solid var(--pink);
}

.caption-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  resize: vertical;
  background: transparent;
  color: var(--black);
  font-size: 12px;
}

.delete-caption {
  border: 0;
  background: transparent;
  color: #777;
  font-size: 16px;
}

.muted {
  margin: -5px 0 10px;
  color: #999;
  font-size: 12px;
}

.style-tabs {
  display: flex;
  align-items: center;
  gap: 4px;
  flex-wrap: wrap;
}

.style-tab,
.caps-toggle {
  padding: 6px 8px;
  border: 1px solid var(--black);
  border-radius: 6px;
  background: white;
  font-size: 11px;
  font-weight: bold;
}

.style-tab.active {
  background: var(--yellow);
}

.caps-toggle {
  margin-left: auto;
  border-radius: 15px;
  background: var(--black);
  color: var(--yellow);
}

.range-label {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-top: 17px;
  color: #999;
  font-size: 12px;
}

.range-label input {
  flex: 1;
  accent-color: var(--pink);
}

.colour-row {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-top: 13px;
  color: #999;
  font-size: 12px;
}

.colour {
  width: 22px;
  height: 22px;
  border: 1px solid #999;
  border-radius: 50%;
}

.colour-white {
  background: white;
}

.colour-black {
  background: #111;
}

.colour-yellow {
  background: #ffe58a;
}

.colour-pink {
  background: #ff9db0;
}

.colour-green {
  background: #a9e7d0;
}

.colour-blue {
  background: #a9c9ed;
}

.outline-row {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 12px;
  color: #999;
  font-size: 12px;
}

.outline-row input {
  accent-color: var(--pink);
}

.gallery-section {
  margin-top: 72px;
}

.section-heading {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.section-heading h2 {
  margin: 0 0 14px;
  font-family: Impact, Anton, sans-serif;
  font-size: 24px;
}

.section-heading a {
  color: var(--black);
  font-size: 12px;
  font-weight: bold;
}

.empty-gallery {
  min-height: 130px;
  display: grid;
  place-content: center;
  border: 2px dashed #b9b09f;
  text-align: center;
}

.empty-gallery h3 {
  margin: 0 0 5px;
  font-family: Impact, Anton, sans-serif;
  font-size: 18px;
}

.empty-gallery p {
  margin: 0;
  color: #988d7d;
  font-size: 13px;
}

footer {
  padding: 32px 18px;
  background: #151515;
  color: #c5ae56;
  text-align: center;
  font-size: 11px;
}

footer strong {
  color: var(--yellow);
}

@media (max-width: 760px) {
  .workspace {
    grid-template-columns: 1fr;
  }

  .controls {
    order: 2;
  }

  .preview-column {
    order: 1;
  }

  .canvas-frame {
    min-height: 300px;
  }

  .action-buttons {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 470px) {
  .header-inner {
    min-height: 62px;
  }

  .hero {
    padding-top: 28px;
  }

  .hero h1 {
    font-size: 44px;
  }

  nav {
    gap: 10px;
    font-size: 12px;
  }

  .footer-links {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-top: 12px;
}

.footer-links a {
  color: #fff1a3;
  text-decoration: none;
  font-size: 11px;
  font-weight: bold;
}

.footer-links a:hover {
  color: #ffffff;
  text-decoration: underline;
}

.legal-page {
  max-width: 820px;
  margin: 0 auto;
  padding: 54px 18px 80px;
}

.legal-page h1 {
  margin: 12px 0 12px;
  font-family: Impact, Anton, sans-serif;
  font-size: clamp(42px, 7vw, 64px);
  line-height: 0.95;
  letter-spacing: 0.5px;
}

.legal-page h2 {
  margin: 34px 0 10px;
  font-family: Impact, Anton, sans-serif;
  font-size: 26px;
  letter-spacing: 0.3px;
}

.legal-page p,
.legal-page li {
  color: #423d35;
  font-size: 16px;
  line-height: 1.7;
}

.legal-page ul {
  padding-left: 24px;
}

.legal-page a {
  color: #b4002c;
  font-weight: bold;
}

.last-updated {
  margin-bottom: 28px;
  color: #766d60 !important;
  font-size: 13px !important;
}

.contact-card {
  margin: 24px 0 28px;
  padding: 20px;
  border: var(--border);
  border-radius: 11px;
  background: white;
  box-shadow: var(--shadow);
}

.contact-card h2 {
  margin-top: 0;
}

.contact-card p {
  margin-bottom: 0;
}

/* =========================================================
   MOBILE AND TABLET IMPROVEMENTS
   ========================================================= */

@media (max-width: 760px) {
  body {
    overflow-x: hidden;
  }

  main {
    padding: 0 14px 55px;
  }

  .header-inner {
    padding: 0 14px;
  }

  .site-header {
    position: sticky;
    top: 0;
    z-index: 50;
  }

  .brand {
    font-size: 17px;
  }

  .brand-icon {
    width: 28px;
    height: 28px;
  }

  nav {
    gap: 10px;
    font-size: 12px;
  }

  .nav-create {
    padding: 7px 13px;
  }

  .hero {
    padding: 27px 0 23px;
  }

  .hero h1 {
    max-width: 100%;
    font-size: clamp(42px, 13vw, 62px);
    line-height: 0.92;
  }

  .hero p {
    max-width: 560px;
    font-size: 14px;
  }

  .workspace {
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .preview-column {
    order: 1;
  }

  .controls {
    order: 2;
    gap: 14px;
  }

  .canvas-frame {
    min-height: 0;
    width: 100%;
    padding: 0;
  }

  #memeCanvas {
    width: 100%;
    max-width: 100%;
    height: auto;
    touch-action: none;
  }

  .canvas-tip {
    padding: 0 8px;
    font-size: 10px;
    line-height: 1.4;
  }

  .action-buttons {
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .action-btn {
    min-height: 46px;
    padding: 9px 6px;
    font-size: 14px;
  }

  .control-card {
    padding: 13px;
  }

  .control-card h2 {
    font-size: 17px;
  }

  .template-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 7px;
  }

  .template-thumb {
    border-radius: 7px;
  }

  .upload-strip {
    min-height: 42px;
    font-size: 13px;
  }

  .caption-row {
    min-height: 48px;
    padding: 8px;
  }

  .caption-input {
    min-height: 30px;
    font-size: 14px;
  }

  .delete-caption {
    min-width: 36px;
    min-height: 36px;
    font-size: 23px;
  }

  .add-text-btn {
    min-height: 35px;
    padding: 7px 10px;
    font-size: 12px;
  }

  .style-tabs {
    gap: 6px;
  }

  .style-tab,
  .caps-toggle {
    min-height: 35px;
    padding: 7px 9px;
    font-size: 11px;
  }

  .caps-toggle {
    margin-left: 0;
  }

  .range-label {
    margin-top: 16px;
  }

  .range-label input {
    min-height: 28px;
  }

  .colour-row {
    flex-wrap: wrap;
    gap: 9px;
  }

  .colour {
    width: 28px;
    height: 28px;
  }

  .outline-row {
    min-height: 32px;
    font-size: 13px;
  }

  .outline-row input {
    width: 18px;
    height: 18px;
  }

  .gallery-section {
    margin-top: 50px;
  }

  .section-heading h2 {
    font-size: 23px;
  }

  .empty-gallery {
    min-height: 120px;
    padding: 18px;
  }

  .legal-page {
    padding: 35px 14px 60px;
  }

  .legal-page h1 {
    font-size: clamp(40px, 13vw, 56px);
  }

  .legal-page h2 {
    font-size: 24px;
  }

  .legal-page p,
  .legal-page li {
    font-size: 15px;
    line-height: 1.65;
  }

  footer {
    padding: 26px 14px;
    line-height: 1.5;
  }

  .footer-links {
    gap: 10px 14px;
  }
}

/* Small phones: e.g. 320px–390px wide */
@media (max-width: 420px) {
  .header-inner {
    min-height: 60px;
  }

  .brand span:last-child {
    font-size: 15px;
  }

  nav {
    gap: 7px;
  }

  nav a {
    font-size: 11px;
  }

  .nav-create {
    padding: 7px 10px;
    font-size: 11px;
  }

  .eyebrow {
    font-size: 9px;
  }

  .hero h1 {
    font-size: 42px;
    letter-spacing: 0;
  }

  .hero p {
    font-size: 13px;
  }

  .action-buttons {
    grid-template-columns: 1fr 1fr;
  }

  .action-btn {
    font-size: 13px;
  }

  .template-grid {
    gap: 5px;
  }

  .control-card {
    padding: 11px;
  }

  .card-heading {
    gap: 8px;
  }

  .card-heading h2 {
    font-size: 16px;
  }

  .style-tab,
  .caps-toggle {
    padding: 7px;
    font-size: 10px;
  }

  .colour-row {
    gap: 7px;
  }

  .colour {
    width: 25px;
    height: 25px;
  }
}

/* Device has no mouse: make dragging clearer for touch users */
@media (hover: none) and (pointer: coarse) {
  #memeCanvas {
    cursor: default;
  }

  .template-thumb,
  .action-btn,
  .upload-strip,
  .style-tab,
  .caps-toggle,
  .colour,
  .add-text-btn {
    -webkit-tap-highlight-color: transparent;
  }
}
}