@font-face {
  font-family: "Pixelify Sans";
  font-style: normal;
  font-weight: 400;
  font-display: swap;
  src: url("assets/fonts/pixelify-sans-400.ttf") format("truetype");
}

@font-face {
  font-family: "Pixelify Sans";
  font-style: normal;
  font-weight: 500;
  font-display: swap;
  src: url("assets/fonts/pixelify-sans-500.ttf") format("truetype");
}

@font-face {
  font-family: "Pixelify Sans";
  font-style: normal;
  font-weight: 600;
  font-display: swap;
  src: url("assets/fonts/pixelify-sans-600.ttf") format("truetype");
}

@font-face {
  font-family: "Pixelify Sans";
  font-style: normal;
  font-weight: 700;
  font-display: swap;
  src: url("assets/fonts/pixelify-sans-700.ttf") format("truetype");
}

:root {
  color-scheme: light;
  --ink: #111827;
  --muted: #667085;
  --line: #d8dee8;
  --paper: #f7f5ef;
  --surface: #ffffff;
  --accent: #0f766e;
  --accent-strong: #115e59;
  --accent-blue: #2563eb;
  --soft-blue: #e0f2fe;
  --soft-green: #eef7f4;
  --soft-pink: #fff1f2;
  --warm: #f59e0b;
  --danger: #dc2626;
  --shadow: 0 18px 45px rgba(17, 24, 39, 0.12);
  --corner-images:
    url("assets/ui/corner-tl.svg?v=2"),
    url("assets/ui/corner-tr.svg?v=2"),
    url("assets/ui/corner-bl.svg?v=2"),
    url("assets/ui/corner-br.svg?v=2");
  --corner-positions:
    left 8px top 8px,
    right 8px top 8px,
    left 8px bottom 8px,
    right 8px bottom 8px;
  --corner-size: 24px 24px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  font-family: "Pixelify Sans", "Lucida Console", "Courier New", monospace;
}

html {
  min-height: 100%;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  background-color: var(--paper);
  background-image: url("assets/ui/pixel-grid.svg?v=2");
  background-size: 48px 48px;
  color: var(--ink);
  overflow-x: hidden;
}

button,
input,
select,
textarea {
  font: inherit;
  max-width: 100%;
}

button {
  cursor: pointer;
  touch-action: manipulation;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.58;
}

.app-shell {
  min-height: 100vh;
}

.screen {
  position: relative;
  isolation: isolate;
  width: min(1360px, 100%);
  margin: 0 auto;
  padding: 22px 16px calc(20px + var(--safe-bottom));
}

.entry-layout {
  position: relative;
  min-height: calc(100dvh - 64px);
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(320px, 430px);
  gap: 36px;
  align-items: center;
}

.entry-layout::after {
  content: "";
  position: absolute;
  right: clamp(6px, 5vw, 52px);
  bottom: clamp(10px, 6vh, 64px);
  z-index: -1;
  width: 120px;
  height: 120px;
  background: url("assets/ui/sparkles.svg") center / 48px 48px repeat;
  opacity: 0.45;
}

.game-select-layout {
  grid-template-columns: minmax(0, 0.9fr) minmax(420px, 1.1fr);
}

