:root{
  /* comic-like bright palette */
  --bg:#fff2f7;
  --card:#fff;
  --accent:#ff2d6f;
  --accent-2:#ffd400;
  --muted:#6b6b6b;
  --shadow: 0 22px 36px rgba(0,0,0,0.22);
  --radius:18px;
  --pad:20px;
  font-family: "Comic Sans MS", "Comic Neue", "Marker Felt", "Permanent Marker", system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial;
  --paper-texture: linear-gradient(180deg, rgba(255,248,250,0.9), rgba(255,242,247,0.9));
}

/* page title — thicker, more sketched outline */
#pageTitle{
  font-size:40px;
  text-align:center;
  font-weight:900;
  color:var(--accent);
  margin:18px 0 6px;
  letter-spacing:1px;
  text-shadow:6px 6px 0 rgba(0,0,0,0.16);
  transform:skewX(-8deg) rotate(-1deg);
  padding:10px 16px;
  border:6px solid #000;
  display:inline-block;
  background: linear-gradient(90deg, rgba(255,255,255,0.85), rgba(255,240,245,0.85));
  border-radius:12px;
  box-shadow: 12px 12px 0 rgba(0,0,0,0.12);
}

/* global reset */
*{box-sizing:border-box}
html,body,#app{height:100%;margin:0;
  /* enhanced comic-like backdrop: bolder halftone, rays, panel borders and paper grain */
  background:
    /* warm gradient base */
    linear-gradient(180deg, rgba(255,244,247,1) 0%, rgba(255,234,241,1) 40%, rgba(255,220,235,1) 100%),
    /* larger comic sunburst rays for a bold pop */
    radial-gradient(ellipse at 50% 5%, rgba(255,200,230,0.06) 0%, rgba(255,200,230,0.00) 40%),
    /* stronger top-left halftone cluster (comic dot pattern) */
    radial-gradient(circle at 6% 10%, rgba(255,180,215,0.22) 0 2%, rgba(255,180,215,0.00) 18%),
    /* stronger bottom-right halftone */
    radial-gradient(circle at 92% 88%, rgba(255,240,200,0.16) 0 3%, rgba(255,240,200,0.00) 20%),
    /* subtle vignette to frame the card like a comic panel */
    radial-gradient(ellipse at center, rgba(0,0,0,0.00) 40%, rgba(0,0,0,0.03) 100%);
  background-blend-mode: normal, screen, screen, screen, multiply;
  -webkit-font-smoothing:antialiased;
  /* printed comic dot texture using repeating-radial pattern + paper grain */
  background-image:
    linear-gradient(180deg, rgba(255,244,247,1) 0%, rgba(255,234,241,1) 40%, rgba(255,220,235,1) 100%),
    repeating-radial-gradient(circle at 6% 10%, rgba(0,0,0,0.02) 0 2px, rgba(0,0,0,0.00) 2px 8px),
    radial-gradient(circle at 6% 10%, rgba(255,180,215,0.22) 0 2%, rgba(255,180,215,0.00) 18%),
    radial-gradient(circle at 92% 88%, rgba(255,240,200,0.16) 0 3%, rgba(255,240,200,0.00) 20%),
    radial-gradient(ellipse at center, rgba(0,0,0,0.00) 40%, rgba(0,0,0,0.03) 100%);
  /* subtle comic panel grid lines (very faint) */
  --panel-line: repeating-linear-gradient(90deg, rgba(0,0,0,0.03) 0 1px, transparent 1px 48px);
  background-repeat: no-repeat, repeat, no-repeat, no-repeat, no-repeat;
  background-position: center, 0 0, 6% 10%, 92% 88%, center;
  /* overlay a faint panel-line layer using a pseudo-element on #app (see below) */
}

/* small comic panel ticks using a pseudo-element for #app for crisp lines without altering other backgrounds */
#app::before{
  content:"";
  position:fixed;
  inset:0;
  pointer-events:none;
  background-image:
    linear-gradient(transparent 0 58px, rgba(0,0,0,0.02) 58px 60px),
    linear-gradient(90deg, transparent 0 58px, rgba(0,0,0,0.02) 58px 60px);
  opacity:0.35;
  mix-blend-mode:multiply;
  z-index:0;
}

