/* === GRVTY Games Portal — Design System === */

@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@300;400;500;600;700&display=swap');

/* --- Reset & Base --- */

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

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
  font-weight: 400;
  color: rgba(0, 0, 0, 0.64);
  background: #FFFFFF;
  line-height: 1.6;
  min-height: 100vh;
}

a {
  color: #0080FF;
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

button {
  font-family: inherit;
  cursor: pointer;
}

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

/* --- Layout --- */

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 24px;
}

/* --- Header --- */

.site-header {
  padding: 24px 0;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  font-size: 20px;
  font-weight: 700;
  color: #000;
  letter-spacing: 0.05em;
  text-decoration: none;
}

.logo:hover {
  text-decoration: none;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 24px;
}

.header-nav a {
  font-size: 14px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.64);
  transition: color 0.15s;
}

.header-nav a:hover {
  color: #000;
  text-decoration: none;
}

.auth-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 20px;
  font-size: 14px;
  font-weight: 600;
  color: #FFF;
  background: #000;
  border: none;
  border-radius: 6px;
  transition: background 0.15s;
}

.auth-btn:hover {
  background: #222;
}

.user-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 6px 12px 6px 6px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 100px;
  font-size: 14px;
  font-weight: 500;
  color: #000;
}

.user-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #000;
  color: #FFF;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.02em;
}

.user-pill .logout-link {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.4);
  margin-left: 4px;
}

/* --- Hero --- */

.hero {
  padding: 80px 0 64px;
  text-align: center;
}

.hero h1 {
  font-size: 64px;
  font-weight: 700;
  color: #000;
  letter-spacing: -0.02em;
  line-height: 1.1;
  margin-bottom: 16px;
}

.hero p {
  font-size: 20px;
  font-weight: 300;
  color: rgba(0, 0, 0, 0.48);
  max-width: 480px;
  margin: 0 auto;
}

/* --- Game Grid --- */

.section-title {
  font-size: 14px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(0, 0, 0, 0.4);
  margin-bottom: 32px;
}

.game-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(340px, 1fr));
  gap: 32px;
  padding-bottom: 80px;
}

.game-card {
  background: #FFF;
  border-radius: 12px;
  border: 1px solid rgba(0, 0, 0, 0.08);
  overflow: hidden;
  transition: box-shadow 0.2s, transform 0.2s;
}

.game-card:hover {
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
  transform: translateY(-2px);
}

.game-card-thumb {
  width: 100%;
  aspect-ratio: 16 / 9;
  background: linear-gradient(135deg, #f0f0f0 0%, #e0e0e0 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.game-card-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.game-card-thumb .thumb-placeholder {
  font-size: 48px;
  opacity: 0.3;
}

.game-card-body {
  padding: 24px;
}

.game-card-body h3 {
  font-size: 22px;
  font-weight: 700;
  color: #000;
  margin-bottom: 4px;
}

.game-card-body .tagline {
  font-size: 14px;
  color: rgba(0, 0, 0, 0.48);
  margin-bottom: 16px;
}

.game-card-tags {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.tag {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  padding: 3px 8px;
  background: rgba(0, 0, 0, 0.04);
  border-radius: 4px;
  color: rgba(0, 0, 0, 0.5);
}

/* Leaderboard preview on card */
.card-leaderboard {
  margin-bottom: 20px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
  padding-top: 16px;
}

.card-leaderboard-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(0, 0, 0, 0.3);
  margin-bottom: 8px;
}

.card-leaderboard-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 0;
  font-size: 13px;
}

.card-leaderboard-row .rank {
  font-weight: 600;
  color: rgba(0, 0, 0, 0.3);
  width: 24px;
}

.card-leaderboard-row .name {
  flex: 1;
  font-weight: 500;
  color: #000;
}

.card-leaderboard-row .score {
  font-weight: 600;
  color: rgba(0, 0, 0, 0.64);
  font-variant-numeric: tabular-nums;
}

.card-leaderboard-empty {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.3);
  font-style: italic;
}

/* Card actions */
.game-card-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

.play-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 28px;
  font-size: 14px;
  font-weight: 700;
  color: #FFF;
  background: #FD5847;
  border: none;
  border-radius: 8px;
  text-decoration: none;
  transition: background 0.15s, transform 0.1s;
}

.play-btn:hover {
  background: #e8483a;
  text-decoration: none;
  transform: scale(1.02);
}

.leaderboard-link {
  font-size: 13px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.4);
  transition: color 0.15s;
}

.leaderboard-link:hover {
  color: #0080FF;
}

/* --- Auth Modal --- */

.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal-overlay.active {
  display: flex;
}

.modal-box {
  background: #FFF;
  border-radius: 16px;
  width: 100%;
  max-width: 420px;
  margin: 24px;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.12);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px 0;
}

.modal-tabs {
  display: flex;
  gap: 0;
}

