:root {
  --bg-deep: #07080f;
  --bg-card: rgba(18, 20, 32, 0.72);
  --glass-border: rgba(255, 255, 255, 0.09);
  --glass-highlight: rgba(255, 255, 255, 0.07);
  --text: #f1f4fb;
  --muted: #8b92a8;
  --accent: #5ee9b5;
  --accent-dim: #34d399;
  --danger: #fb7185;
  --warn: #fcd34d;
  --violet: #a78bfa;
  --violet-glow: rgba(139, 92, 246, 0.35);
  --green-cell: #15803d;
  --green-glow: rgba(34, 197, 94, 0.35);
  --yellow-cell: #a16207;
  --yellow-glow: rgba(234, 179, 8, 0.35);
  --grey-cell: #3f3f46;
  --radius: 22px;
  --radius-sm: 12px;
  --font: 'Outfit', system-ui, sans-serif;
  --display: 'Syne', var(--font);
  --mono: 'JetBrains Mono', ui-monospace, monospace;
  --shadow: 0 28px 90px rgba(0, 0, 0, 0.55);
  --shadow-soft: 0 8px 32px rgba(0, 0, 0, 0.35);
}

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

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
  -webkit-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

body {
  margin: 0;
  min-height: 100dvh;
  font-family: var(--font);
  color: var(--text);
  background: var(--bg-deep);
  overflow-x: hidden;
}

input,
textarea,
[contenteditable='true'] {
  -webkit-user-select: text;
  user-select: text;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

.bg-gradient {
  position: fixed;
  inset: 0;
  z-index: 0;
  background:
    radial-gradient(ellipse 100% 70% at 50% -15%, rgba(94, 234, 181, 0.18), transparent 52%),
    radial-gradient(ellipse 70% 50% at 100% 20%, rgba(167, 139, 250, 0.16), transparent 48%),
    radial-gradient(ellipse 55% 45% at 0% 75%, rgba(56, 189, 248, 0.1), transparent 42%),
    radial-gradient(ellipse 50% 40% at 85% 90%, rgba(244, 114, 182, 0.06), transparent 40%),
    var(--bg-deep);
}

.noise {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.04;
  pointer-events: none;
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 256 256' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='n'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.85' numOctaves='4' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23n)'/%3E%3C/svg%3E");
}

.app {
  position: relative;
  z-index: 1;
  max-width: 640px;
  margin: 0 auto;
  padding: max(clamp(1rem, 4vw, 2rem), env(safe-area-inset-top))
    max(clamp(1rem, 4vw, 2rem), env(safe-area-inset-right))
    max(clamp(1rem, 4vw, 2rem), env(safe-area-inset-bottom))
    max(clamp(1rem, 4vw, 2rem), env(safe-area-inset-left));
  min-height: 100dvh;
  display: flex;
  flex-direction: column;
}

.app:has(#screenHome.active),
.app:has(#screenHowTo.active) {
  max-width: 820px;
}

.top-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  margin: 0;
  padding: 0;
  font: inherit;
  font-family: var(--display);
  font-weight: 700;
  font-size: 1.15rem;
  letter-spacing: -0.03em;
  color: inherit;
  background: none;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  text-align: left;
  -webkit-tap-highlight-color: transparent;
}

.brand:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 3px;
}

.brand-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2rem;
  height: 2rem;
  border-radius: 10px;
  background: linear-gradient(145deg, rgba(94, 234, 181, 0.25), rgba(94, 234, 181, 0.05));
  border: 1px solid rgba(94, 234, 181, 0.25);
  color: var(--accent);
  font-size: 1rem;
  box-shadow: 0 4px 20px rgba(94, 234, 181, 0.12);
}

.conn-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.8rem;
  font-weight: 500;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid var(--glass-border);
  transition: border-color 0.25s, background 0.25s;
}

.conn-pill[data-state='connected'] {
  border-color: rgba(52, 211, 153, 0.35);
  background: rgba(16, 185, 129, 0.12);
}

.conn-pill[data-state='connected'] .conn-dot {
  background: #34d399;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.6);
}

.conn-pill[data-state='disconnected'] .conn-dot {
  background: var(--danger);
}

