:root{
  --bg: #1b1035;
  --panel: #241547;
  --panel-light: #2f1c5c;
  --accent: #ffcf5c;
  --text: #f4f0ff;
  --muted: #b7abe0;
  --red: #e74c3c;
  --blue: #3498db;
  --green: #2ecc71;
  --yellow: #f1c40f;
  --radius: 14px;
}

*{ box-sizing: border-box; }

body{
  margin:0;
  min-height:100vh;
  font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: radial-gradient(circle at top, #2a1a56, var(--bg));
  color: var(--text);
  display:flex;
  justify-content:center;
  padding: 20px;
}

.screen{ width:100%; max-width:1200px; }
.hidden{ display:none !important; }

h1, h2, h3{ margin: 0 0 10px 0; }

/* ---------------- Setup Screen ---------------- */

#setup-screen{ display:flex; align-items:center; justify-content:center; min-height:90vh; }

.setup-card{
  background: var(--panel);
  border-radius: var(--radius);
  padding: 36px 40px;
  max-width: 520px;
  width:100%;
  box-shadow: 0 20px 60px rgba(0,0,0,0.4);
  text-align:center;
}

.tagline{ color: var(--muted); margin-bottom: 24px; }

.count-buttons{
  display:flex;
  justify-content:center;
  gap:10px;
  margin-bottom: 20px;
}

.count-btn{
  width:48px; height:48px;
  border-radius: 50%;
  border: 2px solid var(--panel-light);
  background: var(--panel-light);
  color: var(--text);
  font-size:18px;
  font-weight:bold;
  cursor:pointer;
  transition: all 0.15s ease;
}
.count-btn:hover{ transform: translateY(-2px); }
.count-btn.active{
  background: var(--accent);
  color: #1b1035;
  border-color: var(--accent);
}

.name-inputs{
  display:flex;
  flex-direction:column;
  gap:12px;
  margin-bottom: 20px;
  text-align:left;
}

.name-row{
  display:flex;
  align-items:center;
  gap:10px;
  background: var(--panel-light);
  padding: 8px 12px;
  border-radius: 10px;
}

.color-swatch{
  width:20px; height:20px;
  border-radius:50%;
  flex-shrink:0;
  border: 2px solid rgba(255,255,255,0.6);
}

.name-row input{
  flex:1;
  border:none;
  background:transparent;
  color: var(--text);
  font-size:16px;
  padding: 6px 4px;
  outline:none;
}
.name-row input::placeholder{ color: var(--muted); }

.primary-btn{
  background: linear-gradient(135deg, var(--accent), #ff9d5c);
  border:none;
  color: #1b1035;
  font-weight:bold;
  font-size:16px;
  padding: 12px 26px;
  border-radius: 30px;
  cursor:pointer;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  box-shadow: 0 6px 18px rgba(255, 159, 92, 0.35);
}
.primary-btn:hover:not(:disabled){ transform: translateY(-2px); }
.primary-btn:disabled{ opacity:0.5; cursor:not-allowed; box-shadow:none; }

.secondary-btn{
  background: var(--panel-light);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text);
  font-size:14px;
  padding: 8px 16px;
  border-radius: 20px;
  cursor:pointer;
}
.secondary-btn:hover{ background:#3a2472; }

.error-msg{ color: var(--red); min-height: 20px; font-size:14px; margin-top:10px; }

/* ---------------- Game Screen ---------------- */

.game-header{
  display:flex;
  align-items:center;
  justify-content:space-between;
  margin-bottom: 10px;
}
.title-small{ font-size: 22px; }

.turn-indicator{
  text-align:center;
  font-size: 18px;
  font-weight:bold;
  padding: 10px;
  border-radius: 10px;
  background: var(--panel);
  margin-bottom: 16px;
  border: 2px solid transparent;
  transition: border-color 0.3s ease;
}

.game-layout{
  display:flex;
  gap: 24px;
  align-items:flex-start;
  flex-wrap:wrap;
}

.board-wrapper{
  flex: 1 1 600px;
  max-width: 640px;
}

.board-container{
  position:relative;
  width:100%;
  aspect-ratio: 1 / 1;
  background: var(--panel);
  border-radius: var(--radius);
  padding: 8px;
  box-shadow: 0 15px 40px rgba(0,0,0,0.35);
  transition: box-shadow 0.3s ease, transform 0.3s ease;
}

.board-container.shifting{
  animation: shift-pulse 0.5s ease-in-out;
}
@keyframes shift-pulse{
  0%{ box-shadow: 0 15px 40px rgba(0,0,0,0.35); }
  50%{ box-shadow: 0 0 0 4px var(--accent), 0 15px 40px rgba(0,0,0,0.35); transform: scale(1.01); }
  100%{ box-shadow: 0 15px 40px rgba(0,0,0,0.35); }
}

.board-grid{
  position:relative;
  display:grid;
  grid-template-columns: repeat(10, 1fr);
  grid-template-rows: repeat(10, 1fr);
  gap: 2px;
  width:100%;
  height:100%;
}

.board-svg{
  position:absolute;
  top:8px; left:8px;
  width: calc(100% - 16px);
  height: calc(100% - 16px);
  pointer-events:none;
  z-index: 5;
}

.square{
  position:relative;
  background: #33206b;
  border-radius: 4px;
  display:flex;
  flex-direction:column;
  justify-content:flex-end;
  overflow:hidden;
  font-size: 10px;
}
.square.alt{ background: #3a2578; }

.sq-number{
  position:absolute;
  top:2px; left:4px;
  font-size: 9px;
  color: var(--muted);
  font-weight:bold;
  z-index: 2;
}

.sq-content{
  position:absolute;
  top:50%; left:50%;
  transform: translate(-50%,-50%);
  font-size: 15px;
  line-height:1;
  white-space:nowrap;
  z-index: 3;
  filter: drop-shadow(0 1px 2px rgba(0,0,0,0.6));
}

.sq-players{
  position:relative;
  z-index: 4;
  display:flex;
  flex-wrap:wrap;
  gap:1px;
  padding: 1px;
  justify-content:center;
}

.player-token{
  width: 13px; height:13px;
  border-radius: 50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size: 8px;
  font-weight:bold;
  color:#1b1035;
  border: 1.5px solid rgba(255,255,255,0.85);
  box-shadow: 0 1px 3px rgba(0,0,0,0.5);
}

.legend{
  display:flex;
  flex-wrap:wrap;
  gap: 14px;
  justify-content:center;
  margin-top: 12px;
  font-size: 13px;
  color: var(--muted);
}

/* Sidebar */

.sidebar{
  flex: 1 1 280px;
  max-width: 340px;
  display:flex;
  flex-direction:column;
  gap: 16px;
}

.dice-area{
  background: var(--panel);
  border-radius: var(--radius);
  padding: 20px;
  text-align:center;
}

.dice-face{
  font-size: 60px;
  margin-bottom: 12px;
  transition: transform 0.1s ease;
}
.dice-face.rolling{ animation: dice-spin 0.15s linear infinite; }
@keyframes dice-spin{
  0%{ transform: rotate(0deg) scale(1); }
  50%{ transform: rotate(15deg) scale(1.1); }
  100%{ transform: rotate(-10deg) scale(1); }
}

.player-list{
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  display:flex;
  flex-direction:column;
  gap: 10px;
}

.player-row{
  display:flex;
  align-items:center;
  gap:10px;
  padding: 8px 10px;
  border-radius: 10px;
  background: var(--panel-light);
  border: 2px solid transparent;
  transition: border-color 0.2s ease, transform 0.2s ease;
}
.player-row.current-turn{
  border-color: var(--accent);
  transform: scale(1.02);
}

.player-dot{
  width: 18px; height:18px;
  border-radius:50%;
  flex-shrink:0;
  border: 2px solid rgba(255,255,255,0.7);
}

.player-row .p-name{ font-weight:bold; flex:1; }
.player-row .p-pos{ color: var(--muted); font-size:13px; }

.log-panel{
  background: var(--panel);
  border-radius: var(--radius);
  padding: 16px;
  display:flex;
  flex-direction:column;
  min-height: 200px;
  max-height: 320px;
}

.log-content{
  overflow-y:auto;
  flex:1;
  display:flex;
  flex-direction:column;
  gap: 6px;
  font-size: 13px;
  padding-right: 4px;
}

.log-content div{
  padding: 6px 8px;
  border-radius: 6px;
  background: var(--panel-light);
  animation: log-in 0.25s ease;
}
.log-content .log-slither{ color: var(--accent); font-style:italic; }
.log-content .log-bite{ color: var(--red); }
.log-content .log-climb{ color: var(--green); }
.log-content .log-win{ color: var(--accent); font-weight:bold; }
.log-content .log-scoop{ color: #7fd1ff; }

@keyframes log-in{
  from{ opacity:0; transform: translateY(-4px); }
  to{ opacity:1; transform: translateY(0); }
}

/* Win overlay */

.win-overlay{
  position: fixed;
  inset:0;
  background: rgba(10, 5, 25, 0.8);
  display:flex;
  align-items:center;
  justify-content:center;
  z-index: 100;
}

.win-card{
  background: var(--panel);
  padding: 40px 50px;
  border-radius: var(--radius);
  text-align:center;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.win-card h2{ font-size: 28px; margin-bottom: 20px; }

@media (max-width: 720px){
  .game-layout{ flex-direction:column; }
  .board-wrapper, .sidebar{ max-width:100%; }
}
