﻿@import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@400;700&display=swap');

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

:root {
  --bg: #0a0a0a;
  --green: #00ff41;
  --green-dim: #00aa2a;
  --green-bg: rgba(0, 255, 65, 0.08);
  --green-bg-bright: rgba(0, 255, 65, 0.18);
  --cyan: #00e5ff;
  --magenta: #ff00ff;
  --pink: #ff6ec7;
}

body {
  font-family: 'Fira Code', 'Courier New', monospace;
  background: var(--bg);
  color: var(--green);
  min-height: 100vh;
  overflow-x: hidden;
  position: relative;
}

/* CRT scanline overlay */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.15) 2px,
    rgba(0, 0, 0, 0.15) 4px
  );
  pointer-events: none;
  z-index: 100;
}

#matrix-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.12;
}

.container {
  position: relative;
  z-index: 1;
  max-width: 650px;
  width: 95vw;
  margin: 0 auto;
  padding: 24px 16px 40px;
  display: flex;
  flex-direction: column;
  align-items: center;
  min-height: 100vh;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 24px;
}

h1 {
  font-size: clamp(1.1rem, 4vw, 1.8rem);
  font-weight: 700;
  text-shadow: 0 0 12px var(--green), 0 0 24px rgba(0, 255, 65, 0.3);
  letter-spacing: 0.05em;
}

.cursor {
  animation: blink 1s step-end infinite;
}

@keyframes blink {
  50% { opacity: 0; }
}

.subtitle {
  font-size: clamp(0.6rem, 1.8vw, 0.8rem);
  color: var(--green-dim);
  margin-top: 8px;
}

/* Bingo Grid */
.board-shell {
  position: relative;
  width: 100%;
  max-width: 560px;
}

.grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 3px;
  width: 100%;
  background: rgba(0, 255, 65, 0.1);
  border: 1px solid var(--green-dim);
  padding: 3px;
  border-radius: 2px;
}

.cell {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  font-size: clamp(0.5rem, 2vw, 0.78rem);
  font-family: 'Fira Code', monospace;
  padding: 4px 2px;
  cursor: pointer;
  background: var(--bg);
  color: var(--green-dim);
  border: 1px solid rgba(0, 255, 65, 0.2);
  transition: all 0.15s ease;
  word-break: break-word;
  line-height: 1.2;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  overflow: hidden;
  appearance: none;
  font-family: inherit;
  border-radius: 0;
}

.cell:hover {
  background: var(--green-bg);
  color: var(--green);
  transform: scale(1.04);
  z-index: 2;
  text-shadow: 0 0 6px var(--green);
}

.cell:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.cell.selected {
  background: var(--green-bg-bright);
  color: var(--green);
  text-shadow: 0 0 8px var(--green);
  border-color: var(--green);
  box-shadow: inset 0 0 12px rgba(0, 255, 65, 0.15), 0 0 8px rgba(0, 255, 65, 0.2);
}

.cell.center {
  background: rgba(0, 229, 255, 0.1);
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan);
  border-color: var(--cyan);
  font-weight: 700;
  font-size: clamp(0.7rem, 2.5vw, 1rem);
  cursor: default;
}

.cell.winning {
  animation: pulse-glow 0.8s ease-in-out infinite alternate;
  border-color: var(--cyan);
  color: var(--cyan);
  z-index: 3;
}

@keyframes pulse-glow {
  from {
    box-shadow: 0 0 8px var(--cyan), inset 0 0 8px rgba(0, 229, 255, 0.2);
    background: rgba(0, 229, 255, 0.08);
    text-shadow: 0 0 8px var(--cyan);
  }
  to {
    box-shadow: 0 0 20px var(--cyan), 0 0 40px rgba(0, 229, 255, 0.35), inset 0 0 16px rgba(0, 229, 255, 0.25);
    background: rgba(0, 229, 255, 0.16);
    text-shadow: 0 0 16px var(--cyan);
  }
}

/* Select animation */
.cell.pop {
  animation: cell-pop 0.2s ease-out;
}

@keyframes cell-pop {
  0% { transform: scale(0.9); opacity: 0.6; }
  60% { transform: scale(1.08); }
  100% { transform: scale(1); opacity: 1; }
}

