/* Grundl Game Styles */

:root {
  --color-start-end: #1a1a1a;
  --color-correct: #16a34a;
  --color-clue: #bf3294;
  --color-guess: #1e3a8a;
  --color-wrong: #ea580c;
  --color-border: #e5e7eb;
  --color-bg: #f9fafb;
  --color-card: #ffffff;
  --color-text: #111827;
  --color-muted: #6b7280;
  --shadow: 0 1px 4px rgba(0,0,0,0.08);
  --cell-gap: 20px;
  --cell-border: 12px;
}

* {
  box-sizing: border-box;
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background-color: var(--color-bg);
  color: var(--color-text);
  margin: 0;
  padding: 0;
}

.grundl-container {
  max-width: 720px;
  margin: 0 auto;
  padding: 20px 20px 40px;
}

/* Header */
.grundl-header {
  text-align: center;
  padding: 24px 0 16px;
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 20px;
}

.grundl-logo {
  font-family: 'Silkscreen', monospace;
  font-size: 2.8rem;
  font-weight: 700;
  margin: 0;
  letter-spacing: 0.12em;
  text-transform: lowercase;
}

.logo-black {
  color: var(--color-text);
}

.logo-green {
  color: var(--color-correct);
}

.grundl-tagline {
  font-size: 14px;
  color: var(--color-muted);
  margin: 6px 0 0;
}

.how-to-play-btn {
  background: none;
  border: none;
  font-size: 12px;
  color: var(--color-muted);
  cursor: pointer;
  font-family: inherit;
  text-decoration: underline;
  padding: 4px;
  margin-top: 8px;
  display: block;
  margin-left: auto;
  margin-right: auto;
}

.how-to-play-btn:hover {
  color: var(--color-text);
}

/* Game Info Bar */
.game-info {
  display: flex;
  justify-content: center;
  gap: 32px;
  margin-bottom: 24px;
}

.info-item {
  text-align: center;
}

.info-item .label {
  display: block;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  font-weight: 600;
  margin-bottom: 2px;
}

.info-item .value {
  font-size: 20px;
  font-weight: 700;
  color: var(--color-text);
}


/* ─── Chain Grid ─────────────────────────────────────────── */

.chain-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--cell-gap);
  position: relative;
  margin-bottom: 20px;
}

/* Base cell */
.chain-cell {
  position: relative;
  background: transparent;
  border-radius: 8px;
  border: var(--cell-border) solid transparent;
  padding: 10px 8px;
  aspect-ratio: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  overflow: visible;
  transition: border-color 0.2s;
}

/* Cell type colors */
.cell-start,
.cell-end {
  border-color: var(--color-start-end);
}


.cell-guess {
  border-color: var(--color-correct);
  background: rgba(22, 163, 74, 0.04);
  animation: pulseGuess 2.5s ease-in-out infinite;
}

@keyframes pulseGuess {
  0%, 100% { box-shadow: 0 2px 10px rgba(22, 163, 74, 0.18); }
  50%       { box-shadow: 0 2px 22px rgba(22, 163, 74, 0.38); }
}

.cell-correct {
  border-color: var(--color-correct);
}

.cell-wrong {
  border-color: var(--color-wrong);
}

.cell-failed {
  border-color: var(--color-wrong);
}

/* Cell content */
.cell-type-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--color-muted);
  font-weight: 600;
  margin-bottom: 4px;
}

.cell-name {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.25;
  word-break: break-word;
}

.cell-meta {
  font-size: 12px;
  color: var(--color-muted);
  margin-top: 3px;
  font-weight: 500;
}

.cell-x {
  font-size: 28px;
  color: var(--color-wrong);
  font-weight: 700;
  line-height: 1;
}

/* G box input */
.guess-form {
  width: 100%;
  position: relative;
}

.guess-cell-input {
  width: 100%;
  border: 2px solid rgba(22, 163, 74, 0.45);
  border-radius: 6px;
  background: white;
  text-align: center;
  font-size: 13px;
  font-family: inherit;
  font-weight: 600;
  padding: 7px 6px;
  outline: none;
  color: var(--color-text);
  transition: border-color 0.15s, box-shadow 0.15s;
}

