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

body {
  font-family: system-ui, sans-serif;
  background: #f5f0e8;
  color: #1a1a1a;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  align-items: stretch;
}

header {
  background: #c0392b;
  color: #fff;
  padding: 1rem;
  text-align: center;
}

header h1 {
  font-size: 1.8rem;
  letter-spacing: 0.05em;
  margin-bottom: 0.6rem;
}

.code-box {
  font-size: 0.95rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-bottom: 0.6rem;
}

.code-input-box {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
}

.code-input-box label {
  font-size: 0.85rem;
  opacity: 0.9;
}

#code-input {
  font-family: monospace;
  font-size: 1rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  width: 7rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid rgba(255,255,255,0.5);
  border-radius: 4px;
  background: rgba(255,255,255,0.15);
  color: #fff;
  outline: none;
}

#code-input::placeholder {
  color: rgba(255,255,255,0.5);
  text-transform: none;
  letter-spacing: normal;
}

#code-input:focus {
  background: rgba(255,255,255,0.25);
  border-color: #fff;
}

#code-go-btn {
  background: rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.5);
  color: #fff;
  padding: 0.2rem 0.65rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
}

#code-go-btn:hover {
  background: rgba(255,255,255,0.4);
}

#code-display {
  font-family: monospace;
  font-size: 1.1rem;
  font-weight: bold;
  background: rgba(255,255,255,0.2);
  padding: 0.1rem 0.4rem;
  border-radius: 4px;
  letter-spacing: 0.1em;
}

#copy-btn {
  background: rgba(255,255,255,0.25);
  border: 1px solid rgba(255,255,255,0.5);
  color: #fff;
  padding: 0.15rem 0.5rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.8rem;
}

#copy-btn:hover {
  background: rgba(255,255,255,0.4);
}

main {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  width: 100%;
}

.board {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 6px;
  width: min(95vw, 520px);
}

.cell {
  aspect-ratio: 1;
  background: #fff;
  border: 2px solid #d0c8b8;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 6px;
  font-size: clamp(0.55rem, 2vw, 0.75rem);
  font-weight: 500;
  cursor: pointer;
  user-select: none;
  transition: background 0.15s, transform 0.1s, border-color 0.15s;
  line-height: 1.2;
  white-space: pre-wrap;
  word-break: break-word;
}

.cell:hover {
  border-color: #c0392b;
  transform: scale(1.03);
}

.cell:active {
  transform: scale(0.97);
}

.cell.marked {
  background: #c0392b;
  border-color: #a93226;
  color: #fff;
  position: relative;
}

.cell.marked::after {
  content: "✓";
  position: absolute;
  top: 4px;
  right: 6px;
  font-size: 0.7rem;
  opacity: 0.8;
}

.cell.bingo-line {
  background: #e8b84b;
  border-color: #c9992a;
  color: #1a1a1a;
}

.cell.marked.bingo-line {
  background: #e8b84b;
  border-color: #c9992a;
  color: #1a1a1a;
}

.bingo-banner {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: clamp(3rem, 15vw, 6rem);
  font-weight: 900;
  color: #fff;
  text-shadow: 0 4px 20px rgba(0,0,0,0.5);
  background: rgba(0, 0, 0, 0.35);
  letter-spacing: 0.1em;
  z-index: 100;
  pointer-events: none;
  transition: opacity 0.5s;
}

.bingo-banner.hidden {
  display: none;
}

.bingo-banner.fading {
  opacity: 0;
}