.game-select-panel {
  display: grid;
  gap: 16px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.game-select-card {
  display: grid;
  gap: 10px;
  min-height: 184px;
  border: 2px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  color: var(--ink);
  text-align: left;
  box-shadow: 4px 4px 0 rgba(17, 24, 39, 0.06);
}

.game-select-card.selected {
  border-color: var(--accent);
  background: var(--soft-green);
  box-shadow: 5px 5px 0 rgba(15, 118, 110, 0.16);
}

.game-select-card.locked {
  background: #f8fafc;
  color: #475467;
}

.game-select-card strong {
  font-size: 28px;
  line-height: 1;
}

.game-select-card small {
  color: var(--muted);
  font-size: 14px;
  font-weight: 700;
  line-height: 1.25;
}

.game-select-card > span:last-child {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  align-items: center;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

.game-status {
  width: fit-content;
  border: 1px solid #b7d8d0;
  border-radius: 999px;
  background: #fff;
  padding: 5px 9px;
  color: var(--accent-strong);
  font-size: 12px;
  font-weight: 900;
  text-transform: uppercase;
}

.game-select-card.locked .game-status {
  border-color: #d8dee8;
  color: #667085;
}

.back-action {
  margin-top: 10px;
}

.brand-mark {
  width: 74px;
  height: 74px;
  margin-bottom: 14px;
  image-rendering: pixelated;
  filter: drop-shadow(6px 8px 0 rgba(17, 24, 39, 0.08));
}

.brand-block h1 {
  max-width: 760px;
  margin: 0;
  font-size: 62px;
  line-height: 0.95;
  letter-spacing: 0;
}

.game-tagline {
  max-width: 560px;
  margin: 16px 0 0;
  color: var(--muted);
  font-size: 24px;
  font-weight: 600;
}

.eyebrow,
.section-kicker {
  display: flex;
  gap: 6px;
  align-items: center;
  width: fit-content;
  margin: 0 0 8px;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.ui-icon {
  width: 19px;
  height: 19px;
  flex: 0 0 auto;
  object-fit: contain;
  image-rendering: pixelated;
}

.game-card {
  display: grid;
  gap: 4px;
  margin-bottom: 16px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #eef7f4;
  padding: 12px;
}

.game-card span {
  display: inline-flex;
  gap: 7px;
  align-items: center;
}

.game-card span,
.game-card small {
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 800;
}

.game-card strong {
  font-size: 24px;
  line-height: 1;
}

.entry-panel,
.host-panel {
  background: var(--surface);
  background-image: var(--corner-images);
  background-repeat: no-repeat;
  background-position: var(--corner-positions);
  background-size: var(--corner-size);
  border: 1px solid var(--line);
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 22px;
}

label {
  display: grid;
  gap: 8px;
  margin-bottom: 16px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

input,
select,
textarea {
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 12px;
  background: #fff;
  color: var(--ink);
}

textarea {
  min-height: 132px;
  padding: 12px;
  resize: vertical;
  line-height: 1.25;
}

.split-actions,
.submit-row {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
  align-items: center;
}

.submit-row {
  display: flex;
  flex-wrap: wrap;
}

.submit-row .primary-action,
.submit-row .secondary-action {
  min-width: 180px;
}

.primary-action,
.secondary-action,
.icon-action {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-height: 42px;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 0 14px;
  font-weight: 800;
  line-height: 1.1;
  text-align: center;
  white-space: nowrap;
}

.primary-action span,
.secondary-action span,
.icon-action span {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
}

.primary-action {
  background: var(--accent);
  color: white;
}

.primary-action .ui-icon {
  filter: drop-shadow(0 1px 0 rgba(255, 255, 255, 0.28));
}

.primary-action:hover:not(:disabled) {
  background: var(--accent-strong);
}

.secondary-action,
.icon-action {
  background: #fff;
  border-color: var(--line);
  color: var(--ink);
}

.connect-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: fit-content;
  text-decoration: none;
}

.danger {
  color: var(--danger);
}

.wide {
  width: 100%;
}

.notice {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  width: fit-content;
  max-width: 100%;
  margin: 16px 0 0;
  border-left: 4px solid var(--warm);
  padding: 10px 12px;
  background: #fffbeb;
  color: #713f12;
  font-weight: 700;
}

.topbar {
  display: grid;
  grid-template-columns: minmax(120px, 220px) minmax(0, 1fr) auto;
  gap: 16px;
  align-items: center;
  margin-bottom: 24px;
}

.topbar > div {
  min-width: 0;
}

.topbar h2 {
  margin: 0;
  font-size: 34px;
  letter-spacing: 0;
}

.phase-nav {
  justify-self: center;
  min-width: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 5px;
  background: #e9edf2;
  border-radius: 8px;
}

.phase-nav span {
  min-width: 76px;
  padding: 8px 10px;
  border-radius: 6px;
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-align: center;
  text-transform: capitalize;
  white-space: nowrap;
}

.phase-nav .active {
  background: #fff;
  color: var(--ink);
  box-shadow: inset 0 -3px 0 var(--warm);
}

.media-layer {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 14px;
  align-items: start;
  margin-bottom: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #fff;
  background-image: var(--corner-images);
  background-repeat: no-repeat;
  background-position: var(--corner-positions);
  background-size: var(--corner-size);
  box-shadow: 0 12px 28px rgba(17, 24, 39, 0.08);
  padding: 14px;
  overflow: hidden;
}

.media-layer.compact {
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  padding: 12px;
}

.media-bar {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 74px;
  margin-bottom: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #fff;
  background-image: var(--corner-images);
  background-repeat: no-repeat;
  background-position: var(--corner-positions);
  background-size: var(--corner-size);
  padding: 10px 12px;
  box-shadow: 0 8px 20px rgba(17, 24, 39, 0.07);
  overflow: hidden;
}

.media-bar .media-now {
  grid-template-columns: 52px minmax(0, 1fr);
}

.media-bar .album-art {
  width: 52px;
  height: 52px;
}

.media-bar .section-kicker {
  margin-bottom: 3px;
}

.media-bar .media-progress {
  margin-top: 5px;
}

.media-bar-actions {
  justify-content: end;
}

.media-column {
  display: grid;
  gap: 14px;
  align-content: start;
}

.media-layer.compact .media-column {
  gap: 8px;
}

.media-layer.compact .media-now {
  grid-template-columns: 54px minmax(0, 1fr);
}

.media-layer.compact .album-art {
  width: 54px;
  height: 54px;
}

.media-layer.compact .media-progress {
  margin-top: 6px;
}

.media-now {
  display: grid;
  grid-template-columns: 72px minmax(0, 1fr);
  gap: 12px;
  align-items: center;
}

.album-art {
  display: grid;
  place-items: center;
  width: 72px;
  height: 72px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--soft-blue);
  color: #075985;
  font-weight: 900;
}

.album-art img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.album-fallback {
  display: grid;
  place-items: center;
  gap: 2px;
}

.album-fallback .ui-icon {
  width: 22px;
  height: 22px;
}

.album-fallback b {
  font-size: 13px;
  line-height: 1;
}

.now-copy {
  min-width: 0;
}

.now-copy strong,
.queue-track strong {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.now-copy span,
.now-copy small,
.media-status,
.media-error,
.media-section-title span,
.queue-track span,
.chat-message span,
.empty-state {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.media-error {
  color: var(--danger);
}

.media-progress {
  overflow: hidden;
  height: 8px;
  margin: 8px 0 4px;
  border-radius: 999px;
  background: #e5e7eb;
}

.media-progress span {
  display: block;
  height: 100%;
  background: var(--warm);
}

.media-controls,
.media-queue,
.media-chat {
  display: grid;
  gap: 10px;
}

.button-cluster,
.spotify-device-row,
.media-add-form,
.chat-form,
.media-section-title {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  align-items: center;
}

.media-section-title {
  justify-content: space-between;
}

.media-section-title strong {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-width: 0;
}

.media-section-title strong span {
  color: var(--ink);
  font-size: 15px;
  font-weight: 900;
}

.media-add-form input,
.chat-form input,
.spotify-device-row select {
  min-width: 180px;
  flex: 1 1 180px;
}

.media-settings {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(110px, 1fr));
  gap: 8px;
  align-items: end;
}

.media-settings label {
  margin: 0;
}

.toggle-line {
  display: flex;
  flex-direction: row;
  gap: 8px;
  align-items: center;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0 10px;
  background: #fafafa;
}

.toggle-line input {
  min-height: auto;
  width: 18px;
  height: 18px;
  padding: 0;
}

.queue-list,
.chat-feed {
  display: grid;
  gap: 7px;
}

.queue-list {
  max-height: 252px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}

.queue-track {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 48px;
  border: 1px solid #edf0f5;
  border-radius: 6px;
  padding: 7px;
  background: #fafafa;
  min-width: 0;
}

.provider-dot {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff !important;
  font-size: 12px !important;
}

.small {
  min-height: 32px;
  padding: 0 10px;
  font-size: 12px;
}

.small .ui-icon {
  width: 15px;
  height: 15px;
}

.chat-feed {
  max-height: 170px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #edf0f5;
  border-radius: 6px;
  padding: 8px;
  background: #fafafa;
  scrollbar-width: thin;
}

.chat-message {
  display: grid;
  gap: 2px;
  margin: 0;
}

.chat-message.system strong {
  color: var(--accent-strong);
}

.room-chat,
.show-section {
  display: grid;
  gap: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #fff;
  background-image: var(--corner-images);
  background-repeat: no-repeat;
  background-position: var(--corner-positions);
  background-size: var(--corner-size);
  padding: 12px;
}

.room-chat-feed {
  display: grid;
  gap: 7px;
  max-height: 220px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  border: 1px solid #edf0f5;
  border-radius: 6px;
  padding: 8px;
  background: #fafafa;
  scrollbar-width: thin;
}

.queue-list::-webkit-scrollbar,
.chat-feed::-webkit-scrollbar,
.room-chat-feed::-webkit-scrollbar {
  width: 8px;
}

.queue-list::-webkit-scrollbar-thumb,
.chat-feed::-webkit-scrollbar-thumb,
.room-chat-feed::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 8px;
}

.lobby-layout,
.draw-layout,
.reveal-layout,
.results-layout {
  display: grid;
  gap: 18px;
}

.draw-layout {
  gap: 12px;
}

.join-strip,
.draw-header,
.results-head {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr) auto;
  gap: 18px;
  align-items: center;
  background-color: var(--soft-green);
  background-image: var(--corner-images);
  background-repeat: no-repeat;
  background-position: var(--corner-positions);
  background-size: var(--corner-size);
  border: 1px solid #b7d8d0;
  border-radius: 8px;
  padding: 18px 20px;
}

.join-strip > div,
.draw-header > div,
.results-head > div {
  min-width: 0;
}

.show-marquee {
  grid-template-columns: minmax(250px, 0.75fr) minmax(0, 1.15fr) minmax(220px, 0.7fr);
  align-items: stretch;
  padding: 16px;
}

.show-marquee > div {
  display: grid;
  gap: 8px;
  align-content: center;
  min-height: 102px;
}

.show-marquee .join-code {
  width: 100%;
  justify-content: center;
  font-size: clamp(34px, 5vw, 58px);
}

.show-marquee .prompt-word,
.show-marquee .prompt-mode-pill {
  width: 100%;
}

.draw-header {
  grid-template-columns: minmax(0, 1fr) auto;
  padding: 12px 14px;
  background-image: none;
}

.join-code {
  display: inline-flex;
  gap: 10px;
  align-items: center;
  min-height: 56px;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: 48px;
  font-weight: 900;
  letter-spacing: 0;
  padding: 0 12px;
  box-shadow: 5px 5px 0 rgba(17, 24, 39, 0.12);
}

.join-code .ui-icon {
  width: 28px;
  height: 28px;
}

.prompt-word {
  display: inline-flex;
  align-items: center;
  max-width: 100%;
  min-height: 54px;
  border: 2px solid #111827;
  border-radius: 8px;
  background: #fff;
  box-shadow: 4px 4px 0 rgba(17, 24, 39, 0.1);
  padding: 0 18px;
  font-size: clamp(22px, 3vw, 32px);
  font-weight: 900;
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.prompt-word.small {
  min-height: 42px;
  padding: 0 12px;
  font-size: clamp(18px, 2.2vw, 22px);
}

.prompt-hidden {
  color: var(--muted);
  font-weight: 800;
}

.prompt-mode-select,
.prompt-mode-pill {
  min-width: 170px;
}

.prompt-mode-pill {
  display: inline-flex;
  align-items: center;
  min-height: 42px;
  border: 1px solid #b7d8d0;
  border-radius: 6px;
  background: #fff;
  box-shadow: 3px 3px 0 rgba(15, 118, 110, 0.12);
  padding: 0 12px;
  color: var(--accent-strong);
  font-weight: 900;
}

.lobby-main {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 300px;
  gap: 18px;
  align-items: start;
}

.lobby-main.show-main {
  grid-template-columns: minmax(0, 1fr);
}

.host-panel {
  display: grid;
  gap: 14px;
}

.show-controls {
  grid-template-columns: minmax(210px, 0.75fr) minmax(320px, 1.1fr) minmax(170px, 0.6fr) minmax(260px, 0.85fr);
  align-items: end;
}

.show-controls > .primary-action {
  min-height: 64px;
  font-size: 20px;
}

.show-rules {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
}

.show-rule {
  display: grid;
  grid-template-columns: auto minmax(0, 1fr);
  gap: 4px 7px;
  align-items: center;
  min-height: 58px;
  border: 1px solid #edf0f5;
  border-radius: 6px;
  background: #fafafa;
  padding: 8px;
}

.show-rule .ui-icon {
  grid-row: 1 / span 2;
}

.show-rule strong,
.show-rule em {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-style: normal;
}

.show-rule strong {
  font-size: 13px;
  font-weight: 900;
}

.show-rule em {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

.show-section {
  width: 100%;
}

.show-roster {
  gap: 14px;
}

.host-panel .primary-action {
  min-height: 50px;
}

.host-panel .meter,
.host-panel .profile-form {
  margin-bottom: 0;
}

.player-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
}

.player-card,
.replay-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 8px;
}

.player-card {
  display: flex;
  gap: 12px;
  align-items: center;
  min-height: 78px;
  padding: 13px;
  background-image: linear-gradient(90deg, rgba(245, 158, 11, 0.08), rgba(255, 255, 255, 0));
}

.player-card > div {
  min-width: 0;
  flex: 1 1 auto;
}

.profile-form {
  display: grid;
  gap: 10px;
  margin-bottom: 16px;
}

.profile-form label {
  margin: 0;
}

.player-card strong,
.replay-title strong {
  display: inline-flex;
  gap: 6px;
  align-items: center;
  min-width: 0;
}

.player-card strong span,
.replay-title strong span,
.ranking-list strong span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-card span:not(.avatar),
.replay-title span,
.rating-row.muted,
.ranking-list span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 700;
}