.guess-cell-input:focus {
  border-color: var(--color-correct);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.15);
}

.guess-cell-input::placeholder {
  color: #4ade80;
  font-size: 11px;
  font-weight: 400;
}

/* Autocomplete dropdown anchored to guess cell */
.chain-cell .autocomplete-results {
  position: absolute;
  top: calc(100% + 4px);
  left: 50%;
  transform: translateX(-50%);
  width: 280px;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  max-height: 240px;
  overflow-y: auto;
  z-index: 200;
}

/* Hide the results container when it has no content */
.chain-cell .autocomplete-results:empty {
  display: none;
}

/* ─── Connectors (::after pseudo-element) ──────────────────── */
/* Each connecting cell draws one outgoing line */

.chain-cell::after {
  content: none;
}

.chain-cell.connects-right::after,
.chain-cell.connects-left::after,
.chain-cell.connects-down::after {
  content: '';
  position: absolute;
  pointer-events: none;
  z-index: 2;
  border-radius: 2px;
}

/* Right: line from outer right border edge to outer left border edge of next cell */
.chain-cell.connects-right::after {
  top: 50%;
  left: calc(100% + var(--cell-border));
  width: var(--cell-gap);
  height: 3px;
  transform: translateY(-50%);
}

/* Left: line from outer left border edge to outer right border edge of next cell */
.chain-cell.connects-left::after {
  top: 50%;
  right: calc(100% + var(--cell-border));
  width: var(--cell-gap);
  height: 3px;
  transform: translateY(-50%);
}

/* Down: line from outer bottom border edge to outer top border edge of next row cell */
.chain-cell.connects-down::after {
  top: calc(100% + var(--cell-border));
  left: 50%;
  width: 3px;
  height: var(--cell-gap);
  transform: translateX(-50%);
}

/* Connector colors */
.chain-cell.link-established::after {
  background: var(--color-correct);
}

.chain-cell.link-pending::after {
  background: #d1d5db;
}

/* ─── Clues Panel ────────────────────────────────────────── */

.clues-panel {
  margin: 12px 0;
  background: var(--color-card);
  border-radius: 10px;
  padding: 12px 16px;
  box-shadow: var(--shadow);
}

.clue-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  margin-top: 8px;
}

.clue-button-wrapper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

.clue-button-wrapper form {
  width: 100%;
}

.clue-button {
  width: 100%;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  font-family: inherit;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  background: var(--color-bg);
  color: var(--color-text);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.clue-button:hover:not(:disabled) {
  background: var(--color-card);
  border-color: var(--color-clue);
}

.clue-button:disabled,
.clue-button--disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.clue-button--revealed,
.clue-button--revealed:disabled {
  background: var(--color-clue);
  color: white;
  border-color: var(--color-clue);
  opacity: 1;
  cursor: default;
}

.clue-cost {
  font-size: 10px;
  color: var(--color-wrong);
  font-weight: 600;
  letter-spacing: 0.04em;
}

.clue-revealed-label {
  font-size: 11px;
  color: var(--color-clue);
  font-weight: 600;
  text-align: center;
}

.cell-meta-line {
  display: block;
}

.cell-meta-history {
  display: block;
  font-size: 11px;
  color: var(--color-muted);
  margin-top: 2px;
}

.clues-data {
  margin-bottom: 12px;
}

.clues-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px;
}

.clues-table th {
  text-align: left;
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  font-weight: 600;
  padding: 4px 8px 4px 0;
  border-bottom: 1px solid var(--color-border);
}

.clues-table td {
  padding: 6px 8px 6px 0;
  border-bottom: 1px solid var(--color-border);
  color: var(--color-text);
  vertical-align: middle;
}

.clues-table tr:last-child td {
  border-bottom: none;
}

.clue-player-name {
  font-weight: 600;
}

.clue-team-history {
  font-size: 11px;
  color: var(--color-muted);
}

/* ─── Wrong Guesses Panel ────────────────────────────────── */