.conn-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
}

.screen {
  display: none;
  flex-direction: column;
  align-items: stretch;
  gap: 1.25rem;
  padding: clamp(1.5rem, 5vw, 2rem);
  border-radius: var(--radius);
  animation: cardIn 0.45s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.screen.active {
  display: flex;
}

@keyframes cardIn {
  from {
    opacity: 0;
    transform: translateY(12px) scale(0.98);
  }
  to {
    opacity: 1;
    transform: none;
  }
}

.glass {
  background: var(--bg-card);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--glass-border);
  box-shadow: var(--shadow);
}

.card {
  width: 100%;
}

.screen-home {
  position: relative;
  overflow: hidden;
  padding: clamp(1.75rem, 5vw, 2.5rem);
  gap: 1.75rem;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    var(--shadow),
    inset 0 1px 0 rgba(255, 255, 255, 0.06);
}

.screen-home::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background-image:
    linear-gradient(rgba(255, 255, 255, 0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.03) 1px, transparent 1px);
  background-size: 48px 48px;
  pointer-events: none;
  opacity: 0.5;
  mask-image: radial-gradient(ellipse 80% 70% at 50% 0%, black 20%, transparent 70%);
}

.home-hero {
  position: relative;
  text-align: center;
  z-index: 1;
}

.home-eyebrow {
  margin: 0 0 0.75rem;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: rgba(139, 146, 168, 0.95);
}

.home-online-stat {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin: 0 0 1rem;
  padding: 0.4rem 0.85rem;
  border-radius: 999px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
  font-size: 0.88rem;
  font-weight: 500;
  color: #c8d0e4;
}

.home-online-stat.is-offline {
  border-color: rgba(251, 113, 133, 0.25);
  color: #a8b0c4;
}

.home-online-pulse {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
  flex-shrink: 0;
  transition:
    background 0.3s ease,
    box-shadow 0.3s ease;
}

.home-online-stat.is-live .home-online-pulse {
  background: #34d399;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.55);
  animation: onlinePulse 2s ease-in-out infinite;
}

@keyframes onlinePulse {
  0%,
  100% {
    opacity: 1;
    transform: scale(1);
  }
  50% {
    opacity: 0.85;
    transform: scale(1.05);
  }
}

.home-online-text strong {
  font-weight: 700;
  color: #e8edf7;
}

.home-title {
  margin: 0;
  font-family: var(--display);
  font-weight: 800;
  font-size: clamp(2rem, 7vw, 2.85rem);
  line-height: 1.05;
  letter-spacing: -0.04em;
}

.home-title-line {
  display: block;
  color: var(--text);
}

.home-title-accent {
  display: block;
  margin-top: 0.15rem;
  background: linear-gradient(120deg, #5ee9b5 0%, #34d399 35%, #a78bfa 75%, #c4b5fd 100%);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  filter: drop-shadow(0 12px 40px rgba(94, 234, 181, 0.25));
}

.home-tagline {
  margin: 1rem auto 0;
  max-width: 26rem;
  font-size: 1.02rem;
  line-height: 1.55;
  color: var(--muted);
}

.home-howto-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
  margin-top: 1.25rem;
}

.btn-howto {
  min-height: 2.75rem;
  padding: 0.75rem 1.5rem;
  touch-action: manipulation;
  width: 100%;
  max-width: 18rem;
}

.screen-howto {
  position: relative;
  gap: 1rem;
  padding: clamp(1.25rem, 4vw, 1.75rem);
  max-height: min(100dvh - 2rem, 900px);
  overflow: hidden;
}

.screen-howto .howto-inner {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.15rem;
}

.howto-inner {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 28rem;
  margin: 0 auto;
  padding: 1.1rem 1.15rem 1.15rem;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.07);
  text-align: left;
}

.btn-back-howto {
  align-self: flex-start;
  min-height: 2.75rem;
  padding: 0.65rem 0.85rem;
  touch-action: manipulation;
}

.home-rules-title {
  margin: 0 0 0.75rem;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  text-align: center;
}