.avatar {
  display: inline-grid;
  place-items: center;
  flex: 0 0 auto;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--avatar);
  color: white;
  font-size: 14px;
  font-weight: 900;
}

.meter {
  display: grid;
  gap: 12px;
  margin-bottom: 16px;
  font-weight: 900;
}

.meter-track {
  overflow: hidden;
  height: 10px;
  border-radius: 999px;
  background: #e5e7eb;
}

.meter-track span {
  display: block;
  height: 100%;
  background: var(--warm);
}

.timer {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  justify-content: center;
  min-width: 92px;
  border-radius: 8px;
  background: var(--ink);
  color: white;
  padding: 12px 16px;
  font-size: 32px;
  font-weight: 900;
  line-height: 1;
  text-align: center;
}

.timer .ui-icon {
  width: 24px;
  height: 24px;
}

.tool-row {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: center;
  justify-content: center;
  background-color: #fff;
  background-image: var(--corner-images);
  background-repeat: no-repeat;
  background-position: var(--corner-positions);
  background-size: var(--corner-size);
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 12px 14px;
}

.draw-layout .tool-row {
  background-image: none;
}

.tool-label {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  color: var(--accent-strong);
  font-size: 13px;
  font-weight: 900;
  text-transform: uppercase;
}

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

.swatch {
  width: 34px;
  height: 34px;
  border: 2px solid #fff;
  border-radius: 50%;
  background: var(--swatch);
  box-shadow: 0 0 0 1px var(--line);
  image-rendering: pixelated;
}

