/* styles.css - Wordsmyth (Coral Theme) */
:root {
  --fixed-height: 72px;
  --primary: #ee7751;
  --primary-hover: #d9643f;
  --primary-light: #f4937a;
  --primary-dark: #b8502e;
  --background: #212121;
  --surface: #424242;
  --darker-surface: #2E2E2E;
  --correct: #4CAF50;
  --text-primary: #FFFFFF;
  --disabled: #757575;
}

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

.fullscreen-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: #212121;
  display: flex;
  flex-direction: column;
  z-index: 9999;
  margin: 0;
  padding: 0;
}

.modal-content-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  color: #FFFFFF;
}

.landing-title {
  font-size: 3em;
  margin: 0;
  font-family: 'Caudex', serif;
  font-weight: 700;
}

.landing-subheader {
  font-size: 2em;
  margin: 0;
  font-family: 'Caudex', serif;
  font-weight: normal;
}

.landing-small-text-bold {
  font-size: 1.25em;
  font-weight: bold;
  margin: 12px 0 0 0;
  height: 32px;
}

.landing-small-text {
  font-size: 1.25em;
  font-weight: normal;
  margin: 0;
  padding: 0;
  height: 32px;
}

/* Landing loading state */
.landing-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  font-size: 1.25em;
  color: var(--text-primary);
  /* Match height of puzzle content: button (44px) + spacing (30px) + 3 text lines (32px each) */
  min-height: 170px;
}

.flame-icon {
  display: inline-block;
  width: 24px;
  height: 24px;
  -webkit-mask-image: url('/icons/flame.svg');
  mask-image: url('/icons/flame.svg');
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
  background-color: var(--primary);
  animation: flame-flicker 0.3s ease-in-out infinite alternate;
  transform-origin: bottom center;
}

@keyframes flame-flicker {
  0% {
    transform: scaleX(1) scaleY(1);
  }
  100% {
    transform: scaleX(0.85) scaleY(1.1);
  }
}

#ad-modal {
  display: none;
}

/* Landing modal shown by default to prevent flash of game content */
#landing-modal {
  display: flex;
}

/* Hide game UI until modal is dismissed */
.header,
.date-nav-row,
.game-content {
  visibility: hidden;
}

body.game-ready .header,
body.game-ready .date-nav-row,
body.game-ready .game-content {
  visibility: visible;
}

/* When skipLanding=true, hide modal and show game immediately */
html.skip-landing #landing-modal {
  display: none;
}

html.skip-landing .header,
html.skip-landing .date-nav-row,
html.skip-landing .game-content {
  visibility: visible;
}

html {
  height: 100%;
}

body {
  font-family: sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
  margin: 0;
  padding: 0;
  background-color: var(--background);
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  height: calc(var(--vh, 1vh) * 100);
  overflow: hidden;
}

/* Header styles */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 15px 10px;
  background-color: transparent;
  width: 100%;
  box-sizing: border-box;
  flex-shrink: 0;
  position: relative;
}

.header-spacer {
  display: flex;
  gap: 8px;
  width: calc(3 * 2.5rem + 2 * 8px);
}

.header-buttons {
  display: flex;
  gap: 8px;
}

.header-buttons button {
  background-color: var(--primary);
  color: white;
  border: none;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
}

.header-buttons button:hover {
  background-color: var(--primary-hover);
}

@media (max-width: 480px) {
  .header-spacer {
    display: none !important;
    width: 0 !important;
  }

  .title {
    flex-grow: 0 !important;
    justify-content: flex-start !important;
    font-size: 1.5em;
  }
}

@media (max-width: 400px) {
  .header {
    padding: 15px 8px;
  }

  .header-buttons {
    gap: 6px;
  }

  .header-buttons button {
    width: 2rem;
    height: 2rem;
    font-size: 12px;
  }

  .title {
    font-size: 1.3em;
  }
}

@media (max-width: 320px) {
  .title {
    font-size: 1.1em;
  }

  .header-buttons {
    gap: 5px;
  }

  .header-buttons button {
    width: 1.8rem;
    height: 1.8rem;
    font-size: 11px;
  }
}

/* Date Navigation Row */
.date-nav-row {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 15px;
  padding: 4px 20px;
  background-color: var(--darker-surface);
  flex-shrink: 0;
}

.date-nav-button {
  background-color: var(--primary);
  color: white;
  border: none;
  width: 2.2rem;
  height: 2.2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  font-size: 14px;
  font-weight: bold;
}

.date-nav-button:hover {
  background-color: var(--primary-hover);
}