/* ensure app content sits above the pseudo-element grid */
#app{display:flex;flex-direction:column;align-items:stretch;gap:18px;padding:24px;max-width:1200px;margin:0 auto;position:relative;z-index:1}

/* controls panel: bolder, playful */
#controls{display:flex;flex-direction:column;gap:14px}
.row{display:flex;gap:12px;align-items:center}
.row.actions{justify-content:space-between}
input,select,textarea,button{
  border:4px solid #000;
  padding:14px 18px;border-radius:14px;background:#fff;font-size:18px;
  box-shadow: 8px 8px 0 rgba(0,0,0,0.12);
  font-weight:900;
}
textarea{min-height:120px;resize:vertical}
label.label-inline{align-self:center;font-size:16px;color:var(--muted);padding:0 8px}

/* hand-drawn primary button */
#generate{
  background:linear-gradient(180deg,var(--accent), #e01856);
  color:#fff;border:none;min-width:160px;padding:16px 20px;font-size:18px;border-radius:16px;
  box-shadow: 10px 10px 0 rgba(0,0,0,0.22), inset 0 -5px 0 rgba(0,0,0,0.08);
  transform:skewX(-6deg);
  border-bottom:8px solid rgba(0,0,0,0.06);
}
#random.muted{
  background:transparent;border:4px dashed #000;color:var(--muted);padding:12px 14px;
  border-radius:14px;font-weight:900;
}
#copy,#share,#download{
  flex:1;padding:14px;border-radius:14px;background:linear-gradient(180deg,#fff,#fff7f0);font-size:16px;
  border:4px solid #000; box-shadow:8px 8px 0 rgba(0,0,0,0.14); font-weight:900;
}
#copy{margin-right:10px}

/* card wrapper with heavy halftone/stipple edge to feel comic printed */
#cardWrap{display:flex;justify-content:center;align-items:center;padding:12px}
#card{
  width:100%;
  max-width:1200px;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.98) 0%, rgba(255,249,250,0.98) 100%),
    repeating-radial-gradient(circle at 6% 10%, rgba(255,200,230,0.06) 0 3px, transparent 3px 7px);
  border-radius:20px;
  box-shadow: var(--shadow);
  padding:30px 32px 44px;
  display:flex;
  flex-direction:column;
  gap:18px;
  align-items:center;
  text-align:center;
  user-select:none;
  position:relative;
  overflow:visible;
  border:8px solid #000; /* extra-bold comic outline */
}

/* add comic sticker: "Secret" burst */
#card::before{
  content:"SECRET";
  position:absolute;
  top:-16px;
  left:18px;
  background:var(--accent-2);
  color:#111;
  padding:6px 12px;
  font-weight:900;
  border:4px solid #000;
  border-radius:8px;
  transform:rotate(-8deg);
  box-shadow: 10px 10px 0 rgba(0,0,0,0.14);
  font-size:14px;
}

/* decorative heart wrapper - sketchier */
.card-decor{
  position:absolute;
  top:-42px;
  right:-42px;
  width:140px;
  height:140px;
  pointer-events:none;
  transform:rotate(8deg);
  filter: drop-shadow(0 12px 30px rgba(0,0,0,0.18));
  outline:6px dashed rgba(0,0,0,0.06);
}
.card-decor .decor-heart{width:100%;height:100%}

/* header styling: louder and sketched */
#cardHeader{
  font-weight:900;
  color:var(--accent);
  font-size:46px;
  letter-spacing:1px;
  margin-top:6px;
  text-shadow:6px 6px 0 rgba(0,0,0,0.16);
  transform:skewX(-8deg);
  padding:8px 18px;
  border:6px solid #000;
  border-radius:10px;
  background: linear-gradient(90deg, rgba(255,255,255,0.9), rgba(255,240,245,0.9));
  box-shadow: 12px 12px 0 rgba(0,0,0,0.12);
}

