:root {
  --pine: #0b6b45;
  --pine-dark: #064a2f;
  --berry: #c22f4b;
  --gold: #f7d047;
  --snow: #f8fbff;
  --paper: #ffffff;
  --ink: #1e2a3a;
  --frost: #dce7f2;
  --shadow: 0 10px 30px rgba(17, 43, 72, 0.15);
}

* {
  box-sizing: border-box;
}

body {
  font-family: "Fredoka", "Inter", system-ui, sans-serif;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  color: var(--ink);
  background: radial-gradient(circle at 10% 20%, rgba(242, 253, 255, 0.9), rgba(232, 242, 255, 0.55)),
              radial-gradient(circle at 80% 0%, rgba(255, 240, 245, 0.8), rgba(255, 255, 255, 0.7)),
              linear-gradient(120deg, #fefefe, #f1f7ff);
  background-attachment: fixed;
  position: relative;
  overflow-x: hidden;
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  background-image:
    radial-gradient(1px 1px at 10px 20px, rgba(255, 255, 255, 0.6), transparent),
    radial-gradient(1px 1px at 50px 80px, rgba(255, 255, 255, 0.4), transparent),
    radial-gradient(1.5px 1.5px at 120px 150px, rgba(255, 255, 255, 0.6), transparent);
  animation: snowfall 16s linear infinite;
  z-index: 0;
}

@keyframes snowfall {
  from { transform: translateY(-20px); }
  to { transform: translateY(20px); }
}

a {
  color: var(--pine);
  font-weight: 700;
  text-decoration: none;
}

h1, h2, h3, h4 {
  font-family: "Fredoka", "Inter", system-ui, sans-serif;
  color: var(--pine-dark);
  letter-spacing: 0.3px;
}

header {
  background: linear-gradient(90deg, var(--pine), var(--pine-dark));
  color: #fff;
  box-shadow: var(--shadow);
  border-bottom: 4px solid var(--gold);
  position: sticky;
  top: 0;
  z-index: 10;
}

nav ul {
  display: flex;
  gap: 14px;
  list-style: none;
  padding: 14px 24px;
  margin: 0;
  flex-wrap: wrap;
}

nav a {
  color: #fff;
  font-weight: 600;
  padding: 8px 14px;
  border-radius: 10px;
  transition: background 0.2s ease, transform 0.2s ease;
}

nav a:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-1px);
}

main, .game-container, .content-box {
  position: relative;
  z-index: 1;
}

.game-container {
  max-width: 1100px;
  margin: 24px auto;
  padding: 24px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 20px;
  box-shadow: var(--shadow);
  border: 3px solid var(--frost);
}

.festive-topper {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

.festive-topper .badge {
  background: var(--gold);
  color: var(--pine-dark);
  padding: 8px 12px;
  border-radius: 999px;
  font-weight: 700;
  box-shadow: 0 6px 16px rgba(247, 208, 71, 0.35);
}

.game-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  padding: 12px 16px;
  border-radius: 14px;
  background: linear-gradient(90deg, rgba(11, 107, 69, 0.12), rgba(194, 47, 75, 0.08));
  border: 1px solid var(--frost);
}

.player {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--pine-dark);
}

.player small {
  display: block;
  font-size: 0.9rem;
  color: #3b4a5d;
  margin-top: 2px;
}

.other-players {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-end;
  min-width: 200px;
}

