:root {
  --bg: #f6f7fb;
  --paper: #ffffff;
  --text: #151820;
  --muted: #5d6675;
  --line: #d8dde7;
  --blue: #2563eb;
  --red: #dc2626;
  --green: #16a34a;
  --yellow: #eab308;
}

body.dark {
  --bg: #10131a;
  --paper: #171c26;
  --text: #f4f6fb;
  --muted: #aab3c2;
  --line: #343c4d;
  --blue: #60a5fa;
}

body.dark .screen-tile,
body.dark .tic-cell {
  background: #111827;
}

body.dark .screen-tile:hover,
body.dark nav button:hover,
body.dark nav button.active,
body.dark .tile-icon,
body.dark .card-icon,
body.dark .fun-symbol {
  background: #1f2937;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  color: var(--text);
  background: var(--bg);
  font-family: Arial, Helvetica, sans-serif;
  overflow-x: hidden;
}

button {
  font-family: inherit;
}

a {
  color: inherit;
}

.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 20px;
  padding: 18px clamp(16px, 5vw, 56px);
  background: var(--paper);
  border-bottom: 1px solid var(--line);
}

.account-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 40px;
  padding: 4px 10px 4px 4px;
  color: var(--text);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 999px;
  font-weight: 700;
  cursor: pointer;
}

.account-avatar {
  display: grid;
  width: 32px;
  height: 32px;
  place-items: center;
  color: #fff;
  background: var(--blue);
  background-position: center;
  background-size: cover;
  border-radius: 999px;
  font-size: 0.9rem;
  font-weight: 800;
}

.account-avatar.big {
  width: 96px;
  height: 96px;
  font-size: 2rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  color: var(--text);
  background: transparent;
  border: 0;
  font-size: 1.1rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.brand-mark {
  display: grid;
  width: 36px;
  height: 36px;
  place-items: center;
  color: #fff;
  background: var(--blue);
  border-radius: 6px;
  font-weight: 700;
}

nav {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

nav button {
  padding: 8px 10px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-size: 0.95rem;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
}

.mode-toggle {
  border: 1px solid var(--line);
}

nav button:hover,
nav button.active {
  color: var(--blue);
  background: #eef3ff;
}

.page {
  display: none;
}

.page.active {
  display: block;
}

.section-shell {
  width: min(1040px, calc(100% - 32px));
  margin: 0 auto;
  padding: 52px 0;
}

.top-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.hero {
  display: grid;
  min-height: 520px;
  grid-template-columns: minmax(0, 0.9fr) minmax(300px, 1.1fr);
  align-items: center;
  gap: 34px;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 14px;
  font-size: clamp(3rem, 8vw, 5.7rem);
  line-height: 0.95;
}

h2 {
  margin-bottom: 8px;
  font-size: clamp(2rem, 4vw, 3rem);
  line-height: 1;
}

h3 {
  margin-bottom: 10px;
  font-size: 1.35rem;
}

p {
  color: var(--muted);
  line-height: 1.6;
}

.hero-copy p {
  max-width: 500px;
  font-size: 1.1rem;
}

.hero-actions,
.guess-row,
.tool-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 10px;
}

.button {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--blue);
  border-radius: 6px;
  padding: 0 16px;
  color: #fff;
  background: var(--blue);
  font: 700 0.95rem/1 Arial, Helvetica, sans-serif;
  text-decoration: none;
  cursor: pointer;
}

.button.ghost {
  color: var(--blue);
  background: var(--paper);
}

.button.small {
  min-height: 38px;
  padding-inline: 14px;
  font-size: 0.9rem;
}