/* Win banner */
.win-banner {
  position: absolute;
  left: 0;
  top: 50%;
  transform: translateY(-50%);
  z-index: 20;
  padding: 16px 24px;
  border: 1px solid var(--cyan);
  background: rgba(10, 10, 10, 0.72);
  backdrop-filter: blur(1px);
  text-align: center;
  font-size: clamp(0.7rem, 2.5vw, 1rem);
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan);
  white-space: pre-line;
  animation: banner-in 0.5s ease-out;
  width: 100%;
  pointer-events: none;
}

@keyframes banner-in {
  from { opacity: 0; transform: translateY(-20px); }
  to { opacity: 1; transform: translateY(0); }
}

.hidden {
  display: none !important;
}

/* Controls */
.controls {
  display: flex;
  gap: 12px;
  margin-top: 20px;
  flex-wrap: wrap;
  justify-content: center;
}

.controls button {
  font-family: 'Fira Code', monospace;
  font-size: clamp(0.65rem, 2vw, 0.85rem);
  padding: 10px 20px;
  background: transparent;
  color: var(--green);
  border: 1px solid var(--green-dim);
  cursor: pointer;
  transition: all 0.15s ease;
  letter-spacing: 0.05em;
}

.controls button:hover {
  background: var(--green-bg);
  border-color: var(--green);
  text-shadow: 0 0 8px var(--green);
  box-shadow: 0 0 12px rgba(0, 255, 65, 0.2);
}

.controls button:active {
  transform: scale(0.96);
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--green-bg-bright);
  color: var(--green);
  border: 1px solid var(--green);
  padding: 10px 20px;
  font-family: 'Fira Code', monospace;
  font-size: 0.75rem;
  z-index: 200;
  animation: toast-in 0.3s ease-out;
  text-shadow: 0 0 6px var(--green);
}

@keyframes toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(20px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* Share modal */
.modal {
  position: fixed;
  inset: 0;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(2px);
}

.modal-card {
  width: min(560px, 100%);
  border: 1px solid var(--cyan);
  background: rgba(10, 10, 10, 0.96);
  box-shadow: 0 0 20px rgba(0, 229, 255, 0.18), inset 0 0 12px rgba(0, 255, 65, 0.1);
  padding: 16px;
}

.modal-card h2 {
  color: var(--cyan);
  font-size: clamp(0.9rem, 2.8vw, 1.1rem);
  text-shadow: 0 0 10px rgba(0, 229, 255, 0.45);
}

.modal-subtitle {
  margin-top: 10px;
  margin-bottom: 10px;
  color: var(--green-dim);
  font-size: clamp(0.62rem, 1.8vw, 0.8rem);
}

.modal-input {
  width: 100%;
  padding: 10px;
  border: 1px solid var(--green-dim);
  background: rgba(0, 255, 65, 0.05);
  color: var(--green);
  font-family: 'Fira Code', monospace;
  font-size: clamp(0.62rem, 1.9vw, 0.82rem);
}

.modal-input:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

.modal-actions {
  margin-top: 12px;
  display: flex;
  gap: 10px;
  justify-content: flex-end;
  flex-wrap: wrap;
}

.modal-actions button {
  font-family: 'Fira Code', monospace;
  font-size: clamp(0.62rem, 1.9vw, 0.82rem);
  padding: 10px 16px;
  background: transparent;
  color: var(--green);
  border: 1px solid var(--green-dim);
  cursor: pointer;
  letter-spacing: 0.05em;
  transition: all 0.15s ease;
}

.modal-actions button:hover {
  background: var(--green-bg);
  border-color: var(--green);
  text-shadow: 0 0 8px var(--green);
}

.modal-actions button:focus-visible {
  outline: 2px solid var(--cyan);
  outline-offset: 2px;
}

/* Footer */
.footer {
  margin-top: 24px;
  font-size: clamp(0.55rem, 1.6vw, 0.72rem);
  color: var(--green-dim);
  text-align: center;
}

.footer a {
  color: var(--green);
  text-decoration: none;
  border-bottom: 1px solid rgba(0, 255, 65, 0.3);
  transition: all 0.15s ease;
}

.footer a:hover {
  text-shadow: 0 0 8px var(--green);
  border-bottom-color: var(--green);
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
  #matrix-bg { display: none; }
}
