:root {
  --red: #ec161c;
  --pink: #e8bfd8;
  --blue: #99d4dd;
  --green: #78bf51;
  --forest: #477b36;
  --bg: #477b36;
  --bg-accent: #2f5725;
  --card: rgba(255, 255, 255, 0.16);
  --card-strong: rgba(255, 255, 255, 0.22);
  --line: rgba(255, 255, 255, 0.22);
  --text: #f8fff4;
  --muted: #d9ecd0;
  --primary: #99d4dd;
  --primary-ink: #203c19;
  --shadow: 0 20px 50px rgba(0, 0, 0, 0.28);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: Inter, "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  background:
    linear-gradient(135deg, rgba(232, 191, 216, 0.35), transparent 28%),
    radial-gradient(circle at 88% 4%, rgba(236, 22, 28, 0.22), transparent 24%),
    radial-gradient(circle at 10% 92%, rgba(153, 212, 221, 0.32), transparent 30%),
    linear-gradient(160deg, var(--bg), var(--bg-accent) 62%, #264b20);
  color: var(--text);
  overflow-x: hidden;
}

.layout {
  max-width: 1080px;
  margin: 0 auto;
  padding: 0.85rem;
  display: grid;
  gap: 1rem;
  min-height: 100dvh;
}

.landing-view {
  display: grid;
  gap: 1rem;
}

body.in-game {
  overflow-y: auto;
}

body.in-game .landing-view {
  display: none;
}

.hero-shell,
.game-screen,
.docs-screen {
  backdrop-filter: blur(24px);
}

.docs-screen summary {
  cursor: pointer;
  font-weight: 700;
  list-style: none;
}

.docs-screen summary::-webkit-details-marker {
  display: none;
}

.docs-screen[open] summary {
  margin-bottom: 0.9rem;
}

.card {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.19), rgba(255, 255, 255, 0.10));
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 1.15rem;
  box-shadow: var(--shadow);
}

.subcard {
  background:
    linear-gradient(180deg, rgba(255, 255, 255, 0.24), rgba(255, 255, 255, 0.13));
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 1rem;
  backdrop-filter: blur(18px);
}

.hero-shell {
  position: relative;
  overflow: hidden;
  border-color: rgba(255, 255, 255, 0.3);
}

.hero-shell::before {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 0.5rem;
  background: linear-gradient(90deg, var(--red) 0 20%, var(--pink) 20% 40%, var(--blue) 40% 60%, var(--green) 60% 80%, var(--forest) 80% 100%);
}

.hero {
  padding: 0.8rem 0 0.25rem;
}

