/* --- Word Scramble Game: Pixel-perfect match to latest screenshot --- */
/* --- Start Screen Overlay Styles --- */
.start-screen-overlay {
  position: fixed;
  z-index: 10;
  top: 0; left: 0; width: 100vw; height: 100vh;
  background: linear-gradient(120deg, #fffbe6 0%, #fff 100%);
  display: flex;
  align-items: flex-start;
  justify-content: center;
  transition: background 0.4s;
  animation: fadeInOverlay 0.7s;
  min-height: 100vh;
  padding-top: 110px; /* Offset for header/navigation height */
  box-sizing: border-box;
}
@media (max-width: 700px) {
  .start-screen-overlay {
    padding-top: 80px;
  }
}
@media (max-width: 500px) {
  .start-screen-overlay {
    padding-top: 60px;
  }
}
@keyframes fadeInOverlay {
  from { opacity: 0; }
  to { opacity: 1; }
}
.start-card {
  margin-bottom: auto;
  margin-top: auto;
  background: #fff;
  border-radius: 28px;
  box-shadow: 0 8px 32px rgba(254, 176, 1, 0.13), 0 2px 12px rgba(80, 80, 80, 0.07);
  padding: 2.5em 2.2em 2em 2.2em;
  min-width: 320px;
  max-width: 95vw;
  display: flex;
  flex-direction: column;
  animation: cardPopIn 0.8s cubic-bezier(.68, -0.55, .27, 1.55);
}
@keyframes cardPopIn {
  0% { transform: scale(0.85) translateY(40px); opacity: 0; }
  60% { transform: scale(1.05) translateY(-10px); opacity: 1; }
  100% { transform: scale(1) translateY(0); opacity: 1; }
}
.start-card-header {
  display: flex;
  flex-direction: column;
  align-items: center;
  margin-bottom: 1.2em;
}
.start-icon {
  font-size: 2.5em;
  margin-bottom: 0.2em;
  color: #FEB001;
  filter: drop-shadow(0 2px 8px #feb00133);
  animation: iconBounce 1.1s;
}
@keyframes iconBounce {
  0% { transform: scale(0.7) rotate(-10deg);}
  60% { transform: scale(1.2) rotate(8deg);}
  100% { transform: scale(1) rotate(0);}
}
.start-title {
  font-size: 2.1em;
  font-weight: 800;
  letter-spacing: -1px;
  /* Fallback solid color for browsers that don't support gradient text */
  color: #222;
  /* Gradient text effect for modern browsers */
  background: linear-gradient(90deg, #FEB001 30%, #ff7e5f 100%);
  /* Use -webkit- prefix for maximum compatibility */
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  /* The following are not widely supported, but included for future compatibility */
  background-clip: text;
  /* text-fill-color is not standard; only -webkit-text-fill-color is supported */
  margin: 0;
  text-align: center;
}
.start-form {
  display: flex;
  flex-direction: column;
  gap: 1.2em;
  align-items: center;
  width: 100%;
}
.start-form-group {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  width: 100%;
}
.start-label {
  font-weight: 600;
  font-size: 1.08em;
  margin-bottom: 0.3em;
  color: #222;
}
.start-input-wrapper {
  display: flex;
  align-items: center;
  width: 100%;
  background: #f5f6fa;
  border-radius: 12px;
  padding: 0.2em 0.7em;
  box-shadow: 0 1px 4px rgba(0,0,0,0.03);
  border: 2px solid #fffbe6;
  transition: border 0.2s;
}
.start-input-icon {
  font-size: 1.2em;
  margin-right: 0.5em;
  color: #FEB001;
  opacity: 0.85;
}
.start-input, .start-select {
  border: none;
  background: transparent;
  font-size: 1.08em;
  padding: 0.5em 0.2em;
  outline: none;
  width: 100%;
  color: #222;
  font-family: inherit;
}
.start-input:focus, .start-select:focus {
  background: #fff;
}
.start-input-wrapper:focus-within {
  border: 2px solid #FEB001;
}
.start-btn {
  background: linear-gradient(90deg, #FEB001 60%, #ff7e5f 100%);
  color: #fff;
  font-weight: 700;
  font-size: 1.15em;
  border: none;
  border-radius: 18px;
  padding: 0.7em 2.5em;
  margin-top: 0.7em;
  box-shadow: 0 2px 12px #feb00133;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  letter-spacing: 0.5px;
  outline: none;
}
.start-btn:hover, .start-btn:focus {
  background: linear-gradient(90deg, #ff7e5f 0%, #FEB001 100%);
  transform: scale(1.04);
  box-shadow: 0 4px 18px #feb00144;
}
@media (max-width: 600px) {
  .start-screen-overlay {
    padding-top: 24vw;
    padding-left: 2vw;
    padding-right: 2vw;
    align-items: flex-start;
    min-height: 100vh;
    box-sizing: border-box;
  }
  .start-card {
    margin-bottom: auto;
    margin-top: auto;
    min-width: 0;
    width: 96vw;
    max-width: 420px;
    padding: 1.2em 0.7em 1em 0.7em;
    box-sizing: border-box;
  }
  .start-title {
    font-size: 1.1em;
    word-break: break-word;
    text-align: center;
  }
  .start-btn {
    font-size: 1em;
    padding: 0.6em 1.2em;
  }
  .start-form-group {
    width: 100%;
  }
  .start-input-wrapper {
    font-size: 1em;
    padding: 0.15em 0.4em;
  }
}

/* --- End Start Screen Overlay Styles --- */

.word-scramble-game {
  font-family: 'Poppins', 'Nunito Sans', Arial, sans-serif;
  color: #222;
}

/* --- Enhanced Tip/Score Area Styles --- */
.word-scramble-game .scorecard {
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 4px 18px rgba(254,176,1,0.08), 0 1.5px 6px rgba(80,80,80,0.04);
  padding: 1.2em 1.3em 1em 1.3em;
  margin-bottom: 1.2em;
  transition: box-shadow 0.2s;
  border-left: 5px solid #FEB001;
  /* border: 4px solid #ff0033 !important;  DEBUG: Should show a thick red border if CSS is loaded */
}

/* Add space between meta message and scorecard in sidebar */
.word-scramble-game aside.right .meta.small {
  margin-bottom: 22px;
}

/* --- Difficulty Badge Styles --- */
.difficulty-badge {
  display: inline-block;
  padding: 0.45em 1.3em;
  border-radius: 999px;
  font-size: 1.13rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  box-shadow: 0 2px 8px rgba(254,176,1,0.08);
  margin-bottom: 0.5em;
  background: #f5f6fa;
  color: #444;
  border: 2.5px solid #FEB001;
  transition: background 0.2s, color 0.2s, border 0.2s;
}
.difficulty-badge.easy {
  background: #e6ffe6;
  color: #228B22;
  border-color: #22c55e;
}
.difficulty-badge.medium {
  background: #fffbe6;
  color: #b48a00;
  border-color: #FEB001;
}
.difficulty-badge.hard {
  background: #ffe6e6;
  color: #d32f2f;
  border-color: #f43f5e;
}

.word-scramble-game .scorecard .score-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 1.15rem;
  margin-bottom: 0.5em;
}

.word-scramble-game .scorecard .score-row div:last-child {
  font-size: 1.4rem;
  font-weight: 700;
  color: #FEB001;
  display: flex;
  align-items: center;
  gap: 0.3em;
}

.word-scramble-game .scorecard .score-row .icon {
  font-size: 1.2em;
  margin-right: 0.2em;
}

.word-scramble-game .scorecard .small {
  color: #6B7280;
  font-size: 1.05rem;
  margin-bottom: 0.3em;
}

.word-scramble-game .scorecard .hint {
  background: #fffbe6;
  color: #b48a00;
  border-left: 4px solid #FEB001;
  border-radius: 10px;
  padding: 0.7em 1em 0.7em 1.2em;
  margin-bottom: 0.5em;
  display: flex;
  align-items: flex-start;
  gap: 0.7em;
  font-size: 1.08rem;
  position: relative;
}

.word-scramble-game .scorecard .hint::before {
  content: "💡";
  font-size: 1.3em;
  margin-right: 0.5em;
  position: relative;
  top: 1px;
}

.word-scramble-game .scorecard .controls-list {
  display: flex;
  flex-direction: column;
  gap: 0.3em;
  margin-top: 0.3em;
}

.word-scramble-game .scorecard .controls-list .icon {
  margin-right: 0.4em;
  font-size: 1.1em;
  color: #FEB001;
}

/* --- Enhanced Feedback Section --- */
.word-scramble-game #feedback {
  background: #fffbe6;
  border: 2.5px solid #FEB001;
  color: #111;
  font-family: 'Nunito Sans', Arial, sans-serif;
  font-size: 1.25rem;
  font-weight: 700;
  border-radius: 18px;
  padding: 1.5em 2em;
  margin: 2em 0 1.5em 0;
  min-height: 48px;
  box-shadow: 0 6px 24px #feb00144, 0 0 0 6px #fffbe6;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  letter-spacing: 0.5px;
  opacity: 0;
  animation: feedbackBounceIn 0.7s forwards;
  position: relative;
  transition: background 0.3s, border 0.3s, color 0.3s, box-shadow 0.3s;
}
@keyframes feedbackBounceIn {
  0% { opacity: 0; transform: translateY(40px) scale(0.9);}
  60% { opacity: 1; transform: translateY(-10px) scale(1.05);}
  80% { transform: translateY(2px) scale(0.98);}
  100% { opacity: 1; transform: translateY(0) scale(1);}
}
.word-scramble-game #feedback.success {
  background: #e6ffed;
  border-color: #22c55e;
  color: #228B22;
  font-family: 'Nunito Sans', Arial, sans-serif;
  font-weight: 800;
}
.word-scramble-game #feedback.success::before {
  content: "✔️";
  font-size: 2em;
  margin-right: 16px;
  display: inline-block;
  vertical-align: middle;
  animation: iconPop 0.5s;
}
.word-scramble-game #feedback.error {
  background: #ffe6e6;
  border-color: #f43f5e;
  color: #d32f2f;
  font-family: 'Nunito Sans', Arial, sans-serif;
  font-weight: 800;
}
.word-scramble-game #feedback.error::before {
  content: "❌";
  font-size: 2em;
  margin-right: 16px;
  display: inline-block;
  vertical-align: middle;
  animation: iconPop 0.5s;
}
.word-scramble-game #feedback.hint {
  background: #fffbe6;
  border-color: #feb001;
  color: #1a237e!important;
  font-style: italic;
  font-family: 'Nunito Sans', Arial, sans-serif;
  font-weight: 800;
}
.word-scramble-game #feedback.hint::before {
  content: "💡";
  font-size: 2em;
  margin-right: 16px;
  display: inline-block;
  vertical-align: middle;
  animation: iconPop 0.5s;
}
@keyframes iconPop {
  0% { transform: scale(0.5) rotate(-20deg);}
  60% { transform: scale(1.2) rotate(10deg);}
  100% { transform: scale(1) rotate(0);}
}