/* speech-bubble message area — halftone dots + stronger outline */
.message{
  font-size:30px;
  color:#151515;
  line-height:1.35;
  min-height:220px;
  display:flex;
  align-items:center;
  justify-content:center;
  padding:20px 26px;
  width:100%;
  max-width:860px;
  background:
    var(--paper-texture),
    radial-gradient(circle at 20% 10%, rgba(255,230,245,0.6) 0, rgba(255,230,245,0.0) 25%);
  border-radius:20px;
  box-shadow: 16px 16px 0 rgba(0,0,0,0.16);
  border:8px solid #000;
  position:relative;
  text-align:left;
  background-image:
    linear-gradient(180deg, rgba(255,255,255,0.98), rgba(255,249,250,0.98)),
    repeating-linear-gradient(0deg, rgba(0,0,0,0.02) 0 1px, transparent 1px 6px);
}

/* halftone dots texture inside bubble (pseudo-element) */
.message::before{
  content:"";
  position:absolute;
  inset:6px;
  background: radial-gradient(circle at 10% 10%, rgba(255,180,210,0.10) 0, rgba(255,180,210,0.00) 20%);
  border-radius:14px;
  pointer-events:none;
  mix-blend-mode:multiply;
  opacity:0.9;
}

/* speech bubble tail — thicker and dotted edge */
.message::after{
  content:"";
  position:absolute;
  bottom:-34px;
  left:40px;
  width:0;height:0;
  border-left:22px solid transparent;
  border-right:22px solid transparent;
  border-top:34px solid #fff;
  transform:rotate(-8deg);
  border-top-color:#fff;
  box-shadow: 10px 10px 0 rgba(0,0,0,0.1);
  outline:4px solid rgba(0,0,0,0.02);
}
/* inner message supports multi-line spacing and comic feel */
#messageInner{white-space:pre-wrap; font-weight:900; font-size:24px; padding:12px;}

/* footer: bold caption with sketched underline */
.footer{
  color:#000;
  font-size:16px;
  margin-top:4px;
  opacity:0.98;
  font-weight:900;
  letter-spacing:0.6px;
  text-decoration: underline;
  text-decoration-thickness: 4px;
  text-decoration-color: rgba(0,0,0,0.06);
}

/* floating hearts decoration with heavier outlines and pop */
.floating-hearts{
  position:absolute;
  left:12px;
  bottom:12px;
  display:flex;
  gap:10px;
  pointer-events:none;
}
.heart{
  font-size:22px;
  opacity:0.98;
  transform-origin:center;
  display:inline-block;
  animation: floatUp 4.4s infinite ease-in-out;
  filter: drop-shadow(0 10px 26px rgba(0,0,0,0.18));
  text-shadow: 3px 3px 0 #fff, 8px 8px 0 rgba(0,0,0,0.12);
}
.h1{animation-delay:0s;font-size:26px}
.h2{animation-delay:0.5s;font-size:30px}
.h3{animation-delay:1.1s;font-size:22px}

@keyframes floatUp{
  0% { transform: translateY(0) scale(1); opacity:0.95; }
  50% { transform: translateY(-16px) scale(1.08); opacity:1; }
  100% { transform: translateY(0) scale(1); opacity:0.95; }
}

/* comic-style photo frames: sketched borders */
.card-photos{display:flex;gap:16px;flex-wrap:wrap;justify-content:center;margin-top:18px}
.card-photos img{
  max-width:190px;max-height:190px;border-radius:10px;object-fit:cover;
  border:8px solid #000; box-shadow:12px 12px 0 rgba(0,0,0,0.16);
  transform:rotate(-1deg);
}

/* responsive tweaks */
@media (max-width:420px){
  #card{padding:18px;border-radius:14px}
  .card-decor{display:none}
  #cardHeader{font-size:22px;padding:8px}
  .message{font-size:18px;min-height:140px}
  #messageInner{font-weight:900}
  .card-photos img{max-width:120px;max-height:120px;border-radius:6px}
}

