/* ============================================
   Foremula! Flashcards - Fun, cartoon-style
   Color palette from logo: dark green + creamy beige
   ============================================ */

/* CSS variables - logo-inspired palette */
:root {
  --color-bg: #f4efe4;
  --color-surface: #faf7f0;
  --color-card: #ffffff;
  --color-accent: #1a432b;
  --color-accent-hover: #234f36;
  --color-text: #1a432b;
  --color-text-muted: #4a6b57;
  --color-border: #c9bfad;
  --radius: 20px;
  --radius-sm: 12px;
  --transition: 0.25s ease;
  --shadow: 0 4px 0 rgba(26, 67, 43, 0.2);
  --shadow-hover: 0 6px 0 rgba(26, 67, 43, 0.25);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 20px;
  font-family: "Nunito", "Comic Sans MS", "Segoe UI", system-ui, sans-serif;
  background: var(--color-bg);
  color: var(--color-text);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
}

body:has(#screen-online.active) {
  padding: 10px 12px;
  align-items: flex-start;
}

/* Main app container */
.app {
  width: 100%;
  max-width: 680px;
}

.app:has(#screen-online.active) {
  max-width: none;
  width: min(96vw, 1520px);
}

/* Logo header - prominent on setup, smaller on question/answer */
.logo-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.logo-header .logo-img {
  max-width: 280px;
  width: 100%;
  height: auto;
}

.logo-header-small .logo-img {
  max-width: 140px;
  margin-bottom: 0.5rem;
}

.logo-header-offline {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-bottom: 1rem;
}

.logo-header-offline .logo-img {
  max-width: 260px;
  width: 100%;
  height: auto;
  margin: 0 auto;
  display: block;
  transform: translateX(14px);
}

/* All screens start hidden; active screen is visible */
.screen {
  display: none;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity var(--transition), transform var(--transition);
}

.screen.active {
  display: block;
  opacity: 1;
  transform: translateY(0);
}

/* Card-style container - cartoon-like with thick border */
.card {
  background: var(--color-card);
  border-radius: var(--radius);
  padding: 2rem;
  border: 3px solid var(--color-accent);
  box-shadow: var(--shadow);
}

/* Labels */
label {
  display: block;
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 0.5rem;
}

/* Subject dropdown - rounded, fun - same green as accent */
select {
  width: 100%;
  padding: 1rem 1.25rem;
  font-size: 1.1rem;
  font-weight: 600;
  border: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  margin-bottom: 1.5rem;
  cursor: pointer;
}

select:focus {
  outline: none;
}

/* Difficulty buttons - pill-shaped, cartoon style */
.difficulty-buttons {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.difficulty-btn {
  flex: 1;
  min-width: 100px;
  padding: 1rem 1.25rem;
  font-size: 1rem;
  font-weight: 700;
  border: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.difficulty-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.difficulty-btn.selected {
  background: var(--color-accent);
  color: white;
  box-shadow: var(--shadow);
}

.difficulty-btn.selected:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-hover);
}

/* Primary action buttons - bold, cartoon-style */
.primary-btn {
  width: 100%;
  padding: 1.25rem 2rem;
  font-size: 1.2rem;
  font-weight: 800;
  border: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: var(--color-accent);
  color: white;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.primary-btn:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-hover);
}

.primary-btn:active {
  transform: translateY(-1px);
}

/* Back to Setup button */
.back-btn {
  display: inline-block;
  padding: 0.5rem 1rem;
  margin-bottom: 0.75rem;
  font-size: 0.9rem;
  font-weight: 600;
  border: 2px solid var(--color-text-muted);
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition);
}

.back-btn:hover {
  color: var(--color-accent);
  border-color: var(--color-accent);
}

/* Meta text (subject + difficulty) */
.meta {
  font-size: 1rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-align: center;
  margin-bottom: 1rem;
}

.hidden {
  display: none;
}