.home-rules-steps {
  margin: 0 0 0.65rem;
  padding-left: 1.35rem;
  font-size: 0.88rem;
  line-height: 1.55;
  color: rgba(200, 208, 224, 0.95);
}

.home-rules-steps li {
  margin-bottom: 0.4rem;
}

.home-rules-steps li::marker {
  color: rgba(94, 234, 181, 0.75);
  font-weight: 700;
}

.home-rules-clues {
  margin: 0 0 0.75rem;
  padding: 0.65rem 0.75rem;
  list-style: none;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.home-rules-clues li {
  display: flex;
  align-items: flex-start;
  gap: 0.55rem;
  margin-bottom: 0.5rem;
  font-size: 0.84rem;
  line-height: 1.45;
  color: rgba(180, 188, 206, 0.98);
}

.home-rules-clues li:last-child {
  margin-bottom: 0;
}

.home-clue-swatch {
  flex-shrink: 0;
  width: 14px;
  height: 16px;
  margin-top: 0.12rem;
  border-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.12);
}

.home-clue-swatch--g {
  background: linear-gradient(165deg, #2dd48a, #15803d);
  box-shadow: 0 0 10px rgba(34, 197, 94, 0.35);
}

.home-clue-swatch--y {
  background: linear-gradient(165deg, #f0c030, #a16207);
  box-shadow: 0 0 10px rgba(234, 179, 8, 0.25);
}

.home-clue-swatch--x {
  background: linear-gradient(165deg, #5c5c66, #3f3f46);
}

.home-rules-foot {
  margin: 0;
  font-size: 0.82rem;
  line-height: 1.5;
  color: rgba(139, 146, 168, 0.98);
  text-align: center;
}

.home-options {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

@media (min-width: 720px) {
  .home-options {
    flex-direction: row;
    align-items: stretch;
    gap: 0.35rem;
  }
}

.home-card {
  position: relative;
  flex: 1;
  min-width: 0;
  padding: 1.35rem 1.35rem 1.5rem;
  border-radius: calc(var(--radius) - 2px);
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(10, 12, 22, 0.55);
  transition:
    transform 0.35s cubic-bezier(0.22, 1, 0.36, 1),
    border-color 0.3s,
    box-shadow 0.35s;
}

.home-card:hover {
  border-color: rgba(255, 255, 255, 0.14);
  box-shadow: var(--shadow-soft);
}

.home-card--create:hover {
  transform: translateY(-3px);
}

.home-card--join:hover {
  transform: translateY(-3px);
}

.home-card-bg {
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: radial-gradient(ellipse 90% 80% at 20% 0%, rgba(94, 234, 181, 0.14), transparent 55%);
  pointer-events: none;
}

.home-card-bg--violet {
  background: radial-gradient(ellipse 90% 80% at 80% 0%, rgba(167, 139, 250, 0.16), transparent 55%);
}

.home-card-icon {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  margin-bottom: 1rem;
  border-radius: 14px;
  color: var(--accent);
  background: linear-gradient(145deg, rgba(94, 234, 181, 0.18), rgba(94, 234, 181, 0.04));
  border: 1px solid rgba(94, 234, 181, 0.22);
  box-shadow: 0 8px 28px rgba(94, 234, 181, 0.1);
}

.home-card-icon--violet {
  color: #c4b5fd;
  background: linear-gradient(145deg, rgba(167, 139, 250, 0.2), rgba(167, 139, 250, 0.05));
  border-color: rgba(167, 139, 250, 0.28);
  box-shadow: 0 8px 28px var(--violet-glow);
}

.home-card-title {
  position: relative;
  margin: 0 0 0.45rem;
  font-family: var(--display);
  font-size: 1.28rem;
  font-weight: 700;
  letter-spacing: -0.03em;
}

.home-card-desc {
  position: relative;
  margin: 0 0 1.15rem;
  font-size: 0.92rem;
  line-height: 1.5;
  color: var(--muted);
}

.home-pinlen-field {
  position: relative;
  margin: 0 0 1rem;
  padding: 0;
  border: none;
  min-width: 0;
  text-align: left;
}

.home-pinlen-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(180, 188, 206, 0.95);
  margin-bottom: 0.5rem;
  padding: 0;
}

.home-pinlen-seg {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.45rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(94, 234, 181, 0.14);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.04);
}

.home-pinlen-chip {
  position: relative;
  flex: 1 1 calc(14.28% - 0.35rem);
  min-width: 2.35rem;
  margin: 0;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}

.home-pinlen-chip input {
  position: absolute;
  inset: 0;
  opacity: 0;
  margin: 0;
  cursor: pointer;
}

.home-pinlen-chip span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 2.35rem;
  padding: 0.35rem 0.25rem;
  border-radius: 10px;
  font-family: var(--mono);
  font-size: 0.92rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: rgba(220, 226, 240, 0.82);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  transition:
    background 0.15s ease,
    border-color 0.15s ease,
    color 0.15s ease,
    box-shadow 0.15s ease,
    transform 0.12s ease;
}

.home-pinlen-chip:hover span {
  background: rgba(94, 234, 181, 0.08);
  border-color: rgba(94, 234, 181, 0.22);
  color: var(--text);
}

.home-pinlen-chip input:focus-visible + span {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

.home-pinlen-chip input:checked + span {
  color: var(--bg-deep);
  background: linear-gradient(160deg, var(--accent) 0%, var(--accent-dim) 100%);
  border-color: rgba(94, 234, 181, 0.55);
  box-shadow:
    0 0 0 1px rgba(94, 234, 181, 0.25),
    0 6px 18px rgba(52, 211, 153, 0.22);
}

.home-pinlen-chip:active span {
  transform: scale(0.97);
}

.home-pinlen-hint {
  margin: 0.45rem 0 0;
  font-size: 0.75rem;
  line-height: 1.4;
  color: rgba(139, 146, 168, 0.95);
}

.home-card-btn {
  position: relative;
  width: 100%;
  padding: 0.88rem 1.1rem;
  font-size: 0.98rem;
  border-radius: 14px;
  overflow: hidden;
}

.home-btn-shine {
  position: absolute;
  inset: 0;
  background: linear-gradient(
    105deg,
    transparent 0%,
    rgba(255, 255, 255, 0.18) 45%,
    transparent 55%
  );
  transform: translateX(-100%);
  animation: btnShine 4s ease-in-out infinite;
}

@keyframes btnShine {
  0%,
  80% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(200%);
  }
}

.home-join-fields {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
}

.home-join-input {
  text-align: center;
  letter-spacing: 0.2em;
  font-size: 1.05rem;
  padding: 0.85rem 1rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.45);
  border: 1px solid rgba(167, 139, 250, 0.15);
  transition: border-color 0.25s, box-shadow 0.25s;
}

