:root {
  --bg-top: #1a0033;
  --bg-bottom: #000010;
  --panel-bg: rgba(20, 10, 40, 0.72);
  --panel-border: rgba(255, 255, 255, 0.09);
  --text: #ffffff;
  --muted: #d1c4e9;

  --neon-pink: #ff4ecd;
  --neon-purple: #7c3aed;
  --neon-cyan: #22d3ee;
  --neon-lime: #a3e635;
  --success-green: #22c55e;
  --success-green-2: #4ade80;
  --danger: #fb7185;

  --tile-bg-1: #1f1f3a;
  --tile-bg-2: #0f0f2a;
  --tile-hover-1: #2a2450;
  --tile-hover-2: #17173a;

  --shadow-soft: 0 0 20px rgba(124, 58, 237, 0.18);
  --shadow-pink: 0 0 20px rgba(255, 78, 205, 0.55);
  --shadow-purple: 0 0 20px rgba(124, 58, 237, 0.5);
  --shadow-green: 0 0 20px rgba(34, 197, 94, 0.55);

  --radius-xl: 24px;
  --radius-lg: 20px;
  --radius-md: 16px;
  --radius-sm: 12px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Poppins", ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background:
    radial-gradient(circle at top, var(--bg-top), var(--bg-bottom));
  color: var(--text);
  min-height: 100vh;
}

.container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 24px;
}

.hero {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: 24px;
}


h1 {
  margin: 0 0 6px 0;
  font-size: 2.7rem;
  font-weight: 800;
  line-height: 1;
  letter-spacing: 0.02em;
  color: var(--neon-cyan);
}

.brand {
  display: flex;
  align-items: center;
  gap: clamp(12px, 2vw, 18px);
}

.logo {
  width: clamp(72px, 12vw, 120px);
  height: clamp(72px, 12vw, 120px);
  object-fit: contain;
  flex-shrink: 0;
}

.subtitle {
  margin-top: 6px;
  font-size: 1rem;
  line-height: 1.4;
  color: rgba(255,255,255,0.78);
  max-width: 34ch;
}

.badge {
  padding: 4px 10px;
  border-radius: 999px;

  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;

  background: rgba(34, 211, 238, 0.08);
  color: rgba(34, 211, 238, 0.95);
  border: 1px solid rgba(34, 211, 238, 0.18);

  box-shadow: none;
  cursor: default;
}

.layout {
  display: grid;
  grid-template-columns: 300px 1fr;
  gap: 20px;
  transition: grid-template-columns 0.28s ease;
}

.sidebar {
  min-width: 0;
  overflow: hidden;
  opacity: 1;
  transform: translateX(0);
  transition:
    opacity 0.22s ease,
    transform 0.28s ease,
    padding 0.28s ease,
    border-width 0.28s ease;
}

.layout.sidebar-hidden {
  grid-template-columns: 0 1fr;
}

.layout.sidebar-hidden .sidebar {
  opacity: 0;
  transform: translateX(-10px);
  padding-left: 0;
  padding-right: 0;
  border-width: 0;
}

.layout.sidebar-hidden .sidebar > * {
  pointer-events: none;
}

.sidebar-divider {
  height: 1px;
  margin: 18px 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255,255,255,0.12),
    transparent
  );
}

.sidebar h2,
.main h3 {
  margin-top: 0;
  margin-bottom: 14px;
  font-size: 1rem;
  color: #f5d0fe;
  letter-spacing: 0.04em;
}

.sidebar h2.section-gap {
  margin-top: 20px;
}

.main {
  min-width: 0;
}

.panel {
  background: var(--panel-bg);
  border-radius: var(--radius-xl);
  padding: 18px;
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(10px);
  box-shadow:
    0 0 30px rgba(124, 58, 237, 0.2),
    inset 0 0 18px rgba(255, 255, 255, 0.03);
}

label {
  display: block;
  margin-bottom: 14px;
  font-size: 0.92rem;
  color: var(--muted);
}

input {
  width: 100%;
  margin-top: 6px;
  padding: 12px 14px;
  border-radius: 14px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  outline: none;
  background: rgba(10, 10, 30, 0.9);
  color: white;
  font-size: 0.98rem;
  box-shadow: inset 0 0 12px rgba(255, 255, 255, 0.03);
}

input:focus {
  border-color: rgba(34, 211, 238, 0.65);
  box-shadow:
    0 0 0 3px rgba(34, 211, 238, 0.12),
    inset 0 0 12px rgba(255, 255, 255, 0.03);
}

input.input-error {
  border-color: rgba(34, 211, 238, 0.9);
  box-shadow:
    0 0 0 3px rgba(34, 211, 238, 0.15),
    0 0 12px rgba(34, 211, 238, 0.35),
    inset 0 0 12px rgba(255, 255, 255, 0.03);
}


