:root {
  --gold: #c9a84c;
  --gold-light: #e8d08a;
  --gold-dark: #8b6914;
  --parchment: #f5e6c8;
  --parchment-dark: #d4b896;
  --ink: #1a1008;
  --shadow: #0a0603;
  --ember: #ff6b1a;
  --ember-dark: #cc4400;
  --mithril: #a8bcc8;
  --elvish: #6e9e7e;
}

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

body {
  min-height: 100vh;
  background: #0d0a05;
  font-family: 'EB Garamond', Georgia, serif;
  overflow-x: hidden;
  position: relative;
  cursor: default;
}

/* Starfield background */
.stars {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}
.stars::before, .stars::after {
  content: '';
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 10% 20%, rgba(200,180,120,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 30% 60%, rgba(200,180,120,0.4) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 50% 10%, rgba(200,180,120,0.8) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 40%, rgba(200,180,120,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 85% 75%, rgba(200,180,120,0.6) 0%, transparent 100%),
    radial-gradient(1px 1px at 15% 85%, rgba(200,180,120,0.4) 0%, transparent 100%),
    radial-gradient(2px 2px at 60% 30%, rgba(200,180,120,0.9) 0%, transparent 100%),
    radial-gradient(1px 1px at 40% 80%, rgba(200,180,120,0.5) 0%, transparent 100%),
    radial-gradient(1px 1px at 90% 15%, rgba(200,180,120,0.7) 0%, transparent 100%),
    radial-gradient(1.5px 1.5px at 25% 45%, rgba(200,180,120,0.6) 0%, transparent 100%);
}

/* Mountain silhouette */
.mountains {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 35vh;
  z-index: 1;
  pointer-events: none;
  background:
    radial-gradient(ellipse 200% 100% at 50% 110%, rgba(13,10,5,0.9) 0%, transparent 70%);
}
.mountains svg {
  width: 100%;
  height: 100%;
  position: absolute;
  bottom: 0;
}

/* Vignette */
.vignette {
  position: fixed;
  inset: 0;
  z-index: 2;
  pointer-events: none;
  background: radial-gradient(ellipse 80% 80% at 50% 50%, transparent 40%, rgba(0,0,0,0.7) 100%);
}

/* Main container */
.container {
  position: relative;
  z-index: 10;
  max-width: 860px;
  margin: 0 auto;
  padding: 2rem 1.5rem 6rem;
}

/* Header */
.header {
  text-align: center;
  padding: 2.5rem 0 2rem;
  position: relative;
}

.eye-of-sauron {
  width: 70px;
  height: 70px;
  margin: 0 auto 1.2rem;
  position: relative;
  animation: eyePulse 4s ease-in-out infinite;
}

@keyframes eyePulse {
  0%, 100% { filter: drop-shadow(0 0 8px var(--gold)) drop-shadow(0 0 20px rgba(201,168,76,0.4)); transform: scale(1); }
  50% { filter: drop-shadow(0 0 14px var(--gold-light)) drop-shadow(0 0 35px rgba(201,168,76,0.7)); transform: scale(1.05); }
}

.gandalf-icon {
  font-size: 3.5rem;
  line-height: 1;
  animation: staffGlow 3s ease-in-out infinite alternate;
  display: block;
  margin-bottom: 0.5rem;
}
@keyframes staffGlow {
  from { text-shadow: 0 0 10px var(--gold), 0 0 20px rgba(201,168,76,0.3); }
  to { text-shadow: 0 0 20px var(--gold-light), 0 0 40px rgba(201,168,76,0.6), 0 0 60px rgba(201,168,76,0.2); }
}

.title-main {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(1.4rem, 4vw, 2.2rem);
  color: var(--gold-light);
  letter-spacing: 0.08em;
  text-shadow: 0 0 20px var(--gold), 0 2px 4px var(--shadow);
  line-height: 1.3;
  margin-bottom: 0.3rem;
}

.title-sub {
  font-family: 'Cinzel', serif;
  font-size: clamp(0.75rem, 2vw, 0.95rem);
  color: var(--gold-dark);
  letter-spacing: 0.25em;
  text-transform: uppercase;
  margin-bottom: 0.8rem;
}

.elvish-text {
  font-family: 'EB Garamond', serif;
  font-style: italic;
  font-size: 0.85rem;
  color: rgba(201,168,76,0.4);
  letter-spacing: 0.15em;
}

/* Divider */
.divider {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin: 1.5rem 0;
  opacity: 0.6;
}
.divider-line {
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, transparent, var(--gold-dark), transparent);
}
.divider-rune {
  color: var(--gold);
  font-size: 1.2rem;
  font-family: 'Cinzel', serif;
}

