:root {
  color-scheme: light;
  --paper: #fbfaf6;
  --panel: #ffffff;
  --ink: #202124;
  --muted: #5f6368;
  --line: #dad7cd;
  --accent: #236c61;
  --accent-strong: #174b43;
  --accent-soft: #d9eee9;
  --warn: #9c3f30;
  --warn-soft: #f5ddd7;
  --gold: #c48b19;
  --shadow: 0 20px 60px rgb(38 42 46 / 10%);
  font-family:
    Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI",
    sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  min-width: 320px;
  min-height: 100vh;
  margin: 0;
  color: var(--ink);
  background:
    linear-gradient(180deg, #eef4f2 0, var(--paper) 310px),
    var(--paper);
}

a {
  color: var(--accent-strong);
}

button,
input {
  font: inherit;
}

button {
  border: 0;
}

button:disabled {
  cursor: not-allowed;
}

.skip-link {
  position: absolute;
  top: 10px;
  left: 10px;
  z-index: 10;
  padding: 8px 10px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  font-weight: 800;
  transform: translateY(-140%);
}

.skip-link:focus {
  transform: translateY(0);
}

.app-shell {
  width: min(1120px, calc(100% - 32px));
  margin: 0 auto;
  padding: 22px 0 36px;
}

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.link-brand {
  color: var(--ink);
  text-decoration: none;
}

.brand-mark {
  display: grid;
  width: 38px;
  height: 38px;
  place-items: center;
  border: 2px solid var(--ink);
  border-radius: 8px;
  background: var(--panel);
  box-shadow: 4px 4px 0 var(--gold);
  font-weight: 900;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 850;
  line-height: 1.1;
}

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

h1 {
  font-size: 1.25rem;
  line-height: 1.1;
}

.room-badge,
.status-pill {
  display: inline-flex;
  align-items: center;
  min-height: 32px;
  padding: 5px 10px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: rgb(255 255 255 / 70%);
  color: var(--muted);
  font-size: 0.88rem;
  white-space: nowrap;
}

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

.setup-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) 330px;
  gap: 18px;
  align-items: stretch;
}

.game-panel,
.side-panel,
.setup-panel,
.loading-panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 88%);
  box-shadow: var(--shadow);
}

.game-panel,
.setup-panel,
.loading-panel {
  padding: clamp(18px, 3vw, 28px);
}

.side-panel {
  padding: 18px;
}

.loading-panel {
  margin-top: 60px;
}

.setup-panel {
  display: grid;
  align-content: start;
  gap: 22px;
}

.setup-panel h2,
.side-panel h2,
.side-panel h3 {
  font-size: 1rem;
  line-height: 1.25;
}

.intro-copy {
  max-width: 58ch;
  color: var(--muted);
  line-height: 1.45;
}

.mode-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

.mode-button,
.primary-button,
.secondary-button,
.letter-button {
  min-height: 44px;
  border-radius: 8px;
  cursor: pointer;
  transition:
    transform 120ms ease,
    background 120ms ease,
    border-color 120ms ease;
}

.mode-button {
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 700;
}

.mode-button[aria-pressed="true"] {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.primary-button {
  width: 100%;
  background: var(--accent);
  color: #fff;
  font-weight: 800;
}

.secondary-button {
  width: 100%;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 750;
}

.mode-button:hover,
.primary-button:hover,
.secondary-button:hover,
.letter-button:hover:not(:disabled) {
  transform: translateY(-1px);
}

.primary-button:disabled,
.secondary-button:disabled,
.letter-button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
}

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

.field label {
  color: var(--muted);
  font-size: 0.86rem;
  font-weight: 700;
}

.field input {
  width: 100%;
  min-height: 46px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 10px 12px;
  background: var(--panel);
  color: var(--ink);
}

.field input:focus,
.copy-button:focus-visible,
.letter-button:focus-visible,
.primary-button:focus-visible,
.secondary-button:focus-visible,
.mode-button:focus-visible {
  outline: 3px solid rgb(35 108 97 / 24%);
  outline-offset: 2px;
}

.notice {
  min-height: 24px;
  color: var(--warn);
  font-size: 0.92rem;
}

.footer-links {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  justify-content: center;
  margin-top: 20px;
  color: var(--muted);
  font-size: 0.9rem;
}

