@import url('https://fonts.googleapis.com/css2?family=Baloo+2:wght@600;700;800&family=Nunito:wght@400;600;700;800&display=swap');

:root {
  --green-950: #0c2a14;
  --green-900: #14532d;
  --green-800: #166534;
  --green-700: #15803d;
  --green-600: #16a34a;
  --green-500: #22c55e;
  --green-400: #4ade80;
  --green-300: #86efac;
  --green-200: #bbf7d0;
  --green-100: #dcfce7;
  --green-50: #f0fdf4;
  --lime: #a3e635;
  --mint: #ecfdf5;
  --ink: #12301c;
  --muted: #3f6b4d;
  --white: #ffffff;
  --danger: #dc2626;
  --shadow: 0 18px 40px rgba(20, 83, 45, 0.14);
  --radius: 22px;
  --font-display: 'Baloo 2', system-ui, sans-serif;
  --font-body: 'Nunito', system-ui, sans-serif;
}

*,
*::before,
*::after {
  box-sizing: border-box;
}

html {
  scroll-behavior: smooth;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: var(--font-body);
  color: var(--ink);
  background:
    radial-gradient(ellipse 80% 50% at 10% -10%, rgba(163, 230, 53, 0.35), transparent 55%),
    radial-gradient(ellipse 60% 40% at 90% 0%, rgba(34, 197, 94, 0.28), transparent 50%),
    linear-gradient(180deg, #e8fce9 0%, #d1fae5 40%, #ecfdf5 100%);
  background-attachment: fixed;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.35;
  background-image:
    radial-gradient(circle at 20% 30%, rgba(22, 163, 74, 0.08) 0 2px, transparent 3px),
    radial-gradient(circle at 70% 60%, rgba(34, 197, 94, 0.07) 0 2px, transparent 3px);
  background-size: 48px 48px, 64px 64px;
  z-index: 0;
}

a {
  color: inherit;
  text-decoration: none;
}

img {
  max-width: 100%;
  display: block;
}

.site {
  position: relative;
  z-index: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.container {
  width: min(1100px, calc(100% - 2rem));
  margin: 0 auto;
}

/* Header */
.topbar {
  padding: 1.1rem 0 0.4rem;
}

.topbar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.brand {
  display: inline-flex;
  align-items: center;
  gap: 0.65rem;
  font-family: var(--font-display);
  font-weight: 800;
  font-size: 1.55rem;
  letter-spacing: 0.02em;
  color: var(--green-800);
  animation: brandPop 0.7s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.brand-mark {
  width: 42px;
  height: 42px;
  border-radius: 14px;
  background: linear-gradient(145deg, var(--green-500), var(--green-700));
  color: var(--white);
  display: grid;
  place-items: center;
  font-size: 1.25rem;
  box-shadow: 0 8px 20px rgba(22, 163, 74, 0.35);
}

.nav-link {
  font-weight: 700;
  color: var(--green-800);
  padding: 0.55rem 1rem;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.55);
  border: 1px solid rgba(22, 163, 74, 0.18);
  transition: transform 0.2s ease, background 0.2s ease;
}

.nav-link:hover {
  transform: translateY(-2px);
  background: var(--white);
}

/* Hero */
.hero {
  padding: 1.5rem 0 2rem;
  text-align: center;
  animation: riseIn 0.8s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.hero-brand {
  font-family: var(--font-display);
  font-size: clamp(3.4rem, 10vw, 6.5rem);
  line-height: 0.95;
  margin: 0;
  background: linear-gradient(120deg, var(--green-700), var(--green-500) 45%, #65a30d);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
  letter-spacing: 0.04em;
  text-shadow: 0 10px 40px rgba(22, 163, 74, 0.15);
}

.hero h2 {
  font-family: var(--font-display);
  font-size: clamp(1.4rem, 3vw, 2rem);
  margin: 0.7rem 0 0.4rem;
  color: var(--green-900);
}

.hero p {
  margin: 0 auto;
  max-width: 36rem;
  color: var(--muted);
  font-size: 1.08rem;
  font-weight: 600;
}

.leaf-row {
  display: flex;
  justify-content: center;
  gap: 0.55rem;
  margin-top: 1.1rem;
}

.leaf {
  width: 10px;
  height: 16px;
  border-radius: 0 100% 0 100%;
  background: var(--green-500);
  opacity: 0.75;
  animation: leafBounce 1.8s ease-in-out infinite;
}

.leaf:nth-child(2) {
  background: var(--lime);
  animation-delay: 0.15s;
}

.leaf:nth-child(3) {
  background: var(--green-700);
  animation-delay: 0.3s;
}

/* Games grid — 3 per row */
.games-section {
  padding: 0.5rem 0 3.5rem;
  flex: 1;
}

.section-title {
  font-family: var(--font-display);
  font-size: 1.55rem;
  margin: 0 0 1.2rem;
  color: var(--green-900);
}

.games-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1.35rem;
}

.game-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 1.1rem 1rem 1.25rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.72);
  border: 1px solid rgba(22, 163, 74, 0.14);
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
  animation: cardIn 0.55s cubic-bezier(0.22, 1, 0.36, 1) both;
}

.game-card:nth-child(1) { animation-delay: 0.05s; }
.game-card:nth-child(2) { animation-delay: 0.12s; }
.game-card:nth-child(3) { animation-delay: 0.19s; }
.game-card:nth-child(4) { animation-delay: 0.26s; }
.game-card:nth-child(5) { animation-delay: 0.33s; }
.game-card:nth-child(6) { animation-delay: 0.4s; }

.game-card:hover {
  transform: translateY(-6px) scale(1.02);
  border-color: rgba(22, 163, 74, 0.35);
  box-shadow: 0 24px 48px rgba(20, 83, 45, 0.2);
}

.game-thumb {
  width: 150px;
  height: 120px;
  border-radius: 16px;
  object-fit: cover;
  background: linear-gradient(145deg, var(--green-200), var(--green-100));
  border: 3px solid rgba(22, 163, 74, 0.2);
  margin-bottom: 0.85rem;
}

.game-thumb.placeholder {
  display: grid;
  place-items: center;
  font-family: var(--font-display);
  font-size: 2rem;
  color: var(--green-700);
}

.game-card h3 {
  font-family: var(--font-display);
  font-size: 1.25rem;
  margin: 0 0 0.35rem;
  color: var(--green-900);
  line-height: 1.2;
}

.game-card p {
  margin: 0;
  color: var(--muted);
  font-size: 0.95rem;
  font-weight: 600;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, 0.65);
  border: 2px dashed rgba(22, 163, 74, 0.3);
  color: var(--muted);
  font-weight: 700;
}