.hero-brand {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.hero-logo {
  width: 94px;
  height: 94px;
  object-fit: contain;
  filter: drop-shadow(0 16px 18px rgba(0, 0, 0, 0.28));
}

.hero h1 {
  margin: 0;
  font-family: "Trebuchet MS", "Segoe UI", sans-serif;
  font-size: clamp(2.05rem, 5vw, 3.55rem);
  letter-spacing: -0.04em;
  color: #ffffff;
  line-height: 0.95;
  text-shadow:
    0 4px 0 rgba(47, 87, 37, 0.68),
    0 10px 22px rgba(0, 0, 0, 0.25);
}

.hero h1 span {
  display: inline-block;
}

.hero h1 span:first-child {
  color: #ffffff;
}

.hero h1 span:last-child {
  color: #fce0ee;
}

.eyebrow {
  margin: 0 0 0.35rem;
  color: #ffedf7;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-size: 0.72rem;
  font-weight: 900;
}

.subtitle {
  margin: 0.35rem 0 0;
  color: #f2fff0;
  max-width: 48rem;
  line-height: 1.5;
}

.landing-stack {
  display: grid;
  gap: 1rem;
}

.primary-cta {
  width: 100%;
  padding: 1.02rem 1.1rem;
  border-radius: 22px;
  font-size: 1rem;
  font-weight: 900;
  background:
    radial-gradient(circle at 13% 24%, rgba(255, 255, 255, 0.72) 0 0.22rem, transparent 0.26rem),
    radial-gradient(circle at 88% 30%, rgba(255, 255, 255, 0.56) 0 0.17rem, transparent 0.21rem),
    linear-gradient(165deg, rgba(255, 255, 255, 0.45), rgba(255, 255, 255, 0) 38%),
    linear-gradient(135deg, var(--blue), var(--green) 52%, #ffd96a);
  color: var(--primary-ink);
  border: 3px solid rgba(255, 255, 255, 0.78);
  box-shadow:
    inset 0 -3px 0 rgba(47, 87, 37, 0.22),
    inset 0 2px 0 rgba(255, 255, 255, 0.58),
    0 8px 0 rgba(47, 87, 37, 0.5),
    0 16px 30px rgba(0, 0, 0, 0.23);
}

.section-copy {
  margin: 0 0 1rem;
  color: var(--muted);
  line-height: 1.55;
}

.agent-kicker {
  margin: 0 0 0.45rem;
  color: #ffffff;
  font-weight: 900;
}

.agent-command-wrap {
  margin-top: 0.8rem;
}

.agent-command-title {
  margin-bottom: 0.45rem;
  font-size: 0.88rem;
  color: var(--muted);
  font-weight: 600;
}

.agent-command,
.docs pre {
  overflow-x: auto;
  max-width: 100%;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  word-break: break-word;
  background: rgba(47, 87, 37, 0.82);
  color: #f7fff4;
  padding: 0.9rem;
  border-radius: 12px;
  border: 1px solid rgba(153, 212, 221, 0.28);
  margin: 0;
}

.agent-doc-blurb {
  margin-top: 0.75rem;
  color: var(--muted);
  font-size: 0.92rem;
}

.agent-instructions {
  margin-top: 1rem;
  padding: 0.85rem;
  background: rgba(153, 212, 221, 0.18);
  border-radius: 12px;
  border: 1px solid rgba(153, 212, 221, 0.28);
}

.agent-instructions h3 {
  margin: 0 0 0.6rem;
  font-size: 1rem;
  color: #ffffff;
}

.agent-instructions ol {
  margin: 0;
  padding-left: 1.4rem;
  color: var(--muted);
  line-height: 1.65;
}

.agent-instructions li {
  margin-bottom: 0.4rem;
}

.agent-instructions code {
  color: #ffffff;
  background: rgba(71, 123, 54, 0.5);
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  font-size: 0.88rem;
}

.agent-command-note {
  margin-top: 0.55rem;
  color: #e8bfd8;
  font-size: 0.85rem;
  font-style: italic;
}

.agent-start-box {
  margin-top: 0.9rem;
  padding: 0.9rem;
  background:
    linear-gradient(135deg, rgba(232, 191, 216, 0.32), rgba(153, 212, 221, 0.24));
  border: 1px solid rgba(255, 255, 255, 0.24);
  border-radius: 14px;
}

.agent-start-box h3 {
  margin: 0 0 0.55rem;
  color: #ffffff;
}

.agent-start-box p {
  margin: 0 0 0.5rem;
  color: var(--muted);
  line-height: 1.5;
}

.agent-link-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 0.75rem;
}

.secondary-btn {
  background: rgba(232, 191, 216, 0.26);
  color: var(--text);
  border-color: var(--line);
}

.agent-link-note {
  margin-top: 0.6rem;
  color: #f3e5ee;
  font-size: 0.88rem;
}

h2,
h3 {
  margin-top: 0;
}

.form-row {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  margin-bottom: 0.75rem;
}

.form-row.compact {
  margin-top: -0.25rem;
}

.form-row label {
  min-width: 120px;
  font-weight: 600;
}

.hint {
  color: var(--muted);
  font-size: 0.9rem;
}

input,
button {
  font: inherit;
  border-radius: 11px;
  border: 1px solid var(--line);
  padding: 0.75rem 0.9rem;
}

input {
  background: rgba(255, 255, 255, 0.16);
  color: var(--text);
}

input::placeholder {
  color: #e3eadf;
}

button {
  background: linear-gradient(180deg, var(--blue), var(--green));
  color: var(--primary-ink);
  border-color: transparent;
  cursor: pointer;
  font-weight: 600;
}

.landing-view button,
.donate-cta {
  position: relative;
  overflow: hidden;
  border-radius: 18px 22px 17px 21px;
  border: 2px solid rgba(255, 255, 255, 0.62);
  background:
    radial-gradient(circle at 14% 26%, rgba(255, 255, 255, 0.66) 0 0.16rem, transparent 0.2rem),
    linear-gradient(165deg, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0) 42%),
    linear-gradient(180deg, var(--blue), var(--green));
  box-shadow:
    inset 0 -2px 0 rgba(47, 87, 37, 0.22),
    inset 0 2px 0 rgba(255, 255, 255, 0.46),
    0 5px 0 rgba(47, 87, 37, 0.38),
    0 10px 20px rgba(0, 0, 0, 0.16);
}

.landing-view button::after,
.donate-cta::after {
  content: '';
  position: absolute;
  left: 0.9rem;
  right: 0.9rem;
  top: 0.34rem;
  height: 0.18rem;
  border-radius: 999px;
  background:
    linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.82) 18% 42%, transparent 58%),
    radial-gradient(circle, rgba(255, 255, 255, 0.86) 0 0.11rem, transparent 0.13rem);
  transform: rotate(-1.4deg);
  pointer-events: none;
}

