/*
 * FLYTUBE.
 *
 * O jogo enche o ecra. Tudo o resto vive por baixo, a distancia de um scroll.
 */

:root {
  --sky: #4ec0ca;
  --sky-deep: #2f8f99;
  --ink: #16161c;
  --panel: #fffaf0;
  --pipe: #74bf2e;
  --pipe-deep: #4a8a1f;
  --gold: #f1c33b;
  --shadow: 0 3px 0 rgba(22, 22, 28, 0.3);
  --stack: "Trebuchet MS", "Segoe UI", Verdana, system-ui, sans-serif;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--stack);
  color: var(--ink);
  background: var(--sky-deep);
  -webkit-text-size-adjust: 100%;
}

h1, h2 {
  font-weight: 900;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin: 0;
}

button, .btn {
  font-family: var(--stack);
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  cursor: pointer;
}

:focus-visible {
  outline: 3px solid var(--gold);
  outline-offset: 2px;
}

/* ------------------------------------------------------- o jogo, em cheio */

.hero {
  position: relative;
  width: 100%;
  height: 100vh;
  /* dvh acompanha a barra do browser no telemovel; vh fica de reserva. */
  height: 100dvh;
  overflow: hidden;
  background: var(--sky);
}

.stage {
  position: absolute;
  inset: 0;
  line-height: 0;
}

#game {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: manipulation;
  cursor: pointer;
  /* O canvas e pixel art: nunca interpolar ao ampliar. */
  image-rendering: pixelated;
}

.topbar {
  position: absolute;
  z-index: 3;
  top: 0;
  left: 0;
  right: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 12px 14px;
  padding-top: max(12px, env(safe-area-inset-top));
  pointer-events: none;
}

.topbar > * { pointer-events: auto; }

.wordmark {
  font-weight: 900;
  font-size: 13px;
  letter-spacing: 0.3em;
  color: #fff;
  text-shadow: 0 2px 0 rgba(22, 22, 28, 0.45);
}

.topactions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.ghost {
  padding: 6px 11px;
  font-size: 11px;
  color: #fff;
  background: rgba(22, 22, 28, 0.35);
  border: 2px solid rgba(255, 255, 255, 0.55);
  border-radius: 999px;
}

.ghost:hover { background: rgba(22, 22, 28, 0.55); }

.connect {
  padding: 7px 14px;
  font-size: 11px;
  color: var(--ink);
  background: var(--gold);
  border: 2px solid var(--ink);
  border-radius: 999px;
  box-shadow: 0 2px 0 rgba(22, 22, 28, 0.35);
}

.connect:hover { background: #ffd451; }
.connect.is-on {
  color: #fff;
  background: var(--pipe);
  font-family: ui-monospace, Consolas, monospace;
  text-transform: none;
  letter-spacing: 0;
}

.hint {
  position: absolute;
  z-index: 2;
  left: 0;
  right: 0;
  bottom: max(12px, env(safe-area-inset-bottom));
  margin: 0;
  text-align: center;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.9);
  text-shadow: 0 2px 0 rgba(22, 22, 28, 0.4);
  pointer-events: none;
}

/* Cartao do nome, por cima do canvas, na metade de baixo. */
.overlay {
  position: absolute;
  z-index: 2;
  inset: 52% 0 0 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: flex-start;
  gap: 10px;
  padding-top: 12px;
  line-height: normal;
  pointer-events: none;
}

.overlay > * { pointer-events: auto; }
.overlay[hidden] { display: none; }

.namecard {
  background: var(--panel);
  border: 3px solid var(--ink);
  border-radius: 8px;
  padding: 10px 12px;
  box-shadow: var(--shadow);
  text-align: center;
  min-width: 228px;
}

.namecard[hidden] { display: none; }

.namecard label {
  display: block;
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  opacity: 0.7;
  margin-bottom: 6px;
}

.namerow {
  display: flex;
  gap: 8px;
  justify-content: center;
}

#initials {
  width: 104px;
  padding: 6px 8px;
  font-family: var(--stack);
  font-size: 26px;
  font-weight: 900;
  letter-spacing: 0.28em;
  text-align: center;
  text-transform: uppercase;
  color: var(--ink);
  background: #fff;
  border: 3px solid var(--ink);
  border-radius: 6px;
}

.namestate {
  margin: 6px 0 0;
  min-height: 14px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.05em;
}

