:root {
  --bg: #d8d8d5;
  --panel: #cecec6;
  --upheads-blue: #12259c;
  --ink: #3f475a;
  --pixel-purple: #675df0;
  --pixel-purple-dark: #1b279f;
  --pixel-yellow: #fdb515;
  --white: #ffffff;
  --lennart-photo: url("./assets/lennart.jpg");
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: Manrope, sans-serif;
  color: var(--ink);
  background: var(--bg);
}

.bg-shape {
  display: none;
}

.app {
  max-width: 1200px;
  margin: 0 auto;
  padding: 18px;
}

.topbar {
  display: flex;
  justify-content: space-between;
  align-items: flex-end;
  gap: 16px;
  flex-wrap: wrap;
  border-top: 1px solid rgba(63, 71, 90, 0.2);
  padding-top: 14px;
}

.brand {
  display: grid;
  gap: 8px;
}

.brand-logo {
  display: block;
  width: min(360px, 42vw);
  height: auto;
}

.brand-logo-fallback {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-size: 1.2rem;
  color: var(--upheads-blue);
}

.brand-tag {
  margin: 0;
  font-family: "Press Start 2P", monospace;
  font-size: 1.02rem;
  line-height: 1.5;
}

.topbar-actions {
  display: flex;
  align-items: flex-end;
  flex-wrap: wrap;
  gap: 10px;
}

.name-input-wrap {
  display: grid;
  gap: 5px;
  font-family: "Press Start 2P", monospace;
  font-size: 0.62rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.name-input {
  width: 190px;
  border: 0;
  border-radius: 0;
  padding: 6px 0;
  font: inherit;
  font-size: 0.86rem;
  font-family: "Press Start 2P", monospace;
  color: var(--ink);
  background: transparent;
}

.name-input[readonly] {
  opacity: 1;
}

.name-input:focus {
  outline: none;
}

.btn {
  border: 3px solid var(--ink);
  border-radius: 0;
  padding: 10px 13px;
  font-family: "Press Start 2P", monospace;
  font-size: 0.68rem;
  cursor: pointer;
  background: #f0f0eb;
  color: var(--ink);
  box-shadow: 4px 4px 0 #747d90;
}

.btn:active {
  transform: translate(2px, 2px);
  box-shadow: 2px 2px 0 #747d90;
}

.btn-primary {
  background: var(--pixel-purple);
  color: var(--white);
  border-color: #2d3181;
}

.layout {
  display: grid;
  grid-template-columns: minmax(300px, 1fr) minmax(300px, 410px);
  gap: 18px;
  margin-top: 16px;
}

.card {
  background: var(--panel);
  border: 2px solid rgba(63, 71, 90, 0.15);
  border-radius: 0;
  box-shadow: none;
}

.game-wrap {
  display: grid;
  place-items: center;
  padding: 18px;
}

#board {
  width: min(100%, 390px);
  height: auto;
  border-radius: 0;
  background: #0f1530;
  border: 6px solid #000;
}

.sidebar {
  display: grid;
  gap: 14px;
}

.stat-card,
.desk-card {
  padding: 16px;
}

.desk-card {
  padding-top: 58px;
  padding-bottom: 28px;
}

h2 {
  margin: 0 0 10px;
  font-family: "Press Start 2P", monospace;
  font-size: 0.8rem;
  line-height: 1.5;
  text-transform: uppercase;
}

.stat-card p {
  margin: 8px 0;
  font-family: "Press Start 2P", monospace;
  font-size: 0.74rem;
  line-height: 1.5;
}

.next-piece {
  margin-top: 12px;
  padding: 10px;
  background: #dfdfd7;
  border: 2px solid rgba(63, 71, 90, 0.2);
}

.next-piece p {
  margin: 0 0 8px;
  font-family: "Press Start 2P", monospace;
  font-size: 0.66rem;
}

#next {
  background: #d7d7d0;
  border-radius: 0;
  border: 2px solid rgba(63, 71, 90, 0.2);
}

.desk-single {
  display: grid;
  gap: 10px;
  margin-top: 34px;
}

.speech {
  position: relative;
  padding: 14px 12px 14px;
  background: var(--pixel-purple);
  color: #f8f8ff;
  border: 4px solid var(--pixel-purple-dark);
  border-radius: 0;
  font-family: "Press Start 2P", monospace;
  font-size: 0.69rem;
  line-height: 1.65;
  min-height: 132px;
  display: flex;
  align-items: center;
}

.speech::after {
  content: "";
  position: absolute;
  bottom: -14px;
  left: calc(50% - 10px);
  width: 20px;
  height: 20px;
  background: var(--pixel-purple);
  border-right: 4px solid var(--pixel-purple-dark);
  border-bottom: 4px solid var(--pixel-purple-dark);
  transform: rotate(45deg);
}

.lennart-avatar {
  width: 126px;
  height: 126px;
  margin: 10px auto 0;
  border-radius: 0;
  overflow: hidden;
  border: 4px solid #000;
  background: #c7d5e6;
  position: relative;
}

.lennart-face {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.avatar-name {
  margin: 0;
  text-align: center;
  font-family: "Press Start 2P", monospace;
  font-size: 0.66rem;
  letter-spacing: 0.03em;
}

.leaderboard-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(25, 32, 48, 0.6);
  z-index: 20;
}

.leaderboard-modal[hidden] {
  display: none;
}

.username-modal {
  position: fixed;
  inset: 0;
  display: grid;
  place-items: center;
  padding: 16px;
  background: rgba(25, 32, 48, 0.7);
  z-index: 30;
}

.username-modal[hidden] {
  display: none;
}

.username-card {
  width: min(460px, 100%);
  padding: 18px;
  background: #d1d1c8;
  border: 3px solid var(--ink);
  display: grid;
  gap: 10px;
}

.leaderboard-card {
  width: min(560px, 100%);
  padding: 18px;
  background: #d1d1c8;
  border: 3px solid var(--ink);
}

.leaderboard-list {
  margin: 12px 0 14px;
  padding-left: 0;
  list-style: none;
  display: grid;
  gap: 8px;
}

.leaderboard-item {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 10px;
  align-items: center;
  border: 2px solid rgba(63, 71, 90, 0.22);
  border-radius: 0;
  padding: 8px 9px;
  background: #ecece5;
}

.leader-rank,
.leader-score,
.leader-meta,
.small,
.leaderboard-card h2,
.leaderboard-card strong {
  font-family: "Press Start 2P", monospace;
}

.leader-rank {
  font-size: 0.66rem;
}

.leader-meta {
  margin: 2px 0 0;
  font-size: 0.53rem;
  line-height: 1.6;
}

.leader-score {
  font-size: 0.64rem;
}

.small {
  font-size: 0.54rem;
  line-height: 1.6;
}

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
  }

  .game-wrap {
    padding: 14px;
  }

  .leaderboard-item {
    grid-template-columns: 30px 1fr;
  }

  .leader-score {
    grid-column: 2 / 3;
    justify-self: end;
  }
}