/* Question card - large readable text */
.question-card h2 {
  font-size: clamp(1.1rem, 3.5vw, 1.5rem);
  line-height: 1.45;
  margin: 0 0 1.25rem;
  font-weight: 700;
}

/* Multiple choice options */
.choices {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.choice {
  display: flex;
  align-items: flex-start;
  gap: 0.65rem;
  width: 100%;
  padding: 0.75rem 0.9rem;
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  font-size: clamp(0.9rem, 2.5vw, 1rem);
  line-height: 1.4;
  text-align: left;
  font-family: inherit;
  color: inherit;
  cursor: pointer;
  transition: border-color var(--transition), background var(--transition);
}

.choice:hover:not(:disabled) {
  border-color: var(--color-accent);
}

.choice:focus-visible {
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.choice:disabled {
  cursor: default;
}

.choice-letter {
  flex-shrink: 0;
  font-weight: 800;
  color: var(--color-accent);
  min-width: 1.25rem;
}

.choice-text {
  flex: 1;
}

.choice.correct {
  border-color: var(--color-accent);
  background: #e3efe8;
  font-weight: 700;
}

.choice.incorrect {
  border-color: #c0392b;
  background: #fdecea;
  font-weight: 700;
}

.choices.answered .choice:not(.correct):not(.incorrect) {
  opacity: 0.75;
}

.choice-feedback {
  border-radius: var(--radius-sm);
  padding: 0.9rem 1rem;
  margin-bottom: 1rem;
  font-size: clamp(0.95rem, 2.5vw, 1.05rem);
  font-weight: 700;
  line-height: 1.45;
  text-align: center;
  border: 2px solid transparent;
}

.choice-feedback.correct {
  border-color: var(--color-accent);
  background: #e3efe8;
  color: var(--color-text);
}

.choice-feedback.incorrect {
  border-color: #c0392b;
  background: #fdecea;
  color: #922b21;
}

/* Fun message at top */
.fun-message {
  text-align: center;
  font-size: clamp(1.5rem, 4vw, 2rem);
  font-weight: 800;
  color: var(--color-accent);
  margin: 0 0 0.5rem;
}

.home-play-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-top: 0.5rem;
}

.home-play-btn {
  margin: 0;
}

.home-play-btn-secondary {
  background: var(--color-surface);
  color: var(--color-accent);
}

.home-play-btn-secondary:hover {
  background: #e3efe8;
}

/* Instructions link */
.instructions-link {
  display: block;
  text-align: center;
  margin-bottom: 1.5rem;
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--color-accent);
  text-decoration: none;
  padding: 0.5rem;
  transition: color var(--transition);
}

.instructions-link:hover {
  color: var(--color-accent-hover);
}

/* About Us */
.about-content {
  font-size: 1rem;
  line-height: 1.65;
  color: var(--color-text);
}

.about-content p {
  margin: 0 0 1.25rem;
}

.about-section-title {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--color-accent);
  margin: 1.5rem 0 0.5rem;
}

.about-section-title:first-child {
  margin-top: 0;
}

.about-lead {
  font-weight: 700;
  color: var(--color-text-muted);
  margin-bottom: 0.35rem !important;
}

/* Completion screen */
.complete-title {
  font-size: clamp(1.35rem, 4vw, 1.75rem);
  margin: 0 0 1rem;
  text-align: center;
  color: var(--color-accent);
}

.complete-message {
  font-size: 1.1rem;
  line-height: 1.6;
  margin: 0 0 1.5rem;
  text-align: center;
  font-weight: 600;
  color: var(--color-text);
}

.complete-card {
  text-align: center;
}

/* Scorecard */
.scorecard-card {
  max-height: 85vh;
  overflow-y: auto;
}

.scorecard-title {
  text-align: center;
  margin-bottom: 0.25rem;
}

.scorecard-subtitle {
  text-align: center;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: 0 0 1.25rem;
}

