/* ═══════════════════════════════════════════════════════════════════════════
   PALAB Point Tracker — Stylesheet
   Theme: Dark background, warm African/family vibes
   Deep purples · Warm oranges/reds · Gold accents
═══════════════════════════════════════════════════════════════════════════ */

/* ─── Reset & Variables ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:            #1a1025;
  --bg-card:       #251838;
  --bg-card2:      #2e1f45;
  --bg-sidebar:    #1f1530;
  --purple:        #6c3fa0;
  --purple-light:  #9b5fd4;
  --gold:          #e8a020;
  --gold-light:    #f5c843;
  --orange:        #d95f1a;
  --orange-light:  #f07c3a;
  --red:           #c0392b;
  --red-light:     #e74c3c;
  --green:         #27ae60;
  --teal:          #1abc9c;
  --text:          #f0e6d3;
  --text-muted:    #9e8fb5;
  --text-dim:      #6b5d84;
  --border:        #3a2558;
  --shadow:        0 4px 24px rgba(0,0,0,.5);

  --gauge-calm:    #1abc9c;
  --gauge-warn:    #e8a020;
  --gauge-danger:  #e74c3c;
  --gauge-crit:    #ff2222;

  --radius:        12px;
  --radius-sm:     7px;
  --transition:    .22s ease;
}

html, body {
  height: 100%;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  overflow-x: hidden;
  line-height: 1.4;
}

/* ─── Screens ────────────────────────────────────────────────────────────── */
.screen {
  display: none;
  min-height: 100vh;
  animation: fadeIn .35s ease;
}
.screen.active { display: flex; }

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ─── Buttons ────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .55rem 1.1rem;
  border: none;
  border-radius: var(--radius-sm);
  font-size: .95rem;
  font-weight: 600;
  cursor: pointer;
  transition: background var(--transition), transform .1s, box-shadow var(--transition);
  user-select: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.95); }

