/* Poké Card Maker — kid-friendly styling. No inline styles (tight CSP). */
/* Pokémon-style display font (Luckiest Guy, OFL — self-hosted so the page
   works with CSP 'self' and never calls out to Google Fonts). */
@font-face {
  font-family: "Luckiest Guy";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("/fonts/luckiest-guy.ttf") format("truetype");
}

:root {
  --ink: #241a5e;
  --deep: #171043;
  --panel: #2a1f72;
  --panel2: #352987;
  --gold: #ffd24a;
  --gold-dark: #b97c12;
  --pink: #ff5d8f;
  --cyan: #43e8ff;
  --lime: #8dff6b;
  --white: #fffdf2;
  --red: #ff4d4d;
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  font-family: "Luckiest Guy", "Trebuchet MS", "Comic Sans MS", Verdana, sans-serif;
  background: radial-gradient(circle at 50% 0%, #2c2170 0%, var(--deep) 70%);
  color: var(--white);
  min-height: 100vh;
  padding-bottom: 40px;
}
.stars {
  position: fixed; inset: 0; pointer-events: none; opacity: .5;
  background-image:
    radial-gradient(2px 2px at 12% 18%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 78% 12%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 32% 62%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 88% 48%, #fff 50%, transparent 51%),
    radial-gradient(1.5px 1.5px at 58% 82%, #fff 50%, transparent 51%),
    radial-gradient(2px 2px at 22% 88%, #fff 50%, transparent 51%);
}
.top { text-align: center; padding: 22px 12px 8px; position: relative; }
.top h1 {
  font-size: clamp(28px, 7vw, 52px);
  color: var(--gold);
  text-shadow: 0 3px 0 var(--gold-dark), 0 6px 18px rgba(255, 210, 74, .45);
  letter-spacing: 1px;
}
.tagline { font-size: clamp(15px, 3.5vw, 22px); color: var(--cyan); margin-top: 6px; font-weight: bold; }
.gear {
  position: absolute; right: 14px; top: 18px; text-decoration: none;
  font-size: 15px; color: var(--white); background: var(--panel2);
  padding: 8px 12px; border-radius: 12px; border: 2px solid #4a3bad;
}
.panel {
  max-width: 1100px; margin: 16px auto; padding: 16px;
}
.party-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 12px;
  padding: 10px 14px;
  background: var(--panel2);
  border-radius: 14px;
}
.party-bar #party-label { font-weight: bold; font-size: 17px; margin-right: auto; }

.hidden { display: none !important; }
.hidden-input { position: absolute; width: 1px; height: 1px; opacity: 0; pointer-events: none; }

/* login */
.login-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(260px, 1fr)); gap: 16px; margin-top: 14px; }
.login-box {
  background: var(--panel); border: 3px solid #4a3bad; border-radius: 20px;
  padding: 22px; text-align: center;
}
.login-box h3 { font-size: 22px; margin-bottom: 8px; color: var(--gold); }
.login-box p { margin-bottom: 12px; color: #cfc7ff; }
.login-box input {
  width: 100%; padding: 14px; border-radius: 14px; border: 3px solid #4a3bad;
  font-size: 18px; text-align: center; margin-bottom: 12px; background: var(--white); color: var(--ink);
}
#setup-box { margin-top: 16px; }

/* buttons */
.big-btn {
  display: inline-block; border: none; cursor: pointer; text-decoration: none;
  background: linear-gradient(180deg, #ffe27a, var(--gold)); color: var(--ink);
  font-size: 19px; font-weight: 900; padding: 15px 22px; border-radius: 16px;
  box-shadow: 0 5px 0 var(--gold-dark); text-align: center;
}
.big-btn:active { transform: translateY(3px); box-shadow: 0 2px 0 var(--gold-dark); }
.big-btn.alt { background: linear-gradient(180deg, #7ef1ff, var(--cyan)); box-shadow: 0 5px 0 #1593a8; }
.big-btn.alt:active { box-shadow: 0 2px 0 #1593a8; }
.big-btn.cam { background: linear-gradient(180deg, #ffa3c1, var(--pink)); box-shadow: 0 5px 0 #b03258; color: #fff; }
.big-btn.cam:active { box-shadow: 0 2px 0 #b03258; }
.big-btn:disabled { filter: grayscale(.7) brightness(.8); cursor: not-allowed; }
.mega-btn {
  display: block; width: 100%; margin-top: 18px; border: none; cursor: pointer;
  background: linear-gradient(180deg, #b1ff8d, var(--lime)); color: var(--ink);
  font-size: clamp(22px, 5vw, 30px); font-weight: 900; padding: 20px; border-radius: 20px;
  box-shadow: 0 6px 0 #3f9c2c;
}
.mega-btn:active { transform: translateY(3px); box-shadow: 0 3px 0 #3f9c2c; }
.mega-btn:disabled { filter: grayscale(.7) brightness(.8); cursor: not-allowed; }
.small-btn {
  border: none; cursor: pointer; background: var(--cyan); color: var(--ink);
  font-weight: bold; padding: 10px 14px; border-radius: 12px; font-size: 15px;
}
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 12px; justify-content: center; }

/* maker */
.maker-grid { display: grid; grid-template-columns: 1fr; gap: 20px; }
@media (min-width: 900px) { .maker-grid { grid-template-columns: 1fr 1fr; } }
.maker-left h2, .maker-right h2 { font-size: 21px; color: var(--gold); margin: 18px 0 10px; }
.capture-frame {
  position: relative; background: var(--panel); border: 3px dashed var(--cyan);
  border-radius: 18px; min-height: 260px; display: flex; align-items: center;
  justify-content: center; overflow: hidden;
}
.capture-frame img { max-width: 100%; max-height: 380px; display: block; }
.frame-hint { text-align: center; padding: 18px; color: #cfc7ff; }
.align-box {
  border: 3px solid var(--gold); border-radius: 12px; padding: 34px 18px;
  color: var(--gold); font-weight: bold; font-size: 15px; letter-spacing: 1px;
  background: rgba(255, 210, 74, .08);
}
.fields label { display: block; margin: 12px 0 4px; font-weight: bold; color: #cfc7ff; }
.fields input, .fields textarea {
  width: 100%; padding: 13px; border-radius: 14px; border: 3px solid #4a3bad;
  font-size: 17px; background: var(--white); color: var(--ink); margin-top: 6px;
  font-family: inherit;
}
.chip-row { margin-top: 14px; }
.chip-label { font-weight: bold; color: #cfc7ff; display: block; margin-bottom: 8px; }
.chips { display: flex; flex-wrap: wrap; gap: 8px; }
.chip {
  border: 3px solid #4a3bad; background: var(--panel2); color: var(--white);
  border-radius: 999px; padding: 9px 15px; font-size: 15px; font-weight: bold; cursor: pointer;
}
.chip.selected { background: var(--gold); color: var(--ink); border-color: var(--gold-dark); }

/* card stage */
.card-placeholder {
  background: var(--panel); border: 3px solid #4a3bad; border-radius: 18px;
  padding: 46px 18px; text-align: center; color: #cfc7ff; font-size: 17px;
}
#card-image {
  width: 100%; max-width: 420px; display: block; margin: 0 auto;
  border-radius: 16px; box-shadow: 0 16px 44px rgba(0, 0, 0, .55);
}
.spinner {
  width: 62px; height: 62px; margin: 0 auto 14px; border-radius: 50%;
  border: 8px solid #4a3bad; border-top-color: var(--gold);
  animation: spin 1s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.share-row {
  display: flex; gap: 8px; align-items: center; margin-top: 14px;
  background: var(--panel); border-radius: 14px; padding: 10px; flex-wrap: wrap;
}
.share-row input {
  flex: 1; min-width: 160px; border: none; border-radius: 10px; padding: 10px;
  font-size: 14px; background: var(--white); color: var(--ink);
}
.tiny { font-size: 12px; color: #b3a9e8; margin-top: 8px; text-align: center; }

/* history */
.history { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.hist-card {
  background: var(--panel); border: 3px solid #4a3bad; border-radius: 14px;
  padding: 8px; cursor: pointer; text-align: center;
}
.hist-card:hover { border-color: var(--gold); }
.hist-card img { width: 100%; border-radius: 8px; display: block; }
.hist-card .ph {
  width: 100%; aspect-ratio: 2 / 3; border-radius: 8px; background: var(--panel2);
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.hist-card p { font-size: 12px; margin-top: 6px; color: #cfc7ff; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.error { color: var(--red); font-weight: bold; margin-top: 12px; min-height: 20px; text-align: center; }

/* config page */
.cfg-grid { display: grid; gap: 16px; max-width: 860px; margin: 0 auto; }
.cfg-card { background: var(--panel); border: 3px solid #4a3bad; border-radius: 18px; padding: 18px; }
.cfg-card h3 { color: var(--gold); margin-bottom: 10px; }
.cfg-card label { display: block; margin: 10px 0 4px; font-weight: bold; color: #cfc7ff; }
.cfg-card input, .cfg-card textarea, .cfg-card select {
  width: 100%; padding: 11px; border-radius: 12px; border: 3px solid #4a3bad;
  font-size: 15px; background: var(--white); color: var(--ink); margin-top: 5px;
  font-family: inherit;
}
.cfg-card textarea { min-height: 140px; font-family: ui-monospace, Menlo, Consolas, monospace; font-size: 13px; }
.cfg-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.hint { font-size: 12.5px; color: #b3a9e8; margin-top: 6px; line-height: 1.5; }
.ok-msg { color: var(--lime); font-weight: bold; margin-top: 10px; min-height: 20px; }