.scorecard-setup-lead {
  margin: 0 0 1rem;
  font-weight: 600;
  color: var(--color-text);
}

.scorecard-name-fields {
  margin-bottom: 1.25rem;
}

.label-optional {
  font-weight: 600;
  color: var(--color-text-muted);
  font-size: 0.85rem;
}

.scorecard-name-input {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  margin-bottom: 1rem;
}

.scorecard-name-input:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(26, 67, 43, 0.15);
}

.scorecard-play.hidden,
.scorecard-setup.hidden {
  display: none;
}

.scorecard-toolbar {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

.secondary-btn {
  flex: 1;
  min-width: 120px;
  padding: 0.65rem 1rem;
  font-size: 0.9rem;
  font-weight: 700;
  font-family: inherit;
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-accent);
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.secondary-btn:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.scorecard-hint {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: 0 0 0.75rem;
}

.scorecard-table-wrap {
  overflow-x: auto;
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
}

.scorecard-table {
  width: 100%;
  min-width: 280px;
  border-collapse: collapse;
  font-size: 0.95rem;
}

.scorecard-table th,
.scorecard-table td {
  border: 1px solid var(--color-border);
  padding: 0.5rem;
  text-align: center;
  vertical-align: middle;
}

.scorecard-table th {
  background: var(--color-accent);
  color: white;
  font-weight: 800;
  font-size: 0.85rem;
  white-space: nowrap;
}

.scorecard-table .hole-label {
  background: #e3efe8;
  font-weight: 800;
  color: var(--color-accent);
  min-width: 3rem;
}

.scorecard-table tfoot td {
  background: var(--color-accent);
  color: white;
  font-weight: 800;
  font-size: 1rem;
}

.scorecard-table tfoot .hole-label {
  background: var(--color-accent-hover);
  color: white;
}

.scorecard-stroke-input {
  width: 3rem;
  padding: 0.35rem 0.25rem;
  font-size: 1rem;
  font-weight: 700;
  font-family: inherit;
  text-align: center;
  border: 2px solid var(--color-border);
  border-radius: 8px;
  background: white;
  color: var(--color-text);
  appearance: textfield;
  -moz-appearance: textfield;
}

.scorecard-stroke-input::-webkit-outer-spin-button,
.scorecard-stroke-input::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

.scorecard-stroke-input:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 2px rgba(26, 67, 43, 0.15);
}

.scorecard-stroke-input::placeholder {
  color: var(--color-border);
  font-weight: 600;
}

.scorecard-complete-btn {
  margin-top: 1.25rem;
}

.scorecard-complete-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.scorecard-result {
  margin-top: 1.25rem;
  padding: 1.25rem;
  border-radius: var(--radius-sm);
  border: 3px solid var(--color-accent);
  text-align: center;
}

.scorecard-result.hidden {
  display: none;
}

