:root {
  color-scheme: light;
  --yellow-soft: #ffe28a;
  --yellow-strong: #ffbf47;
  --orange-soft: #f5a623;
  --orange-strong: #c5851f;
  --metal-dark: #1d1308;
  --metal-mid: rgba(60, 40, 20, 0.85);
  --metal-highlight: rgba(255, 200, 120, 0.35);
  --teal: #1f9ea3;
  --text: #0d0b08;
  --text-muted: rgba(13, 11, 8, 0.72);
  --surface: rgba(255, 255, 255, 0.92);
  --surface-muted: rgba(255, 248, 234, 0.8);
  --border: rgba(255, 215, 130, 0.45);
  --shadow: 0 30px 55px rgba(15, 15, 15, 0.4);
  --radius-lg: 32px;
  --radius-md: 20px;
  --radius-sm: 12px;
  --transition: 220ms ease;
  font-family: "Outfit", "Nunito", "Segoe UI", Roboto, sans-serif;
}

*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  color: var(--text);
  display: flex;
  justify-content: center;
  align-items: stretch;
  padding: clamp(16px, 4vw, 48px);
  background: radial-gradient(circle at top, rgba(255, 244, 193, 0.6), rgba(255, 214, 133, 0.3) 60%, transparent 70%),
    linear-gradient(180deg, #ffe7a3 0%, #f7c05b 55%, #dca33c 100%);
}

.hm-app {
  width: min(1100px, 100%);
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(255, 241, 205, 0.9));
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid rgba(255, 214, 133, 0.6);
  display: flex;
  flex-direction: column;
  min-height: 96vh;
  overflow: hidden;
  backdrop-filter: blur(18px);
}

.hm-header {
  padding: clamp(20px, 5vw, 38px);
  background: linear-gradient(135deg, rgba(255, 214, 133, 0.96), rgba(255, 192, 88, 0.9) 40%, rgba(214, 142, 20, 0.95) 90%);
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 18px;
  border-bottom: 1px solid rgba(255, 214, 133, 0.4);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.hm-brand h1 {
  margin: 0;
  font-size: clamp(26px, 5vw, 38px);
  letter-spacing: 0.03em;
  color: var(--metal-dark);
  text-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.hm-brand p {
  margin: 6px 0 0;
  color: rgba(244, 237, 231, 0.7);
  font-size: 15px;
}

.connection-indicator {
  display: inline-flex;
  gap: 8px;
  align-items: center;
  padding: 6px 16px;
  border-radius: 999px;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  background: rgba(0, 0, 0, 0.08);
  border: 1px solid rgba(255, 214, 133, 0.45);
}

.connection-indicator .dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  background: #ffc03d;
  box-shadow: 0 0 8px rgba(255, 192, 61, 0.7);
}

.connection-indicator[data-state="connected"] .dot {
  background: #66bb6a;
  box-shadow: 0 0 8px rgba(102, 187, 106, 0.7);
}

.connection-indicator[data-state="error"] .dot {
  background: #ff6257;
  box-shadow: 0 0 8px rgba(255, 98, 87, 0.8);
}

.hm-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 3vw, 28px);
  padding: clamp(20px, 4vw, 36px);
  min-height: 0;
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.8), rgba(240, 215, 175, 0.7));
}

.panel {
  display: grid;
  gap: clamp(16px, 3vw, 26px);
}

.panel--lobby {
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
}


.panel--game {
  display: flex;
  flex-direction: column;
  gap: clamp(18px, 3vw, 32px);
  min-height: 0;
}

.card {
  background: linear-gradient(160deg, rgba(255, 255, 255, 0.92), rgba(255, 241, 205, 0.9));
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 206, 126, 0.5);
  padding: clamp(20px, 3.5vw, 32px);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.7), 0 18px 36px rgba(0, 0, 0, 0.18);
}

.hm-game-topbar {
  display: flex;
  justify-content: space-between;
  gap: 18px;
  align-items: center;
  flex-wrap: wrap;
}

.hm-game-topbar .status-chip,
.hm-game-topbar .timer-chip {
  display: inline-flex;
  flex-wrap: nowrap;
  align-items: center;
}

.card h2,
.card h3 {
  margin: 0 0 10px;
  font-size: clamp(20px, 3vw, 24px);
  color: var(--text);
}

.card p {
  margin: 0 0 14px;
  color: var(--text-muted);
}

.btn {
  border: none;
  border-radius: var(--radius-sm);
  padding: 12px 18px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition);
}

.btn--primary {
  background: linear-gradient(135deg, var(--yellow-strong), var(--orange-soft));
  color: #2f1c0f;
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25), inset 0 1px 0 rgba(255, 255, 255, 0.35);
}

