:root {
  --bg: #fafafa;
  --fg: #1a1a1a;
  --primary: #0066cc;
  --danger: #d32f2f;
  --warn: #f57c00;
  --ok: #388e3c;
  --border: #e0e0e0;
  --shadow: rgba(0, 0, 0, 0.1);
}

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

body {
  font-family: system-ui, -apple-system, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--fg);
  line-height: 1.6;
  padding: 1rem;
}

header {
  text-align: center;
  margin-bottom: 2rem;
}

header h1 {
  font-size: 2rem;
  margin-bottom: 0.25rem;
}

header .sub {
  color: #666;
  font-size: 0.95rem;
}

main.grid {
  max-width: 1200px;
  margin: 0 auto;
  display: grid;
  gap: 1.5rem;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
}

section {
  background: white;
  padding: 1.5rem;
  border-radius: 8px;
  box-shadow: 0 2px 8px var(--shadow);
}

section.play {
  grid-column: 1 / -1;
}

h2 {
  font-size: 1.25rem;
  margin-bottom: 1rem;
  border-bottom: 2px solid var(--primary);
  padding-bottom: 0.5rem;
}

h3 {
  font-size: 1.1rem;
  margin: 1.5rem 0 0.75rem;
}

.row {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-bottom: 0.75rem;
}

input[type="text"] {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 1rem;
}

select {
  padding: 0.5rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 0.95rem;
  background: white;
  cursor: pointer;
  min-width: 200px;
}

textarea {
  width: 100%;
  min-height: 150px;
  padding: 0.75rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.9rem;
  resize: vertical;
  margin-bottom: 0.5rem;
}

button {
  padding: 0.5rem 1rem;
  border: none;
  border-radius: 4px;
  font-size: 0.95rem;
  cursor: pointer;
  background: #e0e0e0;
  color: var(--fg);
  transition: all 0.2s;
}

button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px var(--shadow);
}

button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

button.primary { background: var(--primary); color: white; }
button.danger { background: var(--danger); color: white; }
button.warn { background: var(--warn); color: white; }
button.ok { background: var(--ok); color: white; }
button.big { font-size: 1.5rem; padding: 0.75rem 1.5rem; }

.list {
  margin: 0.5rem 0 0 1.5rem;
  padding: 0;
}

.list li {
  padding: 0.25rem 0;
}

.hidden { display: none !important; }

#status {
  background: #e3f2fd;
  border-left: 4px solid var(--primary);
  padding: 0.75rem;
  margin-bottom: 1rem;
  border-radius: 4px;
}

.turn {
  background: #fff8e1;
  padding: 1.5rem;
  border-radius: 8px;
  margin: 1rem 0;
}

.turn h3 {
  margin-top: 0;
  font-size: 1.5rem;
  text-align: center;
}

.result {
  background: white;
  border: 2px solid var(--primary);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1rem 0;
  min-height: 80px;
  font-size: 1.2rem;
  text-align: center;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  position: relative;
  overflow: hidden;
  transition: all 0.3s ease;
}

.result.rolling {
  animation: shake 0.5s infinite;
}

.result.celebrating {
  animation: pulse 0.6s ease-out;
  box-shadow: 0 0 30px rgba(255, 215, 0, 0.6);
  border-color: #ffd700;
}

@keyframes shake {
  0%, 100% { transform: translateX(0) rotate(0deg); }
  25% { transform: translateX(-5px) rotate(-2deg); }
  75% { transform: translateX(5px) rotate(2deg); }
}

@keyframes pulse {
  0% { transform: scale(1); }
  50% { transform: scale(1.05); }
  100% { transform: scale(1); }
}

/* Celebration rays */
.result::before {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(
    circle,
    rgba(255, 215, 0, 0.3) 0%,
    rgba(255, 215, 0, 0.2) 20%,
    transparent 50%
  );
  transform: translate(-50%, -50%) scale(0);
  opacity: 0;
  transition: all 0.6s ease-out;
}

.result.celebrating::before {
  transform: translate(-50%, -50%) scale(1);
  opacity: 1;
  animation: rays 0.6s ease-out;
}

@keyframes rays {
  0% {
    transform: translate(-50%, -50%) scale(0) rotate(0deg);
    opacity: 0;
  }
  50% {
    opacity: 1;
  }
  100% {
    transform: translate(-50%, -50%) scale(1.5) rotate(180deg);
    opacity: 0;
  }
}

/* Sparkles */
.result.celebrating::after {
  content: '✨';
  position: absolute;
  top: -20px;
  right: -20px;
  font-size: 2rem;
  animation: sparkle 0.6s ease-out;
}