.modal-tab {
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.4);
  background: none;
  border: none;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s;
}

.modal-tab.active {
  color: #000;
  border-bottom-color: #000;
}

.modal-close {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  color: rgba(0, 0, 0, 0.4);
  background: none;
  border: none;
  border-radius: 6px;
  transition: background 0.15s;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.04);
}

.modal-panel {
  display: none;
  padding: 24px;
}

.modal-panel.active {
  display: block;
}

.form-field {
  margin-bottom: 16px;
}

.form-field label {
  display: block;
  font-size: 13px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.64);
  margin-bottom: 6px;
}

.form-field input {
  width: 100%;
  padding: 10px 14px;
  font-size: 15px;
  font-family: inherit;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 8px;
  outline: none;
  transition: border-color 0.15s;
}

.form-field input:focus {
  border-color: #000;
}

.modal-submit {
  width: 100%;
  padding: 12px;
  font-size: 15px;
  font-weight: 600;
  color: #FFF;
  background: #000;
  border: none;
  border-radius: 8px;
  margin-top: 4px;
  transition: background 0.15s;
}

.modal-submit:hover {
  background: #222;
}

.modal-divider {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 20px 0;
  color: rgba(0, 0, 0, 0.24);
  font-size: 12px;
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.modal-divider::before,
.modal-divider::after {
  content: '';
  flex: 1;
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
}

.modal-error {
  display: none;
  padding: 10px 14px;
  font-size: 13px;
  color: #d32f2f;
  background: #fdecea;
  border-radius: 6px;
  margin-top: 12px;
}

.modal-error.active {
  display: block;
}

.modal-loading {
  display: none;
  text-align: center;
  padding: 12px;
  font-size: 13px;
  color: rgba(0, 0, 0, 0.4);
}

.modal-loading.active {
  display: block;
}

/* --- Leaderboard Page --- */

.leaderboard-page {
  padding: 48px 0 80px;
}

.leaderboard-page h1 {
  font-size: 48px;
  font-weight: 700;
  color: #000;
  margin-bottom: 8px;
}

.leaderboard-page .subtitle {
  font-size: 16px;
  color: rgba(0, 0, 0, 0.4);
  margin-bottom: 40px;
}

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

.leaderboard-table th {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: rgba(0, 0, 0, 0.3);
  text-align: left;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.leaderboard-table td {
  padding: 14px 16px;
  font-size: 15px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
}

.leaderboard-table tr:hover td {
  background: rgba(0, 0, 0, 0.02);
}

.leaderboard-table .rank-col {
  width: 60px;
  font-weight: 700;
  color: rgba(0, 0, 0, 0.3);
}

.leaderboard-table .name-col {
  font-weight: 500;
  color: #000;
}

.leaderboard-table .score-col {
  text-align: right;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
}

.leaderboard-empty {
  text-align: center;
  padding: 48px 0;
  font-size: 15px;
  color: rgba(0, 0, 0, 0.3);
}

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 14px;
  font-weight: 500;
  color: rgba(0, 0, 0, 0.48);
  margin-bottom: 32px;
}

.back-link:hover {
  color: #000;
  text-decoration: none;
}

/* --- Admin Page --- */

.admin-page {
  padding: 48px 0 80px;
}

.admin-page h1 {
  font-size: 36px;
  font-weight: 700;
  color: #000;
  margin-bottom: 32px;
}

.admin-no-access {
  text-align: center;
  padding: 80px 0;
}

.admin-no-access h2 {
  font-size: 24px;
  font-weight: 700;
  color: #000;
  margin-bottom: 8px;
}

.admin-no-access p {
  font-size: 15px;
  color: rgba(0, 0, 0, 0.4);
}

.admin-toolbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 24px;
}

.admin-add-btn {
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  color: #FFF;
  background: #000;
  border: none;
  border-radius: 8px;
}

.admin-add-btn:hover {
  background: #222;
}

.admin-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 32px;
}

.admin-table th {
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(0, 0, 0, 0.4);
  text-align: left;
  padding: 12px 14px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.08);
}

.admin-table td {
  padding: 14px;
  font-size: 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  vertical-align: middle;
}

.admin-table .status-badge {
  display: inline-block;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-radius: 4px;
}

.admin-table .status-badge.live {
  background: #e8f5e9;
  color: #2e7d32;
}

.admin-table .status-badge.draft {
  background: #fff3e0;
  color: #e65100;
}

.admin-actions {
  display: flex;
  gap: 8px;
}

.admin-actions button {
  padding: 6px 12px;
  font-size: 12px;
  font-weight: 500;
  border: 1px solid rgba(0, 0, 0, 0.12);
  border-radius: 6px;
  background: #FFF;
  color: rgba(0, 0, 0, 0.64);
  transition: background 0.15s;
}

.admin-actions button:hover {
  background: rgba(0, 0, 0, 0.04);
}