.swatch.selected {
  box-shadow: 0 0 0 3px var(--ink);
}

.size-control {
  display: flex;
  grid-auto-flow: column;
  gap: 10px;
  align-items: center;
  margin: 0;
}

.size-control input {
  min-height: auto;
  width: 160px;
  padding: 0;
}

.canvas-wrap {
  width: min(100%, 720px);
  aspect-ratio: 4 / 3;
  overflow: hidden;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: #fff;
  box-shadow: var(--shadow);
  margin: 0 auto;
  outline: 4px solid rgba(245, 158, 11, 0.18);
  outline-offset: 4px;
}

.draw-layout .canvas-wrap {
  width: min(100%, 980px, clamp(320px, calc((100dvh - 325px) * 1.333), 980px));
}

.draw-canvas {
  display: block;
  width: 100%;
  height: 100%;
  touch-action: none;
}

.replay-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px;
  align-items: start;
}

.replay-grid.compact {
  grid-template-columns: repeat(auto-fit, minmax(210px, 1fr));
}

.replay-card {
  display: grid;
  gap: 10px;
  width: 100%;
  max-width: 430px;
  justify-self: center;
  padding: 16px;
  background-image: var(--corner-images);
  background-repeat: no-repeat;
  background-position:
    left 7px top 7px,
    right 7px top 7px,
    left 7px bottom 7px,
    right 7px bottom 7px;
  background-size: 23px 23px;
}

