@import url("https://fonts.googleapis.com/css2?family=M+PLUS+1+Code:wght@400;700&display=swap");

:root {
  color-scheme: dark;
  --bg: #050505;
  --ink: #f4f4f5;
  --muted: #8f9299;
  --neon: #39ff14;
  --cyan: #00e6fe;
  --danger: #ff003c;
  --panel: rgba(7, 7, 8, 0.88);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "M PLUS 1 Code", monospace;
  color: var(--ink);
  background:
    radial-gradient(circle at 12% 18%, rgba(57, 255, 20, 0.18), transparent 38%),
    radial-gradient(circle at 88% 82%, rgba(0, 230, 254, 0.14), transparent 42%),
    var(--bg);
  display: grid;
  place-items: center;
  padding: 20px;
  overflow-x: hidden;
  position: relative;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  background:
    linear-gradient(rgba(18, 16, 16, 0) 50%, rgba(0, 0, 0, 0.34) 50%),
    linear-gradient(90deg, rgba(255, 0, 0, 0.06), rgba(0, 255, 0, 0.03), rgba(0, 0, 255, 0.06));
  background-size: 100% 4px, 6px 100%;
  opacity: 0.3;
  pointer-events: none;
  z-index: 1;
}

body::after {
  content: "";
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.02);
  animation: flicker 0.16s infinite;
  pointer-events: none;
  z-index: 2;
}

.bg-grid {
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(to right, rgba(255, 255, 255, 0.04) 1px, transparent 1px),
    linear-gradient(to bottom, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  opacity: 0.18;
  pointer-events: none;
  z-index: 0;
}

.bg-orb {
  position: fixed;
  width: 280px;
  height: 280px;
  border-radius: 50%;
  filter: blur(42px);
  pointer-events: none;
  z-index: 0;
}

.bg-orb-a {
  background: rgba(57, 255, 20, 0.22);
  top: -70px;
  left: -70px;
}

.bg-orb-b {
  background: rgba(0, 230, 254, 0.22);
  right: -80px;
  bottom: -70px;
}

.app {
  position: relative;
  z-index: 3;
  width: min(980px, 100%);
  background: var(--panel);
  border: 3px solid var(--ink);
  box-shadow: 10px 10px 0 var(--neon);
  padding: 26px;
}

.app-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 14px;
  padding-bottom: 14px;
  border-bottom: 3px solid var(--ink);
}

.kicker {
  margin: 0;
  font-size: 0.72rem;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--cyan);
}

.app-header h1 {
  margin: 6px 0 0;
  font-size: clamp(1.05rem, 3.1vw, 2rem);
  letter-spacing: 0.01em;
  line-height: 1.25;
  word-break: break-word;
}

.glitch {
  position: relative;
  display: inline-block;
}

.glitch::before,
.glitch::after {
  content: attr(data-text);
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.glitch::before {
  left: 2px;
  text-shadow: -2px 0 var(--danger);
  clip-path: inset(58% 0 2% 0);
  animation: glitch-a 2.4s infinite linear alternate-reverse;
}

.glitch::after {
  left: -2px;
  text-shadow: -2px 0 var(--cyan);
  clip-path: inset(8% 0 72% 0);
  animation: glitch-b 3.2s infinite linear alternate-reverse;
}

.subtitle {
  margin: 10px 0 0;
  color: var(--muted);
  font-size: 0.9rem;
}

.debug-profile {
  margin: 8px 0 0;
  font-size: 0.78rem;
  color: var(--cyan);
  letter-spacing: 0.03em;
  word-break: break-word;
}

.top-actions {
  margin-top: 2px;
}

.screen {
  display: none;
  margin-top: 22px;
  padding: 18px;
  border: none;
  background: rgba(0, 0, 0, 0.54);
  animation: panel-in 0.22s ease-out;
}

.screen.active {
  display: block;
}

.screen h2 {
  margin: 0 0 10px;
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.screen p {
  margin: 10px 0 0;
}

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

.hidden {
  display: none !important;
}

.countdown {
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--neon);
}

#session-countdown {
  color: var(--cyan);
}

.spinner {
  width: 30px;
  height: 30px;
  margin-top: 12px;
  border: 3px solid rgba(255, 255, 255, 0.25);
  border-top-color: var(--neon);
  border-right-color: var(--cyan);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}

.chat-meta {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  margin-bottom: 12px;
}

.chat-status {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.chat-status p {
  margin: 0;
}

#status-text {
  font-size: 0.95rem;
  letter-spacing: 0.03em;
}

.chat-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.guess-actions-message .message-text-row {
  margin-top: 8px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.guess-actions-message .message-text {
  margin: 0;
  flex: 1;
}

.guess-actions-message .chat-actions {
  margin-top: 0;
  margin-left: auto;
  justify-content: flex-end;
  flex-wrap: nowrap;
  width: auto;
  flex-direction: row;
}

.chat-log {
  border: 2px solid var(--ink);
  height: 340px;
  overflow: auto;
  padding: 14px;
  background: #020202;
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.1);
}