.wrong-guesses-section {
  margin-top: 8px;
}

.wrong-guesses-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  font-weight: 600;
  margin-bottom: 8px;
  text-align: center;
}

.wrong-guesses-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.wrong-guess-row {
  display: flex;
  align-items: center;
  border: 2px solid var(--color-wrong);
  border-radius: 8px;
  padding: 10px 14px;
  min-height: 52px;
  background: transparent;
}

.wrong-guess-side {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.wrong-guess-from {
  text-align: left;
  align-items: flex-start;
}

.wrong-guess-to {
  text-align: right;
  align-items: flex-end;
}

.wrong-guess-x {
  flex: 0 0 auto;
  font-size: 22px;
  color: var(--color-wrong);
  font-weight: 700;
  padding: 0 16px;
  line-height: 1;
}

.wrong-guess-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1.25;
}

.wrong-guess-meta {
  font-size: 10px;
  color: var(--color-muted);
  margin-top: 2px;
}

/* ─── Game Over Modal ─────────────────────────────────────── */

.game-over-panel {
  background: var(--color-card);
  border-radius: 12px;
  padding: 32px 24px;
  text-align: center;
  box-shadow: var(--shadow);
  margin-top: 24px;
  animation: fadeInUp 0.4s ease-out;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.game-over-panel h2 {
  font-family: 'Silkscreen', monospace;
  font-size: 3rem;
  margin: 0 0 16px;
}

.game-over-panel.completed h2 {
  color: var(--color-correct);
}

.game-over-panel h2 .logo-black { color: var(--color-text); }
.game-over-panel h2 .logo-green { color: var(--color-correct); }

.game-over-panel.failed h2 {
  color: var(--color-wrong);
}

.game-over-panel p {
  color: var(--color-muted);
  margin: 0 0 8px;
  font-size: 15px;
}

.game-over-stats {
  display: flex;
  justify-content: center;
  gap: 40px;
  margin: 20px 0;
}

.game-over-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  border: 2px solid #d1d5db;
  border-radius: 10px;
  padding: 12px 0;
  width: 150px;
}

.game-over-stat .stat-value {
  font-size: 40px;
  font-weight: 700;
  color: var(--color-text);
  line-height: 1;
}

.stat-denom {
  font-size: 14px;
  font-weight: 400;
  color: var(--color-muted);
  margin-left: 1px;
}

.game-over-stat .stat-label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-muted);
  margin-top: 4px;
}

.scoring-breakdown {
  margin: 16px auto;
  width: fit-content;
  min-width: 160px;
}

.scoring-breakdown-title {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--color-text);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--color-border);
}

.breakdown-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;
}

.breakdown-item {
  display: flex;
  justify-content: space-between;
  font-size: 14px;
}

.breakdown-label {
  color: var(--color-muted);
}

.breakdown-value {
  font-weight: 600;
}

.breakdown-value.has-deduction {
  color: var(--color-wrong);
}

.breakdown-value.no-deduction {
  color: var(--color-correct);
}