.namestate.ok { color: #2f7d1f; }
.namestate.bad { color: #b13024; }

.namehint {
  margin: 2px 0 0;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0.55;
}

#submitScore, .again {
  padding: 8px 14px;
  font-size: 13px;
  color: #fff;
  background: var(--pipe);
  border: 3px solid var(--ink);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

#submitScore:hover, .again:hover { background: #82d234; }
#submitScore:active, .again:active { transform: translateY(2px); box-shadow: none; }
#submitScore[disabled] { background: #9bb089; cursor: default; transform: none; }

.again { background: var(--gold); color: var(--ink); }
.again:hover { background: #ffd451; }

/* -------------------------------------------------------- o resto da pagina */

main {
  max-width: 680px;
  margin: 0 auto;
  padding: 26px 16px 8px;
}

.board, .lore {
  margin-bottom: 22px;
  background: var(--panel);
  border: 3px solid var(--ink);
  border-radius: 10px;
  padding: 16px 18px;
  box-shadow: 0 8px 0 rgba(22, 22, 28, 0.24);
}

.board header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}

.board h2, .lore h2 { font-size: 18px; }

.tabsets {
  display: flex;
  gap: 14px;
  flex-wrap: wrap;
}

.tabs { display: flex; gap: 6px; }

.tab {
  padding: 5px 11px;
  font-size: 11px;
  color: var(--ink);
  background: #efe7cf;
  border: 2px solid var(--ink);
  border-radius: 999px;
}

.tab.is-on { background: var(--gold); }

.boardnote {
  margin: 10px 0 6px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  opacity: 0.55;
}

.lb {
  list-style: none;
  margin: 0;
  padding: 0;
}

.lb li {
  display: grid;
  grid-template-columns: 38px 1fr auto;
  align-items: center;
  gap: 10px;
  padding: 8px;
  font-weight: 800;
  border-bottom: 2px dotted rgba(22, 22, 28, 0.16);
}

.lb li:last-child { border-bottom: 0; }
.lb li:nth-child(1) .lb-rank { color: #b8860b; }
.lb li.is-you { background: #fff3c4; border-radius: 6px; }

.lb-rank { font-size: 13px; opacity: 0.6; }

.lb-who {
  display: flex;
  align-items: baseline;
  gap: 10px;
  min-width: 0;
}

.lb-name { letter-spacing: 0.22em; font-size: 15px; }

.lb-addr {
  font-family: ui-monospace, Consolas, monospace;
  font-size: 11px;
  font-weight: 600;
  opacity: 0.5;
  white-space: nowrap;
}

.lb-score { font-size: 17px; font-variant-numeric: tabular-nums; }

.lb-empty {
  display: block !important;
  padding: 16px 4px;
  font-weight: 700;
  opacity: 0.6;
}

.lore p {
  margin: 10px 0 0;
  font-size: 14px;
  line-height: 1.6;
}

.ca {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 16px;
  padding: 8px 10px;
  background: #efe7cf;
  border: 2px solid var(--ink);
  border-radius: 8px;
  overflow: hidden;
}

.ca-label {
  font-size: 11px;
  font-weight: 900;
  letter-spacing: 0.12em;
  opacity: 0.6;
}

.ca-value {
  flex: 1;
  min-width: 0;
  padding: 0;
  font-family: ui-monospace, Consolas, monospace;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0;
  text-transform: none;
  text-align: left;
  color: var(--ink);
  background: none;
  border: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.ca-value:hover { color: var(--pipe-deep); }

.links {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-top: 14px;
}

.btn {
  padding: 9px 16px;
  font-size: 13px;
  text-decoration: none;
  color: #fff;
  background: var(--ink);
  border: 3px solid var(--ink);
  border-radius: 6px;
  box-shadow: var(--shadow);
}

.btn:active { transform: translateY(2px); box-shadow: none; }
.btn.buy { background: var(--pipe); }
.btn.buy:hover { background: #82d234; }
.btn.x:hover { background: #34343f; }
.btn.ghostlink { color: var(--ink); background: #efe7cf; }
.btn.ghostlink:hover { background: #e4d9b8; }
.btn[hidden] { display: none; }

footer {
  max-width: 680px;
  margin: 0 auto;
  padding: 8px 16px 40px;
  text-align: center;
  color: rgba(255, 255, 255, 0.92);
}

footer p { margin: 4px 0; font-size: 12px; font-weight: 700; }
footer .small { font-size: 11px; font-weight: 500; opacity: 0.75; }

@media (max-width: 420px) {
  main { padding: 18px 10px 4px; }
  .board, .lore { padding: 14px; }
  .namecard { min-width: 208px; }
}

@media (prefers-reduced-motion: reduce) {
  #submitScore:active, .again:active, .btn:active { transform: none; }
}
