:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: #1e293b;
  --bg-card-hover: #334155;
  --accent-color: #38bdf8;
  --accent-hover: #0284c7;
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --border-color: #334155;
  --ad-bg: rgba(255, 255, 255, 0.03);
  --shadow-lg: 0 10px 25px -5px rgba(0, 0, 0, 0.5), 0 8px 10px -6px rgba(0, 0, 0, 0.5);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Pretendard", sans-serif;
  background-color: var(--bg-primary);
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Navigation */
header {
  background-color: rgba(30, 41, 59, 0.95);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.75rem 1.5rem;
}

.nav-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 1rem;
}

.logo-group {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  text-decoration: none;
  color: inherit;
}

.logo-badge {
  background: linear-gradient(135deg, #38bdf8, #818cf8);
  color: #0f172a;
  font-weight: 900;
  font-size: 1.25rem;
  padding: 0.25rem 0.6rem;
  border-radius: 8px;
  box-shadow: 0 0 15px rgba(56, 189, 248, 0.4);
}

.logo-title {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.5px;
}

.logo-title span {
  color: var(--accent-color);
}

.search-box {
  display: flex;
  align-items: center;
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: 9999px;
  padding: 0.4rem 1rem;
  width: 100%;
  max-width: 350px;
}

.search-box input {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 0.9rem;
  width: 100%;
  outline: none;
}

.back-to-rodols {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: color 0.2s;
}

.back-to-rodols:hover {
  color: var(--accent-color);
}

/* Ad Slot Container */
.ad-banner-slot {
  max-width: 1200px;
  margin: 1.5rem auto 0.5rem;
  padding: 0 1rem;
  width: 100%;
}

.ad-placeholder {
  background-color: var(--ad-bg);
  border: 1px dashed var(--border-color);
  border-radius: 8px;
  min-height: 90px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

/* Main Layout */
main {
  flex: 1;
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  width: 100%;
}

/* Filter Tags */
.filter-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-bottom: 2rem;
  padding-bottom: 0.25rem;
}

/* Hide scrollbars completely if overflow happens */
.filter-bar::-webkit-scrollbar {
  display: none;
}
.filter-bar {
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.filter-btn {
  background-color: var(--bg-secondary);
  color: var(--text-muted);
  border: 1px solid var(--border-color);
  padding: 0.45rem 1rem;
  border-radius: 9999px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.2s;
}

.filter-btn:hover,
.filter-btn.active {
  background-color: var(--accent-color);
  color: #0f172a;
  font-weight: 700;
  border-color: var(--accent-color);
}

/* Game Grid */
.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 1.5rem;
}

.game-card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  text-decoration: none;
  color: inherit;
  transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
  cursor: pointer;
}

.game-card:hover {
  transform: translateY(-5px);
  box-shadow: var(--shadow-lg);
  border-color: var(--accent-color);
}

.thumbnail-wrapper {
  position: relative;
  aspect-ratio: 4 / 3;
  overflow: hidden;
  background-color: #020617;
}

.thumbnail-wrapper img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.game-card:hover .thumbnail-wrapper img {
  transform: scale(1.06);
}

.badge-featured {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(14, 165, 233, 0.9);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  text-transform: uppercase;
}

.badge-category {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(15, 23, 42, 0.85);
  color: var(--text-muted);
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  border-radius: 4px;
}

.game-info {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.game-title {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.4rem;
  color: #fff;
}

.game-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
  line-height: 1.4;
  margin-bottom: 1rem;
  flex: 1;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.play-action {
  background-color: rgba(56, 189, 248, 0.1);
  color: var(--accent-color);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  padding: 0.45rem;
  border-radius: 6px;
  border: 1px solid rgba(56, 189, 248, 0.2);
  transition: all 0.2s;
}

.game-card:hover .play-action {
  background-color: var(--accent-color);
  color: #0f172a;
}

/* Player Modal / View */
.player-view {
  display: none;
  background-color: #000;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border-color);
  margin-bottom: 2rem;
}

.player-view.active {
  display: block;
}

.player-header {
  background-color: var(--bg-secondary);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid var(--border-color);
}

.player-header h2 {
  font-size: 1.15rem;
  color: #fff;
}

.player-controls {
  display: flex;
  gap: 0.5rem;
}

.btn-ctrl {
  background-color: var(--bg-primary);
  border: 1px solid var(--border-color);
  color: var(--text-muted);
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-ctrl:hover {
  color: #fff;
  border-color: var(--accent-color);
}

.screen-container {
  position: relative;
  width: 100%;
  aspect-ratio: 4 / 3;
  max-height: 80vh;
  display: flex;
  justify-content: center;
  align-items: center;
  background: radial-gradient(circle, #1e293b 0%, #020617 100%);
  overflow: hidden;
}

#ruffle-embed-target {
  width: 100%;
  height: 100%;
  max-width: 100%;
  max-height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
}

ruffle-player {
  width: 100% !important;
  height: 100% !important;
  max-width: 100% !important;
  max-height: 100% !important;
}

/* Mobile Virtual Touch Gamepad */
.virtual-pad-container {
  display: none;
  background-color: #111827;
  padding: 1rem;
  border-top: 1px solid var(--border-color);
  justify-content: space-around;
  align-items: center;
  user-select: none;
}

@media (max-width: 768px) {
  .virtual-pad-container.pad-active {
    display: flex;
  }
}

.dpad {
  display: grid;
  grid-template-columns: repeat(3, 46px);
  grid-template-rows: repeat(3, 46px);
  gap: 5px;
}

.pad-btn {
  background-color: #374151;
  color: #fff;
  border: 1px solid #4b5563;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  font-weight: bold;
  cursor: pointer;
  touch-action: manipulation;
}

.pad-btn:active {
  background-color: var(--accent-color);
  color: #0f172a;
  transform: scale(0.92);
}

.action-buttons {
  display: flex;
  gap: 12px;
}

.action-btn {
  width: 58px;
  height: 58px;
  border-radius: 50%;
  background-color: #38bdf8;
  color: #0f172a;
  border: none;
  font-weight: 800;
  font-size: 1.1rem;
  box-shadow: 0 4px 10px rgba(56, 189, 248, 0.4);
}

/* Footer */
footer {
  background-color: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  padding: 2rem 1rem;
  text-align: center;
  color: var(--text-muted);
  font-size: 0.85rem;
  margin-top: auto;
}

footer a {
  color: var(--accent-color);
  text-decoration: none;
}