.donate-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3rem;
  padding: 0.74rem 1rem;
  color: #fff8fb;
  font-size: 0.94rem;
  font-weight: 900;
  line-height: 1.25;
  text-align: center;
  text-decoration: none;
  background:
    radial-gradient(circle at 12% 24%, rgba(255, 255, 255, 0.68) 0 0.16rem, transparent 0.2rem),
    radial-gradient(circle at 86% 24%, rgba(255, 255, 255, 0.5) 0 0.13rem, transparent 0.17rem),
    linear-gradient(165deg, rgba(255, 255, 255, 0.36), rgba(255, 255, 255, 0) 42%),
    linear-gradient(135deg, var(--red), var(--pink) 48%, var(--blue));
  text-shadow: 0 2px 0 rgba(71, 123, 54, 0.36);
}

.donate-cta:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

.donate-cta:active {
  transform: translateY(0);
  box-shadow:
    inset 0 -1px 0 rgba(47, 87, 37, 0.18),
    inset 0 2px 0 rgba(255, 255, 255, 0.38),
    0 2px 0 rgba(47, 87, 37, 0.38),
    0 6px 14px rgba(0, 0, 0, 0.14);
}

.landing-view .primary-cta::after {
  height: 0.22rem;
  opacity: 0.95;
}

.landing-view .secondary-btn::after {
  opacity: 0.45;
}

.actions button:nth-child(2),
#joinCodeBtn {
  background:
    radial-gradient(circle at 85% 24%, rgba(255, 255, 255, 0.58) 0 0.15rem, transparent 0.19rem),
    linear-gradient(165deg, rgba(255, 255, 255, 0.38), transparent 42%),
    linear-gradient(135deg, var(--pink), var(--blue));
}

#createRoomBtn,
#copyBootstrapCommandBtn {
  background:
    radial-gradient(circle at 86% 24%, rgba(255, 255, 255, 0.58) 0 0.15rem, transparent 0.19rem),
    linear-gradient(165deg, rgba(255, 255, 255, 0.38), transparent 42%),
    linear-gradient(135deg, var(--green), var(--blue));
}

#showHumanPanelBtn {
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

button:hover {
  filter: brightness(1.05);
  transform: translateY(-1px);
}

button {
  transition: transform 140ms ease, filter 140ms ease, box-shadow 140ms ease, opacity 140ms ease;
}

button:active {
  transform: translateY(0);
}

.landing-view button:active {
  box-shadow:
    inset 0 -1px 0 rgba(47, 87, 37, 0.18),
    inset 0 2px 0 rgba(255, 255, 255, 0.38),
    0 2px 0 rgba(47, 87, 37, 0.38),
    0 6px 14px rgba(0, 0, 0, 0.14);
}

button[disabled] {
  opacity: 0.5;
  cursor: default;
}

.actions {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.code-row input {
  width: 120px;
  text-transform: uppercase;
}

.status {
  color: var(--muted);
  font-size: 0.95rem;
}

.game-screen {
  padding: 1rem;
  min-height: calc(100dvh - 2rem);
  display: flex;
  flex-direction: column;
  gap: 0.9rem;
}

.game-stage {
  display: grid;
  gap: 1rem;
}

.game-screen h2 {
  margin-bottom: 0.2rem;
}

.game-topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.game-status-wrap {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 0.35rem;
}

.status-pill {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 120px;
  min-height: 38px;
  padding: 0.55rem 0.85rem;
  border-radius: 999px;
  background: rgba(153, 212, 221, 0.2);
  color: #f7fff4;
  border: 1px solid rgba(153, 212, 221, 0.4);
  font-size: 0.82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-text {
  color: var(--muted);
  font-size: 0.92rem;
  text-align: right;
  max-width: 320px;
}

.room-meta {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(130px, 1fr));
  gap: 0.6rem;
  align-items: stretch;
  margin-bottom: 0.8rem;
}

.room-meta span,
.room-meta button {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 52px;
  padding: 0.8rem 0.9rem;
  border-radius: 16px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--line);
  text-align: center;
}

.room-meta span {
  cursor: default;
}

.room-meta span:has(strong) {
  cursor: pointer;
}

.room-meta span:has(strong):hover {
  background: rgba(255, 255, 255, 0.14);
}

.room-meta strong {
  margin-left: 0.35rem;
}

.room-meta strong:active {
  opacity: 0.7;
}

.action-meta {
  grid-template-columns: minmax(180px, 1.3fr) 1fr 1fr;
}