.date-nav-button:disabled {
  background-color: var(--disabled);
  cursor: not-allowed;
}

.date-nav-button.hidden {
  visibility: hidden;
}

.date-nav-date {
  font-size: clamp(0.7rem, 3vw, 1rem);
  color: var(--text-primary);
  font-family: 'Montserrat', sans-serif;
  font-weight: 500;
  text-align: center;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex: 1 1 auto;
  min-width: 0;
}

/* Title styles */
.title {
  margin: 0;
  font-size: 1.8em;
  color: var(--text-primary);
  text-align: center;
  font-family: 'Caudex', serif;
  font-weight: 700;
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  /* Perfectly centered on larger screens */
  position: absolute;
  left: 50%;
  transform: translateX(-50%);
}

.title:hover {
  opacity: 0.8;
}

.title img {
  height: 1em;
  width: auto;
  margin-right: 0.3em;
  flex-shrink: 0;
}

/* Revert title to flex positioning on smaller screens */
@media (max-width: 600px) {
  .title {
    position: static;
    transform: none;
    flex-grow: 1;
  }
}

.game-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  width: 100%;
  max-width: 600px;
  padding: 5px 10px 10px 10px;
  box-sizing: border-box;
  text-align: center;
  flex: 1;
  min-height: 0;
}

.game-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  align-items: center;
  width: 100%;
  min-height: 0;
  overflow: hidden;
}

/* Word Row - fixed height wrapper to prevent layout shift */
.word-row {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 60px;
  flex-shrink: 0;
}

/* Start Button */
.start-button {
  font-size: 1.2em;
  padding: 12px 30px;
  flex-shrink: 0;
}

/* Current Word Display */
.current-word-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
  width: 100%;
  max-width: 500px;
}

.current-word-wrapper {
  position: relative;
  width: 100%;
}

.current-word-slider {
  position: relative;
  overflow: hidden;
  width: 100%;
  display: grid;
}

.current-word-container.hidden {
  display: none;
}

.current-word {
  grid-area: 1 / 1;
  text-align: center;
  font-size: 2.5em;
  font-family: 'Caudex', serif;
  font-weight: 700;
  color: var(--text-primary);
  text-transform: uppercase;
  letter-spacing: 0.1em;
  margin: 0;
  line-height: 1;
  transition: transform 0.4s ease-out, opacity 0.4s ease-out;
}

.current-word-incoming {
  transform: translateY(-100%);
  opacity: 0;
}

/* Slide animation classes */
.current-word-slider.animating .current-word:not(.current-word-incoming) {
  transform: translateY(100%);
  opacity: 0;
}

.current-word-slider.animating .current-word-incoming {
  transform: translateY(0);
  opacity: 1;
}

.current-word-slider.no-transition .current-word {
  transition: none;
}

/* Sparks */
.spark-particle {
  border-radius: 50%;
  pointer-events: none;
}

.hint-icon {
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  cursor: pointer;
  filter: invert(80%) sepia(10%) saturate(200%) hue-rotate(180deg) brightness(95%);
  opacity: 0.7;
  transition: opacity 0.3s, transform 0.2s;
}

.hint-icon:hover {
  opacity: 1;
  transform: scale(1.1);
}

.hint-icon.disabled {
  opacity: 0.3;
  cursor: not-allowed;
  pointer-events: none;
}

.puzzle-completed .hint-icon {
  display: none;
}

/* Hint icon pulse animation */
@keyframes hintPulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

.hint-icon.pulse {
  animation: hintPulse 0.4s ease-in-out 3;
}

.hint-penalty-text {
  color: var(--primary);
  font-style: italic;
  font-size: 0.9em;
  margin-top: 0;
}

/* Timer Display */
.timer-display {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  line-height: 1;
}

.timer-display.hidden {
  visibility: hidden;
}

.timer-digits {
  font-family: 'Share Tech Mono', monospace;
  font-size: 1.1em;
  color: var(--primary);
  letter-spacing: 0.05em;
}

/* Clues Label */
.clues-label {
  font-size: 0.9em;
  color: var(--disabled);
  letter-spacing: 0.1em;
  margin-bottom: 5px;
  flex-shrink: 0;
}

.puzzle-completed .clues-label {
  display: none;
}

.puzzle-completed .used-clues-divider {
  display: none;
}

/* Clues Container Wrapper */
.clues-wrapper {
  position: relative;
  flex: 1 1 auto;
  min-height: 100px;
  width: 100%;
  max-width: 500px;
  margin: 0 auto;
  overflow: hidden;
}