.footer-links a,
.text-link {
  color: var(--muted);
  font-weight: 750;
  text-decoration-thickness: 2px;
  text-underline-offset: 3px;
}

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

.round-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.round-title {
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

.pattern {
  display: flex;
  flex-wrap: wrap;
  gap: clamp(7px, 1.2vw, 12px);
  align-items: center;
  min-height: 72px;
  font-size: clamp(2rem, 5vw, 4rem);
  font-weight: 900;
  line-height: 1;
}

.pattern span {
  display: grid;
  width: clamp(30px, 6vw, 52px);
  height: clamp(42px, 8vw, 68px);
  place-items: center;
  border-bottom: 4px solid var(--ink);
}

.pattern span[data-open="true"] {
  color: var(--muted);
}

.stage-grid {
  display: grid;
  grid-template-columns: 240px minmax(0, 1fr);
  gap: 22px;
  align-items: center;
}

.hangman {
  width: min(240px, 100%);
  aspect-ratio: 1;
  color: var(--ink);
}

.scaffold {
  fill: none;
  stroke: currentColor;
  stroke-width: 8;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.body-part {
  fill: none;
  stroke: var(--warn);
  stroke-width: 7;
  stroke-linecap: round;
  opacity: 0.12;
}

.body-part.show {
  opacity: 1;
}

.miss-box {
  display: grid;
  gap: 10px;
}

.miss-label {
  color: var(--muted);
  font-weight: 800;
}

.misses {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  min-height: 40px;
}

.miss-chip {
  display: grid;
  min-width: 38px;
  min-height: 38px;
  place-items: center;
  border: 1px solid #e7bbb1;
  border-radius: 8px;
  background: var(--warn-soft);
  color: var(--warn);
  font-weight: 900;
}

.empty-text {
  color: var(--muted);
}

.keyboard {
  display: grid;
  grid-template-columns: repeat(13, minmax(34px, 1fr));
  gap: 7px;
}

.letter-button {
  min-width: 0;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  font-weight: 900;
}

.letter-button.hit {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent-strong);
}

.letter-button.miss {
  border-color: #e7bbb1;
  background: var(--warn-soft);
  color: var(--warn);
}

.side-panel {
  display: grid;
  gap: 18px;
}

.panel-section {
  display: grid;
  gap: 10px;
}

.invite-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
}

.invite-row input {
  min-width: 0;
}

.copy-button {
  min-width: 74px;
  min-height: 46px;
  border-radius: 8px;
  background: var(--ink);
  color: #fff;
  cursor: pointer;
  font-weight: 800;
}

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

.player-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  color: var(--muted);
}

.player-row strong {
  color: var(--ink);
}

.result {
  display: grid;
  gap: 8px;
  min-height: 66px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fffaf0;
}

.result strong {
  font-size: 1.05rem;
}

.result[data-status="playing"] {
  background: var(--panel);
}

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

.legal-page {
  max-width: 820px;
}

.legal-panel {
  display: grid;
  gap: 16px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgb(255 255 255 / 90%);
  box-shadow: var(--shadow);
  padding: clamp(20px, 4vw, 36px);
  line-height: 1.55;
}

.legal-panel h1 {
  font-size: clamp(2rem, 5vw, 3rem);
}

.legal-panel h2 {
  margin-top: 8px;
  font-size: 1.05rem;
}

.legal-panel p {
  color: var(--muted);
}

[hidden] {
  display: none !important;
}

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    scroll-behavior: auto !important;
    transition-duration: 0.01ms !important;
    transition-delay: 0ms !important;
  }
}

@media (max-width: 860px) {
  .layout,
  .setup-layout,
  .stage-grid {
    grid-template-columns: 1fr;
  }

  .side-panel {
    order: -1;
  }

  .keyboard {
    grid-template-columns: repeat(7, minmax(36px, 1fr));
  }

  .app-shell {
    width: min(100% - 20px, 680px);
    padding-top: 14px;
  }
}

@media (max-width: 460px) {
  .topbar {
    align-items: flex-start;
    flex-direction: column;
  }

  .mode-grid {
    grid-template-columns: 1fr;
  }

  .keyboard {
    grid-template-columns: repeat(6, minmax(34px, 1fr));
  }

  .invite-row {
    grid-template-columns: 1fr;
  }
}
