/* ============================================================
   GAMES FIXES 2026-04-17 - Load LAST (after final-fixes-2026.css)
   Fixes:
   1. Game center area too small (was max-width 900px, now adaptive)
   2. Join-by-code proper styling in a clean landing area
   3. Settings panel improvements
   ============================================================ */

/* ============================================================
   FIX 1: ENLARGE GAME CENTER AREA
   The jawlah layout has 3 columns: left-sidebar | center | right-sidebar
   The center game container was capped at 900px, leaving a lot of
   empty gray space on big screens. We expand it responsively and
   remove the artificial max-width cap.
   ============================================================ */

/* The center (main game area in jawlah layout) — full flex, no artificial cap */
.jawlah-game-center {
  padding: 16px 20px !important;
  /* keep flex so content aligns, but DO NOT center vertically on tall games */
  justify-content: flex-start !important;
}

/* The inner container — use near full width, sensible cap for readability */
.jawlah-game-container,
#game-container {
  /* Replace the previous 900px cap with a much more generous value */
  max-width: 1400px !important;
  width: 100% !important;
  margin: 0 auto !important;
  padding: 16px 8px !important;
  box-sizing: border-box !important;
}

/* Games with very wide needs (spin wheel, snakes & ladders) — allow wider */
.jawlah-game-container:has(.wheel-container),
.jawlah-game-container:has(#snakes-board),
.jawlah-game-container:has(#jump-quest-canvas) {
  max-width: 1200px !important;
}

/* Internal game cards should expand to fill the new wider container */
#game-container .glass-card,
#game-container .glass-card-strong,
.jawlah-game-container .glass-card,
.jawlah-game-container .glass-card-strong {
  max-width: 100% !important;
  width: 100% !important;
}

/* Game content cards that had explicit max-w-5xl etc. from Tailwind
   should stretch to fill the new container */
#game-container .max-w-5xl,
#game-container .max-w-4xl,
#game-container .max-w-3xl,
.jawlah-game-container .max-w-5xl,
.jawlah-game-container .max-w-4xl,
.jawlah-game-container .max-w-3xl {
  max-width: 100% !important;
}

/* Slightly smaller sidebars on medium-large screens to give games more room */
@media (min-width: 1100px) and (max-width: 1500px) {
  .jawlah-sidebar-left,
  .jawlah-sidebar-right {
    width: 270px !important;
    min-width: 270px !important;
  }
}

/* Very large screens: allow even more game space, keep sidebars at 300 */
@media (min-width: 1501px) {
  .jawlah-game-container,
  #game-container {
    max-width: 1500px !important;
  }
}

/* Mobile: full width, tighter padding */
@media (max-width: 768px) {
  .jawlah-game-container,
  #game-container {
    padding: 8px 4px !important;
  }
  .jawlah-game-center {
    padding: 12px 10px !important;
  }
}

/* ============================================================
   FIX 2: JOIN BY CODE + ROOM MANAGEMENT — Better styling
   Make the input + button clearly visible and clickable.
   ============================================================ */

.jawlah-rooms-card {
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(232,183,48,0.12);
  border-radius: 16px;
  padding: 18px 20px;
  margin-bottom: 16px;
  width: 100%;
  max-width: 900px;
  margin-left: auto;
  margin-right: auto;
}
.jawlah-rooms-card h3 {
  font-size: 1rem;
  font-weight: 800;
  color: #E8B730;
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}
.jawlah-rooms-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: stretch;
}
.jawlah-rooms-actions .jawlah-btn-primary {
  padding: 10px 18px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(232,183,48,0.2), rgba(232,183,48,0.08));
  border: 1px solid rgba(232,183,48,0.3);
  color: #E8B730;
  font-weight: 700;
  font-size: 0.88rem;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 8px;
}
.jawlah-rooms-actions .jawlah-btn-primary:hover {
  background: linear-gradient(135deg, rgba(232,183,48,0.3), rgba(232,183,48,0.15));
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(232,183,48,0.15);
}
.jawlah-rooms-join {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 220px;
}
.jawlah-rooms-join .jawlah-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 12px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  color: white;
  font-size: 0.88rem;
  outline: none;
  transition: border-color 0.2s;
  direction: ltr; /* room codes are latin */
  text-align: center;
  letter-spacing: 2px;
  font-family: monospace;
  text-transform: uppercase;
}
.jawlah-rooms-join .jawlah-input:focus {
  border-color: rgba(232,183,48,0.4);
  background: rgba(0,0,0,0.5);
}
.jawlah-rooms-join .jawlah-btn-icon {
  padding: 10px 16px;
  border-radius: 12px;
  background: rgba(16,185,129,0.12);
  border: 1px solid rgba(16,185,129,0.3);
  color: #10B981;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-width: 50px;
  font-weight: 700;
}
.jawlah-rooms-join .jawlah-btn-icon:hover {
  background: rgba(16,185,129,0.2);
  border-color: rgba(16,185,129,0.5);
  transform: scale(1.03);
}
.jawlah-rooms-join .jawlah-btn-icon:active {
  transform: scale(0.97);
}
#room-list {
  margin-top: 12px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