.replay-grid.compact .replay-card {
  max-width: 340px;
}

.replay-title {
  display: flex;
  justify-content: space-between;
  gap: 10px;
  align-items: start;
}

.score-pill {
  display: inline-flex;
  gap: 5px;
  align-items: center;
  min-height: 28px;
  border-radius: 999px;
  background: var(--soft-blue);
  color: #075985;
  padding: 0 10px;
  white-space: nowrap;
}

.replay-canvas {
  width: 100%;
  aspect-ratio: 4 / 3;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
}

.rating-row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 6px;
  align-items: center;
}

.rating-row button {
  min-width: 0;
  min-height: 34px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: #fff;
  font-weight: 900;
  display: grid;
  place-items: center;
}

.rating-row button.selected {
  border-color: var(--warm);
  background: #fef3c7;
}

.rating-row button .ui-icon {
  width: 18px;
  height: 18px;
}

.rating-row button:not(.selected) .ui-icon {
  opacity: 0.38;
  filter: grayscale(1);
}

.caption-layout {
  display: grid;
  gap: 14px;
}

.caption-form,
.caption-options,
.caption-results-list {
  display: grid;
  gap: 12px;
}

.caption-form {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  background-image: var(--corner-images);
  background-repeat: no-repeat;
  background-position: var(--corner-positions);
  background-size: var(--corner-size);
  box-shadow: var(--shadow);
  padding: 16px;
}