.home-join-input:focus {
  border-color: rgba(167, 139, 250, 0.45);
  box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.12);
}

.home-join-btn {
  border-radius: 14px;
  padding: 0.88rem 1.1rem;
  background: rgba(255, 255, 255, 0.07);
  border: 1px solid rgba(167, 139, 250, 0.22);
  color: var(--text);
}

.home-join-btn:hover:not(:disabled) {
  background: rgba(167, 139, 250, 0.12);
  border-color: rgba(167, 139, 250, 0.35);
  box-shadow: 0 8px 28px rgba(139, 92, 246, 0.15);
}

.glass-soft {
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.2);
  padding: 1.1rem 1.15rem 1.15rem;
}

.home-quick {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 28rem;
  margin: 0 auto;
}

.home-quick-title {
  margin: 0 0 0.35rem;
  font-family: var(--display);
  font-size: 1.05rem;
  font-weight: 700;
}

.home-quick-desc {
  margin: 0 0 1rem;
  font-size: 0.88rem;
  line-height: 1.45;
  color: var(--muted);
}

.home-quick-row {
  display: flex;
  flex-direction: column;
  gap: 0.55rem;
  margin-bottom: 1rem;
}

@media (min-width: 520px) {
  .home-quick-row {
    flex-direction: row;
  }

  .home-quick-btn {
    flex: 1;
  }
}

.home-open-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  margin-bottom: 0.45rem;
}

.home-open-label {
  font-size: 0.78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(139, 146, 168, 0.95);
}