/* ============================================================
   FIX 3: "Join-by-code" visibility toggle in settings
   When code-only is selected, highlight the code field in header
   ============================================================ */

.jawlah-rooms-join.code-required {
  outline: 2px solid rgba(232,183,48,0.4);
  outline-offset: 4px;
  border-radius: 14px;
  animation: joinCodePulse 1.5s ease-in-out infinite;
}
@keyframes joinCodePulse {
  0%, 100% { outline-color: rgba(232,183,48,0.3); }
  50% { outline-color: rgba(232,183,48,0.7); }
}

/* ============================================================
   FIX 4: Radio group styling — was flat, now clearer
   ============================================================ */
.jawlah-radio-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.jawlah-radio {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  cursor: pointer;
  transition: all 0.2s;
}
.jawlah-radio:hover {
  background: rgba(232,183,48,0.04);
  border-color: rgba(232,183,48,0.15);
}
.jawlah-radio.active {
  background: rgba(232,183,48,0.08);
  border-color: rgba(232,183,48,0.3);
  color: #E8B730;
}
.jawlah-radio input[type="radio"] {
  accent-color: #E8B730;
  cursor: pointer;
}

/* Toggle switches (accept guesses) */
.jawlah-toggle {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
  cursor: pointer;
}
.jawlah-toggle input { opacity: 0; width: 0; height: 0; }
.jawlah-toggle-slider {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 24px;
  transition: all 0.2s;
}
.jawlah-toggle-slider::before {
  content: '';
  position: absolute;
  height: 18px; width: 18px;
  left: 3px; top: 3px;
  background: white;
  border-radius: 50%;
  transition: all 0.2s;
}
.jawlah-toggle input:checked + .jawlah-toggle-slider {
  background: rgba(232,183,48,0.4);
}
.jawlah-toggle input:checked + .jawlah-toggle-slider::before {
  transform: translateX(20px);
  background: #E8B730;
}
html[dir="rtl"] .jawlah-toggle input:checked + .jawlah-toggle-slider::before {
  transform: translateX(-20px);
}

/* Settings hint text */
.jawlah-setting-hint {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.4);
  margin-top: 6px;
}

/* Difficulty cards */
.jawlah-difficulty-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
}
.jawlah-diff-card {
  padding: 10px 8px;
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  border: 1px solid rgba(255,255,255,0.05);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
  display: flex;
  flex-direction: column;
  gap: 3px;
  color: rgba(255,255,255,0.7);
}
.jawlah-diff-card:hover {
  background: rgba(232,183,48,0.04);
  border-color: rgba(232,183,48,0.15);
}
.jawlah-diff-card.active {
  background: rgba(232,183,48,0.08);
  border-color: rgba(232,183,48,0.3);
  color: #E8B730;
}
.jawlah-diff-name { font-weight: 700; font-size: 0.82rem; }
.jawlah-diff-desc { font-size: 0.68rem; color: rgba(255,255,255,0.4); }

.jawlah-setting-divider {
  height: 1px;
  background: rgba(255,255,255,0.05);
  margin: 6px 0;
}