.word-scramble-game #feedback strong {
  font-size: 1.2em;
  font-weight: 900;
  letter-spacing: 1px;
}

@media (max-width: 600px) {
  .word-scramble-game #feedback {
    font-size: 1.05rem;
    padding: 1em 0.7em;
    border-radius: 12px;
    margin: 1.2em 0 1em 0;
    gap: 10px;
  }
  .word-scramble-game #feedback::before {
    font-size: 1.3em;
    margin-right: 8px;
  }
}

.word-scramble-game h2 {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.25em;
  letter-spacing: -1px;
}

.word-scramble-game p {
  color: #6B7280;
  font-size: 1.1rem;
  margin-bottom: 1.5rem;
}

.word-scramble-game .scrambled {
  background: #f5f6fa;
  border: 2px solid #FEB001;
  border-radius: 16px;
  min-height: 90px;
  margin-bottom: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2rem;
  letter-spacing: 0.5rem;
  padding: 1.5rem 1rem;
  flex-wrap: wrap; /* Allow tiles to wrap on desktop */
  gap: 0.5rem;     /* Use gap for spacing instead of margin */
}

/* For long words (9+ letters), shrink tiles and spacing on desktop */
.word-scramble-game .scrambled.long-word .tile {
  min-width: 38px;
  min-height: 38px;
  font-size: 1.25rem;
  margin: 0;
  gap: 0.18rem;
}
@media (max-width: 900px) {
  .word-scramble-game .scrambled.long-word .tile {
    min-width: 28px;
    min-height: 28px;
    font-size: 1rem;
    gap: 0.08rem;
  }
}