.caption-form label {
  margin: 0;
}

.caption-option,
.caption-result-card {
  display: grid;
  gap: 8px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  padding: 14px;
  text-align: left;
}

.caption-option {
  min-height: 104px;
}

.caption-option:not(:disabled):hover {
  border-color: var(--accent);
  background: var(--soft-green);
}

.caption-option.mine {
  background: #f8fafc;
}

.caption-option span,
.caption-result-card span {
  color: var(--muted);
  font-size: 13px;
  font-weight: 800;
  text-transform: uppercase;
}

.caption-option strong,
.caption-result-card strong {
  color: var(--ink);
  font-size: clamp(20px, 3vw, 30px);
  line-height: 1.05;
  overflow-wrap: anywhere;
}

.caption-result-card {
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
}

.caption-result-card > div {
  display: grid;
  gap: 5px;
  min-width: 0;
}

.waiting-count,
.round-number {
  min-height: 38px;
  border-radius: 999px;
  background: #fff;
  border: 1px solid #b7d8d0;
  padding: 8px 12px;
  color: var(--accent-strong);
  font-weight: 900;
}

.ranking-list {
  display: grid;
  gap: 10px;
  padding: 0;
  margin: 0;
  list-style: none;
}

.ranking-list li {
  display: grid;
  grid-template-columns: 42px 42px minmax(0, 1fr) auto;
  gap: 12px;
  align-items: center;
  min-height: 64px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background-color: #fff;
  background-image: linear-gradient(90deg, rgba(224, 242, 254, 0.7), rgba(255, 255, 255, 0));
  padding: 10px 14px;
}

.ranking-list strong {
  display: inline-flex;
  gap: 7px;
  align-items: center;
  min-width: 0;
}

.ranking-meta {
  display: flex;
  gap: 14px;
  align-items: center;
  justify-content: flex-end;
  white-space: nowrap;
}

.rank-number {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--ink);
  color: #fff !important;
  font-size: 16px !important;
}