.jawlah-btn-reset {
  margin: 12px 14px 14px;
  padding: 10px 16px;
  border-radius: 10px;
  background: rgba(239,68,68,0.08);
  border: 1px solid rgba(239,68,68,0.2);
  color: #EF4444;
  font-weight: 600;
  font-size: 0.82rem;
  cursor: pointer;
  transition: all 0.2s;
}
.jawlah-btn-reset:hover {
  background: rgba(239,68,68,0.15);
  border-color: rgba(239,68,68,0.4);
}

/* Settings field labels */
.jawlah-setting-item {
  padding: 12px 14px;
}
.jawlah-setting-item label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255,255,255,0.85);
  margin-bottom: 8px;
}
.jawlah-slider-row {
  display: flex;
  align-items: center;
  gap: 10px;
}
.jawlah-slider {
  flex: 1;
  accent-color: #E8B730;
}
.jawlah-slider-val {
  min-width: 30px;
  padding: 3px 8px;
  background: rgba(232,183,48,0.1);
  border-radius: 6px;
  color: #E8B730;
  font-weight: 700;
  font-size: 0.8rem;
  text-align: center;
}

/* Toggle row */
.jawlah-toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.jawlah-toggle-label {
  font-size: 0.78rem;
  color: rgba(255,255,255,0.7);
  flex: 1;
}

/* ============================================================
   FIX 5: Custom scrollbar for the new wider game center
   ============================================================ */
.jawlah-game-center::-webkit-scrollbar { width: 6px; }
.jawlah-game-center::-webkit-scrollbar-track { background: transparent; }
.jawlah-game-center::-webkit-scrollbar-thumb {
  background: rgba(232,183,48,0.15);
  border-radius: 4px;
}
.jawlah-game-center::-webkit-scrollbar-thumb:hover {
  background: rgba(232,183,48,0.3);
}

/* ============================================================
   FIX 6: Landing page "Join game by code" component
   Shown on the homepage / in the games hub for users who have
   a code but haven't picked a specific game yet.
   ============================================================ */
.global-join-banner {
  max-width: 700px;
  margin: 0 auto 24px;
  padding: 14px 18px;
  border-radius: 16px;
  background: linear-gradient(135deg, rgba(16,185,129,0.08), rgba(232,183,48,0.05));
  border: 1px solid rgba(16,185,129,0.2);
  display: flex;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
}
.global-join-banner .gjb-icon {
  width: 42px; height: 42px;
  border-radius: 12px;
  background: rgba(16,185,129,0.15);
  display: flex; align-items: center; justify-content: center;
  color: #10B981;
  font-size: 1.1rem;
  flex-shrink: 0;
}
.global-join-banner .gjb-label {
  font-weight: 700;
  color: white;
  font-size: 0.9rem;
}
.global-join-banner .gjb-sub {
  font-size: 0.72rem;
  color: rgba(255,255,255,0.5);
}
.global-join-banner-form {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 240px;
}
.global-join-banner-input {
  flex: 1;
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.1);
  color: white;
  font-family: monospace;
  text-transform: uppercase;
  letter-spacing: 2px;
  text-align: center;
  font-size: 0.9rem;
  outline: none;
}
.global-join-banner-input:focus {
  border-color: rgba(16,185,129,0.4);
  background: rgba(0,0,0,0.5);
}
.global-join-banner-btn {
  padding: 10px 18px;
  border-radius: 10px;
  background: #10B981;
  color: white;
  border: none;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.88rem;
  display: flex;
  align-items: center;
  gap: 6px;
}
.global-join-banner-btn:hover {
  background: #059669;
  transform: translateY(-1px);
}

/* ============================================================
   FIX 7: Jawlah player / setting items visual improvements
   ============================================================ */
.jawlah-player-score {
  margin-inline-start: auto;
  font-size: 0.72rem;
  color: #E8B730;
  background: rgba(232,183,48,0.08);
  padding: 2px 8px;
  border-radius: 6px;
  font-weight: 700;
}
.jawlah-player-name {
  font-size: 0.85rem;
  font-weight: 600;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Ensure chat panel for live chat shows messages correctly */
.jawlah-chat-messages {
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