.word-scramble-game .tile {
  background: #fff;
  color: #222;
  border: none;
  border-radius: 50%;
  min-width: 56px;
  min-height: 56px;
  font-size: 2rem;
  font-weight: 600;
  margin: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.04);
  transition: background 0.2s, color 0.2s, border 0.2s;
  cursor: pointer;
}
.word-scramble-game .tile:active,
.word-scramble-game .tile.selected {
  background: #FEB001;
  color: #fff;
}

.word-scramble-game .answer {
  background: #fff;
  border: none;
  border-radius: 12px;
  min-height: 60px;
  margin-bottom: 1.5rem;
  margin-top: 0.5rem;
  display: flex;
  align-items: center;
  font-size: 2rem;
  padding: 1rem 1rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.07);
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.2em;
}

.word-scramble-game .controls {
  margin-bottom: 1.5rem;
  margin-top: 0.5rem;
  display: flex;
  gap: 0.5rem;
}

.word-scramble-game .controls .btn {
  background: #FEB001;
  color: #222;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  border: none;
  border-radius: 8px;
  padding: 0.7rem 2rem;
  font-size: 1.1rem;
  transition: background 0.2s, color 0.2s;
  margin-right: 0.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.word-scramble-game .controls .btn:active {
  background: #e0a800;
}

.word-scramble-game .controls .ghost {
  background: #fff;
  color: #FEB001;
  border: 2px solid #FEB001;
  border-radius: 8px;
  padding: 0.7rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  transition: background 0.2s, color 0.2s;
  margin-right: 0.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.word-scramble-game .controls .ghost:hover {
  background: #FEB001;
  color: #fff;
}

.word-scramble-game #hintBtn {
  background: #fff;
  color: #FEB001 !important;
  border: 2px solid #FEB001 !important;
  border-radius: 8px;
  padding: 0.7rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  margin-right: 0.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
}
.word-scramble-game #hintBtn:hover {
  background: #FEB001;
  color: #fff !important;
}