#username::placeholder {
  color: rgba(255,255,255,0.45);
}


button {
  border-radius: 999px;
  padding: 12px 14px;
  font-size: 0.96rem;
  font-weight: 700;
  border: none;
  cursor: pointer;
  color: white;
  background: #00eaff;
  color: #001418;
  box-shadow: 0 0 15px rgba(0, 234, 255, 0.4);
  transition: transform 0.12s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

button:hover:not(:disabled) {
  transform: translateY(-1px) scale(1.02);
  box-shadow:
    0 0 25px rgba(0, 234, 255, 0.7),
    0 0 40px rgba(0, 234, 255, 0.4);
}


button:active:not(:disabled) {
  transform: translateY(0) scale(1);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.45;
  box-shadow: none;
}

.button-purple-pink {
  background: linear-gradient(135deg, var(--neon-purple), var(--neon-pink));
}

#queueBtn {
  background: linear-gradient(135deg, #24304e, #16213a);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
}

#clearBtn {
  padding: 4px 8px;
  font-size: 0.75rem;
  border-radius: 8px;
  min-height: 48px;
  background: transparent;
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  box-shadow: none;
  cursor: pointer;
}

#queueBtn:hover:not(:disabled),
#clearBtn:hover:not(:disabled) {
  box-shadow: 0 0 18px rgba(34, 211, 238, 0.25);
}

#submitBtn {
  width: 100%;
  margin-top: 18px;
  padding: 14px 16px;
  font-size: 1rem;
}

.button-row {
  display: flex;
  gap: 10px;
  margin-bottom: 16px;
}

.button-row button {
  flex: 1;
}

.stat {
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat div {
  color: var(--muted);
  font-size: 0.84rem;
  margin-bottom: 4px;
}

.stat strong {
  font-size: 1.06rem;
  color: #ffffff;
}

.banner {
  min-height: 28px;
  padding: 12px 14px;
  margin-bottom: 16px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.04);
  color: #fdf4ff;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

.status-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 10px;
  margin-bottom: 20px;
}

.status-card {
  padding: 12px 14px;
  border-radius: 12px;
  background: rgba(255, 255, 255, 0.025);
  border: 1px solid rgba(255, 255, 255, 0.08);
  box-shadow: none;
  position: relative;
  overflow: hidden;
}

.status-card::before {
  content: "";
  position: absolute;
  left: 0;
  top: 10px;
  bottom: 10px;
  width: 3px;
  border-radius: 999px;
  background: rgba(34, 211, 238, 0.75);
}

.status-card strong {
  display: block;
  font-size: 0.72rem;
  color: #b8a9d6;
  margin-bottom: 6px;
  margin-left: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.status-card div {
  font-size: 1.05rem;
  font-weight: 700;
  margin-left: 10px;
  color: #ffffff;
}

#solvedBoard {
  margin-top: 24px;
  border-top: 1px solid rgba(255,255,255,0.1);
  padding-top: 12px;
}

.solved-section {
  margin-top: 28px;
  padding-top: 16px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.solved-group {
  background: linear-gradient(135deg, #22d3ee, #06b6d4);
  color: #001018;

  padding: 12px 14px;
  margin-bottom: 10px;
  border-radius: 18px;

  box-shadow:
    0 0 20px rgba(34, 211, 238, 0.7),
    0 0 40px rgba(34, 211, 238, 0.4);

  border: 1px solid rgba(34, 211, 238, 0.6);

  transition: transform 0.15s ease, box-shadow 0.2s ease;
}

.solved-group strong {
  display: block;
  margin-bottom: 4px;
  font-size: 0.98rem;
}

.selection-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin: 14px 0 10px;
  color: var(--muted);
  font-size: 0.95rem;
}

.board {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 12px;
}

.tile {
  background: linear-gradient(145deg, var(--tile-bg-1), var(--tile-bg-2));
  border-radius: 20px;
  padding: clamp(2px, 1vw, 18px) clamp(2px, 1.2vw, 12px);
  min-height: 84px;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-weight: 700;
  border: 1px solid rgba(255, 255, 255, 0.1);
  box-shadow:
    0 0 10px rgba(124, 58, 237, 0.3),
    inset 0 0 10px rgba(255, 255, 255, 0.05);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
  user-select: none;
  overflow: hidden;
}

.tile-text {
  display: block;
  white-space: nowrap;
  line-height: 1;
  max-width: 100%;
  letter-spacing: 0;
  font-size: 16px;
}

.tile:not(.solved):not(.selected):hover {
  transform: translateY(-3px) scale(1.02);
  background: linear-gradient(145deg, var(--tile-hover-1), var(--tile-hover-2));
  box-shadow:
    0 0 20px rgba(124, 58, 237, 0.55),
    0 0 40px rgba(124, 58, 237, 0.25);
}

.tile.selected {
  background: #00eaff;        /* solid cyan */
  color: #001418;             /* dark text for contrast */

  border-color: #00eaff;

  box-shadow:
    0 0 10px rgba(0, 234, 255, 0.8),
    0 0 20px rgba(0, 234, 255, 0.5);

  transform: scale(1.05);

  animation: pulse-cyan-bg 3s ease-in-out infinite;
}

.tile.wrong {
  background: rgba(251, 113, 133, 0.22);
  border-color: rgba(251, 113, 133, 0.7);
  box-shadow:
    0 0 10px rgba(251, 113, 133, 0.45),
    0 0 18px rgba(251, 113, 133, 0.2);
  animation: wrong-shake 0.35s ease;
}

.tile.solved {
  border-color: #444;
  color: #888;
  background: rgba(255, 255, 255, 0.05);

  box-shadow: none;
  opacity: 0.6;
  cursor: default;
}

.log {
  margin-top: 12px;
  font-size: 12px;
  line-height: 1.45;
  height: 140px;
  overflow: auto;
  background: rgba(2, 6, 23, 0.72);
  padding: 10px;
  border-radius: var(--radius-md);
  border: 1px solid rgba(255, 255, 255, 0.06);
  color: #dbeafe;
  white-space: pre-wrap;
}

.pregame-panel {
  text-align: center;
  padding: 24px 12px;
}

.postgame-panel {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 6, 23, 0.7);
  backdrop-filter: blur(2px);

  overflow-y: auto;
}