@keyframes sparkle {
  0% {
    transform: scale(0) rotate(0deg);
    opacity: 0;
  }
  50% {
    transform: scale(1.2) rotate(180deg);
    opacity: 1;
  }
  100% {
    transform: scale(0) rotate(360deg);
    opacity: 0;
  }
}

#vetoHint {
  display: block;
  text-align: center;
  color: #666;
  margin-top: 0.5rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

table th {
  background: #f5f5f5;
  padding: 0.75rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--border);
}

table td {
  padding: 0.75rem;
  border-bottom: 1px solid var(--border);
}

table tbody tr:hover {
  background: #fafafa;
}

.file input[type="file"] {
  display: none;
}

.file {
  display: inline-flex;
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  background: #e0e0e0;
  font-size: 0.95rem;
  transition: all 0.2s;
}

.file:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px var(--shadow);
}

details {
  margin-top: 1rem;
}

summary {
  cursor: pointer;
  padding: 0.5rem;
  background: #f5f5f5;
  border-radius: 4px;
  user-select: none;
}

summary:hover {
  background: #eeeeee;
}

.menu-img {
  max-width: 100%;
  margin-top: 1rem;
  border-radius: 4px;
  box-shadow: 0 2px 8px var(--shadow);
}

.fullwidth {
  grid-column: 1 / -1;
}

.status-badge {
  display: inline-block;
  padding: 0.5rem 1rem;
  border-radius: 20px;
  background: #ff9800;
  color: white;
  font-size: 0.85rem;
  font-weight: 600;
  margin-top: 0.5rem;
}

.room-info {
  display: inline-block;
  margin-top: 1rem;
  padding: 0.75rem 1.5rem;
  background: white;
  border-radius: 8px;
  box-shadow: 0 2px 6px var(--shadow);
}

.room-info strong {
  color: var(--primary);
  font-size: 1.2rem;
  letter-spacing: 0.1em;
}

.home-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
  gap: 2rem;
  max-width: 800px;
  margin: 2rem auto;
  padding: 0 1rem;
}

.option-card {
  background: white;
  padding: 2rem;
  border-radius: 12px;
  box-shadow: 0 4px 12px var(--shadow);
  text-align: center;
  transition: transform 0.2s;
}

.option-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 6px 16px var(--shadow);
}

.option-card h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.5rem;
}

.option-card p {
  color: #666;
  margin-bottom: 1.5rem;
}

.option-card input {
  width: 100%;
  margin-bottom: 1rem;
}

.join-form {
  display: flex;
  gap: 1rem;
  max-width: 500px;
  margin: 0 auto;
  padding: 2rem;
}

.join-form input {
  flex: 1;
}

.control-group {
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.control-group:last-child {
  border-bottom: none;
}

.control-group h3 {
  margin-top: 0;
  font-size: 1rem;
  color: #666;
}

#adminPlayersList {
  list-style: none;
  margin: 1rem 0;
  padding: 0;
}

#adminPlayersList li {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem;
  margin: 0.25rem 0;
  background: #f5f5f5;
  border-radius: 4px;
}

#menuStatus {
  margin-top: 0.5rem;
  font-weight: 500;
}

button.small {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}

.info-box {
  background: #e3f2fd;
  border-left: 4px solid var(--primary);
  padding: 1.5rem;
  border-radius: 4px;
  text-align: center;
}

.info-box h3 {
  margin-top: 0;
}

.centered {
  justify-content: center;
}

footer {
  text-align: center;
  margin-top: 3rem;
  color: #999;
}

/* Full-screen overlay animations */
.overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.overlay.hidden {
  opacity: 0;
  display: none;
}

.dice-overlay {
  background: rgba(9, 13, 24, 0.85);
  pointer-events: all;
}

.dice-overlay-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
  text-align: center;
  color: #f5f5f5;
  animation: zoomBounce 0.6s ease-out;
}

.dice-container svg {
  width: min(70vw, 260px);
  height: min(70vw, 260px);
  aspect-ratio: 1 / 1;
  filter: drop-shadow(0 12px 25px rgba(0, 0, 0, 0.45));
}

.dice-container .facet {
  transition: fill 0.15s ease, opacity 0.15s ease;
}

.dice-status {
  font-size: 1.25rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #cbd5f5;
}

@keyframes zoomBounce {
  0% {
    transform: scale(0);
    opacity: 0;
  }
  50% {
    transform: scale(1.2);
  }
  70% {
    transform: scale(0.9);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@media (max-width: 640px) {
  main.grid {
    grid-template-columns: 1fr;
  }
  
  header h1 {
    font-size: 1.5rem;
  }

  .home-options {
    grid-template-columns: 1fr;
    padding: 0;
  }

  .option-card {
    width: 100%;
  }

  .row {
    flex-direction: column;
  }

  button.big {
    font-size: 1.2rem;
  }
}