.btn-primary {
  background: linear-gradient(135deg, var(--purple), var(--purple-light));
  color: #fff;
  box-shadow: 0 3px 12px rgba(108,63,160,.4);
}
.btn-primary:hover { background: linear-gradient(135deg, var(--purple-light), #b87fe8); }

.btn-secondary {
  background: var(--bg-card2);
  color: var(--text);
  border: 1px solid var(--border);
}
.btn-secondary:hover { background: var(--bg-card); border-color: var(--purple-light); }

.btn-ghost {
  background: transparent;
  color: var(--text-muted);
  border: 1px solid var(--border);
}
.btn-ghost:hover { color: var(--text); border-color: var(--text-muted); }

.btn-large { padding: .85rem 2rem; font-size: 1.1rem; border-radius: var(--radius); }

/* Card value buttons */
.btn-card {
  background: var(--bg-card2);
  color: var(--gold-light);
  border: 2px solid var(--gold);
  font-size: 1rem;
  font-weight: 700;
  border-radius: var(--radius-sm);
  padding: .7rem .5rem;
  transition: all .15s;
}
.btn-card:hover {
  background: var(--gold);
  color: var(--bg);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(232,160,32,.4);
}
.btn-card-10  { border-color: var(--orange); color: var(--orange-light); }
.btn-card-10:hover  { background: var(--orange); color: #fff; }
.btn-card-neg { border-color: var(--teal); color: var(--teal); }
.btn-card-neg:hover { background: var(--teal); color: var(--bg); }
.btn-card-choice { border-color: var(--purple-light); color: var(--purple-light); }
.btn-card-choice:hover { background: var(--purple-light); color: #fff; }
.btn-card-mirror { border-color: var(--text-muted); color: var(--text-muted); }
.btn-card-mirror:hover { background: var(--text-muted); color: var(--bg); }
.btn-card-max  { border-color: var(--red-light); color: var(--red-light); font-weight: 700; }
.btn-card-max:hover  { background: var(--red); color: #fff; }

/* Action buttons */
.btn-action {
  background: var(--bg-card);
  color: var(--text);
  border: 1px solid var(--border);
  font-size: .85rem;
}
.btn-action:hover { border-color: var(--purple-light); color: var(--purple-light); }
.btn-tofou { border-color: var(--teal); color: var(--teal); }
.btn-tofou:hover { background: var(--teal); color: var(--bg); }
.btn-event { border-color: var(--gold); color: var(--gold); }
.btn-event:hover { background: var(--gold); color: var(--bg); }
.btn-danger { border-color: var(--red); color: var(--red-light); }
.btn-danger:hover { background: var(--red); color: #fff; }
.btn-skip  { border-color: var(--teal); color: var(--teal); }
.btn-skip:hover  { background: var(--teal); color: var(--bg); }
.btn-swap  { border-color: var(--purple-light); color: var(--purple-light); }
.btn-swap:hover  { background: var(--purple-light); color: #fff; }

/* ─── Setup Screen ───────────────────────────────────────────────────────── */
#screen-setup {
  align-items: center;
  justify-content: center;
  padding: 2rem 1rem;
  background: radial-gradient(ellipse at 50% 0%, #3d1f6e 0%, var(--bg) 65%);
}

.setup-container {
  width: 100%;
  max-width: 480px;
  display: flex;
  flex-direction: column;
  gap: 1.2rem;
}

.game-title {
  font-size: 2.2rem;
  font-weight: 800;
  text-align: center;
  line-height: 1.2;
  color: var(--text);
}
.title-accent {
  font-size: 3rem;
  color: var(--gold-light);
  letter-spacing: .12em;
  text-shadow: 0 0 30px rgba(245,200,67,.4);
}
.setup-subtitle { text-align: center; color: var(--text-muted); }

.player-inputs {
  display: flex;
  flex-direction: column;
  gap: .6rem;
}
.player-input-row {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.player-input-label {
  color: var(--text-muted);
  font-size: .85rem;
  min-width: 70px;
}
.player-input-row input {
  flex: 1;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .55rem .8rem;
  font-size: 1rem;
  outline: none;
  transition: border-color var(--transition);
}
.player-input-row input:focus { border-color: var(--purple-light); }
.player-input-row input::placeholder { color: var(--text-dim); }

.setup-controls { display: flex; gap: .6rem; justify-content: center; }

/* ─── Playing Screen Layout ──────────────────────────────────────────────── */
#screen-playing {
  flex-direction: row;
  height: 100vh;
  overflow: hidden;
}

.playing-layout {
  display: flex;
  width: 100%;
  height: 100%;
}

/* ─── Player Sidebar ─────────────────────────────────────────────────────── */
.player-sidebar {
  width: 190px;
  min-width: 190px;
  background: var(--bg-sidebar);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: .8rem .6rem;
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.sidebar-title {
  font-size: .7rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  color: var(--text-dim);
  padding: .2rem .4rem;
}

.player-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: .5rem .7rem;
  transition: border-color var(--transition), background var(--transition);
  position: relative;
}
.player-card.current-player {
  border-color: var(--gold);
  background: var(--bg-card2);
  box-shadow: 0 0 12px rgba(232,160,32,.2);
}
.player-card.eliminated { opacity: .4; }

.player-card-name {
  font-weight: 700;
  font-size: .9rem;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.player-card.current-player .player-card-name { color: var(--gold-light); }

.player-card-meta {
  display: flex;
  align-items: center;
  gap: .5rem;
  margin-top: .25rem;
}

.loss-dots {
  display: flex;
  gap: 3px;
}
.loss-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--text-dim);
  background: transparent;
  transition: background .3s, border-color .3s;
}
.loss-dot.filled {
  background: var(--red);
  border-color: var(--red-light);
  animation: dotPop .4s ease;
}
@keyframes dotPop {
  0%   { transform: scale(0); }
  70%  { transform: scale(1.4); }
  100% { transform: scale(1); }
}

.secret-badge {
  font-size: .7rem;
  padding: .1rem .35rem;
  border-radius: 4px;
  font-weight: 700;
  letter-spacing: .05em;
}
.secret-badge.type-infinite { background: var(--purple); color: #fff; }
.secret-badge.type-flip     { background: var(--orange); color: #fff; }
.secret-badge.used          { opacity: .45; }
.secret-badge.clickable     { cursor: pointer; transition: filter var(--transition), opacity var(--transition); }
.secret-badge.clickable:hover { filter: brightness(1.25); opacity: 1; }

/* Last played card glow */
@keyframes last-played-pulse {
  0%, 100% { box-shadow: 0 0 8px 3px var(--gold), 0 0 20px 6px rgba(232,160,32,.35); }
  50%       { box-shadow: 0 0 16px 6px var(--gold-light), 0 0 36px 12px rgba(245,200,67,.25); }
}
.btn-card.last-played {
  border-color: var(--gold-light) !important;
  color: var(--gold-light) !important;
  animation: last-played-pulse 1.6s ease-in-out infinite;
}

.super-skip-indicator {
  font-size: .7rem;
  color: var(--orange-light);
  margin-top: .15rem;
}

/* ─── Game Main ──────────────────────────────────────────────────────────── */
.game-main {
  flex: 1;
  overflow-y: auto;
  padding: .8rem 1rem 1.5rem;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  align-items: center;
}

/* ─── Game Info Bar ──────────────────────────────────────────────────────── */
.game-info-bar {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: .85rem;
  color: var(--text-muted);
}
.round-label { font-weight: 700; color: var(--purple-light); }
.direction-label { font-size: .9rem; }

/* ─── Gauge Display ──────────────────────────────────────────────────────── */
.gauge-wrapper {
  text-align: center;
  width: 100%;
  max-width: 360px;
}

.gauge-display {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 180px;
  height: 180px;
  border-radius: 50%;
  background: var(--bg-card);
  border: 4px solid var(--gauge-calm);
  transition: border-color .4s, box-shadow .4s;
  box-shadow: 0 0 24px rgba(26,188,156,.18);
  margin-bottom: .4rem;
}

.gauge-display.warn  { border-color: var(--gauge-warn);   box-shadow: 0 0 28px rgba(232,160,32,.35); }
.gauge-display.danger {
  border-color: var(--gauge-danger);
  box-shadow: 0 0 32px rgba(231,76,60,.5);
  animation: gaugePulse 1.2s ease-in-out infinite;
}
.gauge-display.critical {
  border-color: var(--gauge-crit);
  box-shadow: 0 0 48px rgba(255,34,34,.8);
  animation: gaugeCritical .35s ease-in-out infinite;
}

@keyframes gaugePulse {
  0%, 100% { box-shadow: 0 0 28px rgba(231,76,60,.4); }
  50%       { box-shadow: 0 0 52px rgba(231,76,60,.85); }
}
@keyframes gaugeCritical {
  0%, 100% { box-shadow: 0 0 40px rgba(255,34,34,.7); }
  50%       { box-shadow: 0 0 70px rgba(255,34,34,1); }
}

.gauge-value {
  font-size: 4rem;
  font-weight: 900;
  color: var(--text);
  letter-spacing: -.02em;
  transition: color .4s;
  line-height: 1;
}
.gauge-display.warn   .gauge-value { color: var(--gauge-warn); }
.gauge-display.danger .gauge-value { color: var(--gauge-danger); }
.gauge-display.critical .gauge-value { color: var(--gauge-crit); }

.gauge-delta {
  position: absolute;
  top: -24px;
  right: -10px;
  font-size: 1.1rem;
  font-weight: 800;
  pointer-events: none;
  opacity: 0;
}
.gauge-delta.positive { color: var(--orange-light); }
.gauge-delta.negative { color: var(--teal); }
.gauge-delta.visible  { animation: deltaFloat 1s ease forwards; }

@keyframes deltaFloat {
  0%   { opacity: 1; transform: translateY(0); }
  80%  { opacity: 1; transform: translateY(-28px); }
  100% { opacity: 0; transform: translateY(-36px); }
}

.gauge-label { color: var(--text-dim); font-size: .75rem; letter-spacing: .1em; text-transform: uppercase; margin-bottom: .5rem; }

.gauge-bar-container {
  width: 100%;
  height: 8px;
  background: var(--bg-card);
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  border: 1px solid var(--border);
}
.gauge-bar {
  height: 100%;
  border-radius: 4px;
  background: var(--gauge-calm);
  transition: width .35s ease, background .4s;
  width: 0%;
}
.gauge-bar.warn    { background: var(--gauge-warn); }
.gauge-bar.danger  { background: var(--gauge-danger); }
.gauge-bar.critical{ background: var(--gauge-crit); }
.gauge-bar-limit {
  position: absolute;
  right: 0;
  top: -2px;
  bottom: -2px;
  width: 2px;
  background: var(--red-light);
  opacity: .6;
}

/* ─── Current Player Banner ──────────────────────────────────────────────── */
.current-player-banner {
  width: 100%;
  max-width: 460px;
  background: var(--bg-card2);
  border: 1px solid var(--gold);
  border-radius: var(--radius);
  padding: .6rem 1rem;
  display: flex;
  align-items: center;
  gap: .8rem;
  box-shadow: 0 2px 12px rgba(232,160,32,.15);
}
.cpb-label { color: var(--text-dim); font-size: .75rem; text-transform: uppercase; letter-spacing: .1em; }
.cpb-name  { color: var(--gold-light); font-weight: 800; font-size: 1.1rem; }
.cpb-direction { margin-left: auto; font-size: 1.4rem; }

/* ─── Card Buttons Grid ──────────────────────────────────────────────────── */
.card-buttons-section { width: 100%; max-width: 460px; }
.card-buttons-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: .5rem;
}

/* ─── Action Buttons ─────────────────────────────────────────────────────── */
.action-buttons-section {
  width: 100%;
  max-width: 460px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: .5rem;
}

/* ─── Turn Controls ──────────────────────────────────────────────────────── */
.turn-controls {
  width: 100%;
  max-width: 460px;
  display: flex;
  gap: .6rem;
  justify-content: flex-end;
}
.btn-next { flex: 1; }
.btn-set-gauge { font-size: .8rem; padding: .45rem .8rem; }

/* Gauge correction modal input */
.gauge-input {
  width: 100%;
  padding: .65rem 1rem;
  font-size: 1.6rem;
  font-weight: 700;
  text-align: center;
  background: var(--bg);
  color: var(--text);
  border: 2px solid var(--purple);
  border-radius: var(--radius-sm);
  margin: .5rem 0 1rem;
  outline: none;
}
.gauge-input:focus { border-color: var(--gold); }
.modal-set-gauge-actions { display: flex; gap: .6rem; }

/* ─── No-Draw Banner (Event #9) ─────────────────────────────────────────── */
.no-draw-banner {
  width: 100%;
  max-width: 460px;
  background: linear-gradient(135deg, var(--orange), var(--orange-light));
  color: #fff;
  font-weight: 700;
  font-size: .85rem;
  text-align: center;
  padding: .4rem .8rem;
  border-radius: var(--radius-sm);
  letter-spacing: .04em;
}
.no-draw-banner[hidden] { display: none; }

/* ─── Hand Limit Badge ───────────────────────────────────────────────────── */
.hand-limit-badge {
  font-size: .7rem;
  padding: .1rem .35rem;
  border-radius: 4px;
  font-weight: 700;
  background: var(--teal);
  color: var(--bg);
  letter-spacing: .05em;
}

/* ─── Game Over Screen ───────────────────────────────────────────────────── */
#screen-game-over {
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at 50% 30%, #5c1010 0%, var(--bg) 70%);
}
.game-over-container { text-align: center; padding: 2rem; }
.game-over-icon { font-size: 5rem; margin-bottom: 1rem; }
.game-over-title { font-size: 1.8rem; color: var(--red-light); margin-bottom: .5rem; }
.game-over-loser-wrap {
  margin: .6rem 0 .4rem;
  padding: .8rem 1.6rem;
  border-radius: var(--radius);
  background: rgba(232,160,32,.08);
  border: 2px solid var(--gold);
}
@keyframes loser-glow {
  0%, 100% { text-shadow: 0 0 18px rgba(245,200,67,.8), 0 0 40px rgba(245,200,67,.3); }
  50%       { text-shadow: 0 0 32px rgba(245,200,67,1),  0 0 70px rgba(245,200,67,.5); }
}
.game-over-loser {
  font-size: clamp(2.8rem, 8vw, 5rem);
  font-weight: 900;
  color: var(--gold-light);
  letter-spacing: .03em;
  animation: loser-glow 2s ease-in-out infinite;
}
.game-over-sub   { color: var(--text-muted); margin-bottom: 2rem; }

/* ─── Modals ─────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(10,5,20,.78);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 1rem;
  animation: fadeIn .2s ease;
}
.modal-overlay[hidden] { display: none; }

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  width: 100%;
  max-width: 420px;
  display: flex;
  flex-direction: column;
  gap: .9rem;
  box-shadow: var(--shadow);
  animation: modalPop .25s ease;
}
@keyframes modalPop {
  from { transform: scale(.88) translateY(12px); opacity: 0; }
  to   { transform: scale(1) translateY(0); opacity: 1; }
}

.modal-danger { border-color: var(--red); }
.modal-event  { max-width: 500px; }
.modal-secret { max-width: 500px; }
.modal-round-end { text-align: center; }

.modal-title { font-size: 1.1rem; font-weight: 800; color: var(--gold-light); }
.modal-text  { color: var(--text-muted); font-size: .92rem; }
.modal-text-small { font-size: .82rem; }

.modal-cancel { align-self: flex-end; font-size: .8rem; }

.modal-choice-buttons {
  display: flex;
  gap: .7rem;
  justify-content: center;
  flex-wrap: wrap;
}
.modal-choice-buttons .btn { min-width: 90px; font-size: 1.1rem; padding: .7rem 1.4rem; }

.modal-player-list {
  display: flex;
  flex-direction: column;
  gap: .45rem;
}
.modal-player-btn {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .55rem .9rem;
  text-align: left;
  cursor: pointer;
  font-size: .95rem;
  font-weight: 600;
  transition: background .15s, border-color .15s;
}
.modal-player-btn:hover { background: var(--bg-card); border-color: var(--purple-light); }
.modal-player-btn.current { border-color: var(--gold); color: var(--gold-light); }
.modal-player-btn:disabled { opacity: .35; cursor: not-allowed; }

/* ─── Event Modal ────────────────────────────────────────────────────────── */
.event-number-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: .45rem;
}
.event-number-btn {
  background: var(--bg-card2);
  border: 2px solid var(--gold);
  color: var(--gold-light);
  border-radius: var(--radius-sm);
  font-size: 1.1rem;
  font-weight: 800;
  padding: .6rem .3rem;
  cursor: pointer;
  transition: all .15s;
}
.event-number-btn:hover { background: var(--gold); color: var(--bg); }

.event-info { display: flex; flex-direction: column; gap: .6rem; }
.event-info-title { color: var(--gold-light); font-weight: 700; }
.event-info-text  { color: var(--text); font-size: .93rem; background: var(--bg-card2); padding: .6rem .8rem; border-radius: var(--radius-sm); border-left: 3px solid var(--gold); }

/* ─── Secret Options ─────────────────────────────────────────────────────── */
.secret-options-list {
  display: flex;
  flex-direction: column;
  gap: .4rem;
  max-height: 55vh;
  overflow-y: auto;
}
.secret-option-btn {
  background: var(--bg-card2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  padding: .55rem .9rem;
  text-align: left;
  cursor: pointer;
  font-size: .9rem;
  transition: background .15s, border-color .15s;
}
.secret-option-btn:hover { background: var(--purple); border-color: var(--purple-light); }
.secret-option-btn span.secret-type-tag {
  display: inline-block;
  background: var(--purple);
  color: #fff;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 700;
  padding: .1rem .35rem;
  margin-right: .4rem;
}
.secret-option-btn.type-infinite span.secret-type-tag { background: var(--purple); }
.secret-option-btn.type-flip     span.secret-type-tag { background: var(--orange); }

/* ─── Round End Modal ────────────────────────────────────────────────────── */
.round-end-icon { font-size: 3.5rem; }
.modal-round-end .modal-title { font-size: 1.3rem; color: var(--red-light); }

/* ─── Screen Shake ───────────────────────────────────────────────────────── */
@keyframes screenShake {
  0%, 100% { transform: translateX(0); }
  15%  { transform: translateX(-8px) rotate(-.5deg); }
  30%  { transform: translateX(8px)  rotate(.5deg); }
  45%  { transform: translateX(-6px); }
  60%  { transform: translateX(6px); }
  75%  { transform: translateX(-3px); }
  90%  { transform: translateX(3px); }
}
body.shake { animation: screenShake .55s ease; }

/* ─── Scrollbar ──────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--purple); }

/* ─── Responsive (mobile, narrow screens) ───────────────────────────────── */
@media (max-width: 640px) {
  .player-sidebar { width: 130px; min-width: 130px; }
  .card-buttons-grid { grid-template-columns: repeat(3, 1fr); }
  .action-buttons-section { grid-template-columns: repeat(2, 1fr); }
  .gauge-value { font-size: 3rem; }
  .gauge-display { width: 140px; height: 140px; }
}