.word-scramble-game .fab-container {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

/* Difficulty dropdown and reset button */
.word-scramble-game select#difficulty,
.word-scramble-game #resetScore {
  background: #fff;
  color: #FEB001;
  border: 2px solid #FEB001;
  border-radius: 8px;
  padding: 0.7rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  margin-right: 0.5rem;
  box-shadow: 0 2px 6px rgba(0,0,0,0.04);
  transition: background 0.2s, color 0.2s;
}
.word-scramble-game select#difficulty:focus,
.word-scramble-game #resetScore:focus {
  outline: none;
  border-color: #e0a800;
}
.word-scramble-game select#difficulty:hover,
.word-scramble-game #resetScore:hover {
  background: #FEB001;
  color: #fff;
}

/* Add custom word button */
.word-scramble-game #addCustom {
  background: #FEB001;
  color: #222;
  border: none;
  border-radius: 8px;
  padding: 0.7rem 2rem;
  font-size: 1.1rem;
  font-weight: 600;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
  transition: background 0.2s, color 0.2s;
  position: absolute;
  right: 0;
  bottom: 0;
}
.word-scramble-game #addCustom:hover {
  background: #e0a800;
  color: #fff;
}

/* Responsive tweaks for tablet */
@media (max-width: 900px) {
  .word-scramble-game {
    padding: 0 4px;
  }
  .word-scramble-game .scrambled,
  .word-scramble-game .answer {
    font-size: 1.3rem;
    padding: 1rem 0.5rem;
  }
  .word-scramble-game .tile {
    min-width: 40px;
    min-height: 40px;
    font-size: 1.2rem;
    margin: 0 0.3rem;
  }
  .word-scramble-game .controls {
    gap: 0.3rem;
  }
}