.btn-tiny {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  min-height: auto;
}

.home-open-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  max-height: 12rem;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.home-open-list li {
  margin: 0;
}

.home-open-item {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.55rem 0.75rem;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.25);
  font-family: var(--mono);
  font-size: 0.9rem;
  letter-spacing: 0.12em;
  cursor: pointer;
  color: var(--text);
  transition:
    border-color 0.2s,
    background 0.2s;
}

.home-open-item:hover {
  border-color: rgba(94, 234, 181, 0.35);
  background: rgba(16, 185, 129, 0.08);
}

.home-open-empty {
  font-size: 0.85rem;
  color: var(--muted);
  padding: 0.5rem 0;
  text-align: center;
}

.home-or {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.15rem 0;
  flex-shrink: 0;
}

@media (min-width: 720px) {
  .home-or {
    flex-direction: column;
    justify-content: center;
    width: 52px;
    padding: 0 0.15rem;
    gap: 0.65rem;
  }
}

.home-or-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.18), transparent);
}

@media (min-width: 720px) {
  .home-or-line {
    width: 1px;
    height: auto;
    flex: 1;
    min-height: 36px;
    background: linear-gradient(180deg, transparent, rgba(255, 255, 255, 0.18), transparent);
  }
}

.home-or-text {
  font-family: var(--display);
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(139, 146, 168, 0.9);
}

.home-error {
  position: relative;
  z-index: 1;
  padding: 0.65rem 1rem;
  border-radius: 12px;
  background: rgba(251, 113, 133, 0.08);
  border: 1px solid rgba(251, 113, 133, 0.25);
}

.title {
  font-size: clamp(1.5rem, 5vw, 1.85rem);
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
  letter-spacing: -0.03em;
}

.title-sm {
  font-size: 1.35rem;
  font-weight: 700;
  margin: 0;
  text-align: center;
}

.subtitle {
  margin: 0;
  color: var(--muted);
  font-size: 1rem;
  line-height: 1.5;
}

.muted {
  color: var(--muted);
  font-size: 0.95rem;
  margin: 0;
  text-align: center;
}

.actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.join-row {
  display: flex;
  gap: 0.6rem;
}

.input {
  font-family: var(--mono);
  font-size: 1.1rem;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(0, 0, 0, 0.35);
  color: var(--text);
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input:focus {
  border-color: rgba(110, 231, 183, 0.45);
  box-shadow: 0 0 0 3px rgba(110, 231, 183, 0.12);
}

.code-input {
  flex: 1;
  text-transform: uppercase;
  letter-spacing: 0.15em;
}

.pin-input,
.guess-input {
  width: 100%;
  text-align: center;
  letter-spacing: 0.35em;
  font-size: 1.35rem;
}

/* Mask digits like a password field without type=password (avoids “Save password?” in Chrome). */
.pin-input--masked {
  -webkit-text-security: disc;
}

.pin-input--compact,
.guess-input--compact {
  letter-spacing: 0.1em;
  font-size: clamp(0.85rem, 3.2vw, 1.2rem);
}

.btn {
  font-family: var(--font);
  font-weight: 600;
  font-size: 0.95rem;
  min-height: 2.75rem;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  transition:
    transform 0.15s,
    box-shadow 0.2s,
    background 0.2s;
}

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

.btn-primary {
  background: linear-gradient(135deg, #34d399, #059669);
  color: #052e1c;
  box-shadow: 0 8px 24px rgba(16, 185, 129, 0.25);
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 12px 28px rgba(16, 185, 129, 0.35);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text);
  border: 1px solid var(--glass-border);
}

.btn-secondary:hover:not(:disabled) {
  background: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid transparent;
}

.btn-ghost:hover {
  color: var(--text);
  border-color: var(--glass-border);
}

.btn-icon {
  min-width: 2.75rem;
  min-height: 2.75rem;
  padding: 0.5rem 0.65rem;
  font-size: 1.1rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.error-msg {
  color: var(--danger);
  font-size: 0.9rem;
  margin: 0;
  text-align: center;
}

.waiting-anim {
  position: relative;
  width: 72px;
  height: 72px;
  margin: 0 auto 0.5rem;
}

.pulse-ring {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(110, 231, 183, 0.35);
  animation: pulseRing 2s ease-out infinite;
}

.pulse-core {
  position: absolute;
  inset: 18px;
  border-radius: 50%;
  background: radial-gradient(circle at 30% 30%, rgba(110, 231, 183, 0.5), rgba(5, 150, 105, 0.3));
  animation: pulseCore 2s ease-in-out infinite;
}

@keyframes pulseRing {
  0% {
    transform: scale(0.85);
    opacity: 0.8;
  }
  100% {
    transform: scale(1.35);
    opacity: 0;
  }
}

@keyframes pulseCore {
  0%,
  100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.06);
  }
}