.btn--ghost {
  background: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 214, 133, 0.6);
  color: var(--metal-dark);
}

.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn:not(:disabled):hover {
  transform: translateY(-1px);
}

.form-control {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 214, 133, 0.6);
  font-size: 16px;
  background: rgba(255, 255, 255, 0.95);
}

.hm-game-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}

.status-chip {
  font-size: 15px;
  padding: 8px 18px;
  border-radius: 999px;
  background: var(--metal-mid);
  border: 1px solid rgba(255, 189, 101, 0.4);
  color: var(--yellow-soft);
  display: inline-flex;
  gap: 8px;
  align-items: center;
}

.status-chip::before,
.timer-chip::before {
  content: "";
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
  opacity: 0.6;
}

.hm-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.6fr) minmax(0, 1fr);
  gap: clamp(22px, 4vw, 36px);
  min-height: 0;
  margin-top: clamp(14px, 2vw, 28px);
}

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

.word-display {
  font-size: clamp(24px, 5vw, 38px);
  letter-spacing: 0.16em;
  font-weight: 700;
  margin: 6px 0 0;
  color: #f2d5b0;
  text-transform: uppercase;
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.18em;
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  max-width: 100%;
  width: 100%;
}

.word-display[data-obscured="true"] span {
  color: #d3a86d;
}

.word-display span {
  display: inline-block;
  min-width: 0.8ch;
  text-align: center;
  flex: 0 0 auto;
}

.word-display[data-obscured="false"] {
  letter-spacing: 0.08em;
  gap: 0.12em;
  font-size: clamp(24px, 5vw, 36px);
}

.word-display[data-obscured="false"] span {
  min-width: 0.85ch;
  flex: 0 0 auto;
}

.tally-list {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
  margin: 18px 0 6px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tally-mark {
  width: 24px;
  height: 50px;
  border-radius: 6px;
  border: 2px solid rgba(255, 136, 61, 0.4);
  position: relative;
}

.tally-mark[data-state="used"] {
  border-color: rgba(255, 95, 69, 0.9);
  background: linear-gradient(160deg, #ffe1a3, #ffb46d);
}

.tally-mark[data-state="used"]::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 4px;
  border-top: 3px solid rgba(255, 95, 69, 0.9);
}

.guess-panel {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 20px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.92);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.35);
}

.guess-panel#setterPanel {
  border: 1px solid rgba(255, 211, 138, 0.6);
}

.guess-panel#guessPanel {
  border: 1px solid rgba(31, 158, 163, 0.4);
}

.guess-panel#guessPanel {
  gap: 12px;
}

.guess-panel#guessPanel .panel-badge {
  order: 0;
}

.guess-panel#guessPanel .letter-keyboard {
  order: 1;
  margin-top: 0;
}

.guess-panel#guessPanel .guess-intro {
  order: 2;
  margin: 0;
}

.guess-panel#guessPanel .guess-tip {
  order: 3;
  margin: 0;
}

.guess-panel#guessPanel .solve-form {
  order: 4;
}

.guess-panel#guessPanel .game-result {
  order: 5;
}

.panel-badge {
  display: inline-flex;
  align-self: flex-start;
  padding: 4px 12px;
  border-radius: 999px;
  font-size: 12px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  font-weight: 600;
  border: 1px solid rgba(0, 0, 0, 0.08);
}

.panel-badge--setter {
  background: rgba(255, 196, 107, 0.3);
  border-color: rgba(255, 196, 107, 0.6);
}

.panel-badge--guesser {
  background: rgba(31, 158, 163, 0.15);
  border-color: rgba(31, 158, 163, 0.4);
  color: var(--teal);
}

.hm-app[data-role="setter"] .panel-badge--setter,
.hm-app[data-role="setter"] #setterPanel {
  border-color: rgba(255, 196, 107, 0.9);
  box-shadow: 0 0 25px rgba(255, 196, 107, 0.45);
}

.hm-app[data-role="guesser"] .panel-badge--guesser,
.hm-app[data-role="guesser"] #guessPanel {
  border-color: rgba(31, 158, 163, 0.9);
  box-shadow: 0 0 25px rgba(31, 158, 163, 0.45);
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-list li {
  background: rgba(255, 230, 190, 0.9);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 15px;
  border: 1px solid rgba(255, 195, 142, 0.5);
  box-shadow: 0 6px 12px rgba(0, 0, 0, 0.16);
  color: var(--metal-dark);
}

.role-badge {
  font-weight: 700;
  color: var(--orange-strong);
}

.timer-chip {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  background: rgba(31, 158, 163, 0.12);
  color: var(--teal);
  font-weight: 600;
}