/* Top gradient (hidden by default, shown when scrolled down) */
.clues-wrapper::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to top, transparent, var(--background));
  pointer-events: none;
  z-index: 1;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.clues-wrapper.scrolled-down::before {
  opacity: 1;
}

/* Bottom gradient (shown by default, hidden when scrolled to bottom) */
.clues-wrapper::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 60px;
  background: linear-gradient(to bottom, transparent, var(--background));
  pointer-events: none;
  z-index: 1;
  opacity: 1;
  transition: opacity 0.2s ease;
}

.clues-wrapper.scrolled-to-bottom::after {
  opacity: 0;
}

/* Clues Container */
.clues-container {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  height: 100%;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 10px;
  padding-bottom: 70px; /* Extra padding so content isn't hidden behind gradient */

  /* Custom scrollbar for WebKit browsers (Chrome, Safari, Edge) */
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: var(--surface) transparent; /* Firefox */
}

/* WebKit scrollbar styling */
.clues-container::-webkit-scrollbar {
  width: 6px;
}

.clues-container::-webkit-scrollbar-track {
  background: transparent;
}

.clues-container::-webkit-scrollbar-thumb {
  background-color: var(--surface);
  border-radius: 3px;
}

.clues-container::-webkit-scrollbar-thumb:hover {
  background-color: var(--disabled);
}

/* Individual Clue */
.clue-item {
  display: flex;
  flex-direction: column;
  border-radius: 8px;
  flex-shrink: 0;
  border: 1px solid white;
}

.clue-item.solved {
  opacity: 0.5;
}

.clue-item.highlighted {
  outline: 3px solid var(--primary);
  outline-offset: 2px;
  border-radius: 8px;
  border-color: transparent;
}

/* Fire border celebration effect */
.clue-item.fire-border {
  position: relative;
  border-color: transparent;
  z-index: 1;
}

.clue-item.fire-border::before {
  content: '';
  position: absolute;
  top: -3px;
  left: -3px;
  right: -3px;
  bottom: -3px;
  border-radius: 10px;
  background: linear-gradient(
    to top,
    #ffee44 0%,
    #ff8822 50%,
    #ff3311 100%
  );
  background-size: 100% 200%;
  z-index: -1;
  animation:
    fire-flicker-1 0.15s ease-in-out infinite alternate,
    fire-flicker-2 0.25s ease-in-out infinite alternate-reverse,
    fire-flicker-3 0.4s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 4px #ff8822) drop-shadow(0 0 8px #ff441188);
}

.clue-item.fire-border::after {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  border-radius: 8px;
  background: var(--surface);
  z-index: -1;
}

/* Fade out animation for fire border */
.clue-item.fire-border.fade-out::before {
  animation:
    fire-flicker-1 0.15s ease-in-out infinite alternate,
    fire-flicker-2 0.25s ease-in-out infinite alternate-reverse,
    fire-flicker-3 0.4s ease-in-out infinite alternate,
    fire-border-fade 0.5s ease-out forwards;
}

@keyframes fire-border-fade {
  0% {
    opacity: 1;
  }
  100% {
    opacity: 0;
  }
}

.clue-item.solved .clue-type,
.clue-item.solved .clue-text-content {
  text-decoration: line-through;
}

.clue-answer {
  font-weight: bold;
  color: white;
  margin-left: 6px;
}

/* Used clues divider */
.used-clues-divider {
  margin: 16px 0 8px 0;
}

.divider-line {
  height: 1px;
  background-color: rgba(255, 255, 255, 0.3);
  margin-bottom: 8px;
}

.divider-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0 4px;
}

.used-clues-label {
  font-size: 0.85em;
  color: rgba(255, 255, 255, 0.6);
}

.hide-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 0.85em;
  color: rgba(255, 255, 255, 0.6);
}

.hide-toggle input {
  display: none;
}

.toggle-slider {
  width: 36px;
  height: 20px;
  background-color: rgba(255, 255, 255, 0.2);
  border-radius: 10px;
  position: relative;
  transition: background-color 0.2s;
}

.toggle-slider::after {
  content: '';
  position: absolute;
  width: 16px;
  height: 16px;
  background-color: white;
  border-radius: 50%;
  top: 2px;
  left: 2px;
  transition: transform 0.2s;
}

.hide-toggle input:checked + .toggle-slider {
  background-color: var(--primary);
}

.hide-toggle input:checked + .toggle-slider::after {
  transform: translateX(16px);
}

/* Settings modal rows */
.settings-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.settings-row:last-child {
  border-bottom: none;
}

.settings-label {
  font-size: 1em;
  color: var(--text-primary);
}