.room-strip {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  flex-wrap: wrap;
  padding: 0.75rem 1rem;
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid var(--glass-border);
}

.room-strip.compact {
  justify-content: flex-start;
}

.room-strip .label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.room-code {
  font-family: var(--mono);
  font-size: 1.15rem;
  font-weight: 600;
  letter-spacing: 0.2em;
  color: var(--accent);
}

.pin-field-wrap {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.setup-progress {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.65rem;
  margin-bottom: 0.25rem;
}

.setup-chip {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 0.2rem;
  padding: 0.65rem 0.75rem;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(0, 0, 0, 0.28);
  transition:
    border-color 0.3s ease,
    box-shadow 0.3s ease,
    background 0.3s ease;
}

.setup-chip[data-locked='true'] {
  border-color: rgba(94, 234, 181, 0.35);
  background: rgba(16, 185, 129, 0.08);
  box-shadow: 0 0 0 1px rgba(94, 234, 181, 0.12);
}

.setup-chip[data-locked='true'] .setup-chip-dot {
  background: #34d399;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.45);
}

.setup-chip[data-locked='false'] .setup-chip-label {
  color: var(--muted);
}

.setup-chip-text {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: rgba(139, 146, 168, 0.95);
}

.setup-chip-label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text);
}

.setup-chip-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #64748b;
  margin-bottom: 0.15rem;
}

.setup-chip-dot--opp {
  background: #818cf8;
}

.setup-chip[data-locked='true'] .setup-chip-dot--opp {
  background: #34d399;
  box-shadow: 0 0 10px rgba(52, 211, 153, 0.45);
}

.setup-status {
  min-height: 1.5rem;
  transition: color 0.25s ease;
}

.setup-status.setup-status--pulse {
  animation: setupPulse 0.85s ease;
}

@keyframes setupPulse {
  0%,
  100% {
    opacity: 1;
  }
  50% {
    opacity: 0.65;
    color: var(--accent);
  }
}

.setup-status.setup-status--highlight {
  color: #a5f3d0;
}

.game-screen {
  gap: 1.1rem;
}

.game-head {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.turn-status {
  position: relative;
  display: flex;
  align-items: stretch;
  gap: 0;
  padding: 0;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.28);
  border: 1px solid rgba(255, 255, 255, 0.07);
  overflow: hidden;
  pointer-events: none;
  user-select: none;
}

.turn-status-glow {
  width: 4px;
  flex-shrink: 0;
  background: rgba(100, 116, 139, 0.6);
  transition: background 0.35s ease, box-shadow 0.35s ease;
}