.scorecard-result.winner {
  background: linear-gradient(135deg, #e3efe8 0%, #faf7f0 100%);
  animation: scorecard-pop 0.5s ease;
}

.scorecard-result.tie {
  background: var(--color-surface);
  animation: scorecard-pop 0.5s ease;
}

@keyframes scorecard-pop {
  0% {
    opacity: 0;
    transform: scale(0.95) translateY(8px);
  }
  100% {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

@keyframes scorecard-celebrate {
  0%, 100% { transform: scale(1) rotate(0deg); }
  25% { transform: scale(1.08) rotate(-3deg); }
  75% { transform: scale(1.08) rotate(3deg); }
}

.scorecard-result-icon {
  display: block;
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
  animation: scorecard-celebrate 1s ease infinite;
}

.scorecard-result-title {
  font-size: clamp(1.25rem, 4vw, 1.6rem);
  font-weight: 800;
  color: var(--color-accent);
  margin: 0 0 0.5rem;
}

.scorecard-result-message {
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.55;
  margin: 0 0 0.75rem;
  color: var(--color-text);
}

.scorecard-result-scores {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-text-muted);
  margin: 0;
}

.scorecard-confetti {
  display: flex;
  justify-content: center;
  gap: 0.35rem;
  margin-bottom: 0.75rem;
  font-size: 1.35rem;
}

/* Instructions + Design + About screens */
.instructions-card,
.design-card,
.about-card {
  max-height: 85vh;
  overflow-y: auto;
}

.instructions-title {
  font-size: 1.5rem;
  margin: 0 0 1rem;
}

.instructions-image-wrapper {
  max-height: 60vh;
  overflow-y: auto;
}

.instructions-image {
  width: 100%;
  height: auto;
  display: block;
}

/* Green divider between instruction pages */
.instructions-image + .instructions-image {
  border-top: 4px solid var(--color-accent);
  margin-top: 1rem;
  padding-top: 1rem;
}

.answer-box p#answer-text {
  font-size: clamp(1.25rem, 3.5vw, 1.6rem);
  line-height: 1.4;
  margin: 0;
  font-weight: 800;
  color: var(--color-accent);
}

.answer-box p:not(#answer-text) {
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  line-height: 1.6;
  margin: 0;
  font-weight: 600;
}

/* Online mini golf game */
.online-game-root {
  width: 100%;
}

.online-setup-card,
.online-builder-card,
.online-summary-card {
  margin-top: 0.5rem;
}

.online-builder-card {
  padding: 1.25rem;
}

.online-hole-input {
  margin-bottom: 0.35rem;
}

.online-select {
  width: 100%;
  padding: 0.85rem 1rem;
  font-size: 1rem;
  font-weight: 600;
  font-family: inherit;
  border: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  background: var(--color-surface);
  color: var(--color-text);
  margin-bottom: 1rem;
}

.online-rules-lead {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: 0 0 1rem;
}

.online-play-layout {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.online-play-main {
  padding: 0.85rem 1rem;
  width: 100%;
}

.online-sidebar {
  padding: 1.25rem;
  position: static;
  width: 100%;
}

.online-sidebar-title {
  margin: 0 0 1rem;
  font-size: 1.5rem;
  color: var(--color-accent);
}

.online-status-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.online-hole-badge,
.online-turn-badge {
  display: inline-block;
  padding: 0.35rem 0.75rem;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 800;
  background: var(--color-surface);
  border: 2px solid var(--color-accent);
  color: var(--color-accent);
}

.online-turn-badge {
  color: #fff;
  border-color: transparent;
}

.online-turn-banner {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  width: 100%;
  padding: 0.85rem 1rem;
  border-radius: var(--radius-sm);
  color: #fff;
  box-shadow: 0 2px 8px rgba(26, 67, 43, 0.25);
}

.online-turn-banner-name {
  font-size: 1.15rem;
  font-weight: 900;
  line-height: 1.2;
}

.online-turn-banner-action {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.3;
  opacity: 0.95;
}

.online-trivia-header {
  display: flex;
  flex-direction: column;
  gap: 0.65rem;
  margin-bottom: 0.85rem;
}

.online-message {
  font-size: 0.95rem;
  font-weight: 700;
  margin: 0 0 0.75rem;
  line-height: 1.45;
}

.online-hint {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: 0.75rem 0 0;
  text-align: center;
}

.online-canvas {
  width: 100%;
  height: auto;
  max-height: 68vh;
  display: block;
  border: 3px solid var(--color-accent);
  border-radius: var(--radius-sm);
  cursor: crosshair;
  touch-action: none;
}

.online-canvas-wrap {
  padding: 8px;
  background: rgba(26, 67, 43, 0.08);
  border-radius: calc(var(--radius-sm) + 4px);
  border: 2px dashed var(--color-border);
  margin-bottom: 0.5rem;
}

.builder-random-layout {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-muted);
  margin: 0 0 1rem;
  padding: 0.75rem 1rem;
  background: rgba(26, 67, 43, 0.06);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.builder-palette {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.builder-palette .builder-tool.selected,
.builder-palette .builder-tool-remove.selected {
  background: var(--color-accent);
  color: white;
}

.builder-palette .builder-tool-move.selected {
  background: #2471a3;
}

.builder-palette .builder-tool-remove.selected {
  background: #c0392b;
}

.builder-instructions {
  background: rgba(26, 67, 43, 0.06);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  margin-bottom: 1rem;
}

.builder-instructions-title {
  margin: 0 0 0.65rem;
  font-size: 1.05rem;
  color: var(--color-accent);
}

.builder-steps {
  margin: 0 0 0.85rem;
  padding-left: 1.25rem;
  font-size: 0.92rem;
  font-weight: 600;
  line-height: 1.55;
  color: var(--color-text);
}

.builder-steps li + li {
  margin-top: 0.35rem;
}

.builder-tool-status {
  margin: 0;
  padding: 0.65rem 0.75rem;
  background: var(--color-surface);
  border: 2px solid var(--color-accent);
  border-radius: var(--radius-sm);
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--color-accent);
}

.builder-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

.online-trivia-card {
  padding: 1.25rem;
}

.online-question-text {
  font-size: clamp(1.1rem, 3vw, 1.4rem);
  line-height: 1.45;
  margin: 0 0 1rem;
}

.online-trivia-pickers {
  margin-bottom: 1rem;
  padding-bottom: 1rem;
  border-bottom: 2px solid var(--color-border);
}

.online-trivia-locked {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--color-accent);
  margin: 0 0 1rem;
  padding: 0.65rem 0.75rem;
  background: rgba(26, 67, 43, 0.06);
  border: 2px solid var(--color-border);
  border-radius: var(--radius-sm);
}

.online-trivia-choice {
  width: 100%;
  text-align: left;
  cursor: pointer;
  border: 2px solid var(--color-border);
  background: var(--color-surface);
  font-family: inherit;
}

.online-trivia-choice:hover {
  border-color: var(--color-accent);
}

.online-hole-stats {
  margin-top: 1.25rem;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.55;
}

.online-hole-stats p {
  margin: 0.25rem 0;
}

.online-live-score {
  font-size: 1.05rem;
}

.online-scoreboard-wrap {
  overflow: visible;
}

.online-scoreboard-wrap .scorecard-table {
  min-width: 0;
  table-layout: fixed;
}

.online-scoreboard-wrap .scorecard-table th,
.online-scoreboard-wrap .scorecard-table td {
  padding: 0.7rem 0.55rem;
  font-size: 1.05rem;
  word-break: break-word;
  hyphens: auto;
}

.online-scoreboard-wrap .scorecard-table th {
  font-size: 0.95rem;
  line-height: 1.25;
  padding: 0.75rem 0.45rem;
}

.online-scoreboard-wrap .scorecard-table .hole-label {
  width: 2.75rem;
  font-size: 0.95rem;
  font-weight: 800;
}

.online-scoreboard-wrap .scorecard-table tfoot td {
  font-size: 1.1rem;
  font-weight: 800;
}

.online-summary-card {
  text-align: center;
}

.online-summary-card .secondary-btn {
  margin-top: 0.75rem;
  width: 100%;
}

/* Mobile-friendly spacing */
@media (max-width: 480px) {
  body {
    padding: 12px;
  }

  .card {
    padding: 1.25rem;
  }

  .choice {
    padding: 0.65rem 0.75rem;
  }

  .logo-header .logo-img {
    max-width: 200px;
  }

  .logo-header-small .logo-img {
    max-width: 100px;
  }

  .logo-header-offline .logo-img {
    max-width: 220px;
  }

  .scorecard-stroke-input {
    width: 2.5rem;
    font-size: 0.9rem;
  }

  .online-play-layout {
    grid-template-columns: 1fr;
  }

  .online-sidebar {
    position: static;
  }
}