/* Operation row within a clue */
.clue-operation-row {
  display: flex;
  width: 100%;
  min-height: 32px;
}

.clue-operation-row:first-child {
  border-radius: 8px 8px 0 0;
}

.clue-operation-row:last-child {
  border-radius: 0 0 8px 8px;
}

.clue-operation-row:only-child {
  border-radius: 8px;
}

.clue-type {
  flex: 0 0 120px;
  width: 120px;
  padding: 6px 12px;
  font-weight: bold;
  font-size: 12px;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  cursor: pointer;
  transition: opacity 0.15s ease;
}

.clue-type:hover {
  opacity: 0.7;
}

.operation-icon {
  display: inline-block;
  width: 16px;
  height: 16px;
  flex-shrink: 0;
  /* Use mask to allow coloring via background-color */
  -webkit-mask-size: contain;
  mask-size: contain;
  -webkit-mask-repeat: no-repeat;
  mask-repeat: no-repeat;
  -webkit-mask-position: center;
  mask-position: center;
}

.clue-text {
  flex: 1;
  padding: 6px 12px;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: flex-start;
  text-align: left;
  min-width: 0;
}

/* Alternating background colors for visual grouping */
.clue-item:nth-child(odd) .clue-operation-row:nth-child(odd) {
  background-color: #3a3a3a;
}

.clue-item:nth-child(odd) .clue-operation-row:nth-child(even) {
  background-color: #333333;
}

.clue-item:nth-child(even) .clue-operation-row:nth-child(odd) {
  background-color: #4a4a4a;
}

.clue-item:nth-child(even) .clue-operation-row:nth-child(even) {
  background-color: #434343;
}

/* Long type text - scale down */
.clue-type.long-text {
  font-size: 10px;
}

@media (max-width: 600px) {
  .clue-type.long-text {
    font-size: 8px;
  }
}

/* Input Area */
.input-area {
  width: 100%;
  max-width: 400px;
  padding: 10px 20px;
  flex-shrink: 0;
}

.input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
}

.answer-input {
  flex: 1;
  min-width: 0;
  padding: 10px 15px;
  font-size: 1.1em;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  text-align: center;
  border: 3px solid var(--primary);
  border-radius: 12px;
  background-color: var(--surface);
  color: var(--text-primary);
  outline: none;
  transition: border-color 0.3s, box-shadow 0.3s;
}

.answer-input:focus {
  border-color: var(--primary-light);
  box-shadow: 0 0 10px rgba(229, 57, 53, 0.3);
}

.answer-input::placeholder {
  color: var(--disabled);
  text-transform: none;
}

.answer-input:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Custom Keyboard */
.custom-keyboard {
  width: 100%;
  max-width: 500px;
  padding: 8px 4px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.puzzle-completed .custom-keyboard {
  display: none;
}

.keyboard-row {
  display: flex;
  justify-content: center;
  gap: 4px;
}

.key {
  min-width: 28px;
  height: 42px;
  padding: 0 6px;
  font-size: 16px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  border: none;
  border-radius: 6px;
  background-color: var(--surface);
  color: var(--text-primary);
  cursor: pointer;
  flex: 1;
  max-width: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.1s;
  -webkit-tap-highlight-color: transparent;
  user-select: none;
}

.key:active,
.key.active {
  background-color: var(--primary);
}

/* Floating key preview (shows above finger on mobile) */
.key-preview {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  min-width: 44px;
  height: 56px;
  padding: 0 12px;
  font-size: 22px;
  font-weight: 600;
  font-family: 'Montserrat', sans-serif;
  border-radius: 8px;
  background-color: var(--primary);
  color: var(--text-primary);
  display: none;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
  transform: translateX(-50%);
}

.key-preview.visible {
  display: flex;
}

.key-backspace {
  flex: 1.5;
  max-width: 60px;
  font-size: 20px;
}

/* Buttons */
.button {
  padding: 10px 20px;
  font-size: 16px;
  font-weight: 500;
  cursor: pointer;
  border: none;
  border-radius: 8px;
  background-color: var(--primary);
  color: var(--text-primary);
  transition: background-color 0.3s;
}

.button:disabled {
  background-color: var(--disabled);
  cursor: not-allowed;
}

.button:hover:not(:disabled) {
  background-color: var(--primary-hover);
}

.secondary-button {
  background-color: transparent;
  border: 2px solid var(--primary);
  border-radius: 8px;
  color: var(--primary);
  cursor: pointer;
}

.secondary-button:hover:not(:disabled) {
  background-color: transparent !important;
  border: 2px solid var(--primary-hover);
  color: var(--primary-hover);
  transition: border 0.3s;
  transition: color 0.3s;
}

.secondary-button:disabled {
  color: var(--disabled);
  background-color: transparent;
  border: 2px solid var(--disabled);
}

/* Refresh percentile button */
#refresh-percentile-button {
  opacity: 0.7;
  transition: opacity 0.2s;
}

