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

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: #1a1a2e;
  color: #fff;
  min-height: 100vh;
}

.hidden { display: none !important; }

/* Login Screen */
#login-screen {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
}

.login-box {
  background: rgba(255,255,255,0.05);
  padding: 3rem;
  border-radius: 16px;
  text-align: center;
  border: 1px solid rgba(255,255,255,0.1);
}

.login-box h1 {
  font-size: 2.5rem;
  margin-bottom: 0.5rem;
}

.login-box p {
  color: #888;
  margin-bottom: 2rem;
}

.login-box input {
  width: 100%;
  padding: 1rem;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 1rem;
  margin-bottom: 1.5rem;
}

.login-box input::placeholder {
  color: #666;
}

.role-buttons {
  display: flex;
  gap: 1rem;
}

.role-buttons button {
  flex: 1;
  padding: 1rem;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  cursor: pointer;
  transition: transform 0.2s;
}

.role-buttons button:first-child {
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  color: #fff;
}

.role-buttons button:last-child {
  background: linear-gradient(135deg, #3498db, #2980b9);
  color: #fff;
}

.role-buttons button:hover {
  transform: scale(1.05);
}

/* Game Screen */
#game-screen {
  display: grid;
  grid-template-columns: 1fr 350px;
  height: 100vh;
  gap: 0;
}

/* Canvas Panel */
#canvas-panel {
  background: #0f0f1a;
  display: flex;
  flex-direction: column;
  position: relative;
}

#image-display {
  flex: 1;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
}

#image-display img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

#image-display .placeholder {
  color: #444;
  font-size: 1.5rem;
}

#dm-image-controls {
  padding: 1rem;
  background: rgba(0,0,0,0.3);
  border-top: 1px solid #333;
}

#image-gallery {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
  max-height: 120px;
  overflow-y: auto;
}

#image-gallery img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}

#image-gallery img:hover {
  opacity: 1;
}

/* Side Panel */
#side-panel {
  background: #16213e;
  display: flex;
  flex-direction: column;
  border-left: 1px solid #333;
}

#dice-roller {
  padding: 1rem;
  border-bottom: 1px solid #333;
}

#dice-roller h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
}

#dice-input {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.75rem;
}

#dice-input span {
  font-size: 1.5rem;
  color: #888;
}

#dice-input input {
  width: 60px;
  padding: 0.5rem;
  border: none;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 1.2rem;
  text-align: center;
}

#dice-input button {
  padding: 0.5rem 1.5rem;
  border: none;
  border-radius: 4px;
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
}

#quick-rolls {
  display: flex;
  gap: 0.5rem;
}

#quick-rolls button {
  flex: 1;
  padding: 0.5rem;
  border: none;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
  font-size: 0.9rem;
}

#quick-rolls button:hover {
  background: rgba(255,255,255,0.2);
}

/* Dice Log */
#dice-log {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
}

#dice-log h3 {
  margin-bottom: 0.75rem;
  font-size: 1rem;
  position: sticky;
  top: 0;
  background: #16213e;
}

#log-entries {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.log-entry {
  background: rgba(255,255,255,0.05);
  padding: 0.75rem;
  border-radius: 8px;
  border-left: 3px solid #9b59b6;
}

.log-entry.critical {
  background: rgba(76, 175, 80, 0.2);
  border-left-color: #4CAF50;
}

.log-entry.fumble {
  background: rgba(244, 67, 54, 0.2);
  border-left-color: #f44336;
}

.log-entry .player {
  font-weight: bold;
  font-size: 0.85rem;
  color: #888;
  margin-bottom: 0.25rem;
}

.log-entry .dice {
  font-size: 1.1rem;
  margin-bottom: 0.25rem;
}

.log-entry .dice .middle {
  color: #ffd700;
  font-weight: bold;
  text-shadow: 0 0 8px rgba(255, 215, 0, 0.5);
}

.log-entry .dice .other {
  color: #666;
}

.log-entry .total {
  font-size: 1.3rem;
  font-weight: bold;
}

.log-entry .status {
  font-weight: bold;
  margin-top: 0.25rem;
  padding: 0.25rem 0.5rem;
  border-radius: 4px;
  display: inline-block;
}

.log-entry.critical .status {
  background: #4CAF50;
}

.log-entry.fumble .status {
  background: #f44336;
}

.log-entry.chat-message {
  border-left-color: #3498db;
}

.log-entry.chat-message .message {
  font-style: italic;
}

/* Chat Box */
#chat-box {
  padding: 1rem;
  border-top: 1px solid #333;
}

#chat-input {
  width: 100%;
  padding: 0.75rem;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  font-size: 0.95rem;
}

/* Sheet Toggle */
#sheet-toggle {
  position: fixed;
  bottom: 1rem;
  left: 1rem;
  padding: 1rem 1.5rem;
  border: none;
  border-radius: 8px;
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0,0,0,0.3);
}

/* Sheet Modal */
#sheet-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 200;
}

#sheet-content {
  background: #1a1a2e;
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  overflow-y: auto;
  border-radius: 16px;
  padding: 2rem;
  position: relative;
}

.close-btn {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  color: #fff;
  font-size: 1.5rem;
  cursor: pointer;
}

#form-toggle {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

#form-toggle button {
  flex: 1;
  padding: 1rem;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}

#form-toggle #btn-humana.active {
  background: linear-gradient(135deg, #9b59b6, #8e44ad);
}

#form-toggle #btn-extasis.active {
  background: linear-gradient(135deg, #3498db, #2980b9);
}

/* Character Sheet */
#character-sheet {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1rem;
}

.sheet-section {
  background: rgba(255,255,255,0.05);
  border-radius: 8px;
  overflow: hidden;
}

.sheet-section h4 {
  background: var(--section-color, #9b59b6);
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.sheet-section .stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.5rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.sheet-section .stat-row:last-child {
  border-bottom: none;
}

.sheet-section .stat-row label {
  color: #aaa;
}

.sheet-section .stat-row input {
  width: 60px;
  padding: 0.25rem;
  border: none;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  color: #fff;
  text-align: center;
}

/* Checkboxes for drama/extasis/health */
.checkbox-row {
  display: flex;
  gap: 4px;
  padding: 0.5rem 1rem;
  flex-wrap: wrap;
}

.checkbox-row input[type="checkbox"] {
  width: 24px;
  height: 24px;
  cursor: pointer;
  accent-color: #9b59b6;
}

/* Form-specific colors */
.forma-humana { --section-color: #9b59b6; }
.forma-extasis { --section-color: #3498db; }

/* Responsive */
@media (max-width: 768px) {
  #game-screen {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr 1fr;
  }
  
  #side-panel {
    border-left: none;
    border-top: 1px solid #333;
  }
}