.postgame-panel[hidden] {
  display: none !important;
}

.postgame-modal {
  width: min(520px, 92vw);
  text-align: center;
  padding: 28px 24px;
  border-radius: 24px;
  background: rgba(20, 10, 40, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 0 30px rgba(124, 58, 237, 0.28),
    0 0 50px rgba(255, 78, 205, 0.18);
}

.postgame-title {
  margin: 0 0 10px;
  font-size: clamp(2rem, 5vw, 3rem);
  line-height: 1;
}

.postgame-title.win {
  color: #22d3ee;
  text-shadow: 0 0 18px rgba(34, 211, 238, 0.45);
}

.postgame-title.loss {
  color: #ff7aa8;
  text-shadow: 0 0 18px rgba(255, 122, 168, 0.4);
}

.postgame-reason {
  margin: 12px 0 20px;
  color: var(--muted);
  font-size: 1rem;
}

.postgame-actions {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 10px;
}

.postgame-groups-wrap {
  margin-top: 22px;
  text-align: left;
}

.postgame-groups-heading {
  margin: 0 0 12px 0;
  font-size: 0.95rem;
  color: #f5d0fe;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.postgame-solved-board .solved-by-me {
  background: linear-gradient(135deg, #22d3ee, #06b6d4);
  color: #001018;
  border: 1px solid rgba(34, 211, 238, 0.6);
  box-shadow:
    0 0 20px rgba(34, 211, 238, 0.55),
    0 0 36px rgba(34, 211, 238, 0.22);
}

.postgame-solved-board .solved-by-opp {
  background: linear-gradient(135deg, #fb7185, #f43f5e);
  color: #22040a;
  border: 1px solid rgba(251, 113, 133, 0.6);
  box-shadow:
    0 0 20px rgba(251, 113, 133, 0.4),
    0 0 36px rgba(251, 113, 133, 0.16);
}

.postgame-solved-board .solved-unclaimed {
  background: rgba(255, 255, 255, 0.06);
  color: #e9e9f4;
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow: none;
}

.postgame-solved-board .solved-group {
  margin-bottom: 12px;
}

.group-owner-label {
  margin-top: 6px;
  font-size: 0.8rem;
  opacity: 0.9;
  font-weight: 600;
}

.pregame-countdown {
  font-size: 56px;
  font-weight: 800;
  margin-top: 12px;
}

.postgame-reason {
  margin: 12px 0 20px;
}

.quit-btn {
  display: block;
  margin: 48px 0 0 0;
  padding: 12px 20px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 14px;
  background: rgba(255, 255, 255, 0.06);
  color: #ffd7d7;
  font-weight: 700;
  cursor: pointer;
  box-shadow: 0 0 12px rgba(255, 80, 80, 0.12);
  transition: transform 0.15s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.quit-btn:hover {
  transform: translateY(-1px);
  background: rgba(255, 80, 80, 0.12);
  box-shadow: 0 0 16px rgba(255, 80, 80, 0.2);
}

.quit-btn:active {
  transform: translateY(0);
}

.quit-btn[hidden] {
  display: none !important;
}

.confirm-panel {
  position: fixed;
  inset: 0;
  z-index: 1100;
  display: grid;
  place-items: center;
  padding: 24px;
  background: rgba(2, 6, 23, 0.72);
  backdrop-filter: blur(2px);
}

.confirm-panel[hidden] {
  display: none !important;
}

.confirm-modal {
  width: min(380px, 92vw);
  text-align: center;
  padding: 24px;
  border-radius: 22px;
  background: rgba(20, 10, 40, 0.96);
  border: 1px solid rgba(255, 255, 255, 0.12);
  box-shadow:
    0 0 30px rgba(124, 58, 237, 0.3),
    0 0 45px rgba(255, 78, 205, 0.16);
}

.confirm-modal h2 {
  margin: 0 0 10px;
  color: #fff;
}

.confirm-modal p {
  margin: 0 0 20px;
  color: var(--muted);
}

@keyframes pulse-cyan-bg {
  0% {
    background: #00eaff;
    box-shadow:
      0 0 8px rgba(0, 234, 255, 0.6),
      0 0 16px rgba(0, 234, 255, 0.4);
  }
  50% {
    background: #1ff3ff; /* slightly brighter cyan */
    box-shadow:
      0 0 14px rgba(0, 234, 255, 1),
      0 0 28px rgba(0, 234, 255, 0.7);
  }
  100% {
    background: #00eaff;
    box-shadow:
      0 0 8px rgba(0, 234, 255, 0.6),
      0 0 16px rgba(0, 234, 255, 0.4);
  }
}

@keyframes pulseGlow {
  0% {
    box-shadow:
      0 0 12px rgba(124, 58, 237, 0.55),
      0 0 24px rgba(255, 78, 205, 0.25);
  }
  50% {
    box-shadow:
      0 0 24px rgba(255, 78, 205, 0.75),
      0 0 42px rgba(255, 78, 205, 0.35);
  }
  100% {
    box-shadow:
      0 0 12px rgba(124, 58, 237, 0.55),
      0 0 24px rgba(255, 78, 205, 0.25);
  }
}

@keyframes wrong-shake {
  0%   { transform: translateX(0); }
  20%  { transform: translateX(-3px); }
  40%  { transform: translateX(3px); }
  60%  { transform: translateX(-2px); }
  80%  { transform: translateX(2px); }
  100% { transform: translateX(0); }
}

@media (max-width: 900px) {
  .layout {
    display: flex;
    flex-direction: column;
    gap: 20px;
  }

  .main {
    order: 1;
  }

  .sidebar {
    order: 2;
  }

  .layout.sidebar-hidden .sidebar {
    display: none;
  }

  .status-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 640px) {
  .container {
    padding: 12px;
  }

  .hero {
    flex-direction: column;
    align-items: flex-start;
    gap: 10px;
    margin-bottom: 16px;
  }

  h1 {
    font-size: 2rem;
  }

  .subtitle {
    font-size: 0.9rem;
  }

  .badge {
    padding: 8px 12px;
    font-size: 0.82rem;
  }

  .panel {
    padding: 14px;
    border-radius: 18px;
  }

  .status-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 16px;
  }

  .status-card {
    padding: 10px 10px 10px 12px;
  }

  .status-card strong {
    font-size: 0.66rem;
    margin-bottom: 4px;
  }

  .status-card div {
    font-size: 0.95rem;
  }

  .banner {
    padding: 10px 12px;
    margin-bottom: 14px;
    font-size: 0.92rem;
  }

  .board {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
    margin-top: 10px;
  }

  .tile {
    min-height: 64px;
    padding: 10px 6px;
    border-radius: 14px;
    font-size: 0.78rem;
    line-height: 1.1;
    letter-spacing: 0.01em;
  }

  .selection-row {
    flex-direction: row;
    align-items: center;
    gap: 8px;
    margin: 12px 0 8px;
    font-size: 0.88rem;
  }

  .button-row {
    flex-direction: column;
    gap: 8px;
  }

  #submitBtn,
  #clearBtn,
  .button-row button {
    min-height: 48px;
  }

  .solved-section {
    margin-top: 18px;
    padding-top: 12px;
  }

  .solved-group {
    padding: 10px 12px;
    border-radius: 14px;
    margin-bottom: 8px;
  }

  .quit-btn {
    margin: 28px 0 0 0;
    padding: 10px 16px;
    font-size: 0.9rem;
  }

  .pregame-panel {
    padding: 16px 8px;
  }

  .pregame-countdown {
    font-size: 44px;
  }

  .postgame-panel {
    padding: 12px;
  }

  .postgame-modal {
    width: min(560px, 100%);
    padding: 22px 16px;
    border-radius: 18px;
    max-height: 92vh;
    overflow-y: auto;
  }

  .postgame-title {
    font-size: clamp(1.8rem, 9vw, 2.4rem);
  }

  .postgame-reason {
    font-size: 0.95rem;
    margin: 10px 0 16px;
  }

  .postgame-actions {
    margin-top: 14px;
  }
}