/* Crosswordle Native DOM Styling & Mobile Responsiveness */
.crosswordle-native-frame {
  position: relative;
  width: 100%;
  max-width: 540px;
  height: clamp(540px, 80vh, 780px);
  min-height: 520px;
  background: #ffffff !important;
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.1);
  border: 1.5px solid var(--border-light, #e8dcc4);
  margin: 0 auto 1.8rem auto;
  touch-action: manipulation;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
}

#crosswordle-container {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
  padding: 16px;
  position: relative;
  background: #ffffff;
  touch-action: manipulation;
  overscroll-behavior: contain;
}

#menu-view {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  padding: 20px 10px;
  background: linear-gradient(180deg, rgba(255,255,255,0.78) 0%, rgba(255,255,255,0.88) 100%), url('/games/crosswordle/ordkongen_menu_bg.png') center/cover no-repeat;
  border-radius: 20px;
}

.king-menu-avatar {
  width: 95px;
  height: 95px;
  object-fit: contain;
  margin-bottom: 4px;
  filter: drop-shadow(0 6px 14px rgba(0,0,0,0.18));
  animation: gentleFloat 3s ease-in-out infinite alternate;
}

@keyframes gentleFloat {
  from { transform: translateY(0); }
  to { transform: translateY(-6px); }
}

.menu-title {
  font-family: 'Rowdies', sans-serif;
  font-size: 2.2rem;
  font-weight: 900;
  color: #111827;
  margin: 0 0 28px 0;
  text-align: center;
  letter-spacing: -0.5px;
  text-shadow: 0 4px 12px rgba(255,255,255,0.9);
}

.menu-buttons {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.menu-btn {
  width: 100%;
  padding: 16px 20px;
  border-radius: 16px;
  border: none;
  font-family: 'Outfit', sans-serif;
  font-size: 1.15rem;
  font-weight: 900;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 4px 12px rgba(0,0,0,0.08);
}

.menu-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(0,0,0,0.12);
}

.menu-btn:active {
  transform: translateY(1px);
}

.btn-daily {
  background: #538d4e;
  color: #ffffff;
  box-shadow: 0 6px 18px rgba(83, 141, 78, 0.35);
}

.btn-daily-subtext {
  font-size: 0.78rem;
  font-weight: 700;
  opacity: 0.9;
  margin-top: 2px;
}

.btn-unlimited {
  background: #111827;
  color: #ffffff;
}

.btn-practice {
  background: #f3f4f6;
  border: 2px solid #e5e7eb;
  color: #374151;
}

#game-view {
  width: 100%;
  height: 100%;
  display: none;
  flex-direction: column;
  justify-content: space-between;
  align-items: center;
}

.top-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 4px 0;
  position: relative;
}

.btn-back-menu {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  font-size: 0.92rem;
  font-weight: 800;
  color: #374151;
  cursor: pointer;
  padding: 6px 14px;
  border-radius: 10px;
  transition: background 0.15s;
  z-index: 10;
}

.btn-back-menu:hover {
  background: #e5e7eb;
}

.header-title {
  font-family: 'Rowdies', sans-serif;
  font-size: 1.5rem;
  font-weight: 900;
  color: #111827;
  margin: 0;
  text-align: center;
  position: absolute;
  left: 0;
  right: 0;
  pointer-events: none;
}

.timer-badge {
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  padding: 5px 12px;
  border-radius: 10px;
  font-size: 0.88rem;
  font-weight: 800;
  color: #4b5563;
  display: flex;
  align-items: center;
  gap: 4px;
  z-index: 10;
}

.mode-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  margin: 6px 0 10px 0;
  width: 100%;
}

.mode-tab {
  background: #f3f4f6;
  border: 1.5px solid #e5e7eb;
  border-radius: 20px;
  padding: 6px 16px;
  font-size: 0.85rem;
  font-weight: 800;
  color: #4b5563;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mode-tab.active {
  background: #111827;
  color: #ffffff;
  border-color: #111827;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.board-wrapper {
  flex: 1;
  width: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 0;
}

.board-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-template-rows: repeat(7, 1fr);
  gap: 6px;
  width: 100%;
  max-width: 440px;
  aspect-ratio: 1 / 1;
}