#refresh-percentile-button:hover {
  opacity: 1;
}

#refresh-percentile-button img {
  transition: transform 0.5s ease-in-out;
}

#refresh-percentile-button.spinning img {
  transform: rotate(360deg);
}

.win-modal-button {
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100px;
  height: 100px;
  padding: 0.5rem;
  text-align: center;
  border: 3px solid var(--primary);
  border-radius: 8px;
  background-color: transparent;
  cursor: pointer;
  transition: background-color 0.3s;
  font-family: 'Montserrat', sans-serif;
  font-size: 0.8rem;
  text-decoration: none;
  color: inherit;
  white-space: normal;
  word-wrap: break-word;
  overflow: hidden;
}

.win-modal-button:hover {
  background-color: var(--primary-hover);
}

.win-modal-button img[src$=".svg"] {
  filter: invert(1);
}

#win-email-signup {
  margin-bottom: 0.5rem;
  min-height: 2.8rem;
}

#win-email-form {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  align-items: center;
  width: 100%;
}

#win-email-input {
  padding: 0.5rem 0.75rem;
  font-size: 1rem;
  border: 2px solid var(--primary);
  border-radius: 8px;
  flex: 1;
  min-width: 100px;
  background: var(--background);
  color: var(--text-primary);
}

#win-email-button {
  padding: 0.5rem 0.75rem;
  font-size: 0.9rem;
  margin-bottom: 0;
  flex-shrink: 0;
}

#win-email-message {
  margin: 0;
  font-size: 1rem;
  color: var(--primary);
  text-align: center;
  line-height: 2.8rem;
}

#win-email-form.hidden,
#win-email-message.hidden {
  display: none;
}

.reminder-form {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
}

.reminder-form input[type="email"] {
  padding: 0.6rem 0.75rem;
  font-size: 1rem;
  border: 2px solid var(--primary);
  border-radius: 8px;
  width: 100%;
  max-width: 280px;
  box-sizing: border-box;
  background: var(--background);
  color: var(--text-primary);
}

.reminder-form .button {
  width: 100%;
  max-width: 280px;
}

/* Modals */
.modal {
  display: none;
  position: fixed;
  z-index: 10000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: auto;
  background-color: rgba(0,0,0,0.8);
  justify-content: center;
  align-items: center;
}

.modal.show {
  display: flex;
}

.modal.fade-in {
  animation: modal-fade-in 0.5s ease-out;
}

@keyframes modal-fade-in {
  0% {
    opacity: 0;
  }
  100% {
    opacity: 1;
  }
}

.modal-content {
  background-color: var(--surface);
  margin: auto;
  padding: 0;
  border-radius: 10px;
  width: 90%;
  max-width: 500px;
  max-height: 80vh;
  overflow: hidden;
  position: relative;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.modal-header {
  width: 100%;
  padding: 20px 20px 10px 20px;
  flex-shrink: 0;
  position: relative;
  text-align: center;
  z-index: 1;
}

.modal-header h2 {
  margin: 0;
}

.modal-header .close-button {
  position: absolute;
  top: 10px;
  right: 20px;
  z-index: 2;
}

.modal-body {
  width: 100%;
  padding: 10px 20px 20px 20px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;

  /* Custom scrollbar */
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: var(--disabled) transparent; /* Firefox */
}

/* WebKit scrollbar styling for modal body */
.modal-body::-webkit-scrollbar {
  width: 6px;
}

.modal-body::-webkit-scrollbar-track {
  background: transparent;
}

.modal-body::-webkit-scrollbar-thumb {
  background-color: var(--disabled);
  border-radius: 3px;
}

.modal-body::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-secondary);
}

h2 {
  font-family: 'Caudex', serif;
}

.modal-content h2 {
  color: var(--text-primary);
}

.modal-content p,
.modal-content pre {
  width: 100%;
  text-align: center;
}

.close-button {
  position: absolute;
  top: 10px;
  right: 20px;
  cursor: pointer;
  font-size: 32px;
  color: var(--text-primary);
}

#share-text {
  text-align: center;
  white-space: pre-wrap;
  font-size: 18px;
  color: var(--text-primary);
  width: 100%;
}

#copy-button {
  margin-bottom: 20px;
}