.other-players__list {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.player-status {
  background: rgba(255, 255, 255, 0.9);
  border: 1px dashed var(--frost);
  border-radius: 12px;
  padding: 8px 12px;
  min-width: 88px;
  box-shadow: 0 6px 18px rgba(17, 43, 72, 0.08);
  transition: border-color 0.15s ease, transform 0.15s ease;
}

.player-status__name {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  font-weight: 700;
  color: var(--pine-dark);
  font-size: 0.95rem;
}

.player-status__slots {
  color: #3b4a5d;
  font-weight: 600;
  font-size: 0.82rem;
}

.player-status__keys {
  margin-top: 4px;
  display: flex;
  gap: 4px;
  align-items: center;
  flex-wrap: wrap;
  min-height: 26px;
}

.player-status__empty {
  color: #5f6b7a;
  font-size: 0.85rem;
}

.key-token.key-token--mini {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 16px;
  height: 16px;
  background: var(--snow);
  border-radius: 10px;
  border: 1px solid var(--frost);
  box-shadow: var(--shadow);
  font-size: 1rem;
}

.board {
  display: flex;
  flex-direction: column;
  gap: 18px;
  margin-top: 16px;
  min-height: 60vh;
}

.play-area {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
}

.panel {
  background: linear-gradient(160deg, #ffffff, #f7fbff);
  border-radius: 16px;
  padding: 16px;
  min-height: 240px;
  position: relative;
  border: 1px solid var(--frost);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.panel::after {
  content: "";
  position: absolute;
  inset: 0;
  background: radial-gradient(circle at 80% 10%, rgba(194, 47, 75, 0.08), transparent 40%),
              radial-gradient(circle at 0% 0%, rgba(11, 107, 69, 0.06), transparent 35%);
  pointer-events: none;
}

.panel-title {
  font-weight: 800;
  color: var(--pine-dark);
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}

.panel-title .tag {
  background: var(--frost);
  color: var(--pine-dark);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.8rem;
  border: 1px dashed var(--pine);
}

.lock-panel {
  text-align: center;
}

.lock-emoji {
  font-size: 4.5rem;
  margin-bottom: 6px;
  animation: float 4s ease-in-out infinite;
}

.secret {
  font-size: 1.3rem;
  padding: 14px;
  background: #fff;
  border-radius: 12px;
  border: 2px dashed var(--gold);
  display: inline-block;
  margin-top: 6px;
  color: var(--pine-dark);
  font-weight: 700;
}

.inventory {
  border: 2px dashed rgba(11, 107, 69, 0.2);
  background: linear-gradient(150deg, rgba(11, 107, 69, 0.05), rgba(247, 208, 71, 0.05));
  min-height: auto;
  margin-top: auto;
  padding: 14px;
}

.play-area .panel {
  width: min(680px, 100%);
}

.inventory-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.slot {
  flex: 1;
  min-height: 72px;
  max-height: 72px;
  height: 72px;
  min-width: 72px;
  max-width: 72px;
  width: 72px;
  border: 1px dashed #c1d5e6;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.8);
}

.key-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.location-hint {
  margin-bottom: 8px;
}

.key-token {
  width: 72px;
  height: 72px;
  background: #fff;
  border-radius: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.1rem;
  border: 2px solid #e4edf5;
  cursor: grab;
  box-shadow: 0 8px 18px rgba(17, 43, 72, 0.12);
  touch-action: none;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

.key-token:hover {
  transform: translateY(-2px) scale(1.02);
  border-color: var(--gold);
}

.key-token.dragging {
  opacity: 0.6;
  transform: rotate(-2deg) scale(1.05);
}

[data-active-drop="true"] {
  outline: 2px dashed var(--pine);
  box-shadow: 0 0 0 6px rgba(11, 107, 69, 0.1);
}

.message-stack {
  position: fixed;
  top: 110px;
  left: 50%;
  transform: translateX(-50%);
  width: min(92vw, 460px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  align-items: stretch;
  z-index: 30;
  pointer-events: none;
}

.toast {
  background: linear-gradient(135deg, #ffffff, #f6fbff);
  color: var(--pine-dark);
  padding: 12px 16px;
  border-radius: 14px;
  border: 1px solid rgba(17, 43, 72, 0.08);
  box-shadow: 0 12px 30px rgba(17, 43, 72, 0.15);
  opacity: 0;
  transform: translateY(-10px) scale(0.98);
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-weight: 700;
  letter-spacing: 0.01em;
  pointer-events: auto;
}

.toast.show {
  opacity: 1;
  transform: translateY(0) scale(1);
}

.toast.hide {
  opacity: 0;
  transform: translateY(-6px) scale(0.98);
}

.toast.error {
  border-color: rgba(194, 47, 75, 0.16);
  background: linear-gradient(135deg, #fff7f8, #ffe9ed);
  color: var(--berry);
}

.hint {
  color: #3f5063;
  font-size: 0.98rem;
}

.recipient-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 14px;
  margin-top: 12px;
}

.recipient-card {
  text-align: center;
  padding: 14px 10px;
  background: #fff;
  border-radius: 14px;
  border: 2px solid #e4edf5;
  width: 100%;
  font-weight: 700;
  box-shadow: var(--shadow);
  color: #1e2a3a;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.recipient-card .emoji {
  font-size: 2.6rem;
  display: block;
  margin-bottom: 4px;
}

.recipient-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 26px rgba(17, 43, 72, 0.16);
}

.drag-ghost {
  position: fixed;
  pointer-events: none;
  z-index: 1000;
  opacity: 0.9;
  transform: translate(-50%, -50%);
}

.inventory-note {
  margin-top: 10px;
  font-weight: 700;
  color: var(--pine-dark);
}

.button-group {
    display: flex;
    gap: 10px;
}

.banner-divider {
  margin: 12px 0 16px;
  height: 6px;
  background: repeating-linear-gradient(45deg, var(--pine) 0, var(--pine) 12px, var(--berry) 12px, var(--berry) 24px, var(--gold) 24px, var(--gold) 36px);
  border-radius: 12px;
  box-shadow: 0 4px 14px rgba(17, 43, 72, 0.12);
}

.celebration-layer {
  position: fixed;
  inset: 0;
  pointer-events: none;
  display: grid;
  place-items: center;
  z-index: 50;
  opacity: 0;
  transition: opacity 0.25s ease;
}

.celebration-layer.show {
  opacity: 1;
}

.celebration-card {
  background: #fff;
  padding: 20px 24px;
  border-radius: 18px;
  border: 3px solid var(--gold);
  box-shadow: 0 20px 40px rgba(17, 43, 72, 0.18);
  text-align: center;
  max-width: 380px;
  animation: pop 0.4s ease;
}

.celebration-card .gift-icon {
  font-size: 3rem;
  animation: float 3s ease-in-out infinite;
}

.celebration-card .secret-banner {
  margin-top: 8px;
  padding: 10px;
  background: rgba(11, 107, 69, 0.08);
  border-radius: 10px;
  border: 1px dashed var(--pine);
}

.confetti-piece {
  position: absolute;
  width: 10px;
  height: 16px;
  background: var(--gold);
  border-radius: 3px;
  animation: confetti-fall 1.8s linear forwards;
  opacity: 0.95;
}

.confetti-piece:nth-child(3n) { background: var(--berry); }
.confetti-piece:nth-child(4n) { background: var(--pine); }

@keyframes confetti-fall {
  0% { transform: translateY(0) rotate(0deg); opacity: 1; }
  100% { transform: translateY(200px) rotate(220deg); opacity: 0; }
}

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}

@keyframes pop {
  0% { transform: scale(0.8); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* --- Admin dashboard polish --- */

.page-shell {
  max-width: 1200px;
  margin: 20px auto 40px;
  padding: 0 18px;
}

.admin-page {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 12px;
  flex-wrap: wrap;
}

.eyebrow {
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 800;
  color: var(--pine);
  margin: 0 0 6px;
  font-size: 0.8rem;
}

.page-header h1 {
  margin: 0;
}

.page-subhead {
  margin: 6px 0 0;
  color: #3b4a5d;
  max-width: 720px;
}

.action-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  border: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--berry), #e24f68);
  color: #fff;
  box-shadow: 0 12px 28px rgba(194, 47, 75, 0.25);
}

.btn-ghost {
  background: rgba(11, 107, 69, 0.08);
  color: var(--pine-dark);
  border: 1px solid rgba(11, 107, 69, 0.2);
}

.btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 14px 30px rgba(17, 43, 72, 0.18);
}

.admin-card {
  background: rgba(255, 255, 255, 0.95);
  border-radius: 18px;
  border: 1px solid var(--frost);
  box-shadow: var(--shadow);
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.admin-card::after {
  content: "";
  position: absolute;
  inset: 0;
  pointer-events: none;
  background: radial-gradient(circle at 5% 10%, rgba(11, 107, 69, 0.06), transparent 35%),
              radial-gradient(circle at 90% 20%, rgba(194, 47, 75, 0.05), transparent 45%);
}

.detail-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin-bottom: 12px;
}

.data-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px;
  padding: 0;
  margin: 0;
}

.data-list + .data-list {
  margin-top: 10px;
}

.data-item {
  background: rgba(248, 251, 255, 0.85);
  border: 1px solid var(--frost);
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.data-item .label {
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #4f6073;
  margin: 0 0 4px;
  display: block;
}

.data-item .value {
  font-weight: 800;
  color: var(--pine-dark);
  margin: 0;
}

.data-item .muted {
  color: #4f6073;
  font-weight: 600;
}

.banner {
  padding: 12px 14px;
  border-radius: 12px;
  font-weight: 600;
  border: 1px solid var(--frost);
  box-shadow: 0 8px 18px rgba(17, 43, 72, 0.12);
}

.banner.success {
  background: linear-gradient(120deg, rgba(11, 107, 69, 0.12), rgba(11, 107, 69, 0.04));
  color: var(--pine-dark);
}

.banner.alert {
  background: linear-gradient(120deg, rgba(194, 47, 75, 0.12), rgba(194, 47, 75, 0.05));
  color: var(--berry);
}

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

.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border: 1px solid var(--frost);
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 12px 30px rgba(17, 43, 72, 0.1);
}

.admin-table th,
.admin-table td {
  padding: 12px 14px;
  text-align: left;
}

.admin-table th {
  background: linear-gradient(120deg, rgba(11, 107, 69, 0.12), rgba(11, 107, 69, 0.02));
  color: var(--pine-dark);
  font-weight: 800;
  font-size: 0.95rem;
}

.admin-table tr:nth-child(even) td {
  background: rgba(248, 251, 255, 0.7);
}

.admin-table tr:hover td {
  background: rgba(247, 208, 71, 0.12);
}

.pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: 999px;
  background: rgba(11, 107, 69, 0.1);
  color: var(--pine-dark);
  font-weight: 700;
  font-size: 0.9rem;
}

.pill.muted {
  background: rgba(30, 42, 58, 0.08);
  color: #3b4a5d;
}

.table-meta {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
  flex-wrap: wrap;
  color: #3b4a5d;
}

.table-meta strong {
  color: var(--pine-dark);
}

.admin-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.form-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 14px 18px;
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.field-label {
  font-weight: 800;
  color: var(--pine-dark);
}

.form-field .helper {
  color: #4f6073;
  font-size: 0.95rem;
}

.admin-form input[type="text"],
.admin-form input[type="number"],
.admin-form input[type="password"],
.admin-form select,
.admin-form textarea,
.admin-form datalist,
.admin-form input[type="email"],
.admin-form input[type="search"] {
  width: 100%;
  border-radius: 12px;
  border: 1px solid var(--frost);
  padding: 10px 12px;
  font-size: 1rem;
  background: #fff;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.8);
}

.admin-form textarea {
  min-height: 90px;
}

.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus {
  outline: 2px solid rgba(11, 107, 69, 0.25);
  border-color: var(--pine);
  box-shadow: 0 0 0 3px rgba(11, 107, 69, 0.12);
}

.form-errors {
  border: 1px solid rgba(194, 47, 75, 0.3);
  background: rgba(194, 47, 75, 0.08);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--berry);
}

.form-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
}

.btn-danger {
  background: linear-gradient(135deg, #e4536c, #c22f4b);
  color: #fff;
  box-shadow: 0 12px 28px rgba(194, 47, 75, 0.25);
}

footer {
  text-align: center;
  padding: 16px 0 24px;
  color: #4f6073;
}

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

  nav ul {
    justify-content: center;
  }
}