.word-picker {
  border: 1px solid var(--line);
  border-radius: 18px;
  padding: 0.9rem;
  margin-bottom: 0.9rem;
  background: linear-gradient(180deg, rgba(68, 212, 200, 0.12), rgba(255, 255, 255, 0.06));
}

.word-picker h3 {
  margin-bottom: 0.7rem;
}

.word-options {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
}

.word-option {
  background: #0b5f59;
  min-width: 120px;
}

.game-grid {
  display: grid;
  grid-template-columns: minmax(0, 1.7fr) minmax(300px, 1fr);
  gap: 1rem;
  align-items: start;
}

.canvas-wrap {
  min-width: 0;
}

.chat-wrap {
  min-width: 0;
}

.players-strip {
  margin-bottom: 0.2rem;
}

.canvas-wrap,
.chat-wrap,
.players-wrap {
  border: 1px solid var(--line);
  border-radius: 20px;
  padding: 0.9rem;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.canvas-wrap h3,
.chat-wrap h3,
.players-wrap h3 {
  margin-bottom: 0.75rem;
}

#drawCanvas {
  width: 100%;
  height: auto;
  background: rgba(255, 255, 255, 0.98);
  border: 1px dashed rgba(28, 46, 68, 0.35);
  border-radius: 16px;
  touch-action: none;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.chat-log {
  height: 320px;
  overflow-y: auto;
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 0.75rem;
  margin-bottom: 0.65rem;
  background: rgba(4, 12, 24, 0.36);
}

.chat-item {
  margin-bottom: 0.45rem;
  font-size: 0.95rem;
}

.chat-item strong {
  color: #f5fbff;
}

.chat-item.system {
  color: #7ce9df;
  font-style: italic;
}

.chat-item.correct {
  color: #76efaf;
  font-weight: 600;
}

#chatForm {
  display: flex;
  gap: 0.5rem;
}

#chatInput {
  flex: 1;
}

#playersList {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

#playersList li {
  margin-bottom: 0.5rem;
  padding: 0.75rem 0.85rem;
  border-radius: 14px;
  background: rgba(4, 12, 24, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.players-strip #playersList {
  display: flex;
  gap: 0.55rem;
  overflow-x: auto;
  padding-bottom: 0.2rem;
  scroll-snap-type: x proximity;
}

.players-strip #playersList li {
  min-width: 155px;
  margin-bottom: 0;
  flex: 0 0 auto;
  scroll-snap-align: start;
}

code {
  color: #99d4dd;
}

@media (max-width: 860px) {
  .layout {
    padding: 0.75rem;
  }

  .game-grid {
    grid-template-columns: 1fr;
    gap: 0.85rem;
  }

  .hero-brand {
    align-items: flex-start;
    flex-direction: column;
    gap: 0.75rem;
  }

  .hero-logo {
    width: 60px;
    height: 60px;
  }

  .card,
  .subcard {
    padding: 0.9rem;
    border-radius: 20px;
  }

  .game-screen {
    min-height: auto;
    padding-bottom: 1.1rem;
  }

  .game-topbar {
    flex-direction: column;
    align-items: flex-start;
  }

  .game-status-wrap {
    width: 100%;
    align-items: flex-start;
  }

  .status-text {
    text-align: left;
    max-width: none;
  }

  .room-meta,
  .action-meta {
    grid-template-columns: 1fr 1fr;
  }

  .room-meta span,
  .room-meta button {
    min-height: 46px;
    padding: 0.7rem;
    font-size: 0.92rem;
  }

  .action-meta {
    grid-template-columns: 1fr;
  }

  .canvas-wrap,
  .chat-wrap,
  .players-wrap {
    padding: 0.8rem;
  }

  .players-strip {
    order: 1;
  }

  .game-grid {
    order: 2;
  }

  .chat-wrap {
    order: 3;
  }

  #drawCanvas {
    max-height: 34dvh;
    object-fit: contain;
  }

  .form-row,
  .vertical-mobile {
    flex-wrap: wrap;
    align-items: stretch;
  }

  .form-row label,
  .stacked-mobile label {
    min-width: 100%;
  }

  .vertical-mobile button,
  .code-row input,
  .code-row button,
  .agent-link-actions button,
  input,
  button {
    width: 100%;
  }

  #chatForm {
    flex-direction: column;
  }

  .chat-wrap h3,
  .canvas-wrap h3,
  .players-wrap h3 {
    margin-bottom: 0.55rem;
  }

  .chat-log {
    height: 180px;
  }

  .players-strip #playersList li {
    min-width: 132px;
    padding: 0.65rem 0.7rem;
    font-size: 0.9rem;
  }
}