.button-container {
  display: flex;
  justify-content: center;
  gap: 20px;
  margin-top: 20px;
}

.button-container-vertical {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.button-container-vertical .button {
  width: 100px;
  height: 50px;
  padding: 0;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stats-container {
  display: flex;
  flex-wrap: wrap;
  gap: 1em;
}

.stat-header {
  flex: 1 1 72px;
  text-align: center;
  font-size: 1rem;
  font-family: 'Montserrat', sans-serif;
}

.stat {
  flex: 1 1 72px;
  text-align: center;
  font-size: 1.25rem;
  font-family: 'Montserrat', sans-serif;
}

.stat hr {
  border: none;
  border-top: 2px solid #ccc;
  max-width: 100px;
}

.distribution-row {
  display: flex;
  align-items: center;
  margin-bottom: 0.3em;
}

.distribution-label {
  width: 50px;
  text-align: right;
  margin-right: 0.5em;
  font-weight: bold;
  font-size: 0.9rem;
}

.distribution-bar-container {
  flex: 1;
  background-color: #eee;
  height: 20px;
  position: relative;
  border-radius: 4px;
  overflow: hidden;
}

.distribution-bar {
  background-color: var(--primary);
  height: 100%;
  display: flex;
  align-items: center;
  transition: width 1s ease;
  border-radius: 4px 0 0 4px;
  white-space: nowrap;
}

.distribution-count {
  margin-left: 8px;
  color: #fff;
  font-weight: bold;
  font-size: 1rem;
}

#share-distribution-chart {
  width: 100% !important;
  align-self: flex-start !important;
  text-align: left;
}

.modal-body > div {
  width: 100%;
  text-align: left;
}

/* Responsive adjustments */
@media (max-width: 1600px) {
  .game-content {
    justify-content: start;
    width: 100%;
  }
}

@media (max-width: 1300px) {
  .header {
    padding: 10px 10px;
  }

  .game-content {
    justify-content: start;
  }
}

@media (max-width: 768px) {
  .current-word {
    font-size: 2.5em;
  }
}

@media (max-width: 600px) {
  .header-buttons button {
    height: 2rem;
    width: 2rem;
  }

  .modal {
    display: none;
    justify-content: flex-end;
    align-items: flex-end;
  }

  .modal.show {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
  }

  .modal-content {
    margin: 0;
    width: 100%;
    max-width: 100%;
    height: auto;
    border-radius: 20px 20px 0 0;
    box-sizing: border-box;
    position: relative;
    justify-content: flex-start;
    flex-direction: column;
    max-height: 80vh;
    overflow: hidden;
  }

  .current-word {
    font-size: 2em;
  }

  .timer-digits {
    font-size: 1em;
  }

  .clue-type {
    flex: 0 0 100px;
    width: 100px;
    font-size: 10px;
    padding: 8px 10px;
  }

  .clue-text {
    font-size: 12px;
    padding: 8px 10px;
  }

  .answer-input {
    font-size: 1em;
    padding: 12px 15px;
  }

  .modal-content h2 {
    font-size: 1.5em;
  }

  #share-text {
    font-size: 16px;
  }

  #copy-button {
    width: 80%;
  }

  .distribution-label {
    width: 40px;
    font-size: 0.8rem;
  }

  .distribution-bar-container {
    height: 16px;
  }

  .distribution-count {
    font-size: 0.8rem;
  }
}

/* Archive Container */
#archive-container {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 10px;
  width: 100%;
  max-width: 700px;
  margin: 0 auto;
  padding: 10px;
}

.archive-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--primary);
  border: none;
  border-radius: 5px;
  color: var(--text-primary);
  padding: 10px;
  cursor: pointer;
  transition: background-color 0.3s;
  text-align: center;
}

.archive-button:hover {
  background-color: var(--primary-hover);
}

.archive-button-completed {
  background-color: var(--primary-dark);
}

.archive-button-completed:hover {
  background-color: #8a3d1f;
}

