:root {
  --bg: #0d1b2a;
  --bg-soft: #1b263b;
  --panel: rgba(26, 39, 61, 0.92);
  --panel-border: rgba(255, 255, 255, 0.12);
  --text: #f1f5f9;
  --muted: #c2cfdd;
  --accent: #d9a441;
  --danger: #d04f4f;
  --success: #4caf70;
  --shadow: 0 20px 40px rgba(0, 0, 0, 0.35);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  font-family: "Segoe UI", Tahoma, sans-serif;
  color: var(--text);
  background:
    radial-gradient(circle at 10% 10%, rgba(217, 164, 65, 0.15), transparent 35%),
    radial-gradient(circle at 90% 20%, rgba(80, 115, 159, 0.2), transparent 40%),
    linear-gradient(160deg, var(--bg), #0a1727 65%, #050d17);
}

.layout {
  width: min(1160px, 100% - 2rem);
  margin: 0 auto;
  padding: 1.25rem 0 2rem;
  display: grid;
  gap: 1rem;
}

.layout-home {
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  align-items: start;
}

.layout-game {
  grid-template-columns: 1fr;
}

.layout-admin {
  max-width: 760px;
}

.panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: 16px;
  padding: 1rem;
  box-shadow: var(--shadow);
}

.narrow {
  max-width: 520px;
  margin: 0 auto;
}

h1,
h2 {
  margin: 0 0 0.75rem;
}

h1 {
  font-size: clamp(1.4rem, 2.2vw, 2rem);
}

h2 {
  font-size: clamp(1.15rem, 1.7vw, 1.5rem);
}

p {
  margin: 0.3rem 0;
}

.muted {
  color: var(--muted);
  line-height: 1.45;
}

label {
  font-size: 0.95rem;
  color: var(--muted);
}

input,
button,
textarea {
  font: inherit;
}

input {
  width: 100%;
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 10px;
  padding: 0.68rem 0.8rem;
  color: var(--text);
  background: rgba(8, 13, 22, 0.7);
}

input:focus {
  outline: 2px solid rgba(217, 164, 65, 0.45);
  border-color: rgba(217, 164, 65, 0.7);
}

button,
.link-button {
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 0.65rem 1rem;
  background: var(--accent);
  color: #0f172a;
  cursor: pointer;
  text-decoration: none;
  font-weight: 600;
  transition: transform 120ms ease, opacity 120ms ease;
}

button:hover,
.link-button:hover {
  transform: translateY(-1px);
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.5;
  transform: none;
}

button.danger,
.link-button.danger {
  background: var(--danger);
  color: #fff;
}

.row {
  display: flex;
}

.wrap {
  flex-wrap: wrap;
}

.align-end {
  align-items: flex-end;
}

.gap-sm {
  gap: 0.6rem;
}

.stack {
  display: flex;
  flex-direction: column;
}

.top-spaced {
  margin-top: 0.8rem;
}

.field-grow {
  flex: 1;
  min-width: 220px;
}

.table-wrap {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 0.9rem;
}

th,
td {
  border-bottom: 1px solid rgba(255, 255, 255, 0.12);
  padding: 0.55rem;
  text-align: left;
  white-space: nowrap;
}

.query-preview {
  background: rgba(4, 7, 12, 0.85);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 10px;
  margin-top: 0.8rem;
  padding: 0.7rem;
  overflow-x: auto;
  color: #d0dbeb;
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
  flex-wrap: wrap;
}

.status-panel {
  display: grid;
  gap: 0.8rem;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 0.55rem;
}

.result-box {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.85rem;
  background: rgba(7, 12, 21, 0.78);
  border-radius: 10px;
}

.result-win {
  color: var(--success);
}

.result-lose {
  color: #ff7d7d;
}

.result-draw {
  color: #f3c96b;
}

.table-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1rem;
}

.cards {
  margin: 0.9rem 0;
  min-height: 96px;
  display: flex;
  flex-wrap: wrap;
  gap: 0.55rem;
}

.card {
  width: 68px;
  height: 92px;
  border-radius: 10px;
  background: #f8fafc;
  color: #0f172a;
  display: grid;
  place-items: center;
  font-weight: 700;
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.25);
}

.card-red {
  color: #b91c1c;
}

.card-hidden {
  background: #253549;
  color: #e8eef7;
}

.score {
  color: #f4ca71;
  font-weight: 700;
}

.reveal-panel {
  display: grid;
  gap: 1rem;
  grid-template-columns: minmax(220px, 1fr) minmax(240px, 360px);
  align-items: center;
}

.reveal-image-wrap {
  border-radius: 14px;
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.15);
  background: rgba(0, 0, 0, 0.28);
}

.reveal-image-wrap img {
  width: 100%;
  display: block;
  height: auto;
}

.error-text {
  min-height: 1.2rem;
  color: #ff8f8f;
}

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

.link-back:hover {
  text-decoration: underline;
}

@media (max-width: 720px) {
  .layout {
    width: min(100% - 1rem, 100%);
    padding-top: 0.8rem;
  }

  .panel {
    padding: 0.85rem;
    border-radius: 12px;
  }

  .reveal-panel {
    grid-template-columns: 1fr;
  }

  button,
  .link-button {
    width: 100%;
    text-align: center;
  }
}
