/* Make Your Own — studio + toy.
   The toy is always live underneath; the studio is a panel over the top of it,
   so every change is previewed by just typing. */

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

:root {
  --ink: #10496b;
  --ink-soft: #4a6b80;
  --accent: #ff8c42;
  --accent-2: #ffd166;
  --panel: #fffdf6;
}

html, body {
  margin: 0;
  height: 100%;
  overflow: hidden;
  background: #4fb4f2;
  color: var(--ink);
  font-family: "Baloo 2", "Comic Sans MS", "Trebuchet MS", system-ui, sans-serif;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
  overscroll-behavior: none;
  cursor: default;
}
body.playing { touch-action: none; }

/* ------------------------------------------------------------------ scene */

#scene { position: fixed; inset: 0; overflow: hidden; }
#scene .sky { position: absolute; inset: 0; background: var(--sky, #4fb4f2); }
#scene .ground {
  position: absolute; left: 0; right: 0; bottom: 0;
  height: var(--groundH, 22%);
  background: var(--ground, none);
}
#scene .stars { position: absolute; inset: 0; opacity: 0; }
#scene.has-stars .stars {
  opacity: 1;
  /* Stars, not polka dots: the stop has to be an absolute length, or the
     percentage scales with the tile and you get giant circles. */
  background-image:
    radial-gradient(circle at 50% 50%, #fff 0 1.3px, transparent 1.8px),
    radial-gradient(circle at 50% 50%, rgba(255,255,255,.6) 0 1px, transparent 1.5px);
  background-size: 92px 74px, 147px 113px;
  background-position: 11px 23px, 61px 47px;
}
/* A custom background covers everything else. */
#bgimg {
  position: absolute; inset: 0;
  width: 100%; height: 100%;
  object-fit: cover;
  display: none;
}
#scene.has-img #bgimg { display: block; }
#scene.has-img .ground, #scene.has-img .stars { display: none; }

#fx { position: fixed; inset: 0; width: 100%; height: 100%; z-index: 5; pointer-events: none; }

/* -------------------------------------------------------- pop-up windows */