/* Nav tabs */
.tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 4px;
  padding: 0.35rem;
}
.tab {
  flex: 1;
  padding: 0.6rem 1rem;
  font-family: 'Cinzel', serif;
  font-size: 0.78rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold-dark);
  border: none;
  background: transparent;
  border-radius: 3px;
  cursor: pointer;
  transition: all 0.3s;
}
.tab.active {
  background: linear-gradient(135deg, rgba(201,168,76,0.2), rgba(201,168,76,0.08));
  color: var(--gold-light);
  border: 1px solid rgba(201,168,76,0.4);
  text-shadow: 0 0 10px var(--gold);
}
.tab:hover:not(.active) {
  color: var(--gold);
  background: rgba(201,168,76,0.05);
}

/* Panels */
.panel { display: none; }
.panel.active { display: block; }

/* Tirage Panel */
.fellowship-card {
  background: linear-gradient(135deg, rgba(20,15,5,0.95), rgba(10,8,3,0.98));
  border: 1px solid rgba(201,168,76,0.3);
  border-radius: 6px;
  padding: 2rem;
  box-shadow: 0 0 40px rgba(0,0,0,0.8), inset 0 0 60px rgba(0,0,0,0.3);
  position: relative;
  overflow: hidden;
}
.fellowship-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    repeating-linear-gradient(
      45deg,
      transparent,
      transparent 100px,
      rgba(201,168,76,0.01) 100px,
      rgba(201,168,76,0.01) 101px
    );
  pointer-events: none;
}

/* Corner ornaments */
.corner {
  position: absolute;
  width: 28px;
  height: 28px;
  opacity: 0.5;
}
.corner svg { width: 100%; height: 100%; }
.corner.tl { top: 6px; left: 6px; }
.corner.tr { top: 6px; right: 6px; transform: scaleX(-1); }
.corner.bl { bottom: 6px; left: 6px; transform: scaleY(-1); }
.corner.br { bottom: 6px; right: 6px; transform: scale(-1); }

/* Result display */
.result-area {
  text-align: center;
  padding: 2rem 1rem;
  min-height: 180px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1rem;
}

.result-label {
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  letter-spacing: 0.3em;
  text-transform: uppercase;
  color: var(--gold-dark);
}

.result-name {
  font-family: 'Cinzel Decorative', serif;
  font-size: clamp(2rem, 7vw, 3.5rem);
  color: var(--gold-light);
  text-shadow: 0 0 30px var(--gold), 0 0 60px rgba(201,168,76,0.3);
  line-height: 1.1;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.6s ease, transform 0.6s ease;
  min-height: 1.3em;
}
.result-name.revealed {
  opacity: 1;
  transform: translateY(0);
}

.result-sub {
  font-style: italic;
  color: var(--elvish);
  font-size: 0.95rem;
  opacity: 0;
  transition: opacity 0.6s ease 0.4s;
}
.result-sub.revealed { opacity: 1; }

/* Spinning rune during draw */
.spinning-rune {
  font-size: 3rem;
  animation: runeSpinFast 0.15s linear infinite;
  display: none;
  color: var(--gold);
  text-shadow: 0 0 20px var(--gold);
}
.spinning-rune.active { display: block; }
@keyframes runeSpinFast {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* Draw button */
.btn-draw {
  display: block;
  width: 100%;
  padding: 1rem 2rem;
  font-family: 'Cinzel', serif;
  font-size: 1rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--ink);
  background: linear-gradient(135deg, var(--gold), var(--gold-dark) 50%, var(--gold));
  background-size: 200% 100%;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.4s;
  box-shadow: 0 4px 20px rgba(201,168,76,0.3), inset 0 1px 0 rgba(255,255,255,0.2);
  position: relative;
  overflow: hidden;
  margin-top: 1rem;
}
.btn-draw::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, transparent 30%, rgba(255,255,255,0.15) 50%, transparent 70%);
  transform: translateX(-100%);
  transition: transform 0.4s;
}
.btn-draw:hover {
  background-position: 100% 0;
  box-shadow: 0 6px 30px rgba(201,168,76,0.5), inset 0 1px 0 rgba(255,255,255,0.3);
  transform: translateY(-1px);
}
.btn-draw:hover::after { transform: translateX(100%); }
.btn-draw:active { transform: translateY(0); }
.btn-draw:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