.admin-actions button.danger {
  color: #d32f2f;
  border-color: rgba(211, 47, 47, 0.2);
}

.admin-actions button.danger:hover {
  background: #fdecea;
}

/* Admin form modal */
.admin-form-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  z-index: 1000;
  align-items: flex-start;
  justify-content: center;
  padding-top: 80px;
  backdrop-filter: blur(4px);
  overflow-y: auto;
}

.admin-form-overlay.active {
  display: flex;
}

.admin-form-box {
  background: #FFF;
  border-radius: 16px;
  width: 100%;
  max-width: 520px;
  margin: 0 24px 80px;
  padding: 32px;
  box-shadow: 0 24px 64px rgba(0, 0, 0, 0.12);
}

.admin-form-box h2 {
  font-size: 24px;
  font-weight: 700;
  color: #000;
  margin-bottom: 24px;
}

.admin-form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

/* --- Footer --- */

.site-footer {
  padding: 32px 0;
  border-top: 1px solid rgba(0, 0, 0, 0.08);
  text-align: center;
  font-size: 13px;
  color: rgba(0, 0, 0, 0.32);
}

.site-footer a {
  color: rgba(0, 0, 0, 0.48);
}

/* --- Thumbnail Upload --- */

.thumbnail-upload-area {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  border: 2px dashed rgba(0, 0, 0, 0.16);
  border-radius: 8px;
  cursor: pointer;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, background 0.15s;
}

.thumbnail-upload-area:hover {
  border-color: rgba(0, 0, 0, 0.32);
  background: rgba(0, 0, 0, 0.02);
}

.thumbnail-upload-area.dragover {
  border-color: #0080FF;
  background: rgba(0, 128, 255, 0.04);
}

.thumbnail-upload-area.uploading {
  opacity: 0.6;
  pointer-events: none;
}

.thumb-preview {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumb-placeholder-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  color: rgba(0, 0, 0, 0.32);
  font-size: 14px;
}

.thumb-hint {
  font-size: 11px;
  color: rgba(0, 0, 0, 0.24);
}

/* --- Admin DID Management --- */

.admin-section-divider {
  height: 1px;
  background: rgba(0, 0, 0, 0.08);
  margin: 48px 0 32px;
}

.admin-did-list {
  margin-bottom: 16px;
}

.admin-did-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 8px;
  margin-bottom: 8px;
}

.admin-did-text {
  font-size: 13px;
  color: rgba(0, 0, 0, 0.64);
  word-break: break-all;
}

.admin-did-remove {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: rgba(0, 0, 0, 0.3);
  background: none;
  border: none;
  border-radius: 6px;
  flex-shrink: 0;
  margin-left: 12px;
  transition: background 0.15s, color 0.15s;
}

.admin-did-remove:hover {
  background: #fdecea;
  color: #d32f2f;
}

.add-admin-row {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 16px;
}

.admin-did-input {
  flex: 1;
  padding: 10px 14px;
  font-size: 14px;
  font-family: monospace;
  border: 1px solid rgba(0, 0, 0, 0.16);
  border-radius: 8px;
  outline: none;
}

.admin-did-input:focus {
  border-color: #000;
}

.my-did-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: rgba(0, 128, 255, 0.04);
  border: 1px solid rgba(0, 128, 255, 0.16);
  border-radius: 8px;
  margin-bottom: 16px;
}

.my-did-label {
  font-size: 13px;
  font-weight: 600;
  color: rgba(0, 0, 0, 0.5);
  white-space: nowrap;
}

.resolve-status {
  font-size: 12px;
  color: rgba(0, 0, 0, 0.4);
  white-space: nowrap;
}

/* --- Game file upload --- */

.upload-zip-btn {
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  color: #0080FF;
  background: rgba(0, 128, 255, 0.08);
  border: 1px solid rgba(0, 128, 255, 0.2);
  border-radius: 6px;
  cursor: pointer;
  transition: background 0.15s;
}

.upload-zip-btn:hover {
  background: rgba(0, 128, 255, 0.14);
}

.files-link {
  font-size: 12px;
  font-weight: 600;
  color: #2e7d32;
}

/* --- Utilities --- */

.hidden { display: none !important; }

/* --- Responsive --- */

@media (max-width: 768px) {
  .hero { padding: 48px 0 40px; }
  .hero h1 { font-size: 40px; }
  .hero p { font-size: 16px; }
  .game-grid { grid-template-columns: 1fr; gap: 24px; }
  .leaderboard-page h1 { font-size: 32px; }
  .admin-form-row { grid-template-columns: 1fr; }
  .header-nav { gap: 16px; }
}

@media (max-width: 480px) {
  .hero h1 { font-size: 32px; }
  .container { padding: 0 16px; }
  .header-nav a:not(.auth-btn):not(.user-pill) { display: none; }
}
