/* =========================================================
   Tweet Tower – styles for the HTML UI on top of the canvas
   ========================================================= */
:root {
  --ink: #4a2b4f;
  --cream: #fffaf4;
  --pink: #ff7aa8;  --pink-dark: #e2558a;
  --lilac: #a98bff; --lilac-dark: #7f60e0;
  --gold: #ffcf4d;  --mint: #4cc98b; --red: #ff5d7d;
  --soft: #f2d9ea;
  --font: "Nunito", "Baloo 2", "Varela Round", ui-rounded, "SF Pro Rounded",
          "Segoe UI Rounded", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --outline: 3px 0 var(--ink), -3px 0 var(--ink), 0 3px var(--ink), 0 -3px var(--ink),
             2px 2px var(--ink), -2px -2px var(--ink), 2px -2px var(--ink), -2px 2px var(--ink),
             0 6px 0 rgba(74, 43, 79, .25);
  --outline-sm: 2px 0 var(--ink), -2px 0 var(--ink), 0 2px var(--ink), 0 -2px var(--ink),
                1px 1px var(--ink), -1px -1px var(--ink), 1px -1px var(--ink), -1px 1px var(--ink);
}

* { box-sizing: border-box; }
html, body {
  margin: 0; height: 100%; overflow: hidden;
  background: linear-gradient(#ffd6ea, #cdeeff);
  font-family: var(--font); color: var(--ink);
  -webkit-user-select: none; user-select: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}
button { font-family: inherit; }
.hidden { display: none !important; }
.outlined { color: #fff; text-shadow: var(--outline); }
.outlined-sm { color: #fff; text-shadow: var(--outline-sm); }

/* ---------- Stage (canvas + HUD) ---------- */
#stage { position: fixed; left: 50%; top: 50%; transform: translate(-50%, -50%); overflow: hidden; }
#game { display: block; width: 100%; height: 100%; touch-action: none; cursor: grab; }
#game:active { cursor: grabbing; }

/* ---------- HUD ---------- */
#hud { position: absolute; inset: 0; pointer-events: none; }
.hud-left, .hud-right { position: absolute; top: calc(env(safe-area-inset-top) + 12px); display: flex; gap: 8px; }
.hud-left { left: calc(env(safe-area-inset-left) + 12px); flex-direction: column; align-items: flex-start; }
.hud-right { right: calc(env(safe-area-inset-right) + 12px); }
.hud-center { position: absolute; left: 50%; top: calc(env(safe-area-inset-top) + 4px); transform: translateX(-50%); text-align: center; }

.pill {
  background: rgba(255, 255, 255, .85); border: 3px solid #fff; border-radius: 999px;
  padding: 4px 11px; font-weight: 900; font-size: 14px;
  box-shadow: 0 4px 0 rgba(74, 43, 79, .12);
}
.pill.small { font-size: 12px; padding: 3px 10px; }
#hearts span { font-size: 20px; color: var(--red); display: inline-block; margin: 0 1px; }
#hearts span.empty { color: #dcc9df; }

#score { font-size: 60px; font-weight: 900; line-height: 1.05; }
.sub { font-size: 13px; font-weight: 900; letter-spacing: 1px; }
.goal {
  position: relative; margin: 6px auto 0; width: 168px; height: 18px; overflow: hidden;
  background: rgba(255, 255, 255, .8); border: 3px solid #fff; border-radius: 99px;
  box-shadow: 0 3px 0 rgba(74, 43, 79, .12);
}
#goal-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 0; background: linear-gradient(90deg, #ff9ac1, var(--gold)); transition: width .35s; }
#goal-text { position: relative; display: block; font-size: 10px; font-weight: 900; line-height: 12px; }

.round {
  pointer-events: auto; width: 46px; height: 46px; border-radius: 50%;
  border: 3px solid #fff; background: rgba(255, 255, 255, .88); color: var(--ink);
  font-weight: 900; font-size: 17px; cursor: pointer; display: grid; place-items: center;
  box-shadow: 0 4px 0 rgba(74, 43, 79, .18); transition: transform .08s, box-shadow .08s;
}
.round:active { transform: translateY(3px); box-shadow: 0 1px 0 rgba(74, 43, 79, .18); }
.round.rotate {
  position: absolute; right: calc(env(safe-area-inset-right) + 18px); bottom: calc(env(safe-area-inset-bottom) + 22px);
  width: 76px; height: 76px; font-size: 38px; color: #fff; background: var(--lilac);
  box-shadow: 0 6px 0 var(--lilac-dark);
}
.round.rotate:active { box-shadow: 0 2px 0 var(--lilac-dark); }
.round.corner { position: fixed; right: calc(env(safe-area-inset-right) + 14px); bottom: calc(env(safe-area-inset-bottom) + 14px); }

.hint {
  position: absolute; left: 50%; bottom: calc(env(safe-area-inset-bottom) + 34px); transform: translateX(-50%);
  background: rgba(255, 255, 255, .9); border: 3px solid #fff; border-radius: 999px;
  padding: 8px 16px; font-weight: 800; font-size: 13px; white-space: nowrap; pointer-events: none;
  box-shadow: 0 4px 0 rgba(74, 43, 79, .12); animation: float 1.8s ease-in-out infinite;
}

#banner {
  position: absolute; left: 50%; top: 27%; transform: translate(-50%, -50%); opacity: 0;
  font-size: 27px; font-weight: 900; white-space: nowrap; pointer-events: none;
}
#banner.show { animation: banner 2s cubic-bezier(.2, 1.4, .4, 1) forwards; }

/* ---------- Screens ---------- */
.screen {
  position: fixed; inset: 0; z-index: 10; display: flex; overflow-y: auto;
  padding: calc(env(safe-area-inset-top) + 16px) 16px calc(env(safe-area-inset-bottom) + 16px);
  touch-action: pan-y; -webkit-overflow-scrolling: touch;
}
#screen-title { flex-direction: column; background: radial-gradient(circle at 50% 35%, rgba(255, 255, 255, .1), rgba(255, 214, 234, .45)); }

/* "made by" badge: sits under the card, pinned to the bottom centre on tall screens */
.credit {
  align-self: center; flex: none; display: flex; align-items: center; gap: 6px; margin-top: 14px;
  padding: 4px 13px 4px 11px; border: 3px solid #fff; border-radius: 999px;
  background: rgba(255, 255, 255, .88); color: var(--ink); text-decoration: none;
  font-size: 13px; font-weight: 800; white-space: nowrap;
  box-shadow: 0 4px 0 rgba(74, 43, 79, .14); transition: transform .12s, box-shadow .12s;
}
.credit:hover { transform: translateY(-2px); box-shadow: 0 6px 0 rgba(74, 43, 79, .14); }
.credit:hover b { color: var(--pink-dark); text-decoration: underline; }
.credit:active { transform: translateY(2px); box-shadow: 0 2px 0 rgba(74, 43, 79, .14); }
.credit:focus-visible { outline: 3px solid var(--lilac); outline-offset: 2px; }
.credit img { width: 26px; height: 26px; border-radius: 50%; border: 2px solid var(--pink); object-fit: cover; background: var(--soft); }
.credit b { font-weight: 900; }
.credit-made { opacity: .6; }
.credit-check { width: 15px; height: 15px; margin-left: -3px; }
#screen-paused, #screen-over { flex-direction: column; }
/* smaller copy in the bottom-left corner while playing */
.credit.in-play {
  position: absolute; z-index: 2; margin: 0; padding: 3px 11px 3px 8px; font-size: 12px;
  left: calc(env(safe-area-inset-left) + 12px); bottom: calc(env(safe-area-inset-bottom) + 12px);
}
.credit.in-play img { width: 22px; height: 22px; }
.screen.dim { background: rgba(74, 43, 79, .38); backdrop-filter: blur(4px); -webkit-backdrop-filter: blur(4px); }

.card {
  position: relative; width: min(400px, 100%); margin: auto;
  background: var(--cream); border: 5px solid #fff; border-radius: 34px;
  padding: 22px 20px 18px; text-align: center;
  box-shadow: 0 10px 0 rgba(74, 43, 79, .12), 0 30px 60px rgba(120, 60, 140, .25);
  animation: pop .5s cubic-bezier(.2, 1.5, .4, 1);
}
.small-card { width: min(320px, 100%); }

.logo { margin: 0; font-size: 58px; line-height: .92; font-weight: 900; letter-spacing: -1px; }
.logo span { display: block; }
.logo span:first-child { color: #ff8fb8; animation: wiggle 2.6s ease-in-out infinite; }
.logo span:last-child  { color: #8fd3ff; animation: wiggle 2.6s ease-in-out .3s infinite; }
.tagline { margin: 10px 0 16px; font-weight: 800; opacity: .8; }
.big-title { margin: 4px 0 6px; font-size: 38px; font-weight: 900; color: var(--pink); }

label { display: block; text-align: left; font-weight: 900; font-size: 13px; margin: 0 0 6px 6px; }
.input-row {
  display: flex; align-items: center; gap: 6px; background: #fff;
  border: 3px solid var(--soft); border-radius: 18px; padding: 5px 5px 5px 12px; transition: border-color .2s;
}
.input-row:focus-within { border-color: var(--pink); }
.at { font-weight: 900; color: var(--pink); font-size: 20px; }
#handle {
  flex: 1; min-width: 0; border: 0; outline: 0; background: transparent; padding: 6px 0;
  font: 800 18px var(--font); color: var(--ink); -webkit-user-select: text; user-select: text;
}

.btn {
  border: 0; border-radius: 18px; padding: 12px 18px; cursor: pointer;
  font-weight: 900; font-size: 16px; color: #fff; background: var(--lilac);
  box-shadow: 0 5px 0 var(--lilac-dark); transition: transform .08s, box-shadow .08s;
}
.btn:active { transform: translateY(4px); box-shadow: 0 1px 0 var(--lilac-dark); }
.btn:disabled { opacity: .6; pointer-events: none; }
.btn.small { padding: 9px 14px; font-size: 15px; }
.btn.primary { background: var(--pink); box-shadow: 0 6px 0 var(--pink-dark); }
.btn.primary:active { box-shadow: 0 2px 0 var(--pink-dark); }
.btn.big { display: block; width: 100%; margin-top: 12px; padding: 15px; font-size: 20px; }
.btn.primary.big { animation: breathe 2.2s ease-in-out infinite; }
.btn.ghost { background: #fff; color: var(--ink); border: 3px solid var(--soft); box-shadow: 0 4px 0 var(--soft); }
.btn.ghost.big { font-size: 16px; padding: 12px; }
.row { display: flex; gap: 10px; margin-top: 12px; }
.row .btn { flex: 1; }

.profile {
  display: flex; align-items: center; gap: 12px; text-align: left;
  background: #fff; border: 3px solid var(--soft); border-radius: 20px; padding: 10px;
  animation: pop .4s cubic-bezier(.2, 1.5, .4, 1);
}
.profile img { width: 56px; height: 56px; border-radius: 50%; border: 3px solid var(--pink); object-fit: cover; background: var(--soft); flex: none; }
.p-info { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.p-info b, .p-info span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-info span { font-weight: 800; opacity: .65; font-size: 14px; }
.p-info small { font-weight: 800; color: var(--pink-dark); font-size: 12px; }
.x { border: 0; background: var(--soft); color: var(--ink); width: 32px; height: 32px; border-radius: 50%; font-weight: 900; cursor: pointer; flex: none; }

.status { min-height: 20px; margin: 10px 4px 0; font-size: 13px; font-weight: 800; }
.status.ok { color: #2f9e6a; }
.status.err { color: #e0446a; }
.status.info { color: var(--lilac-dark); }
.status.busy::before {
  content: ""; display: inline-block; width: 11px; height: 11px; margin-right: 8px; vertical-align: -1px;
  border: 3px solid currentColor; border-right-color: transparent; border-radius: 50%; animation: spin .7s linear infinite;
}

.howto { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; margin-top: 16px; }
.howto div { background: #fff; border: 2px solid var(--soft); border-radius: 14px; padding: 7px 4px; font-size: 13px; }
.howto b { display: block; font-size: 13px; }
.howto span { opacity: .7; font-weight: 700; }
.tiny { font-size: 12px; font-weight: 800; margin: 10px 0 0; }
.muted { opacity: .55; font-weight: 700; }

.final { margin: 6px 0 4px; }
.final span { display: block; font-size: 76px; font-weight: 900; line-height: 1; }
.final small { font-weight: 900; opacity: .7; }
.badge { display: inline-block; margin: 6px 0 10px; padding: 4px 14px; border-radius: 99px; background: var(--soft); font-weight: 900; font-size: 14px; }
.badge.new { background: var(--gold); animation: bump .5s ease 2; }
.stats { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.stats div { background: #fff; border: 2px solid var(--soft); border-radius: 14px; padding: 8px 2px; }
.stats b { display: block; font-size: 20px; }
.stats small { font-size: 11px; font-weight: 800; opacity: .65; }
.goal-line { font-size: 13px; font-weight: 800; margin: 12px 4px 0; color: var(--pink-dark); }

/* ---------- Animations ---------- */
.bump { animation: bump .35s ease; }
@keyframes bump { 0% { transform: scale(1); } 40% { transform: scale(1.25); } 100% { transform: scale(1); } }
@keyframes pop { 0% { transform: scale(.7); opacity: 0; } 100% { transform: scale(1); opacity: 1; } }
@keyframes breathe { 0%, 100% { transform: scale(1); } 50% { transform: scale(1.03); } }
@keyframes wiggle { 0%, 100% { transform: rotate(-2deg); } 50% { transform: rotate(2deg) translateY(-3px); } }
@keyframes float { 0%, 100% { transform: translate(-50%, 0); } 50% { transform: translate(-50%, -5px); } }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes banner {
  0%   { opacity: 0; transform: translate(-50%, -50%) scale(.5); }
  12%  { opacity: 1; transform: translate(-50%, -50%) scale(1.1); }
  20%  { transform: translate(-50%, -50%) scale(1); }
  80%  { opacity: 1; transform: translate(-50%, -50%) scale(1); }
  100% { opacity: 0; transform: translate(-50%, -90%) scale(1); }
}
@media (prefers-reduced-motion: reduce) {
  .logo span, .btn.primary.big, .hint { animation: none; }
}