/* Confirmation button */
.btn-confirm {
  display: block;
  width: 100%;
  padding: 0.8rem 1.5rem;
  font-family: 'Cinzel', serif;
  font-size: 0.9rem;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--parchment);
  background: linear-gradient(135deg, rgba(110,158,126,0.3), rgba(110,158,126,0.15));
  border: 1px solid rgba(110,158,126,0.5);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  margin-top: 0.8rem;
}
.btn-confirm:hover {
  background: linear-gradient(135deg, rgba(110,158,126,0.4), rgba(110,158,126,0.25));
  border-color: rgba(110,158,126,0.7);
  box-shadow: 0 4px 20px rgba(110,158,126,0.3);
}

/* Participants panel */
.participants-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 0.6rem;
  margin-bottom: 1.5rem;
}

.participant-chip {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(201,168,76,0.06);
  border: 1px solid rgba(201,168,76,0.2);
  border-radius: 4px;
  padding: 0.5rem 0.7rem;
  font-family: 'Cinzel', serif;
  font-size: 0.8rem;
  color: var(--parchment);
  transition: all 0.3s;
  animation: fadeSlideIn 0.3s ease;
  cursor: pointer;
  user-select: none;
}
@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(-4px); }
  to { opacity: 1; transform: translateY(0); }
}
.participant-chip:hover { border-color: rgba(201,168,76,0.5); background: rgba(201,168,76,0.1); }

/* Active state — glowing gold */
.participant-chip.is-active {
  border-color: rgba(201,168,76,0.55);
  background: rgba(201,168,76,0.1);
  box-shadow: 0 0 10px rgba(201,168,76,0.12);
}
.participant-chip.is-active .chip-name {
  color: var(--gold-light);
  text-shadow: 0 0 8px rgba(201,168,76,0.4);
}
.participant-chip.is-active .chip-toggle { color: var(--gold); }

/* Inactive state — dimmed */
.participant-chip.is-inactive {
  border-color: rgba(201,168,76,0.08);
  background: rgba(0,0,0,0.2);
  opacity: 0.45;
}
.participant-chip.is-inactive .chip-name {
  color: rgba(201,168,76,0.35);
  text-decoration: line-through;
  text-decoration-color: rgba(201,168,76,0.25);
}
.participant-chip.is-inactive .chip-toggle { color: rgba(201,168,76,0.2); }

.chip-name {
  flex: 1;
  transition: color 0.3s, text-shadow 0.3s;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chip-toggle {
  background: none;
  border: none;
  font-size: 0.9rem;
  cursor: pointer;
  padding: 0 0.3rem;
  transition: color 0.2s, transform 0.2s;
  line-height: 1;
  color: var(--gold);
  flex-shrink: 0;
}
.chip-toggle:hover { transform: scale(1.2); }

.chip-delete {
  background: none;
  border: none;
  color: rgba(201,168,76,0.2);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 0 0 0 0.2rem;
  transition: color 0.2s;
  flex-shrink: 0;
}
.chip-delete:hover { color: var(--ember); }

.active-count {
  font-size: 0.72rem;
  color: var(--elvish);
  font-family: 'EB Garamond', serif;
  font-style: italic;
  margin-left: 0.5rem;
  font-weight: normal;
  opacity: 0.8;
}

.add-participant {
  display: flex;
  gap: 0.6rem;
  margin-top: 0.5rem;
}
.input-name {
  flex: 1;
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 4px;
  padding: 0.65rem 1rem;
  font-family: 'EB Garamond', serif;
  font-size: 1rem;
  color: var(--parchment);
  outline: none;
  transition: border-color 0.3s;
}
.input-name::placeholder { color: rgba(201,168,76,0.25); font-style: italic; }
.input-name:focus { border-color: rgba(201,168,76,0.6); }

.btn-add {
  padding: 0.65rem 1.2rem;
  font-family: 'Cinzel', serif;
  font-size: 0.75rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--gold);
  background: rgba(201,168,76,0.1);
  border: 1px solid rgba(201,168,76,0.35);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  white-space: nowrap;
}
.btn-add:hover {
  background: rgba(201,168,76,0.2);
  border-color: rgba(201,168,76,0.6);
  box-shadow: 0 0 12px rgba(201,168,76,0.2);
}