.hub-panel,
.game-card,
.fun-box,
.paint-studio,
.channel-card,
.tic-wrap {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.hub-panel {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 16px;
}

.screen-tile {
  position: relative;
  display: grid;
  min-height: 130px;
  align-content: center;
  justify-items: start;
  gap: 10px;
  padding: 18px;
  color: var(--text);
  background: linear-gradient(180deg, #ffffff, #f6f8fc);
  border: 1px solid var(--line);
  border-radius: 8px;
  font: 700 1rem/1 Arial, Helvetica, sans-serif;
  cursor: pointer;
  text-align: left;
  overflow: hidden;
}

.screen-tile::before {
  content: "";
  position: absolute;
  inset: 0 0 auto;
  height: 5px;
  background: var(--blue);
}

.screen-tile small {
  color: var(--muted);
  font-size: 0.82rem;
  font-weight: 700;
}

.screen-tile:hover {
  border-color: var(--blue);
  background: #eef3ff;
}

.tile-icon,
.card-icon,
.fun-symbol {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  color: var(--blue);
  background: #eef3ff;
  border-radius: 6px;
  font-weight: 800;
}

.section-heading {
  display: flex;
  align-items: end;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 20px;
}

.section-heading p {
  max-width: 360px;
  margin-bottom: 0;
}

.section-heading.compact {
  display: block;
}

.game-layout {
  display: grid;
  grid-template-columns: repeat(4, minmax(220px, 1fr));
  gap: 16px;
}

.game-card {
  min-height: 230px;
  padding: 20px;
}

.game-card p {
  min-height: 70px;
}

.mini-result {
  min-height: 0;
  margin: 12px 0 0;
  color: var(--text);
  font-weight: 700;
}

.choice-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.card-icon {
  margin-bottom: 18px;
}

.guess-row input {
  width: 82px;
  min-height: 38px;
  color: var(--text);
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  font: 700 1rem Arial, Helvetica, sans-serif;
}

.score-strip {
  display: flex;
  justify-content: space-between;
  margin-top: 26px;
  padding: 12px;
  color: var(--muted);
  background: #f6f7fb;
  border-radius: 6px;
}

.score-strip strong {
  color: var(--blue);
}

.tic-wrap {
  display: grid;
  grid-template-columns: minmax(280px, 420px) 1fr;
  gap: 24px;
  padding: 20px;
}

.tic-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tic-cell {
  aspect-ratio: 1;
  color: var(--blue);
  background: #f9fafc;
  border: 1px solid var(--line);
  border-radius: 8px;
  font-size: clamp(2.4rem, 8vw, 4rem);
  font-weight: 800;
  cursor: pointer;
}

.tic-cell:hover:empty {
  background: #eef3ff;
}

.tic-info {
  align-self: center;
}

.reaction-game {
  display: grid;
  gap: 18px;
  max-width: 620px;
  padding: 24px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.reaction-light {
  display: grid;
  min-height: 180px;
  place-items: center;
  color: #fff;
  background: #6b7280;
  border-radius: 8px;
  font-size: clamp(3rem, 10vw, 6rem);
  font-weight: 900;
}

.reaction-light.go {
  background: var(--green);
}

.reaction-light.stop {
  background: var(--red);
}

.copy-layout {
  display: grid;
  grid-template-columns: minmax(260px, 360px) 1fr;
  gap: 20px;
}

.copy-reference,
.copy-drawing,
.leaderboard-list {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 16px;
}

.copy-reference {
  position: relative;
  min-height: 320px;
}

.copy-reference img {
  display: block;
  width: 100%;
  max-height: 360px;
  object-fit: contain;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
}

.hidden-target {
  position: absolute;
  inset: 62px 16px 16px;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: var(--muted);
  background: var(--paper);
  border: 1px dashed var(--line);
  border-radius: 8px;
  text-align: center;
  font-weight: 700;
}

.copy-reference.hidden img {
  visibility: hidden;
}

.copy-reference.hidden .hidden-target {
  display: flex;
}

.tank-image {
  display: block;
  width: 100%;
  max-height: calc(100vh - 190px);
  object-fit: contain;
  background: #000;
  border: 1px solid var(--line);
  border-radius: 8px;
}

.leader-row {
  display: flex;
  justify-content: space-between;
  gap: 16px;
  padding: 14px 0;
  border-bottom: 1px solid var(--line);
}

.leader-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 0;
  border-bottom: 1px solid var(--line);
}

.leader-rank {
  min-width: 46px;
  color: var(--blue);
  font-size: 1.2rem;
}

.leader-user h3,
.leader-user p {
  margin: 0;
}

.leader-user p {
  font-size: 0.9rem;
}

.leader-row:last-child {
  border-bottom: 0;
}

.leader-row strong {
  color: var(--blue);
}

.gallery-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.gallery-empty,
.gallery-card {
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px;
}

.gallery-card img {
  display: block;
  width: 100%;
  aspect-ratio: 4 / 3;
  object-fit: contain;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 6px;
}

.gallery-card h3 {
  margin: 12px 0 4px;
  font-size: 1rem;
}

.gallery-card p {
  margin: 0;
  font-size: 0.9rem;
}

.account-panel {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 20px;
  padding: 20px;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.account-preview {
  display: grid;
  align-content: center;
  justify-items: center;
  gap: 10px;
  padding: 18px;
  background: var(--bg);
  border-radius: 8px;
  text-align: center;
}

.account-preview h3,
.account-preview p {
  margin: 0;
}

.account-form {
  display: grid;
  gap: 10px;
}

.auth-tabs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
  padding: 4px;
  background: var(--bg);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.auth-tabs button {
  min-height: 38px;
  color: var(--muted);
  background: transparent;
  border: 0;
  border-radius: 6px;
  font-weight: 800;
  cursor: pointer;
}

.auth-tabs button.active {
  color: #fff;
  background: var(--blue);
}

.account-form label {
  color: var(--muted);
  font-weight: 700;
}

.account-form:not(.signup-mode) label[for="login-name"],
.account-form:not(.signup-mode) #login-name,
.account-form:not(.signup-mode) label[for="login-pfp"],
.account-form:not(.signup-mode) #login-pfp,
.account-form:not(.signup-mode) label[for="login-pfp-file"],
.account-form:not(.signup-mode) #login-pfp-file,
.account-form:not(.signup-mode) label[for="login-description"],
.account-form:not(.signup-mode) #login-description {
  display: none;
}

.account-form input,
.account-form textarea {
  min-height: 42px;
  color: var(--text);
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  font: 700 1rem Arial, Helvetica, sans-serif;
}

.account-form textarea {
  min-height: 88px;
  padding-top: 10px;
  resize: vertical;
}

.auth-message {
  min-height: 24px;
  margin: 4px 0 0;
  font-weight: 700;
}

.auth-message.error {
  color: var(--red);
}

.auth-message.success {
  color: var(--green);
}

.split-section {
  display: grid;
  grid-template-columns: 0.85fr 1.15fr;
  align-items: center;
  gap: 22px;
}

.fun-box {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 18px;
  min-height: 140px;
  padding: 22px;
}

.fun-box p {
  margin: 0;
  color: var(--text);
  font-size: 1.1rem;
  font-weight: 700;
}

.paint-studio {
  padding: 16px;
}

.tool-row {
  margin-bottom: 12px;
  align-items: center;
}

.swatch {
  width: 28px;
  height: 28px;
  border: 2px solid transparent;
  border-radius: 5px;
  background: var(--swatch);
  cursor: pointer;
}

.swatch.active {
  border-color: var(--text);
}

.light-swatch {
  border-color: var(--line);
}

.brush-label {
  color: var(--muted);
  font-weight: 700;
}

#brush-size {
  accent-color: var(--blue);
}

canvas {
  display: block;
  width: 100%;
  max-height: 430px;
  aspect-ratio: 92 / 43;
  background: #fff;
  border: 1px solid var(--line);
  border-radius: 8px;
  touch-action: none;
}

#copy-canvas {
  max-height: 430px;
}