.turn-status.is-yours .turn-status-glow {
  background: linear-gradient(180deg, #4ade80, #059669);
  box-shadow: 0 0 20px rgba(52, 211, 153, 0.35);
}

.turn-status.is-theirs .turn-status-glow {
  background: linear-gradient(180deg, #64748b, #475569);
  box-shadow: 0 0 16px rgba(148, 163, 184, 0.2);
}

.turn-status-body {
  flex: 1;
  padding: 0.75rem 1rem 0.85rem;
  text-align: left;
}

.turn-status-kicker {
  display: block;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: rgba(139, 146, 168, 0.95);
  margin-bottom: 0.2rem;
}

.turn-status-title {
  display: block;
  font-family: var(--display);
  font-size: 1.2rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
  line-height: 1.2;
  overflow-wrap: anywhere;
}

.turn-status.is-yours .turn-status-title {
  color: #a7f3d0;
}

.turn-status.is-theirs .turn-status-title {
  color: #cbd5e1;
}

.turn-status-sub {
  display: block;
  margin-top: 0.35rem;
  font-size: 0.88rem;
  line-height: 1.4;
  color: var(--muted);
  font-weight: 500;
}

.turn-flash {
  pointer-events: none;
  position: fixed;
  inset: 0;
  z-index: 50;
  background: rgba(255, 255, 255, 0.06);
  opacity: 0;
  transition: opacity 0.35s ease;
}

.turn-flash.show {
  opacity: 1;
  animation: flashFade 0.45s ease forwards;
}

@keyframes flashFade {
  0% {
    opacity: 0.35;
  }
  100% {
    opacity: 0;
  }
}

.guess-card {
  padding: 1rem 1.05rem 1.05rem;
  border-radius: 16px;
  background: rgba(0, 0, 0, 0.32);
  border: 1px solid rgba(255, 255, 255, 0.07);
  transition: opacity 0.3s ease, border-color 0.3s ease;
}

.guess-card--waiting {
  opacity: 0.72;
  border-color: rgba(255, 255, 255, 0.05);
}

.guess-card-head {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  margin-bottom: 0.75rem;
}

.guess-card-label {
  font-family: var(--display);
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  color: var(--text);
}

.guess-card-hint {
  font-size: 0.78rem;
  color: rgba(139, 146, 168, 0.95);
}

.guess-panel {
  display: flex;
  gap: 0.65rem;
  align-items: stretch;
}

.guess-panel .guess-input {
  flex: 1;
}

.guess-input {
  appearance: textfield;
  -moz-appearance: textfield;
}

.guess-input::-webkit-outer-spin-button,
.guess-input::-webkit-inner-spin-button {
  appearance: none;
  -webkit-appearance: none;
  margin: 0;
}

.btn-guess {
  min-width: 5.5rem;
  flex-shrink: 0;
}

.clue-legend {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: center;
  gap: 0.35rem 0.5rem;
  margin: 0;
  padding: 0.45rem 0.5rem;
  font-size: 0.72rem;
  color: rgba(139, 146, 168, 0.95);
  line-height: 1.4;
  text-align: center;
}

.clue-legend-sep {
  opacity: 0.45;
}

.clue-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  border-radius: 2px;
  margin-right: 0.25rem;
  vertical-align: 0.05em;
  font-style: normal;
}

.clue-dot--g {
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.45);
}

.clue-dot--y {
  background: #ca8a04;
  box-shadow: 0 0 8px rgba(234, 179, 8, 0.35);
}

.clue-dot--x {
  background: #52525b;
}

.histories {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.85rem;
  margin-top: 0.15rem;
}

