@font-face {
  font-family: 'Klouvatos';
  src: url('KLOUVAT0S.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
  font-display: swap;
}

:root {
  --pond-green: #6fbf73;
  --pond-red: #e57373;
  --pond-blue: #d2e8ff;
  --pond-cream: #f5f9f0;
  --dark-text: #243028;
  --neutral-pill: #edf2e2;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Klouvatos', 'EB Garamond', Garamond, 'Times New Roman', serif, 'Apple Color Emoji', 'Segoe UI Emoji';
  background: linear-gradient(180deg, #f7fbff 0%, #eff7f1 100%);
  color: var(--dark-text);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.top-bar {
  display: grid;
  grid-template-columns: 120px 1fr 160px;
  align-items: center;
  background: #a1d6a4;
  color: #0f2f1c;
  padding: 10px 18px;
  position: sticky;
  top: 0;
  z-index: 10;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.1);
}

.timer {
  font-size: 22px;
  font-weight: 600;
  text-align: left;
}

.title {
  text-align: center;
  font-size: 20px;
  font-weight: 600;
}

.actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.actions button {
  border: none;
  background: #f2ffe8;
  padding: 8px 10px;
  border-radius: 10px;
  font-size: 18px;
  cursor: pointer;
  transition: transform 0.1s ease, background 0.2s ease;
}

.actions button:hover {
  transform: translateY(-1px);
  background: #e5f8d7;
}

main {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px 24px 80px;
  gap: 16px;
}

.words-box {
  width: 100%;
  max-width: 1100px;
  /* Auto-height to fit content up to a sensible cap */
  max-height: 60vh;
  background: linear-gradient(135deg, rgba(204, 236, 216, 0.8), rgba(210, 232, 255, 0.8));
  border-radius: 18px;
  padding: 24px;
  box-shadow: inset 0 1px 4px rgba(0, 0, 0, 0.05);
  background-image: radial-gradient(circle at 20% 20%, rgba(255, 255, 255, 0.35) 0 80px, transparent 90px),
    radial-gradient(circle at 80% 40%, rgba(255, 255, 255, 0.3) 0 90px, transparent 120px);
  overflow: auto;
}

.word-list {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  font-size: 18px;
  /* Avoid horizontal overflow for very long items (e.g., sentences) */
  word-break: break-word;
}

.word-pill {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--neutral-pill);
  color: var(--dark-text);
  transition: background 0.2s ease, color 0.2s ease;
  white-space: normal;
  word-break: break-word;
}

/* Responsive cap adjustments so the typing area and footer remain visible */
@media (max-width: 768px) {
  .words-box {
    max-height: 50vh;
  }
}

@media (max-width: 420px) {
  .words-box {
    max-height: 45vh;
  }
}

.word-pill.correct {
  background: #b1e4b7;
  color: #0f2f1c;
}

.word-pill.wrong {
  background: #f7c1c1;
  color: #3e1111;
}

.typing-area {
  width: 100%;
  display: flex;
  justify-content: center;
  flex-direction: column;
  align-items: center;
}

#nickname-display {
  font-size: 16px;
  font-weight: 600;
  color: #1b3b28;
  margin-bottom: 6px;
  background: #eaf7ec;
  border: 1px solid #cfe7d2;
  padding: 6px 10px;
  border-radius: 999px;
}

#typing-input {
  width: 60%;
  min-width: 360px;
  max-width: 720px;
  padding: 12px 14px;
  font-size: 18px;
  border: 2px solid #c6dec7;
  border-radius: 14px;
  background: #f7fff5;
  outline: none;
  transition: border 0.2s ease, background 0.2s ease;
  font-family: 'Klouvatos', 'EB Garamond', Garamond, 'Times New Roman', serif, 'Apple Color Emoji', 'Segoe UI Emoji';
}

#typing-input:focus {
  border-color: #7ecb82;
  background: #ffffff;
}

#typing-input:disabled {
  background: #ececec;
  color: #8a8a8a;
  border-color: #d4d4d4;
}

/* Cat typing GIF under the input */
.cat-typing-gif {
  margin-top: 10px;
  display: block;
  width: 220px;
  max-width: 60vw;
  height: auto;
  border-radius: 8px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

@media (max-width: 420px) {
  .cat-typing-gif {
    width: 160px;
  }
}

.score-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #d9f3de;
  border-top: 2px solid #a8d6ad;
  padding: 10px 18px;
  display: grid;
  grid-template-columns: 1fr 260px;
  gap: 10px;
  align-items: flex-start;
  font-size: 16px;
}

.frogs {
  min-height: 40px;
  font-size: 22px;
  line-height: 1.6;
  word-break: break-word;
}

.stats div {
  margin: 2px 0;
}

.overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 20;
}

.modal {
  width: 420px;
  max-width: 92vw;
  background: #ffffff;
  border-radius: 16px;
  padding: 18px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.18);
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.modal h2 {
  margin: 0 0 4px 0;
  text-align: center;
}

.modal label,
.modal fieldset {
  display: flex;
  flex-direction: column;
  gap: 6px;
  font-weight: 600;
}

.modal select,
.modal input[type="text"] {
  padding: 10px;
  border-radius: 10px;
  border: 1px solid #cfd8cf;
  font-family: 'Klouvatos', 'EB Garamond', Garamond, 'Times New Roman', serif, 'Apple Color Emoji', 'Segoe UI Emoji';
  font-size: 16px;
}

.mode-field label {
  font-weight: 500;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.mode-field input[type="radio"] {
  margin: 0;
}

.slider-row {
  gap: 4px;
}

#font-size-slider {
  width: 100%;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 6px;
}

.modal button.primary {
  padding: 10px 14px;
  background: var(--pond-green);
  color: white;
  border: none;
  border-radius: 12px;
  cursor: pointer;
  font-size: 16px;
  transition: transform 0.1s ease, background 0.2s ease;
}

.modal button.primary:hover {
  transform: translateY(-1px);
  background: #59a760;
}

.hidden {
  display: none !important;
}

#end-banner {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  background: #fce4a1;
  color: #3f2e00;
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 30;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.15);
}

#end-banner.hidden {
  display: none;
}

#end-banner button {
  border: none;
  background: #ffe36c;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
}

@media (max-width: 768px) {
  #typing-input {
    width: 90%;
  }
  .score-bar {
    grid-template-columns: 1fr;
  }
  .top-bar {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto auto;
    gap: 6px;
  }
  .title {
    text-align: left;
  }
  .actions {
    justify-content: flex-start;
  }
}

/* Mobile-first adjustments: hide score bar so content isn't obscured */
@media (max-width: 600px) {
  .score-bar {
    display: none;
  }
  main {
    padding-bottom: 20px;
  }
  #typing-input {
    min-width: 0;
    width: 100%;
  }
}