@media (max-width: 600px) {
  #archive-container {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}

/* Popup Notice Styling */
.copy-notice {
  visibility: hidden;
  min-width: 160px;
  max-width: 300px;
  width: fit-content;
  background-color: var(--surface);
  color: var(--text-primary);
  text-align: center;
  border-radius: 4px;
  padding: 10px 20px;
  position: fixed;
  z-index: 1000;
  top: 30px;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.5s ease, visibility 0.5s ease;
  font-family: 'Montserrat', sans-serif;
  font-size: 1em;
  display: flex;
  align-items: center;
  justify-content: center;
}

.copy-notice.show {
  visibility: visible;
  opacity: 1;
}

/* Correct answer flash animation */
@keyframes correctFlash {
  0% { background-color: var(--surface); }
  50% { background-color: var(--primary); }
  100% { background-color: var(--surface); }
}

.answer-input.correct {
  animation: correctFlash 0.5s ease;
}

/* Completed state for puzzle */
.puzzle-completed .answer-input {
  border-color: var(--correct);
}

/* Share button (shown when puzzle is completed) */
.share-button {
  width: 100%;
  padding: 15px 20px;
  font-size: 1.25em;
  font-family: 'Montserrat', sans-serif;
  font-weight: 600;
  text-transform: uppercase;
  text-align: center;
  border: none;
  border-radius: 12px;
  background-color: var(--primary);
  color: var(--text-primary);
  cursor: pointer;
  transition: background-color 0.3s;
}

.share-button:hover {
  background-color: var(--primary-hover);
}

.puzzle-completed .current-word-slider {
  overflow: visible;
}

.puzzle-completed .current-word {
  background: linear-gradient(
    to top,
    #ffee44 0%,
    #ff8822 50%,
    #ff3311 100%
  );
  background-size: 100% 200%;
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  animation:
    fire-flicker-1 0.15s ease-in-out infinite alternate,
    fire-flicker-2 0.25s ease-in-out infinite alternate-reverse,
    fire-flicker-3 0.4s ease-in-out infinite alternate;
  filter: drop-shadow(0 0 3px #ff8822) drop-shadow(0 0 6px #ff441188);
}

@keyframes fire-flicker-1 {
  0% {
    background-position: 0% 100%;
  }
  100% {
    background-position: 0% 70%;
  }
}

@keyframes fire-flicker-2 {
  0% {
    background-position: 0% 85%;
  }
  100% {
    background-position: 0% 55%;
  }
}

@keyframes fire-flicker-3 {
  0% {
    background-position: 0% 95%;
  }
  100% {
    background-position: 0% 65%;
  }
}

/* Editor Button (shown in test mode) */
.editor-button {
  display: none !important;
}

body.test-mode .editor-button {
  display: flex !important;
  background-color: #9c27b0;
}

body.test-mode .editor-button:hover {
  background-color: #7b1fa2;
}

/* Reset Button (dev tool - stands out so you remember to hide it) */
#reset-button {
  background-color: #9c27b0;
}

#reset-button:hover {
  background-color: #7b1fa2;
}

/* Hamburger Menu Button */
.hamburger-button {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 5px;
  width: 2.5rem;
  height: 2.5rem;
  background-color: transparent;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 5px;
  transition: background-color 0.2s;
}

.hamburger-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.landing-hamburger {
  position: absolute;
  top: 16px;
  left: 16px;
  z-index: 10;
}

.hamburger-line {
  display: block;
  width: 20px;
  height: 2px;
  background-color: var(--text-primary);
  border-radius: 1px;
  transition: transform 0.3s, opacity 0.3s;
}

/* Slide-out Menu Overlay */
.menu-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  z-index: 10000;
  opacity: 0;
  visibility: hidden;
  transition: opacity 0.3s, visibility 0.3s;
}

.menu-overlay.open {
  opacity: 1;
  visibility: visible;
}

/* Slide-out Menu */
.slide-menu {
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  max-width: 80vw;
  height: 100%;
  background-color: var(--surface);
  z-index: 10001;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  display: flex;
  flex-direction: column;
  box-shadow: 2px 0 10px rgba(0, 0, 0, 0.3);
}

.slide-menu.open {
  transform: translateX(0);
}

.slide-menu-header {
  display: flex;
  justify-content: flex-end;
  padding: 15px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.close-menu-button {
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 28px;
  cursor: pointer;
  padding: 5px 10px;
  line-height: 1;
  border-radius: 5px;
  transition: background-color 0.2s;
}

.close-menu-button:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.slide-menu-nav {
  display: flex;
  flex-direction: column;
  padding: 15px;
  gap: 5px;
}

.menu-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 15px;
  color: var(--text-primary);
  text-decoration: none;
  border-radius: 8px;
  font-family: 'Montserrat', sans-serif;
  font-size: 1rem;
  transition: background-color 0.2s;
}

.menu-link:hover {
  background-color: rgba(255, 255, 255, 0.1);
}

.menu-link-primary {
  font-weight: 600;
  font-size: 1.1rem;
}

.menu-link-icon {
  font-size: 1.3rem;
}

.menu-divider {
  height: 1px;
  background-color: rgba(255, 255, 255, 0.15);
  margin: 10px 0;
}