.section-label {
  font-family: 'Cinzel', serif;
  font-size: 0.72rem;
  letter-spacing: 0.25em;
  text-transform: uppercase;
  color: var(--gold-dark);
  margin-bottom: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.8rem;
}
.section-label::after {
  content: '';
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, rgba(201,168,76,0.2), transparent);
}

/* Log panel */
.log-list {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-height: 420px;
  overflow-y: auto;
  padding-right: 0.3rem;
}
.log-list::-webkit-scrollbar { width: 4px; }
.log-list::-webkit-scrollbar-track { background: transparent; }
.log-list::-webkit-scrollbar-thumb { background: rgba(201,168,76,0.3); border-radius: 4px; }

.log-entry {
  background: rgba(201,168,76,0.04);
  border: 1px solid rgba(201,168,76,0.12);
  border-left: 2px solid var(--gold-dark);
  border-radius: 4px;
  padding: 0.7rem 1rem;
  display: flex;
  align-items: center;
  gap: 1rem;
  animation: fadeSlideIn 0.3s ease;
  transition: background 0.2s;
}
.log-entry:hover { background: rgba(201,168,76,0.08); }
.log-index {
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  color: var(--gold-dark);
  min-width: 1.5rem;
  text-align: right;
  opacity: 0.6;
}
.log-name {
  font-family: 'Cinzel', serif;
  font-size: 0.95rem;
  color: var(--gold-light);
  flex: 1;
}
.log-stats {
  font-size: 0.75rem;
  color: var(--elvish);
  font-style: italic;
  margin-left: 0.5rem;
}
.log-datetime {
  font-size: 0.8rem;
  color: rgba(201,168,76,0.4);
  font-style: italic;
  text-align: right;
  line-height: 1.4;
}
.log-date { display: block; }
.log-time { display: block; color: rgba(201,168,76,0.6); }

.empty-log {
  text-align: center;
  padding: 3rem 1rem;
  color: rgba(201,168,76,0.25);
  font-style: italic;
  font-size: 0.95rem;
}

.btn-clear-log {
  margin-top: 1rem;
  padding: 0.5rem 1rem;
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: rgba(201,168,76,0.3);
  background: transparent;
  border: 1px solid rgba(201,168,76,0.1);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.3s;
  display: block;
  width: 100%;
}
.btn-clear-log:hover { color: var(--ember); border-color: rgba(255,107,26,0.3); }

/* Gandalf quote */
.gandalf-quote {
  margin-top: 2rem;
  text-align: center;
  font-style: italic;
  color: rgba(201,168,76,0.2);
  font-size: 0.85rem;
  line-height: 1.7;
}
.gandalf-quote strong {
  display: block;
  color: rgba(201,168,76,0.15);
  font-family: 'Cinzel', serif;
  font-size: 0.7rem;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  margin-top: 0.3rem;
  font-style: normal;
}

/* Flash animation for reveal */
@keyframes flashReveal {
  0% { text-shadow: 0 0 0px var(--gold); }
  30% { text-shadow: 0 0 60px var(--gold-light), 0 0 100px rgba(201,168,76,0.8), 0 0 150px rgba(201,168,76,0.4); }
  100% { text-shadow: 0 0 30px var(--gold), 0 0 60px rgba(201,168,76,0.3); }
}
.result-name.flash { animation: flashReveal 0.8s ease-out forwards; }

/* Tooltip warning */
.warning-text {
  text-align: center;
  font-size: 0.8rem;
  color: rgba(255,107,26,0.5);
  font-style: italic;
  margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 500px) {
  .container { padding: 1rem 1rem 5rem; }
  .tabs { flex-direction: column; }
  .fellowship-card { padding: 1.2rem; }
}