#windows { position: fixed; inset: 0; z-index: 4; pointer-events: none; }
.popwin {
  position: absolute;
  background: var(--panel);
  border: 3px solid var(--ink);
  border-radius: 16px 20px 14px 18px;
  box-shadow: 0 8px 0 rgba(16, 73, 107, .2), 0 12px 22px rgba(0, 40, 70, .25);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: pop-in .3s cubic-bezier(.2, 1.5, .4, 1);
}
@keyframes pop-in { from { transform: scale(.6) translateY(20px); opacity: 0; } }
.pw-bar {
  background: linear-gradient(#8ce99a, #63cf7a);
  border-bottom: 3px solid var(--ink);
  padding: 5px 9px; font-size: 13px; color: #14472a;
}
.pw-grid { flex: 1; display: grid; grid-template-columns: repeat(6, 1fr); gap: 3px; padding: 6px; }
.pw-grid i {
  font-style: normal;
  display: grid; place-items: center;
  border: 2px solid #ded3f0; border-radius: 5px;
  background: #fff; font-size: 15px; font-weight: 800;
  overflow: hidden;
}
/* Two names for one animation so it can restart without a forced layout. */
.pw-grid i.on-a { background: #fff8dd; animation: cell-a .34s cubic-bezier(.2,1.6,.4,1); }
.pw-grid i.on-b { background: #fff8dd; animation: cell-b .34s cubic-bezier(.2,1.6,.4,1); }
@keyframes cell-a { from { transform: scale(.3); } 60% { transform: scale(1.2); } }
@keyframes cell-b { from { transform: scale(.3); } 60% { transform: scale(1.2); } }

/* ----------------------------------------------------------------- studio */

#studio {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  width: min(430px, 92vw);
  z-index: 20;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border-right: 4px solid var(--ink);
  box-shadow: 6px 0 24px rgba(0, 40, 70, .3);
  transition: transform .28s cubic-bezier(.3, 1.2, .4, 1);
}
#studio.hidden { transform: translateX(-102%); }
body.playing #studio, body.playing #reopen { display: none; }

.s-top {
  flex: none;
  display: flex; align-items: center; gap: 8px;
  padding: 10px 12px;
  border-bottom: 3px solid var(--ink);
  background: linear-gradient(var(--accent-2), #ffbe3d);
}
.back {
  text-decoration: none; font-size: 22px; font-weight: 900; color: #7a4a10;
  width: 34px; height: 34px; display: grid; place-items: center;
  border-radius: 10px; background: rgba(255,255,255,.6); flex: none;
}
#name {
  flex: 1; min-width: 0;
  font: inherit; font-weight: 800; font-size: 16px;
  padding: 7px 10px;
  border: 3px solid var(--ink); border-radius: 10px;
  background: #fff; color: var(--ink);
  -webkit-user-select: text; user-select: text;
}
.s-actions { display: flex; gap: 6px; flex: none; }

.btn {
  font: inherit; font-weight: 800; font-size: 14px;
  padding: 8px 14px;
  border: 3px solid var(--ink); border-radius: 99px;
  background: #fff; color: var(--ink);
  cursor: pointer;
  transition: transform .08s ease, box-shadow .08s ease;
  box-shadow: 0 4px 0 rgba(16, 73, 107, .3);
}
.btn:hover { transform: translateY(-1px); }
.btn:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(16,73,107,.3); }
.btn.go { background: linear-gradient(#ffb06a, var(--accent)); color: #4a2109; }
.btn.ghost { background: #fff; }
.btn.small { font-size: 12px; padding: 6px 11px; box-shadow: 0 3px 0 rgba(16,73,107,.25); }
.btn[disabled] { opacity: .5; cursor: default; transform: none; }

.s-body { flex: 1; overflow-y: auto; padding: 12px 14px 4px; }
.s-body section { margin-bottom: 18px; }
.s-body h2 {
  margin: 0 0 8px;
  font-size: 15px;
  color: var(--ink);
  letter-spacing: .3px;
}
.note { font-size: 12px; color: var(--ink-soft); }

.chips { display: flex; flex-wrap: wrap; gap: 7px; }
.chip {
  font: inherit; font-weight: 800; font-size: 12px;
  display: flex; flex-direction: column; align-items: center; gap: 2px;
  min-width: 74px;
  padding: 8px 8px 7px;
  border: 3px solid #dcd3ea; border-radius: 14px;
  background: #fff; color: var(--ink-soft);
  cursor: pointer;
  transition: transform .08s ease, border-color .12s ease, background .12s ease;
}
.chip b { font-size: 24px; line-height: 1; font-weight: 400; }
.chip:hover { transform: translateY(-2px); }
.chip.on {
  border-color: var(--accent); background: #fff4e6; color: #a34c08;
  box-shadow: 0 0 0 2px rgba(255, 140, 66, .25);
}
.chip .sub { font-size: 10px; opacity: .8; font-weight: 700; }

.upload-row { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; margin-top: 9px; }

.s-foot {
  flex: none;
  display: flex; align-items: center; gap: 10px;
  padding: 9px 14px;
  border-top: 3px solid var(--ink);
  background: #fff7e4;
}

#reopen {
  position: fixed; top: 14px; left: 14px; z-index: 21;
}

/* ---------------------------------------------------------------- account */

.acct { display: flex; align-items: center; gap: 9px; flex-wrap: wrap; font-size: 13px; }
.acct img { width: 30px; height: 30px; border-radius: 50%; border: 2px solid var(--ink); }
.acct .who { font-weight: 800; }
.mygames { margin-top: 10px; display: flex; flex-direction: column; gap: 6px; }
.game-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 9px;
  border: 2px solid #e3dcef; border-radius: 10px;
  background: #fff; font-size: 13px; font-weight: 700;
}
.game-row .gi { font-size: 18px; }
.game-row .gn { flex: 1; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }
.game-row button {
  font: inherit; font-size: 11px; font-weight: 800;
  border: 2px solid var(--ink); border-radius: 8px; background: #fff;
  padding: 3px 8px; cursor: pointer;
}
.game-row button.del { border-color: #d4646d; color: #c2434d; }

/* ------------------------------------------------------------------ misc */

#exit-hint {
  position: fixed; left: 50%; top: 1.6vmin;
  transform: translateX(-50%);
  z-index: 30;
  padding: .8vmin 2.4vmin; border-radius: 99px;
  font-size: clamp(10px, 1.7vmin, 14px);
  color: #fff; background: rgba(0, 40, 70, .45);
  opacity: 0; transition: opacity .5s ease; pointer-events: none;
}
#exit-hint.show { opacity: 1; }

#toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translate(-50%, 20px);
  z-index: 40;
  padding: 10px 20px;
  border: 3px solid var(--ink); border-radius: 99px;
  background: var(--panel);
  font-weight: 800; font-size: 14px;
  box-shadow: 0 6px 0 rgba(16, 73, 107, .25);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease, transform .25s cubic-bezier(.2,1.4,.4,1);
}
#toast.show { opacity: 1; transform: translate(-50%, 0); }

@media (max-width: 620px) {
  #studio { width: 100%; top: auto; height: 74vh; border-right: none; border-top: 4px solid var(--ink); }
  #studio.hidden { transform: translateY(102%); }
}
@media (prefers-reduced-motion: reduce) {
  #studio, .btn, .chip, .popwin, #toast { transition: none; animation: none; }
}