.timer-chip.timer-chip--room {
  background: rgba(255, 255, 255, 0.4);
  color: var(--metal-dark);
  border: 1px solid rgba(255, 214, 133, 0.6);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.12);
  font-size: 0.85rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.timer-chip.timer-chip--countdown {
  background: rgba(255, 214, 133, 0.25);
  color: #b35f16;
  font-size: 0.85rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  border: 1px solid rgba(179, 95, 22, 0.5);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.member-list {
  list-style: none;
  padding: 0;
  margin: 0;
}

.member-list li {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.member-list li:last-child {
  border-bottom: none;
}
.hm-app[data-view="lobby"] .panel--game {
  display: none;
}

.hm-app[data-view="game"] .panel--lobby {
  display: none;
}

.room-code {
  font-family: "Fira Mono", ui-monospace;
  font-size: 22px;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: #c06c1a;
}

.copy-links {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 6px;
}

.copy-links--stack {
  flex-direction: column;
  align-items: stretch;
}

.copy-links--stack .btn {
  width: 100%;
}

.control-buttons {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin: 16px 0 8px;
}

.control-buttons .btn {
  flex: 1;
  min-width: 140px;
}

#inviteNotice {
  margin-bottom: 12px;
}

.hm-app[data-invited="true"] #hostCard {
  display: none;
}

.word-input-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 12px;
}

.word-input-form .form-control {
  flex: 1;
}

.word-input-form .btn {
  min-width: 150px;
}

.guess-form {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-top: 12px;
}

.guess-form .form-control {
  width: auto;
  flex: 1;
  text-transform: uppercase;
  font-weight: 700;
  letter-spacing: 0.15em;
}

.solve-form {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.solve-form .form-control {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  font-weight: 600;
}

.game-result {
  font-size: 18px;
  font-weight: 700;
  color: #bf360c;
}

.alert {
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  background: rgba(255, 243, 205, 0.9);
  border: 1px solid rgba(255, 196, 0, 0.6);
  margin-top: 10px;
}
.letter-keyboard {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(34px, 1fr));
  gap: 10px;
  margin-top: 8px;
}
.letter-key {
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border-radius: 12px;
  padding: 10px;
  font-weight: 700;
  font-size: 16px;
  text-align: center;
  cursor: pointer;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition), opacity var(--transition);
}
.letter-key:disabled {
  cursor: not-allowed;
  opacity: 0.4;
  background: rgba(255, 255, 255, 0.06);
  box-shadow: none;
  transform: none;
}
.letter-key:not(:disabled):hover {
  transform: translateY(-1px);
  box-shadow: 0 8px 14px rgba(0, 0, 0, 0.35);
}
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

@media (max-width: 900px) {
  body {
    padding: 0;
    background-attachment: fixed;
  }

  .hm-app {
    border-radius: 0;
    min-height: 100vh;
  }

  .hm-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 8px;
    width: 100%;
    position: relative;
  }

  .connection-indicator {
    position: absolute;
    top: 16px;
    right: 16px;
    align-self: auto;
    justify-content: flex-end;
    padding: 6px 12px;
  }

  .hm-main {
    padding: 20px;
  }

  .panel--lobby {
    grid-template-columns: 1fr;
  }

  .hm-layout {
    grid-template-columns: 1fr;
  }

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

  .copy-links {
    width: 100%;
  }

  .control-buttons,
  .copy-links,
  .word-input-form,
  .guess-form,
  .solve-form {
    flex-direction: column;
  }

  .control-buttons .btn,
  .copy-links .btn,
  .btn {
    width: 100%;
  }

  .guess-form .form-control,
  .solve-form .form-control,
  .word-input-form .form-control {
    width: 100%;
  }
}

@media (max-width: 520px) {
  .hm-header {
    padding: 18px;
  }

  .hm-main {
    padding: 16px;
  }

  .card {
    padding: 16px;
  }

  .hm-brand h1 {
    font-size: 22px;
  }

  .hm-brand p {
    font-size: 14px;
  }

  .room-code {
    font-size: 18px;
    letter-spacing: 0.2em;
  }

  .word-display {
    font-size: 28px;
    letter-spacing: 0.14em;
  }

  .tally-list {
    justify-content: center;
  }

  .guess-panel {
    padding: 16px;
  }

  .hm-game-topbar {
    gap: 10px;
  }

  .panel-badge {
    font-size: 11px;
  }
  .word-display {
    font-size: clamp(22px, 5vw, 32px);
    letter-spacing: 0.08em;
    gap: 0.14em;
  }
  .word-display span {
    min-width: 0.8ch;
  }
}
.join-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 12px;
}

.join-form .btn {
  width: 100%;
}
