:root {
  --bg: #0f1b2d;
  --panel: #fffdf7;
  --ink: #1d2433;
  --muted: #5b6577;
  --accent: #ff7a1a;
  --accent-ink: #ffffff;
  --good: #1f9d55;
  --line: #e4ddd0;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  min-height: 100%;
  background: var(--bg);
  color: var(--ink);
  font-family: "Trebuchet MS", system-ui, sans-serif;
}

a { color: var(--accent); }

.wrap {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

header.top {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #fff;
}
header.top h1 { font-size: 22px; margin: 0; letter-spacing: .5px; }
header.top a { font-size: 14px; color: #ffd2b0; text-decoration: none; }
header.top a:hover { text-decoration: underline; }

.stage {
  position: relative;
  width: 100%;
  aspect-ratio: 2 / 3;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 40px rgba(0, 0, 0, .45);
  touch-action: manipulation;
  user-select: none;
}

canvas { display: block; width: 100%; height: 100%; }

.overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 18px;
  background: rgba(15, 27, 45, .55);
}
.overlay[hidden] { display: none; }

.card {
  background: var(--panel);
  border-radius: 12px;
  padding: 20px;
  width: 100%;
  max-width: 340px;
  max-height: 100%;
  overflow: auto;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .3);
}
.card h2 { margin: 0 0 6px; font-size: 22px; }
.card p { margin: 6px 0; color: var(--muted); font-size: 14px; line-height: 1.4; }
.card .letter {
  font-family: Georgia, serif;
  font-style: italic;
  color: var(--ink);
  border-left: 3px solid var(--accent);
  padding-left: 10px;
  margin: 10px 0;
}

.avatar {
  width: 72px; height: 72px;
  border-radius: 50%;
  object-fit: cover;
  object-position: 62% 70%;
  border: 3px solid var(--accent);
  display: block;
  margin: 0 auto 8px;
}

label { font-size: 13px; color: var(--muted); display: block; margin-top: 10px; }
input, textarea {
  width: 100%;
  font: inherit;
  padding: 10px 12px;
  margin-top: 4px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
}
input:focus, textarea:focus { outline: none; border-color: var(--accent); }

button {
  font: inherit;
  font-weight: bold;
  border: 0;
  border-radius: 8px;
  padding: 11px 16px;
  margin-top: 12px;
  width: 100%;
  cursor: pointer;
  background: var(--accent);
  color: var(--accent-ink);
}
button.secondary { background: transparent; color: var(--ink); border: 2px solid var(--line); }
button:hover { filter: brightness(1.05); }

.score-big { font-size: 44px; font-weight: bold; text-align: center; margin: 4px 0; color: var(--ink); }
.stats { display: flex; justify-content: center; gap: 16px; font-size: 13px; color: var(--muted); }

.board {
  width: 100%;
  background: var(--panel);
  border-radius: 12px;
  padding: 14px 16px;
}
.board h3 { margin: 0 0 8px; font-size: 16px; }
.board ol { margin: 0; padding: 0; list-style: none; }
.board li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px dashed var(--line);
  font-size: 15px;
}
.board li:last-child { border-bottom: 0; }
.board li.me { color: var(--accent); font-weight: bold; }
.board .rank { width: 28px; color: var(--muted); }
.board .name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.board .empty { color: var(--muted); font-size: 14px; }

.hint { color: #9fb0c9; font-size: 13px; text-align: center; }

/* ---------- Fake ads ---------- */
.layout {
  display: flex;
  justify-content: center;
  align-items: flex-start;
  gap: 24px;
}
.layout > .wrap { flex: 0 1 480px; width: 100%; margin: 0; }

.ad-rail { display: none; }

.ad {
  --ad-bg: #fff;
  --ad-ink: #111;
  width: 100%;
  border-radius: 10px;
  overflow: hidden;
  background: var(--ad-bg);
  color: var(--ad-ink);
  box-shadow: 0 6px 20px rgba(0, 0, 0, .35);
  transition: opacity .25s ease;
}
.ad.ad-fade { opacity: 0; }

.ad-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 8px;
  font-size: 11px;
  color: #5f6368;
  background: #f1f3f4;
}
.ad-meta .ad-close {
  width: auto;
  margin: 0;
  padding: 0 4px;
  background: none;
  color: #5f6368;
  font-size: 13px;
  line-height: 1.4;
  border-radius: 4px;
}
.ad-meta .ad-close:hover { background: #dadce0; }

.ad-body { padding: 14px; display: flex; flex-direction: column; gap: 8px; }
.ad-tag {
  align-self: flex-start;
  font-size: 11px;
  font-weight: bold;
  letter-spacing: .5px;
  padding: 2px 8px;
  border-radius: 999px;
  border: 1.5px solid currentColor;
}
.ad-title { font-size: 19px; line-height: 1.2; }
.ad-text { margin: 0; font-size: 14px; line-height: 1.4; opacity: .9; }
.ad-cta {
  margin-top: 4px;
  background: var(--ad-ink);
  color: var(--ad-bg);
  border-radius: 6px;
  padding: 10px 12px;
  animation: ad-pulse 1.6s ease-in-out infinite;
}
.ad-cta:disabled { animation: none; opacity: .75; cursor: default; }
@keyframes ad-pulse { 50% { transform: scale(1.04); } }

.ad-closed {
  padding: 26px 14px;
  text-align: center;
  font-weight: bold;
  color: #111;
  background: #fff;
}
.ad-closed small { font-weight: normal; color: #5f6368; }

/* Phones and small screens: one banner ad under the leaderboard. */
.ad-inline .ad-body { display: grid; grid-template-columns: 1fr auto; align-items: center; column-gap: 12px; }
.ad-inline .ad-tag, .ad-inline .ad-title, .ad-inline .ad-text { grid-column: 1; }
.ad-inline .ad-cta { grid-column: 2; grid-row: 1 / span 3; margin: 0; width: auto; }
.ad-inline .ad-title { font-size: 16px; }
.ad-inline .ad-tag { justify-self: start; }

/* Wide screens: skyscraper rails either side of the game. */
@media (min-width: 1000px) {
  .ad-rail {
    display: flex;
    flex-direction: column;
    gap: 16px;
    flex: 0 0 210px;
    position: sticky;
    top: 16px;
    padding-top: 58px;
  }
  .ad-rail .ad-body { min-height: 230px; justify-content: center; }
  .ad-inline { display: none; }
}

@media (max-width: 400px) {
  .ad-inline .ad-body { grid-template-columns: 1fr; row-gap: 8px; }
  .ad-inline .ad-cta { grid-column: 1; grid-row: auto; width: 100%; }
}
.ad-link { display: block; text-align: center; text-decoration: none; font-weight: bold; animation: none; }
.ad-link:hover { filter: brightness(1.08); }
