:root {
  --bg: #0a0e1a;
  --panel: #121a2b;
  --panel-soft: #162038;
  --text: #ecedf2;
  --muted: #a6afc6;
  --gold: #c9a84c;
  --gold-soft: rgba(201, 168, 76, 0.2);
  --danger: #ff6f7d;
  --success: #58d18e;
  --radius: 14px;
  --shadow: 0 14px 35px rgba(0, 0, 0, 0.45);
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
}

body {
  min-height: 100vh;
  font-family: "DM Sans", Arial, sans-serif;
  color: var(--text);
  background: radial-gradient(circle at 20% 10%, #172340 0%, var(--bg) 45%),
    var(--bg);
  animation: fadeInBody 0.55s ease-in;
}

@keyframes fadeInBody {
  from {
    opacity: 0;
    transform: translateY(6px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

a {
  color: inherit;
  text-decoration: none;
}

.container {
  width: min(1120px, 92%);
  margin: 0 auto;
}

.top-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1.1rem 0;
}

.brand {
  font-family: "Playfair Display", serif;
  letter-spacing: 0.8px;
  font-size: 1.35rem;
  color: var(--gold);
}

.nav-actions {
  display: flex;
  gap: 0.65rem;
}

.btn {
  border: 1px solid var(--gold);
  background: transparent;
  color: var(--text);
  border-radius: 999px;
  padding: 0.62rem 1.15rem;
  cursor: pointer;
  font-family: inherit;
  font-weight: 600;
  transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.2s ease;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn-primary {
  background: linear-gradient(140deg, #d8bb66 0%, #b9983f 100%);
  color: #171202;
  border: 0;
  box-shadow: 0 8px 20px rgba(201, 168, 76, 0.35);
}

.btn-primary:hover {
  box-shadow: 0 12px 26px rgba(201, 168, 76, 0.45);
}

.btn-secondary {
  border-color: #5c6784;
  color: #d3d8e9;
}

.hero {
  padding: 3rem 0 2.2rem;
}

.hero h1 {
  margin: 0;
  max-width: 780px;
  font-size: clamp(2rem, 5vw, 3.1rem);
  line-height: 1.15;
  font-family: "Playfair Display", serif;
}

.hero p {
  max-width: 720px;
  color: var(--muted);
  margin: 1rem 0 0;
  font-size: 1.03rem;
}

.card-grid {
  padding: 1rem 0 3rem;
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 1rem;
}

.game-card {
  background: linear-gradient(180deg, rgba(18, 26, 43, 0.95), rgba(11, 16, 29, 0.95));
  border: 1px solid rgba(102, 117, 154, 0.35);
  border-radius: var(--radius);
  padding: 1.1rem;
  min-height: 190px;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  box-shadow: var(--shadow);
  transition: transform 0.25s ease, box-shadow 0.25s ease, border-color 0.25s ease;
}

.game-card:hover {
  transform: translateY(-4px);
  border-color: var(--gold);
  box-shadow: 0 0 20px var(--gold-soft), var(--shadow);
}

.game-card h3 {
  margin: 0;
  font-family: "Playfair Display", serif;
  color: #f4f5f9;
}

.game-card p {
  color: var(--muted);
  margin: 0.8rem 0 1.1rem;
}

.panel {
  background: linear-gradient(180deg, rgba(19, 27, 46, 0.98), rgba(12, 18, 31, 0.98));
  border: 1px solid rgba(96, 109, 145, 0.35);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1.4rem;
}

.form-wrap {
  width: min(520px, 92%);
  margin: 2.2rem auto;
}

.title {
  margin-top: 0.2rem;
  margin-bottom: 1.2rem;
  font-size: 2rem;
  font-family: "Playfair Display", serif;
}

.form {
  display: grid;
  gap: 0.9rem;
}

.form label {
  display: grid;
  gap: 0.35rem;
  color: #e6e8f1;
  font-weight: 500;
}

.input,
.select {
  width: 100%;
  background: rgba(9, 14, 26, 0.9);
  border: 1px solid #35405f;
  color: #f2f4fa;
  border-radius: 10px;
  padding: 0.65rem 0.75rem;
  font-size: 0.98rem;
}

.input:focus,
.select:focus {
  outline: 2px solid rgba(201, 168, 76, 0.45);
  border-color: var(--gold);
}

.amount-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
  margin-bottom: 0.8rem;
}

.amount-btn {
  border: 1px solid #4c5879;
  border-radius: 10px;
  background: #10192d;
  color: #e5e8f4;
  padding: 0.55rem 0.8rem;
  cursor: pointer;
}

.amount-btn.active {
  border-color: var(--gold);
  background: rgba(201, 168, 76, 0.18);
  color: #f9f4e4;
}

.info-bar {
  background: rgba(18, 28, 47, 0.9);
  border: 1px solid rgba(90, 105, 140, 0.4);
  border-radius: 12px;
  padding: 0.85rem 1rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.65rem 1.1rem;
  margin: 0.8rem 0 1.4rem;
}

.pill {
  color: #e5e8f3;
  background: rgba(12, 18, 31, 0.65);
  border: 1px solid rgba(100, 111, 143, 0.45);
  border-radius: 999px;
  padding: 0.35rem 0.65rem;
  font-size: 0.9rem;
}

.message {
  margin-top: 0.9rem;
  font-size: 0.95rem;
}

.message.error {
  color: var(--danger);
}

.message.success {
  color: var(--success);
}

.cta-row {
  display: flex;
  flex-wrap: wrap;
  gap: 0.6rem;
  margin-top: 1rem;
}

.game-area {
  margin: 1rem 0;
  border: 1px dashed #526084;
  border-radius: 12px;
  min-height: 260px;
  display: grid;
  place-items: center;
  color: #cbd3ec;
  background: rgba(15, 22, 38, 0.5);
}

.debug-toggle {
  position: fixed;
  right: 16px;
  bottom: 16px;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  border: 1px solid #5d6681;
  background: #161f36;
  color: #f0f3fd;
  cursor: pointer;
  z-index: 1001;
}

.debug-panel {
  position: fixed;
  right: 16px;
  bottom: 66px;
  width: min(290px, calc(100vw - 32px));
  background: rgba(8, 12, 21, 0.96);
  border: 1px solid #606b8b;
  border-radius: 12px;
  padding: 0.8rem;
  color: #d7ddee;
  font-size: 0.86rem;
  z-index: 1000;
  box-shadow: var(--shadow);
  display: none;
}

.debug-panel.open {
  display: block;
}

.debug-row {
  display: flex;
  justify-content: space-between;
  gap: 0.7rem;
  margin: 0.3rem 0;
}

.debug-key {
  color: #9aa5c6;
}

.hidden {
  display: none !important;
}

.login-modal {
  position: fixed;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1200;
}

.login-modal.open {
  display: flex;
}

.login-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 16, 0.72);
}

.login-modal-content {
  position: relative;
  width: min(760px, 96vw);
  border-radius: 14px;
  border: 1px solid rgba(111, 124, 161, 0.45);
  background: linear-gradient(180deg, rgba(19, 27, 46, 0.98), rgba(12, 18, 31, 0.98));
  box-shadow: var(--shadow);
  padding: 1.2rem;
}

.login-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.login-modal-header h2 {
  margin: 0;
  font-family: "Playfair Display", serif;
}

.modal-close {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: 1px solid #5d6681;
  background: #161f36;
  color: #eff2fb;
  font-size: 1.1rem;
  cursor: pointer;
}

.user-cards {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.8rem;
}

.user-card {
  text-align: left;
  border: 1px solid rgba(93, 106, 138, 0.5);
  background: rgba(11, 17, 30, 0.9);
  color: var(--text);
  border-radius: 12px;
  padding: 0.8rem;
  cursor: pointer;
}

.user-card:hover {
  border-color: var(--gold);
  box-shadow: 0 0 16px var(--gold-soft);
}

.user-card strong {
  display: block;
  font-size: 1rem;
}

.user-card span {
  color: var(--muted);
  font-size: 0.92rem;
}

@media (max-width: 980px) {
  .card-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 620px) {
  .top-nav {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.7rem;
  }

  .card-grid {
    grid-template-columns: 1fr;
  }

  .title {
    font-size: 1.6rem;
  }

  .user-cards {
    grid-template-columns: 1fr;
  }
}