/* Responsive tweaks for mobile */
@media (max-width: 600px) {
  .word-scramble-game {
    padding: 0 2px;
  }
  .word-scramble-game .scrambled,
  .word-scramble-game .answer {
    font-size: 1rem;
    padding: 0.5rem 0.2rem;
    min-height: 44px;
  }
  .word-scramble-game .tile {
    min-width: 28px;
    min-height: 28px;
    font-size: 0.95rem;
    margin: 0 0.1rem;
  }
  .word-scramble-game .controls {
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.2rem;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
  }
  .word-scramble-game .controls .btn,
  .word-scramble-game .controls .ghost,
  .word-scramble-game #hintBtn {
    padding: 0.4rem 0.7rem;
    font-size: 0.95rem;
    min-width: 70px;
    margin-bottom: 2px;
    word-break: keep-all;
  }
}

/* Extra small screens */
@media (max-width: 400px) {
  .word-scramble-game .scrambled,
  .word-scramble-game .answer {
    font-size: 0.85rem;
    padding: 0.2rem 0.1rem;
    min-height: 32px;
  }
  .word-scramble-game .tile {
    min-width: 18px;
    min-height: 18px;
    font-size: 0.8rem;
    margin: 0 0.05rem;
  }
  .word-scramble-game .controls .btn,
  .word-scramble-game .controls .ghost,
  .word-scramble-game #hintBtn {
    padding: 0.2rem 0.4rem;
    font-size: 0.8rem;
    min-width: 48px;
  }
}

/* Responsive visibility for Controls/Tip duplication */
.desktop-only { display: block; }
.mobile-only { display: none; }

@media (max-width: 600px) {
  .desktop-only { display: none !important; }
  .mobile-only { display: block !important; }
}

/* --- Leaderboard Table Styles --- */
.leaderboard-table {
  border-collapse: collapse;
  width: 100%;
  margin-top: 0.2em;
  margin-bottom: 0.2em;
}
.leaderboard-table th, .leaderboard-table td {
  padding: 0.38em 0.6em;
  text-align: left;
  font-size: 1em;
}
.leaderboard-table th {
  background: #f5f6fa;
  color: #444;
  font-weight: 700;
  border-bottom: 2px solid #FEB001;
}
.leaderboard-table tr:nth-child(even) {
  background: #faf7ee;
}
.leaderboard-table tr:nth-child(odd) {
  background: #fff;
}
.leaderboard-highlight {
  background: #fffbe6 !important;
  color: #b48a00 !important;
  font-weight: 700;
  border-left: 4px solid #FEB001;
}
.leaderboard-top1 {
  background: #ffe9b3 !important;
  color: #d4a100 !important;
  font-weight: 800;
}
.leaderboard-top2 {
  background: #f0f0f0 !important;
  color: #888 !important;
  font-weight: 700;
}
.leaderboard-top3 {
  background: #ffe0c1 !important;
  color: #b87333 !important;
  font-weight: 700;
}
.leaderboard-table tr.leaderboard-highlight td {
  border-left: 4px solid #FEB001;
}
.leaderboard-table td {
  border-bottom: 1px solid #f5f6fa;
  vertical-align: middle;
}
.leaderboard-table td:first-child {
  font-weight: 600;
  max-width: 120px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.leaderboard-table td {
  font-size: 1em;
}
@media (max-width: 600px) {
  .leaderboard-table th, .leaderboard-table td {
    font-size: 0.95em;
    padding: 0.25em 0.3em;
  }
  .leaderboard-table td:first-child {
    max-width: 70px;
  }
}

/* Desktop and larger: two-column layout */
@media (min-width: 900px) {
  .word-scramble-game .board {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    gap: 2.5rem;
  }
  .word-scramble-game .board .left {
    flex: 2 1 0;
    min-width: 0;
  }
  .word-scramble-game .board aside.right {
    flex: 1 1 0;
    min-width: 260px;
    max-width: 340px;
  }
}

/* --- Ensure answer tiles always fit, even for 9+ letters --- */
.word-scramble-game .answer .tile {
  min-width: 38px;
  min-height: 38px;
  font-size: 1.25rem;
  margin: 0 0.18rem;
  border-radius: 50%;
  padding: 0;
}
@media (max-width: 600px) {
  .word-scramble-game .answer .tile {
    min-width: 22px;
    min-height: 22px;
    font-size: 0.85rem;
    margin: 0 0.06rem;
  }
}
@media (max-width: 400px) {
  .word-scramble-game .answer .tile {
    min-width: 14px;
    min-height: 14px;
    font-size: 0.7rem;
    margin: 0 0.02rem;
  }
}