.game-over-stat .stat-value.score-red     { color: #dc2626; }
.game-over-stat .stat-value.score-orange  { color: var(--color-wrong); }
.game-over-stat .stat-value.score-yellow  { color: #ca8a04; }
.game-over-stat .stat-value.score-green   { color: var(--color-correct); }
.game-over-stat .stat-value.score-fuchsia { color: var(--color-clue); }

.share-button {
  padding: 12px 36px;
  background: var(--color-correct);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  margin-top: 16px;
  transition: opacity 0.2s;
  font-family: inherit;
}

.share-button:hover {
  opacity: 0.85;
}

/* ─── How to Play Modal ───────────────────────────────────── */

.how-to-play-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease-out;
}

.how-to-play-panel {
  background: var(--color-card);
  border-radius: 12px;
  padding: 32px 28px;
  max-width: 400px;
  width: 90%;
  position: relative;
  box-shadow: var(--shadow);
}

.how-to-play-panel h2 {
  font-family: 'Silkscreen', monospace;
  font-size: 1.4rem;
  color: var(--color-text);
  margin: 0 0 16px;
  text-align: center;
}

.how-to-play-content p {
  font-size: 14px;
  color: var(--color-text);
  margin: 0 0 14px;
  line-height: 1.5;
  text-align: center;
}

.how-to-play-content ul {
  list-style: none;
  padding: 0;
  margin: 0;
}

.how-to-play-content li {
  font-size: 13px;
  color: var(--color-muted);
  padding: 8px 0 8px 20px;
  border-bottom: 1px solid var(--color-border);
  position: relative;
  line-height: 1.4;
}

.how-to-play-content li:last-child {
  border-bottom: none;
}

.how-to-play-content li::before {
  content: '→';
  position: absolute;
  left: 0;
  color: var(--color-correct);
  font-weight: 700;
}

/* ─── Win Modal ───────────────────────────────────────────── */

.win-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  animation: fadeIn 0.3s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.win-modal-overlay .game-over-panel {
  margin-top: 0;
  max-width: 400px;
  width: 90%;
  position: relative;
}

.modal-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: none;
  border: none;
  font-size: 22px;
  line-height: 1;
  color: var(--color-muted);
  cursor: pointer;
  padding: 2px 6px;
  font-family: inherit;
}

.modal-close:hover {
  color: var(--color-text);
}

/* ─── Splash (pre-game) ───────────────────────────────────── */

.splash-panel {
  background: var(--color-card);
  border-radius: 12px;
  padding: 48px 32px;
  text-align: center;
  box-shadow: var(--shadow);
}

.splash-text {
  font-size: 17px;
  color: var(--color-text);
  margin: 0 0 10px;
  line-height: 1.5;
}

.splash-warning {
  font-size: 13px;
  color: var(--color-muted);
  margin: 0 0 28px;
}

.play-button {
  padding: 16px 56px;
  background: var(--color-correct);
  color: white;
  border: none;
  border-radius: 8px;
  font-size: 18px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  transition: opacity 0.2s, transform 0.1s;
  letter-spacing: 0.02em;
}

.play-button:hover {
  opacity: 0.85;
}

.play-button:active {
  transform: scale(0.97);
}

/* ─── Autocomplete (shared) ──────────────────────────────── */

.autocomplete-item {
  padding: 10px 14px;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  transition: background 0.15s;
  font-size: 13px;
}

.autocomplete-item:last-child {
  border-bottom: none;
}

.autocomplete-item:hover,
.autocomplete-item.selected {
  background: #eff6ff;
}

.autocomplete-item .player-name {
  font-weight: 600;
  color: var(--color-text);
}

.autocomplete-item .player-meta {
  display: flex;
  gap: 8px;
  align-items: center;
  font-size: 11px;
  color: var(--color-muted);
}

.autocomplete-item .player-team {
  font-weight: 600;
}

.no-results {
  padding: 12px;
  text-align: center;
  color: var(--color-muted);
  font-size: 13px;
  font-style: italic;
}

/* ─── Responsive ─────────────────────────────────────────── */

/* Mid-size screens: scale down cell content to prevent overflow in 3-column grid */
@media (max-width: 620px) {
  :root {
    --cell-gap: 14px;
    --cell-border: 8px;
  }

  .grundl-container {
    padding: 16px 12px 32px;
  }

  .grundl-logo {
    font-size: 2.2rem;
  }

  .cell-name {
    font-size: 13px;
  }

  .cell-meta {
    font-size: 10px;
  }

  .cell-meta-history {
    font-size: 9px;
  }

  .cell-type-label {
    font-size: 9px;
  }

  .guess-cell-input {
    font-size: 11px;
    padding: 5px 4px;
  }

  .guess-cell-input::placeholder {
    font-size: 10px;
  }

  .chain-cell {
    padding: 6px 5px;
  }
}

