:root {
  --paper: #fbf1e2;
  --card: #fff9ef;
  --ink: #46301f;
  --ink-soft: #6f5642;
  --terracotta: #b9562a;
  --terracotta-light: #cc7040;
  --blue: #3f5f86;
  --line: #c9a98a;
  --sketchy: 255px 18px 225px 18px / 18px 225px 18px 255px;
  --sketchy-alt: 18px 225px 18px 255px / 255px 18px 225px 18px;
}

[hidden] { display: none !important; }

* { box-sizing: border-box; }

html, body { margin: 0; min-height: 100%; }

body {
  background-color: var(--paper);
  background-image: repeating-linear-gradient(118deg, rgba(201, 140, 90, 0.07) 0 2px, transparent 2px 7px);
  color: var(--ink);
  font-family: "Fraunces", Georgia, "Times New Roman", serif;
  font-size: 17px;
  line-height: 1.4;
}

h1 {
  margin: 0;
  font-size: clamp(32px, 6vw, 56px);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.01em;
}

input {
  width: 100%;
  min-width: 0;
  padding: 12px 16px;
  border: 2px solid var(--ink);
  border-radius: var(--sketchy-alt);
  background: var(--card);
  color: var(--ink);
  font: inherit;
  font-size: 16px;
}

input::placeholder { color: var(--ink-soft); opacity: 1; }
input:focus-visible, button:focus-visible, a:focus-visible { outline: 3px solid var(--blue); outline-offset: 2px; }

button {
  padding: 12px 24px;
  border: 2px solid var(--ink);
  border-radius: var(--sketchy);
  background-color: var(--terracotta);
  background-image: repeating-linear-gradient(118deg, rgba(255, 255, 255, 0.1) 0 2px, transparent 2px 6px);
  color: #fffaf1;
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  touch-action: manipulation;
  user-select: none;
  -webkit-user-select: none;
  -webkit-tap-highlight-color: transparent;
}

button:active { background-color: #9c4620; transform: translateY(1px); }

.status { margin: 0; color: var(--ink-soft); font-size: 15px; }
.status:empty { display: none; }

.card {
  border: 2px solid var(--ink);
  border-radius: var(--sketchy);
  background: var(--card);
}

/* Lander: the drawing fills the screen, with the title on the empty wall above the sofa. */
.lander { position: relative; min-height: 100dvh; overflow: hidden; }

.lander-art {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: 49% 100%;
}

.lander-card {
  position: relative;
  display: grid;
  gap: 12px;
  width: 100%;
  padding: max(32px, 7dvh) 16px 16px;
  text-align: center;
}

.lander-card form {
  display: grid;
  gap: 8px;
  width: 100%;
  max-width: 420px;
  margin: 8px auto 0;
  padding: 16px;
}

/* Controls */
#controls { display: flex; flex-direction: column; min-height: 100dvh; }

.band { position: relative; flex: none; height: 26dvh; min-height: 150px; overflow: hidden; }
.band img { width: 100%; height: 100%; object-fit: cover; object-position: 49% 82%; display: block; }

.controls-title { padding: 16px 16px 0; text-align: center; }
.controls-title h1 { font-size: clamp(26px, 5vw, 40px); }

#menu { flex: 1; display: flex; flex-direction: column; gap: 12px; margin: 16px; }

#jump, #tug-open {
  flex: 1;
  min-height: 96px;
  font-size: clamp(32px, 10vmin, 64px);
  letter-spacing: 0.01em;
}

#tug-open { background-color: var(--blue); }

.quiet {
  flex: none;
  padding: 8px 16px;
  border: 0;
  background: none;
  color: var(--blue);
  font-weight: 400;
  text-decoration: underline;
}

.quiet:active { background: none; }

#message { display: grid; gap: 8px; margin: 0 16px 16px; padding: 16px; }
#message input { text-transform: uppercase; }
#message input::placeholder { text-transform: none; }
#message h2 { margin: 0; font-size: 18px; font-weight: 600; }

/* Now playing */
#now { display: flex; gap: 12px; align-items: center; margin: 16px 16px 0; padding: 12px; }
#now-art { flex: none; width: 76px; height: 76px; border: 2px solid var(--ink); border-radius: 6px; object-fit: cover; }
.now-text { flex: 1; min-width: 0; }
.now-text p { margin: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.now-label { color: var(--ink-soft); font-size: 13px; }
#now-title { font-size: 19px; font-weight: 600; }
#now-artist { color: var(--ink-soft); font-size: 15px; }
#now-track { position: relative; height: 4px; margin: 10px 8px 4px; border-radius: 2px; background: var(--line); }
#now-train { position: absolute; top: -4px; left: 0; width: 18px; height: 12px; margin-left: -9px; border: 2px solid var(--ink); border-radius: 3px; background: var(--terracotta); transition: left 5s linear; }

/* Leaderboard */
#scores, #claim { margin: 0 16px 16px; padding: 16px; }
#claim { display: grid; gap: 8px; background: #fbe7cf; }
#scores h2, #claim h2 { margin: 0 0 8px; font-size: 18px; font-weight: 600; }
#score-list { display: grid; gap: 8px; margin: 0; padding: 0; list-style: none; }
#score-list:empty { display: none; }
#score-list li { display: flex; gap: 10px; align-items: center; }
#score-list .rank { flex: none; width: 18px; color: var(--ink-soft); text-align: right; }
#score-list .portrait { flex: none; display: grid; place-items: center; width: 48px; height: 48px; border: 2px solid var(--ink); border-radius: 50%; background: var(--paper); object-fit: cover; font-weight: 600; }
#score-list .name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
#score-list b { flex: none; font-size: 19px; }

/* Tug of war */
#tug { display: flex; flex-direction: column; gap: 16px; min-height: 100dvh; padding: 24px 16px; text-align: center; }
#tug-join { display: grid; gap: 8px; padding: 16px; }
.tug-message { margin: 0; font-size: 22px; font-weight: 600; }
#tug-rope { position: relative; height: 12px; margin: 8px 12px; border-radius: 6px; background: var(--line); }
#tug-knot { position: absolute; top: -8px; left: 50%; width: 28px; height: 28px; margin-left: -14px; border: 2px solid var(--ink); border-radius: 50%; background: var(--terracotta); transition: left 0.15s linear; }
#pull { flex: 1; min-height: 240px; font-size: clamp(48px, 16vmin, 96px); }
#tug-again { min-height: 96px; font-size: clamp(28px, 8vmin, 48px); }
#tug .quiet { align-self: center; }

/* Owner page */
.owner { max-width: 640px; margin: 0 auto; padding: 32px 16px; }
.owner .card { display: grid; gap: 12px; margin-top: 16px; padding: 24px; overflow-wrap: anywhere; }
.owner p { margin: 0; }
.owner a { color: var(--blue); }
.owner textarea {
  width: 100%;
  padding: 12px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: var(--paper);
  color: var(--ink);
  font: 14px ui-monospace, Menlo, monospace;
}
.owner form { margin: 0; }

@media (min-width: 760px) {
  .lander-card form { max-width: 560px; grid-template-columns: 1fr auto; align-items: center; }
  .lander-card .status { grid-column: 1 / -1; }
  #controls { max-width: 760px; margin: 0 auto; }
  .band { height: 30dvh; }
  #menu { flex-direction: row; flex-wrap: wrap; }
  #jump, #tug-open { min-height: 200px; }
  .quiet { flex-basis: 100%; }
}