@media (max-width: 1040px) {
  .show-marquee {
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  }

  .show-marquee > div:first-child {
    grid-column: 1 / -1;
  }

  .show-controls {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .show-controls > .primary-action,
  .show-controls .show-rules {
    grid-column: 1 / -1;
  }
}

@media (max-width: 760px) {
  .screen {
    padding: 10px 10px calc(18px + var(--safe-bottom));
  }

  .entry-layout,
  .lobby-main,
  .show-controls,
  .show-marquee,
  .media-layer,
  .media-layer.compact,
  .media-bar {
    grid-template-columns: 1fr;
  }

  .show-controls > .primary-action {
    min-height: 52px;
    font-size: 17px;
  }

  .show-rules {
    grid-template-columns: 1fr;
  }

  .show-marquee > div:first-child {
    grid-column: auto;
  }

  .show-marquee > div {
    min-height: auto;
  }

  .topbar {
    grid-template-columns: minmax(0, 1fr) auto;
    gap: 8px;
    margin-bottom: 12px;
  }

  .topbar > div {
    grid-column: 1;
    grid-row: 1;
  }

  .topbar .secondary-action {
    grid-column: 2;
    grid-row: 1;
    min-width: 0;
    padding-inline: 12px;
  }

  .topbar h2 {
    font-size: 24px;
  }

  .topbar .eyebrow {
    gap: 4px;
    margin-bottom: 2px;
    font-size: 11px;
  }

  .topbar .eyebrow .ui-icon {
    width: 15px;
    height: 15px;
  }

  .entry-layout {
    min-height: auto;
    align-items: start;
    gap: 20px;
    padding-top: 18px;
  }

  .brand-block h1 {
    font-size: 42px;
  }

  .game-tagline {
    font-size: 20px;
  }

  .phase-nav {
    grid-column: 1 / -1;
    grid-row: 2;
    justify-self: stretch;
    flex-wrap: nowrap;
    overflow-x: auto;
    scrollbar-width: none;
  }

  .phase-nav::-webkit-scrollbar {
    display: none;
  }

  .phase-nav span {
    min-width: 0;
    flex: 1 0 62px;
    padding: 5px 7px;
    font-size: 12px;
  }

  .join-strip,
  .draw-header,
  .results-head {
    display: grid;
    grid-template-columns: 1fr;
    gap: 12px;
    padding: 16px;
  }

  .join-strip .section-kicker,
  .draw-header .section-kicker,
  .results-head .section-kicker {
    margin-bottom: 6px;
  }

  .join-code {
    font-size: 38px;
  }

  .timer {
    width: 100%;
    min-height: 48px;
    padding: 8px 12px;
    font-size: 28px;
  }

  .media-bar {
    min-height: 0;
  }

  .media-bar-actions {
    justify-content: stretch;
  }

  .media-bar-actions .icon-action {
    width: 100%;
  }

  .media-now {
    grid-template-columns: 56px minmax(0, 1fr);
  }

  .album-art {
    width: 56px;
    height: 56px;
  }

  .queue-track {
    grid-template-columns: 30px minmax(0, 1fr);
  }

  .queue-track .small {
    grid-column: 2;
    width: fit-content;
  }

  .canvas-wrap {
    width: 100%;
    aspect-ratio: 1 / 1;
  }

  .draw-layout .canvas-wrap {
    width: min(100%, clamp(280px, calc(100dvh - 500px), 640px));
    outline-width: 3px;
    outline-offset: 3px;
  }

  .tool-row {
    gap: 8px;
    padding: 12px;
  }

  .tool-label {
    display: none;
  }

  .swatches {
    justify-content: center;
    width: 100%;
    gap: 7px;
  }

  .swatch {
    width: 28px;
    height: 28px;
  }

  .size-control {
    flex: 1 1 100%;
    justify-content: space-between;
    gap: 8px;
  }

  .size-control input {
    flex: 1 1 auto;
    width: auto;
  }

  .tool-row .icon-action {
    flex: 1 1 120px;
    min-height: 38px;
  }

  .split-actions,
  .submit-row {
    display: grid;
    grid-template-columns: 1fr;
  }

  .ranking-list li {
    grid-template-columns: 34px 42px minmax(0, 1fr);
    min-height: 80px;
  }

  .ranking-meta {
    grid-column: 3;
    justify-content: flex-start;
  }

  .caption-result-card {
    grid-template-columns: 1fr;
  }
}