.menu-section-label {
  color: var(--text-secondary);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 8px 15px 5px;
  margin: 0;
  font-family: 'Montserrat', sans-serif;
}

.menu-link-logo {
  width: 24px;
  height: 24px;
  border-radius: 4px;
  object-fit: contain;
}

.menu-link-logo[src$=".svg"] {
  filter: invert(1);
}

.slide-menu-footer {
  margin-top: auto;
  padding: 15px;
}

.menu-link-secondary {
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.menu-link-secondary:hover {
  color: var(--text-primary);
}

/* Mode Selection (Landing Screen) */
#landing-mode-selection {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.mode-toggle-container {
  display: flex;
  justify-content: center;
}

.mode-toggle-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-label {
  font-size: 0.9em;
  color: var(--text-secondary);
  transition: color 0.2s;
}

/* Use text-stroke to simulate bold, preventing layout shift */
.mode-label-competitive.active,
.mode-label-casual.active {
  color: var(--text-primary);
  -webkit-text-stroke: 0.5px currentColor;
}

/* Toggle Switch */
.mode-toggle-switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.mode-toggle-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.mode-toggle-slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--primary);
  transition: 0.3s;
  border-radius: 26px;
  box-sizing: border-box;
  border: 2px solid transparent;
}

.mode-toggle-slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 2px;
  bottom: 2px;
  background-color: white;
  transition: 0.3s;
  border-radius: 50%;
}

.mode-toggle-switch input:checked + .mode-toggle-slider {
  background-color: var(--surface-light);
  border: 2px solid rgba(255, 255, 255, 0.5);
}

.mode-toggle-switch input:checked + .mode-toggle-slider:before {
  transform: translateX(26px);
}

#landing-continue-button {
  display: block;
  margin: 0 auto;
}

.mode-help-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background-color: transparent;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

.mode-help-button:hover {
  opacity: 1;
}


/* Casual Mode - Hide timer and stats */
body.casual-mode .timer-display {
  display: none;
}

body.casual-mode #stats-button {
  display: none;
}

body.casual-mode .menu-link-secondary[id="menu-stats-link"] {
  display: none;
}

/* Responsive: Stack mode buttons vertically on very small screens */
@media (max-width: 380px) {
  .mode-buttons-container {
    flex-direction: column;
  }

  .mode-button {
    width: 100%;
    min-width: unset;
  }
}

/* Membership modal styles */
#membership-modal {
  z-index: 10001; /* Above landing modal */
}

.membership-body {
  padding: 10px 20px 20px 20px;
  text-align: left;
  overflow-y: auto;
  max-height: calc(80vh - 60px);
  /* Custom scrollbar */
  scrollbar-width: thin; /* Firefox */
  scrollbar-color: var(--disabled) transparent; /* Firefox */
}

/* WebKit scrollbar styling for membership modal */
.membership-body::-webkit-scrollbar {
  width: 6px;
}

.membership-body::-webkit-scrollbar-track {
  background: transparent;
}

.membership-body::-webkit-scrollbar-thumb {
  background-color: var(--disabled);
  border-radius: 3px;
}

.membership-body::-webkit-scrollbar-thumb:hover {
  background-color: var(--text-secondary);
}

.membership-body p {
  margin-bottom: 0.75rem;
  line-height: 1.5;
  font-size: 0.85rem;
  color: #ccc;
}

.membership-icon {
  text-align: center;
  margin-bottom: 1rem;
}

.membership-header-icon {
  width: 48px;
  height: 48px;
  filter: invert(56%) sepia(31%) saturate(1752%) hue-rotate(330deg) brightness(99%) contrast(89%);
}

/* Override white filter for membership icon in menu */
.menu-link-logo[src*="heart-partner-handshake"] {
  filter: invert(56%) sepia(31%) saturate(1752%) hue-rotate(330deg) brightness(99%) contrast(89%);
}

.membership-greeting {
  font-size: 1.1rem !important;
  text-align: center;
  color: #fff !important;
}

.membership-calculation {
  font-style: italic;
  color: #999 !important;
}

.membership-signoff {
  margin-top: 1rem !important;
}

.membership-signature {
  text-align: left;
  margin-top: 0.5rem !important;
  margin-bottom: 0 !important;
}

.membership-company {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: #999;
  font-size: 0.9rem;
}

.membership-fpg-logo {
  width: 20px;
  height: 20px;
  border-radius: 4px;
}

.membership-buttons {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-top: 1.5rem;
}

.membership-buttons .button {
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