.credits-section {
  padding-bottom: 80px;
}

.channel-card {
  display: grid;
  grid-template-columns: 150px 1fr;
  align-items: center;
  gap: 22px;
  padding: 22px;
}

.channel-badge {
  display: grid;
  width: 150px;
  height: 150px;
  place-items: center;
  color: #fff;
  background: var(--blue);
  border-radius: 8px;
  font-size: 2.2rem;
  font-weight: 800;
}

.channel-card p {
  margin-bottom: 16px;
}

.youtube-link {
  display: inline-flex;
  min-height: 42px;
  align-items: center;
  border-radius: 6px;
  padding: 0 14px;
  color: #fff;
  background: var(--red);
  font-weight: 700;
  text-decoration: none;
}

@media (max-width: 820px) {
  .site-header,
  .section-heading,
  .hero,
  .split-section,
  .channel-card,
  .tic-wrap,
  .account-panel {
    display: block;
  }

  nav {
    justify-content: flex-start;
    margin-top: 14px;
  }

  .account-pill {
    margin-top: 14px;
  }

  .hero {
    min-height: 0;
  }

  .hero-copy p {
    max-width: 28ch;
  }

  .hub-panel {
    grid-template-columns: 1fr;
    margin-top: 28px;
  }

  .game-layout,
  .copy-layout {
    grid-template-columns: 1fr;
  }

  .tic-board {
    margin-bottom: 18px;
  }

  .section-heading p {
    margin-top: 10px;
  }

  .fun-box,
  .channel-card {
    margin-top: 20px;
  }

  .channel-badge {
    width: 128px;
    height: 128px;
    margin-bottom: 16px;
  }
}