@media (max-width: 700px) {
  .histories {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 560px) {
  .guess-panel {
    flex-direction: column;
  }

  .guess-panel .guess-input {
    width: 100%;
  }

  .btn-guess {
    width: 100%;
    min-width: 0;
  }

  .game-head .room-strip.compact {
    justify-content: center;
  }
}

.history-col {
  padding: 0.85rem 0.75rem 0.75rem;
  border-radius: 14px;
  background: rgba(0, 0, 0, 0.22);
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.history-col--mine {
  border-left: 3px solid rgba(52, 211, 153, 0.45);
}

.history-col--opp {
  border-left: 3px solid rgba(148, 163, 184, 0.5);
}

.history-title {
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: rgba(180, 188, 206, 0.95);
  margin: 0 0 0.35rem;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.35rem;
}

.history-blurb {
  margin: 0 0 0.65rem;
  font-size: 0.78rem;
  line-height: 1.45;
  color: rgba(139, 146, 168, 0.98);
}

.history-blurb strong {
  color: #c4d0e8;
  font-weight: 600;
}

.history-hint-title {
  margin: 0 0 0.35rem;
  font-size: 0.68rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: rgba(139, 146, 168, 0.95);
}

.history-hint-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  justify-content: center;
  margin: 0 0 0.65rem;
  padding: 0.5rem 0.45rem;
  border-radius: 12px;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.history-hint-slot {
  min-width: 1.75rem;
  padding: 0.2rem 0.35rem;
  text-align: center;
  font-family: var(--mono);
  font-weight: 700;
  font-size: 0.95rem;
  border-radius: 8px;
  border: 1px dashed rgba(255, 255, 255, 0.18);
  color: rgba(139, 146, 168, 0.85);
  line-height: 1.2;
}

.history-hint-slot--on {
  border-style: solid;
  border-color: rgba(52, 211, 153, 0.45);
  background: rgba(16, 185, 129, 0.12);
  color: #a7f3d0;
  box-shadow: 0 0 12px rgba(52, 211, 153, 0.15);
}

.badge {
  display: inline-block;
  padding: 0.12rem 0.42rem;
  border-radius: 6px;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.04em;
}

.badge--me {
  background: rgba(52, 211, 153, 0.14);
  color: #6ee7b7;
  border: 1px solid rgba(52, 211, 153, 0.25);
}

.badge--opp {
  background: rgba(148, 163, 184, 0.12);
  color: #cbd5e1;
  border: 1px solid rgba(148, 163, 184, 0.28);
}

.history-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  max-height: 220px;
  overflow-y: auto;
}

.history-row {
  display: flex;
  gap: 0.35rem;
  justify-content: center;
  flex-wrap: wrap;
}

.feedback-cell {
  width: clamp(26px, 6.5vw, 40px);
  min-width: 24px;
  height: clamp(30px, 7.5vw, 44px);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 10px;
  font-family: var(--mono);
  font-weight: 600;
  font-size: clamp(0.72rem, 2.8vw, 1.1rem);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: inset 0 1px 0 var(--glass-highlight);
  transition: transform 0.2s ease;
}

.feedback-cell.green {
  background: linear-gradient(165deg, #2dd48a 0%, #15803d 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.18),
    0 3px 12px rgba(34, 197, 94, 0.28);
}

.feedback-cell.yellow {
  background: linear-gradient(165deg, #f0c030 0%, #a16207 100%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.16),
    0 3px 12px rgba(234, 179, 8, 0.22);
}

.feedback-cell.grey {
  background: linear-gradient(165deg, #5c5c66 0%, #3f3f46 100%);
  color: #e4e4e7;
}

.cell-hint {
  font-size: 0.55rem;
  margin-left: 1px;
  opacity: 0.85;
}

.btn-leave {
  align-self: center;
  margin-top: 0.25rem;
}

.end-screen {
  position: relative;
  overflow: hidden;
  text-align: center;
}

.end-title {
  font-size: clamp(1.75rem, 6vw, 2.25rem);
  margin-top: 0.5rem;
}

.end-sub {
  margin: 0;
}

.reveal-pins {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  align-items: center;
  margin: 0.5rem 0;
}

.reveal-row {
  font-size: 0.85rem;
  color: var(--muted);
}

.reveal-row strong {
  font-family: var(--mono);
  font-size: 1.1rem;
  color: var(--text);
  letter-spacing: 0.2em;
}

.end-actions {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
}

.confetti {
  position: absolute;
  inset: 0;
  pointer-events: none;
  overflow: hidden;
}

.confetti span {
  position: absolute;
  width: 8px;
  height: 12px;
  top: -20px;
  border-radius: 2px;
  animation: confettiFall linear forwards;
}

@keyframes confettiFall {
  to {
    transform: translateY(120vh) rotate(720deg);
    opacity: 0.9;
  }
}

.toast {
  position: fixed;
  bottom: max(1.5rem, env(safe-area-inset-bottom));
  left: 50%;
  max-width: calc(100vw - 2rem);
  transform: translateX(-50%) translateY(100px);
  z-index: 100;
  padding: 0.6rem 1.2rem;
  border-radius: 999px;
  background: rgba(22, 26, 40, 0.95);
  border: 1px solid var(--glass-border);
  font-size: 0.9rem;
  box-shadow: var(--shadow);
  transition: transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
  text-align: center;
}

.toast.show {
  transform: translateX(-50%) translateY(0);
}