/* Mobile: single-column layout + stacked clue buttons */
@media (max-width: 500px) {
  /* Stack all cells into a single column */
  .chain-grid {
    grid-template-columns: 1fr;
  }

  /* Override the inline grid-row/grid-column from the snake layout */
  .chain-cell {
    grid-column: 1 !important;
    grid-row: auto !important;
    aspect-ratio: auto;
    min-height: 72px;
  }

  /* Convert horizontal connectors into downward connectors */
  .chain-cell.connects-right::after,
  .chain-cell.connects-left::after {
    top: calc(100% + var(--cell-border));
    left: 50%;
    right: auto;
    width: 3px;
    height: var(--cell-gap);
    transform: translateX(-50%);
  }

  .chain-cell .autocomplete-results {
    width: 240px;
  }

  /* Stack clue buttons vertically */
  .clue-buttons {
    flex-direction: column;
    gap: 6px;
  }

  .clue-button-wrapper {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
  }

  .clue-button-wrapper form {
    flex: 1;
  }

  .clue-cost {
    flex-shrink: 0;
    min-width: 36px;
    text-align: right;
  }
}

@media (max-width: 400px) {
  .game-over-stat .stat-value {
    font-size: 30px;
  }
}

/* Flash messages */
.flash {
  padding: 10px 20px;
  text-align: center;
  font-size: 14px;
  font-family: Inter, sans-serif;
}
.flash-notice {
  background: #d1fae5;
  color: #065f46;
}
.flash-alert {
  background: #fee2e2;
  color: #991b1b;
}

/* User nav */
.user-nav {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 12px;
  padding: 8px 16px;
  font-size: 13px;
  font-family: Inter, sans-serif;
  color: #888;
}
.user-nav a {
  color: #555;
  text-decoration: none;
}
.user-nav a:hover {
  text-decoration: underline;
}

/* ─── Auth Pages (sign in / sign up) ─────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background-color: var(--color-bg);
}

.auth-card {
  width: 100%;
  max-width: 380px;
  background: var(--color-card);
  border: 1px solid var(--color-border);
  border-radius: 16px;
  padding: 40px 36px 32px;
  box-shadow: var(--shadow);
}

.auth-logo {
  display: block;
  text-align: center;
  font-family: 'Silkscreen', monospace;
  font-size: 2.2rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-decoration: none;
  margin-bottom: 6px;
}

.auth-tagline {
  text-align: center;
  font-size: 13px;
  color: var(--color-muted);
  margin: 0 0 28px;
}

.auth-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.auth-field {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.auth-label {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
}

.auth-input {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--color-border);
  border-radius: 8px;
  font-size: 15px;
  font-family: inherit;
  color: var(--color-text);
  background: #fff;
  transition: border-color 0.15s;
  box-sizing: border-box;
}

.auth-input:focus {
  outline: none;
  border-color: var(--color-correct);
  box-shadow: 0 0 0 3px rgba(22, 163, 74, 0.12);
}

.auth-hint {
  font-size: 11px;
  color: var(--color-muted);
}

.auth-remember {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 2px;
}

.auth-checkbox {
  width: 15px;
  height: 15px;
  accent-color: var(--color-correct);
  cursor: pointer;
}

.auth-remember-label {
  font-size: 13px;
  color: var(--color-muted);
  cursor: pointer;
}

.auth-submit {
  width: 100%;
  padding: 12px;
  margin-top: 4px;
  background: var(--color-correct);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  font-family: 'Silkscreen', monospace;
  letter-spacing: 0.06em;
  cursor: pointer;
  transition: background 0.15s, transform 0.1s;
}

.auth-submit:hover {
  background: #15803d;
}

.auth-submit:active {
  transform: scale(0.98);
}

.auth-links {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 20px;
  font-size: 13px;
}

.auth-links a {
  color: var(--color-muted);
  text-decoration: none;
}

.auth-links a:hover {
  color: var(--color-text);
  text-decoration: underline;
}

.auth-links-sep {
  color: var(--color-border);
}

.auth-errors {
  background: #fef2f2;
  border: 1px solid #fecaca;
  border-radius: 8px;
  padding: 12px 14px;
}

.auth-error-item {
  font-size: 13px;
  color: #991b1b;
  margin: 0;
}

.auth-error-item + .auth-error-item {
  margin-top: 4px;
}
/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *


 */