.message {
  margin: 0 0 11px;
  border: 2px solid var(--ink);
  padding: 10px;
  background: transparent;
}

.message-role {
  margin: 0;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.message-text {
  margin: 8px 0 0;
  white-space: pre-wrap;
  line-height: 1.45;
}

.message.user {
  border-color: var(--ink);
  background: transparent;
  color: var(--ink);
}

.message.user .message-role {
  color: var(--muted);
}

.message.partner {
  border-color: var(--neon);
  background: transparent;
  color: var(--neon);
}

.message.partner .message-role {
  color: #8dff77;
}

.message.system {
  border-style: dashed;
  border-color: var(--danger);
  background: rgba(255, 0, 60, 0.08);
}

.message.system .message-role {
  color: var(--danger);
}

.chat-form {
  display: flex;
  gap: 10px;
  margin-top: 14px;
}

.chat-form input {
  flex: 1;
  border: 2px solid var(--ink);
  background: transparent;
  color: var(--ink);
  padding: 12px 14px;
  font-family: inherit;
  font-size: 1rem;
}

.chat-form input::placeholder {
  color: #6f737a;
}

.chat-form input:focus {
  outline: none;
  border-color: var(--cyan);
  box-shadow: 0 0 0 2px rgba(0, 230, 254, 0.26);
}

button {
  appearance: none;
  border: 2px solid var(--ink);
  border-radius: 0;
  background: var(--ink);
  color: #050505;
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  transition: transform 0.08s ease, box-shadow 0.08s ease, background 0.08s ease, color 0.08s ease;
}

button:hover {
  transform: translate(-2px, -2px);
  box-shadow: 4px 4px 0 var(--ink);
}

button:active {
  transform: translate(0, 0);
  box-shadow: none;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

button.secondary {
  background: transparent;
  color: var(--ink);
}

button.secondary:hover {
  background: var(--ink);
  color: #050505;
}

.guess-btn {
  min-width: 150px;
}

.guess-btn[data-guess="ai"] {
  border-color: var(--neon);
  color: var(--neon);
  background: transparent;
}

.guess-btn[data-guess="ai"]:hover {
  background: var(--neon);
  color: #051305;
  box-shadow: 4px 4px 0 var(--neon);
}

.guess-btn[data-guess="human"] {
  border-color: var(--ink);
  color: var(--ink);
  background: transparent;
}

.guess-btn[data-guess="human"]:hover {
  background: var(--ink);
  color: #050505;
}

#screen-result,
#screen-exited {
  text-align: left;
}

#result-text {
  font-size: 1.05rem;
  margin: 12px 0 16px;
  border: 2px dashed var(--ink);
  padding: 12px;
  background: rgba(255, 255, 255, 0.04);
  white-space: pre-line;
}

#result-rematch-btn,
#result-top-btn {
  margin-right: 10px;
}

::-webkit-scrollbar {
  width: 11px;
}

::-webkit-scrollbar-track {
  background: #050505;
}

::-webkit-scrollbar-thumb {
  background: var(--neon);
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes panel-in {
  from {
    opacity: 0;
    transform: translateY(6px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes flicker {
  0% {
    opacity: 0.16;
  }

  5% {
    opacity: 0.1;
  }

  12% {
    opacity: 0.16;
  }

  100% {
    opacity: 0.16;
  }
}

@keyframes glitch-a {
  0% {
    clip-path: inset(58% 0 2% 0);
  }

  20% {
    clip-path: inset(15% 0 68% 0);
  }

  40% {
    clip-path: inset(70% 0 6% 0);
  }

  60% {
    clip-path: inset(35% 0 43% 0);
  }

  80% {
    clip-path: inset(8% 0 76% 0);
  }

  100% {
    clip-path: inset(46% 0 22% 0);
  }
}

@keyframes glitch-b {
  0% {
    clip-path: inset(8% 0 72% 0);
  }

  25% {
    clip-path: inset(78% 0 4% 0);
  }

  50% {
    clip-path: inset(30% 0 44% 0);
  }

  75% {
    clip-path: inset(63% 0 20% 0);
  }

  100% {
    clip-path: inset(19% 0 60% 0);
  }
}

@media (max-width: 760px) {
  body {
    padding: 10px;
  }

  .app {
    padding: 16px;
    box-shadow: 6px 6px 0 var(--neon);
  }

  .app-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .screen {
    padding: 14px;
  }

  .chat-meta {
    flex-direction: column;
    align-items: stretch;
  }

  .chat-actions {
    width: 100%;
    flex-direction: column;
  }

  .guess-actions-message .chat-actions {
    width: auto;
    flex-direction: row;
  }

  .guess-actions-message .guess-btn {
    width: auto;
  }

  .chat-form {
    flex-direction: column;
  }

  .chat-form button,
  #result-rematch-btn,
  #result-top-btn,
  #exit-btn,
  #exit-reconnect-btn,
  .guess-btn {
    width: 100%;
  }

  #result-rematch-btn,
  #result-top-btn {
    margin-right: 0;
    margin-top: 8px;
  }
}