/* Phrase menu: bold panels and comic headings */
.phrase-menu{
  width:100%;
  background:linear-gradient(180deg, #fff 0%, #fffefc 100%);
  border-radius:14px;
  padding:16px;
  display:flex;
  flex-direction:column;
  gap:14px;
  box-shadow: 10px 10px 0 rgba(0,0,0,0.14);
  border:4px solid #000;
}

/* Emoji + photo asset styles */
.asset-gallery{display:flex;gap:10px;flex-wrap:wrap;align-items:center;max-width:560px}

/* Surprise panel styles */
.surprise-box{
  position:fixed;
  inset:0;
  display:flex;
  align-items:center;
  justify-content:center;
  background:rgba(0,0,0,0.45);
  opacity:0;
  pointer-events:none;
  transition:opacity 180ms ease;
  z-index:1200;
}
.surprise-box.open{opacity:1;pointer-events:auto}
.surprise-inner{
  width:min(760px, 94%);
  max-width:760px;
  background:linear-gradient(180deg,#fff,#fff6f8);
  border-radius:14px;
  padding:18px;
  box-shadow: 0 20px 40px rgba(0,0,0,0.28);
  border:6px solid #000;
  display:flex;
  flex-direction:column;
  gap:12px;
}
.surprise-head{display:flex;justify-content:space-between;align-items:center;gap:8px}
.surprise-close{
  background:#fff;border:4px solid #000;padding:8px 10px;border-radius:10px;font-weight:900;cursor:pointer;
  box-shadow:8px 8px 0 rgba(0,0,0,0.12);
}
.surprise-actions{display:flex;gap:10px;justify-content:flex-end;padding-top:6px}
.surprise-actions .emoji-btn{min-width:120px}
.surprise-actions .phrase-btn{min-width:120px}
@media (max-width:420px){
  .surprise-inner{padding:12px}
  .surprise-head strong{font-size:16px}
  .surprise-actions{flex-direction:column;align-items:stretch}
}
.emoji-btn{
  background:linear-gradient(180deg,#fff,#fff3f6);border:4px solid #000;padding:10px 14px;border-radius:10px;font-size:28px;cursor:pointer;min-width:54px;min-height:54px;
  box-shadow:8px 8px 0 rgba(0,0,0,0.14);
}
.emoji-btn.selected{outline:8px solid rgba(255,45,111,0.12);box-shadow:14px 14px 0 rgba(0,0,0,0.18)}
.card-photos{display:flex;gap:12px;flex-wrap:wrap;justify-content:center;margin-top:12px}
.card-photos img{max-width:160px;max-height:160px;border-radius:12px;object-fit:cover;box-shadow:0 10px 28px rgba(0,0,0,0.07)}
.phrase-category{display:flex;flex-direction:column;gap:10px}
.phrase-cat-title{
  font-weight:900;color:var(--accent);font-size:20px;
  text-shadow:4px 4px 0 rgba(0,0,0,0.10);
  border-bottom:4px solid #000; padding-bottom:8px;
}
.phrase-list{display:flex;flex-wrap:wrap;gap:12px}
.phrase-btn{
  background:#fff;border:4px solid #000;padding:14px 16px;border-radius:14px;font-size:16px;
  cursor:pointer;flex:1 1 auto;min-width:220px;text-align:left;font-weight:900;
  box-shadow:8px 8px 0 rgba(0,0,0,0.12);
}
.phrase-btn:hover{transform:translateY(-6px);transition:transform 180ms}
.phrase-btn.selected{outline:8px solid rgba(255,45,111,0.12);box-shadow:14px 14px 0 rgba(0,0,0,0.18)}

.hint{display:block;text-align:center;color:var(--muted);font-size:15px;margin-top:8px}

/* small-screen adjustments */
@media (max-width:420px){
  :root{--pad:12px}
  #app{padding:12px;max-width:100%}
  #card{padding:16px}
  .message{font-size:16px;min-height:120px}
  input,select,textarea,button{font-size:14px;padding:10px}
  .phrase-btn{min-width:140px}
  .emoji-btn{font-size:22px;padding:8px}
  #generate{min-width:140px}
}