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

body {
  background: #0c1a0c;
  color: #e8f5e9;
  font-family: 'Segoe UI', Tahoma, sans-serif;
  height: 100vh;
  overflow: hidden;
  display: flex;
}

/* ---- SCREENS ---- */
.screen { width: 100%; height: 100%; display: flex; align-items: center; justify-content: center; }
.screen.hidden { display: none; }

/* ---- SETUP ---- */
.setup-box {
  background: #162516;
  border: 2px solid #4ade80;
  border-radius: 16px;
  padding: 2rem 2.5rem;
  max-width: 680px;
  width: 92vw;
  max-height: 92vh;
  overflow-y: auto;
}

.setup-title {
  font-size: 2.2rem;
  font-weight: 900;
  text-align: center;
  color: #fde047;
  text-shadow: 0 0 24px rgba(253,224,71,.45);
  letter-spacing: 2px;
  margin-bottom: .3rem;
}

.setup-sub { text-align: center; color: #86efac; font-style: italic; margin-bottom: 1.4rem; }

.player-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  background: #0c1a0c;
  border: 1px solid #2d4a2d;
  border-radius: 8px;
  padding: .6rem .75rem;
  margin-bottom: .45rem;
}

.p-num { color: #6b7280; font-size: .8rem; width: 28px; flex-shrink: 0; }

.char-sel {
  flex: 1;
  background: #1f2d1f;
  color: #e8f5e9;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: .4rem .5rem;
  font-size: .82rem;
  cursor: pointer;
}

.name-inp {
  background: #1f2d1f;
  color: #e8f5e9;
  border: 1px solid #374151;
  border-radius: 6px;
  padding: .35rem .5rem;
  width: 110px;
  font-size: .82rem;
}

.type-btn {
  background: #1f2d1f;
  border: 1px solid #4ade80;
  border-radius: 6px;
  color: #86efac;
  padding: .35rem .6rem;
  cursor: pointer;
  font-size: .78rem;
  white-space: nowrap;
}
.type-btn.cpu { color: #fbbf24; border-color: #fbbf24; }

.setup-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 1.4rem;
  gap: .75rem;
}

.count-ctrl { display: flex; align-items: center; gap: .6rem; color: #86efac; font-size: .9rem; }

/* ---- BUTTONS ---- */
.btn-sm {
  background: #1f2d1f;
  color: #86efac;
  border: 1px solid #4ade80;
  border-radius: 6px;
  padding: .3rem .65rem;
  font-size: 1rem;
  cursor: pointer;
  line-height: 1;
}
.btn-sm:hover { background: #2d4a2d; }

.btn-go {
  background: #16a34a;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .7rem 1.4rem;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .5px;
}
.btn-go:hover { background: #15803d; }

.btn-roll {
  background: #1d4ed8;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .65rem 1rem;
  font-size: .95rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
}
.btn-roll:hover:not(:disabled) { background: #1e40af; }
.btn-roll:disabled { background: #374151; cursor: not-allowed; }

.btn-ability {
  background: #7c3aed;
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: .5rem 1rem;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  width: 100%;
  margin-top: .4rem;
}
.btn-ability:hover:not(:disabled) { background: #6d28d9; }
.btn-ability:disabled { background: #374151; cursor: not-allowed; opacity: .6; }
.btn-ability.hidden { display: none; }

/* ---- GAME LAYOUT ---- */
.game-layout {
  display: flex;
  width: 100%;
  height: 100%;
}

.panel {
  width: 220px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: .6rem;
  padding: .65rem;
  background: #0c1a0c;
  overflow: hidden;
}

.left-panel { border-right: 1px solid #1a2e1a; }
.right-panel { border-left: 1px solid #1a2e1a; }

.board-wrap {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #080f08;
  position: relative;
}

canvas { display: block; }

/* ---- TURN BAR ---- */
.turn-bar {
  background: #1a2e1a;
  border: 1px solid #2d4a2d;
  border-radius: 6px;
  padding: .4rem .5rem;
  font-size: .78rem;
  text-align: center;
  color: #86efac;
  flex-shrink: 0;
}

/* ---- PLAYER LIST ---- */
.player-list { flex: 1; overflow-y: auto; }

.player-item {
  display: flex;
  align-items: center;
  gap: .45rem;
  padding: .42rem .5rem;
  border-radius: 7px;
  margin-bottom: .3rem;
  border: 1.5px solid transparent;
}
.player-item.active { border-color: #fde047; background: rgba(253,224,71,.04); }
.player-item.done   { border-color: #fbbf24; background: rgba(251,191,36,.06); }

.p-emoji { font-size: 1.35rem; width: 28px; text-align: center; }

.p-info { flex: 1; min-width: 0; }
.p-name { font-size: .78rem; font-weight: 700; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.p-car  { font-size: .62rem; color: #4b5563; }
.p-stat { font-size: .62rem; color: #fbbf24; }

.p-pos { font-size: .72rem; color: #86efac; text-align: right; white-space: nowrap; }

/* ---- ABILITY BOX ---- */
.ability-box {
  background: #10181a;
  border: 1px solid #5b21b6;
  border-radius: 7px;
  padding: .5rem;
  flex-shrink: 0;
}
.ability-name { color: #c4b5fd; font-weight: 700; font-size: .8rem; }
.ability-desc { color: #4b5563; font-size: .7rem; margin-top: .2rem; line-height: 1.3; }

/* ---- DICE ---- */
.dice-area { display: flex; flex-direction: column; gap: .35rem; align-items: center; flex-shrink: 0; }

.die {
  font-size: 2.8rem;
  line-height: 1;
  min-height: 52px;
  text-align: center;
}
.die.rolling { animation: spin .7s ease-out; }

@keyframes spin {
  0%   { transform: rotate(0deg) scale(1); }
  30%  { transform: rotate(180deg) scale(1.25); }
  70%  { transform: rotate(300deg) scale(.85); }
  100% { transform: rotate(360deg) scale(1); }
}

.die-result { font-size: 1.1rem; color: #fde047; font-weight: 700; text-align: center; min-height: 1.4rem; }

/* ---- RIGHT PANEL ---- */
.card-display {
  background: #0f1f0f;
  border: 1px solid #3a3a7a;
  border-radius: 7px;
  padding: .6rem;
  flex-shrink: 0;
}
.card-label { font-size: .76rem; color: #a855f7; font-weight: 700; margin-bottom: .3rem; }
.card-text  { font-size: .76rem; color: #9ca3af; font-style: italic; line-height: 1.4; }

.log-area { flex: 1; display: flex; flex-direction: column; overflow: hidden; }
.log-label { font-size: .76rem; color: #4b5563; margin-bottom: .3rem; flex-shrink: 0; }

.log-list {
  flex: 1;
  overflow-y: auto;
  font-size: .72rem;
  color: #9ca3af;
}
.log-entry { padding: .2rem 0; border-bottom: 1px solid #1a2e1a; line-height: 1.3; }

/* ---- EVENT POPUP ---- */
.event-pop {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 20;
  pointer-events: none;
}
.event-pop.hidden { display: none; }

.event-inner {
  background: #162516;
  border: 3px solid #4ade80;
  border-radius: 16px;
  padding: 1.4rem 2rem;
  text-align: center;
  min-width: 230px;
  max-width: 290px;
  animation: pop .25s cubic-bezier(.2,1.5,.5,1);
}
@keyframes pop {
  from { transform: scale(.4); opacity: 0; }
  to   { transform: scale(1);  opacity: 1; }
}

.ev-icon  { font-size: 2.4rem; margin-bottom: .4rem; }
.ev-title { font-size: 1.25rem; font-weight: 900; color: #fde047; margin-bottom: .4rem; }
.ev-text  { font-size: .88rem; color: #d1d5db; }

/* ---- WIN SCREEN ---- */
.win-box {
  background: #162516;
  border: 3px solid #fde047;
  border-radius: 16px;
  padding: 2.5rem;
  text-align: center;
  max-width: 480px;
  width: 90vw;
}
.win-title { font-size: 2rem; font-weight: 900; color: #fde047; margin-bottom: .75rem; }
.winner-info { font-size: 1.4rem; margin: .75rem 0; }
.standings { margin: .75rem 0 1.5rem; text-align: left; }
.stand-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .4rem .5rem;
  border-bottom: 1px solid #1a2e1a;
}
.stand-rank { font-size: 1.1rem; width: 28px; }
.stand-score { margin-left: auto; font-size: .78rem; color: #6b7280; }

/* ---- SCROLLBAR ---- */
::-webkit-scrollbar { width: 3px; }
::-webkit-scrollbar-track { background: #0c1a0c; }
::-webkit-scrollbar-thumb { background: #2d4a2d; border-radius: 2px; }