.tile {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  border-radius: 6px;
  display: flex;
  justify-content: center;
  align-items: center;
  font-family: 'Outfit', sans-serif;
  font-size: clamp(1.4rem, 4vh, 2.2rem);
  font-weight: 900;
  color: #ffffff;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.25s ease, box-shadow 0.15s ease;
  position: relative;
  border: none;
  box-shadow: 0 2px 4px rgba(0,0,0,0.06);
}

.tile.empty {
  background: transparent;
  box-shadow: none;
  cursor: default;
  pointer-events: none;
}

.tile.green {
  background-color: #538d4e !important;
  color: #ffffff !important;
}

.tile.yellow {
  background-color: #b59f3b !important;
  color: #ffffff !important;
}

.tile.grey {
  background-color: #787c7e !important;
  color: #ffffff !important;
}

.tile.selected {
  transform: scale(1.08);
  box-shadow: 0 0 0 3px #3b82f6, 0 8px 16px rgba(59, 130, 246, 0.4);
  z-index: 10;
}

.bottom-bar {
  width: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  margin-bottom: 6px;
}

.swaps-counter {
  font-size: 1.1rem;
  font-weight: 900;
  color: #111827;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.swaps-counter span {
  color: #538d4e;
  font-size: 1.3rem;
}

.powerup-bar {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 16px;
  margin-top: 4px;
  margin-bottom: 4px;
}

.powerup-btn {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: 2px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
  transition: transform 0.15s cubic-bezier(0.175, 0.885, 0.32, 1.275), box-shadow 0.15s ease;
  touch-action: manipulation;
}

.powerup-btn.p-hint {
  background: radial-gradient(circle at 35% 35%, #fbbf24 0%, #d97706 60%, #92400e 100%);
  box-shadow: 0 6px 14px rgba(217, 119, 6, 0.4);
}

.powerup-btn.p-swaps {
  background: radial-gradient(circle at 35% 35%, #34d399 0%, #10b981 60%, #047857 100%);
  box-shadow: 0 6px 14px rgba(16, 185, 129, 0.4);
}

.powerup-btn.p-bullseye {
  background: radial-gradient(circle at 35% 35%, #f87171 0%, #ef4444 60%, #991b1b 100%);
  box-shadow: 0 6px 14px rgba(239, 68, 68, 0.4);
}

.powerup-btn.p-fasit {
  background: radial-gradient(circle at 35% 35%, #a78bfa 0%, #7c3aed 60%, #4c1d95 100%);
  box-shadow: 0 6px 14px rgba(124, 58, 237, 0.4);
}

.powerup-icon {
  font-size: 1.4rem;
  line-height: 1;
}

.powerup-cost {
  position: absolute;
  bottom: -7px;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
  border: 1px solid #fbbf24;
  color: #fbbf24;
  font-size: 0.72rem;
  font-weight: 900;
  padding: 1px 6px;
  border-radius: 10px;
  white-space: nowrap;
}

/* Modal Victory Popup */
.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(17, 24, 39, 0.8);
  backdrop-filter: blur(4px);
  display: none;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

.modal-card {
  background: #ffffff;
  border-radius: 24px;
  padding: 28px 24px;
  width: 90%;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

.modal-title {
  font-family: 'Rowdies', sans-serif;
  font-size: 2rem;
  color: #111827;
  margin: 0 0 8px 0;
}

.btn-next {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  color: white;
  border: none;
  border-radius: 14px;
  padding: 12px 24px;
  font-size: 1.1rem;
  font-weight: 900;
  cursor: pointer;
  width: 100%;
  box-shadow: 0 6px 20px rgba(16, 185, 129, 0.4);
}

/* Mobile Responsiveness */
@media (max-width: 767px) {
  .crosswordle-native-frame {
    min-height: unset !important;
    height: auto !important;
    max-height: none !important;
    max-width: calc(100% - 16px) !important;
    margin: 0.5rem auto 1.5rem auto !important;
    border-radius: 20px !important;
    padding: 4px !important;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
  }

  #crosswordle-container {
    height: auto !important;
    min-height: unset !important;
    padding: 10px 8px !important;
  }

  .board-grid {
    max-width: 350px !important;
    gap: 4px !important;
  }

  .powerup-btn {
    width: 44px !important;
    height: 44px !important;
  }

  .powerup-icon {
    font-size: 1.2rem !important;
  }
}