.site-footer {
  padding: 1.25rem 0 2rem;
  text-align: center;
  color: var(--muted);
  font-weight: 600;
  font-size: 0.92rem;
}

/* Play page */
.play-body {
  background: var(--green-950);
  color: var(--white);
}

.play-body::before {
  display: none;
}

.play-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(90deg, #14532d, #166534 55%, #15803d);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.play-title {
  font-family: var(--font-display);
  font-size: 1.15rem;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.play-actions {
  display: flex;
  gap: 0.55rem;
  flex-shrink: 0;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  border: none;
  cursor: pointer;
  font-family: var(--font-body);
  font-weight: 800;
  font-size: 0.95rem;
  border-radius: 12px;
  padding: 0.65rem 1.1rem;
  transition: transform 0.15s ease, filter 0.15s ease, background 0.15s ease;
}

.btn:hover {
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background: linear-gradient(145deg, var(--green-500), var(--green-700));
  color: var(--white);
  box-shadow: 0 8px 18px rgba(22, 163, 74, 0.28);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.9);
  color: var(--green-800);
  border: 1px solid rgba(22, 163, 74, 0.2);
}

.btn-ghost {
  background: rgba(255, 255, 255, 0.14);
  color: var(--white);
  border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-danger {
  background: #fee2e2;
  color: #b91c1c;
  border: 1px solid #fecaca;
}

.btn-sm {
  padding: 0.45rem 0.8rem;
  font-size: 0.85rem;
  border-radius: 10px;
}

.play-frame-wrap {
  height: calc(100vh - 58px);
  background: #000;
}

.play-frame-wrap iframe {
  width: 100%;
  height: 100%;
  border: 0;
  display: block;
  background: #000;
}

/* Admin */
.admin-body .hero {
  padding: 1rem 0 1.25rem;
  text-align: left;
}

.admin-body .hero-brand {
  font-size: clamp(2.4rem, 6vw, 3.6rem);
  text-align: left;
}

.panel {
  background: rgba(255, 255, 255, 0.78);
  border: 1px solid rgba(22, 163, 74, 0.16);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
  margin-bottom: 1.4rem;
}

.panel h2 {
  font-family: var(--font-display);
  margin: 0 0 1rem;
  color: var(--green-900);
  font-size: 1.4rem;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  font-weight: 800;
  color: var(--green-900);
  margin-bottom: 0.4rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="file"],
.form-group textarea {
  width: 100%;
  font: inherit;
  font-weight: 600;
  padding: 0.75rem 0.9rem;
  border-radius: 12px;
  border: 1.5px solid rgba(22, 163, 74, 0.25);
  background: var(--white);
  color: var(--ink);
  outline: none;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.form-group input:focus,
.form-group textarea:focus {
  border-color: var(--green-500);
  box-shadow: 0 0 0 4px rgba(34, 197, 94, 0.18);
}

.form-hint {
  margin: 0.35rem 0 0;
  font-size: 0.85rem;
  color: var(--muted);
  font-weight: 600;
}

.flash {
  padding: 0.85rem 1rem;
  border-radius: 12px;
  font-weight: 700;
  margin-bottom: 1rem;
}

.flash-success {
  background: #dcfce7;
  color: #166534;
  border: 1px solid #bbf7d0;
}

.flash-error {
  background: #fee2e2;
  color: #991b1b;
  border: 1px solid #fecaca;
}

.admin-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem;
  margin-bottom: 1.25rem;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
}

.admin-table th,
.admin-table td {
  text-align: left;
  padding: 0.75rem 0.5rem;
  border-bottom: 1px solid rgba(22, 163, 74, 0.12);
  vertical-align: middle;
}

.admin-table th {
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--muted);
}

