:root {
  --neon: #00ffff;
  --accent: #4b7bec;
  --bg-1: #0f2027;
  --bg-2: #203a43;
  --bg-3: #2c5364;
}

* {
  box-sizing: border-box;
}

html, body {
  height: 100%;
  margin: 0;
  font-family: 'Inter', sans-serif;
  background: radial-gradient(circle at 20% 10%, var(--bg-1), var(--bg-2), var(--bg-3));
  color: #ecf0f1;
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 14px;
}

/* Heading */
h1 {
  font-family: 'Orbitron', sans-serif;
  font-size: 28px;
  font-weight: 700;
  color: var(--neon);
  text-shadow: 0 0 8px rgba(0,255,255,0.9), 0 0 20px rgba(75,123,236,0.7);
  margin-bottom: 18px;
}

/* Center main content */
#main-content {
  width: 100%;
  max-width: 1400px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

/* User info form styling */
#user-info {
  width: 820px;
  text-align: left;
  padding: 16px;
  border-radius: 12px;
  background: rgba(0,0,0,0.35);
  box-shadow: 0 8px 20px rgba(0,0,0,0.6), 0 0 12px rgba(0,255,255,0.06);
  margin-bottom: 10px;
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 16px;
  justify-content: center;
}

#user-fields-row {
  width: 100%;
  display: flex;
  flex-direction: row;
  gap: 16px;
}

#user-info label {
  color: var(--neon);
  font-weight: 600;
  font-family: 'Orbitron', sans-serif;
  font-size: 14px;
  flex: 1 1 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

#user-info input {
  width: 100%;
  padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(255,255,255,0.08);
  background: #111;
  color: #fff;
  outline: none;
  font-size: 14px;
}

#clue-button, #toggle-answers {
  padding: 10px 25px;
  font-weight: 700;
  color: white;
  width: auto;          /* allow flex wrapper to control width */
  display: inline-flex; /* remove block forcing vertical stacking */
  margin: 0;            /* remove auto centering */
  justify-content: center;
  align-items: center;
  background: linear-gradient(135deg, var(--accent), #00c6ff);
  border: none;
  border-radius: 10px;
  transition: transform .12s ease, box-shadow .12s ease;
  cursor: pointer;
}

#clue-button:hover, #toggle-answers:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 10px rgba(0,255,255,0.12);
}

/* Timer display */
#timer-display {
  margin-bottom: 14px;
  font-weight: 600;
  color: var(--neon);
  text-shadow: 0 0 8px rgba(0,255,255,0.7);
  font-size: 16px;
  display: inline-block;
}

/* Main puzzle layout */
#puzzle-wrapper {
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  align-items: flex-start;
  gap: 10px;
  width: 100%;
  margin-bottom: 10px;
  box-sizing: border-box;
}

/* Clues container */
.clues-container {
  flex: 0 0 220px;
  min-width: 180px;
  max-width: 270px;
  font-family: 'Inter', sans-serif;
  font-size: 12px;
  padding: 16px;
  border-radius: 12px;
  background: rgba(0,255,255,0.04);
  box-shadow: 0 8px 24px rgba(0,0,0,0.6);
  overflow-y: auto;
  line-height: 1.4;
  text-align: left; /* added to override center */
}

.clues-container h2 {
  font-size: 18px;
  margin-bottom: 10px;
  color: var(--neon);
  font-family: 'Orbitron', sans-serif;
  text-shadow: 0 0 8px rgba(0,255,255,0.7);
  border-bottom: 2px solid var(--accent);
  padding-bottom: 2px;
  margin-top: 0;
}

.clues-container ul {
  margin: 0;
  padding-left: 15px;
}

.clues-container li,
.clue-item {
  margin-bottom: 4px;
  color: #fff;
}

/* Left and Right ordering */
.clues-left {
  order: 0;
}

.clues-right {
  order: 2;
}

/* Crossword grid container */
#crossword-scroll-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255,255,255,0.03);
  border-radius: 12px;
  padding: 10px;
  box-shadow: 0 8px 28px rgba(0,0,0,0.6), 0 0 30px rgba(0,255,255,0.06);
  min-width: 0;
  min-height: 0;
  flex: 1 1 auto;
  overflow-x: auto;
  margin: 0;
  order: 1;
}

/* Crossword grid layout */
#crossword-container {
  display: grid;
  grid-auto-rows: 24px;
  grid-auto-columns: 24px;
  gap: 1px;
  background: none;
  justify-content: center;
  align-content: center;
}

.cell {
  position: relative;
  width: 24px;
  height: 24px;
  background: rgba(0,255,255,0.08);
  border-radius: 3px;
  color: var(--neon);
  font-weight: 700;
  font-size: 12px; /* Letter size */
  box-sizing: border-box;
  transition: transform .12s ease, box-shadow .12s ease, background .12s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  overflow: hidden;
  box-shadow: 0 0 0 1px rgba(0,255,255,0.08);
}

.cell:hover {
  transform: scale(1.08);
  box-shadow: 0 0 10px rgba(0,255,255,0.12);
}

.cell.black {
  background-color: #222 !important;
  border: none !important;
  box-shadow: none !important;
}

.number {
  position: absolute;
  top: 2px;
  left: 4px;
  font-size: 8px; /* Number size */
  color: var(--accent);
  user-select: none;
  font-family: 'Orbitron', sans-serif;
  pointer-events: none;
  font-weight: 400;
  line-height: 1;
}

.letter-input {
  width: 100%;
  height: 100%;
  border: none;
  text-align: center;
  font-weight: 700;
  font-size: 12px; /* Letter size */
  text-transform: uppercase;
  outline: none;
  cursor: pointer;
  background: transparent;
  padding: 0;
  margin: 0;
  line-height: 24px;
  color: var(--neon);
  font-family: 'Orbitron', sans-serif;
  transition: background .12s, color .12s;
}

/* Selected input */
.letter-input.selected {
  background-color: var(--accent);
  color: #fff;
  outline: 2px solid var(--neon);
}

/* Correct answer */
.cell.completed .letter-input,
.letter-input:disabled {
  background-color: #27ae60 !important;
  color: #fff !important;
  font-weight: 700;
}

/* Invalid letters */
.cell.invalid,
.letter-input.invalid {
  background-color: #f43256 !important;
  border: 1.5px solid #f43256 !important;
  color: #fff !important;
}

/* Clue lists */
#across-list,
#down-list {
  list-style: none;
  padding-left: 5px;
  margin: 0;
  font-size: 12px;
  line-height: 1.2;
}

#across-list li,
#down-list li {
  margin-bottom: 6px;
}

/* Show/Hide Answers button */
#toggle-answers {
  padding: 10px 25px;
  font-weight: 700;
  color: white;
  background: linear-gradient(135deg, var(--accent), #00c6ff);
  border: none;
  border-radius: 10px;
  transition: transform .12s ease, box-shadow .12s ease;
  cursor: pointer;
}

#toggle-answers:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 10px rgba(0,255,255,0.12);
}

/* Responsive: stack layout on small screens */
@media (max-width: 900px) {
  #puzzle-wrapper {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
  }
  .clues-container, #crossword-scroll-wrapper {
    max-width: 100%;
    min-width: 0;
    flex: 1 1 100%;
  }
}

/* Add this below */
@media (max-width: 600px) {
  .cell, .letter-input {
    width: 36px !important;
    height: 36px !important;
    font-size: 18px !important;
  }
  .number {
    font-size: 12px !important;
  }
  #clue-button, #toggle-answers {
    font-size: 16px;
    padding: 14px 0;
    width: 100%;
  }
}

@media (max-width: 600px) {
  #user-info {
    width: 98%;
    padding: 10px;
  }
  #user-fields-row {
    flex-direction: column;
    gap: 8px;
  }
  #clue-button {
    width: 100%;
  }
}