.admin-thumb {
  width: 75px;
  height: 60px;
  object-fit: cover;
  border-radius: 8px;
  border: 2px solid rgba(22, 163, 74, 0.2);
}

.row-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.login-wrap {
  min-height: calc(100vh - 8rem);
  display: grid;
  place-items: center;
  padding: 2rem 0;
}

.login-card {
  width: min(420px, 100%);
}

.login-card .hero-brand {
  text-align: center;
  font-size: 3.2rem;
  margin-bottom: 0.25rem;
}

.login-card .panel {
  margin: 0;
}

@keyframes brandPop {
  from { opacity: 0; transform: scale(0.9) translateY(-8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

@keyframes riseIn {
  from { opacity: 0; transform: translateY(18px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes cardIn {
  from { opacity: 0; transform: translateY(16px) scale(0.98); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

@keyframes leafBounce {
  0%, 100% { transform: translateY(0) rotate(-12deg); }
  50% { transform: translateY(-6px) rotate(8deg); }
}

@media (max-width: 900px) {
  .games-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 560px) {
  .games-grid {
    grid-template-columns: 1fr;
  }

  .play-bar {
    flex-wrap: wrap;
  }

  .admin-table,
  .admin-table tbody,
  .admin-table tr,
  .admin-table td {
    display: block;
    width: 100%;
  }

  .admin-table thead {
    display: none;
  }

  .admin-table tr {
    padding: 0.85rem 0;
    border-bottom: 1px solid rgba(22, 163, 74, 0.15);
  }

  .admin-table td {
    border: none;
    padding: 0.25rem 0;
  }
}
