﻿:root {
  --dice-canvas-height: 600px;
}

.dice-panel {
  max-width: 1100px;
  margin: 0 auto;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}

.card-header h3 {
  margin: 0 0 6px;
  font-size: 1.25rem;
}

.card-header p {
  margin: 0;
  color: var(--muted);
}

.chip {
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  font-weight: 700;
  color: var(--muted);
  font-size: 0.85rem;
}

.controls {
  display: grid;
  grid-template-columns: 1fr;
  gap: 24px;
    padding: 24px;
}

.field {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.field-label {
  font-weight: 600;
  color: var(--muted);
  font-size: 0.95rem;
  text-align: center;
}

.count-controls {
  display: flex;
  justify-content: center;
  gap: 8px;
}

.count-row {
  display: flex;
  align-items: center;
  gap: 16px;
  background: var(--surface-2);
  padding: 6px;
  border-radius: 99px;
  border: 1px solid var(--border);
}

.count-value {
  font-size: 1.25rem;
  font-weight: 700;
  min-width: 28px;
  text-align: center;
}

#count-decrease, #count-increase {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  padding: 0;
  font-size: 1.2rem;
  font-weight: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  cursor: pointer;
  transition: all 0.2s;
}

#count-decrease:hover, #count-increase:hover {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
  transform: scale(1.05);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#count-decrease.is-disabled, #count-increase.is-disabled {
  opacity: 0.4;
  cursor: not-allowed;
  pointer-events: none;
  transform: none;
  box-shadow: none;
}

.option-grid {
  display: grid;
  grid-template-columns: repeat(6, 1fr); /* 6 columns for dice types */
  gap: 12px;
}

.option-grid.is-disabled {
  opacity: 0.5;
  pointer-events: none;
}

.option-chip {
  position: relative;
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px;
  background: var(--surface-1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-weight: 600;
  color: var(--muted);
  transition: all 0.2s ease;
  overflow: hidden;
  width: 100%; /* Fill the grid cell */
}

.option-chip input {
  position: absolute;
  opacity: 0;
  width: 0;
  height: 0;
}

.option-chip input:disabled ~ * {
  opacity: 0.5;
  pointer-events: none;
}

.option-chip .dice-icon {
  width: 36px;
  height: 36px;
  object-fit: contain;
  opacity: 0.6;
  transition: opacity 0.2s ease;
  filter: grayscale(100%);
}

.option-chip:has(input:checked) {
  border-color: var(--primary);
  background: var(--surface-2); 
  color: var(--primary);
}

[data-theme="dark"] .option-chip:has(input:checked) {
  background: rgba(59, 130, 246, 0.15);
}
[data-theme="light"] .option-chip:has(input:checked) {
  background: rgba(37, 99, 235, 0.1);
}

.option-chip:has(input:checked) .dice-icon {
  opacity: 1;
  filter: none;
  transform: scale(1.1);
}

.option-chip:hover {
  background: var(--surface-2);
  border-color: var(--text-2);
}

.dice-stage {
  width: 100%;
  height: var(--dice-canvas-height);
  background: var(--surface-2);
  border-radius: 12px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 10px rgba(0,0,0,0.1);
  margin-bottom: 20px;
}

.dice-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.action-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 24px;
}

.main-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

.results-container {
  background: var(--surface-2);
  border-radius: 16px;
  padding: 20px;
  display: flex;
  flex-direction: column;
  align-items: center; /* Center content */
  gap: 16px;
  gap: 20px;
  border: 1px solid var(--border);
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.05);
}

.result-summary {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border);
  width: 100%;
}

.summary-label {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
}

.summary-value {
  font-size: 3rem;
  font-weight: 800;
  color: var(--primary);
  line-height: 1;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  font-variant-numeric: tabular-nums;
}

.result-details {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  width: 100%;
  max-width: calc(6 * 90px + 5 * 12px); /* Exactly 6 items per row: 600px */
  margin: 0 auto; /* Center the container */
  justify-content: center; /* Center the items */
}

.result-chip {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 12px 8px;
  width: 90px; /* Increased from 70px */
  height: 90px; /* Increased from 70px */
  flex-shrink: 0; /* Prevent shrinking */
  flex-grow: 0; /* Prevent growing */
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 5px rgba(0,0,0,0.05);
  animation: popIn 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275) backwards;
}

.result-chip:hover {
  transform: translateY(-3px);
  border-color: var(--primary);
  box-shadow: 0 5px 15px rgba(var(--primary-rgb, 59, 130, 246), 0.15);
}

.result-chip__label {
  font-size: 0.7rem;
  color: var(--muted);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.result-chip__value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text);
  line-height: 1.2;
}

.empty-state {
  grid-column: 1 / -1;
  text-align: center;
  padding: 20px;
  color: var(--muted);
  font-style: italic;
  font-size: 0.95rem;
  background: rgba(0,0,0,0.05);
  border-radius: 8px;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.8) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Result layout is always vertical - media query removed */

/* ===================== Options Collapsible ===================== */
.options-collapsible {
  position: relative;
  z-index: 10;
  background: transparent;
  border: none;
  box-shadow: none;
  border-radius: 0;
  overflow: visible;
}

.options-collapsible:not(.collapsed) {
  border: none;
  box-shadow: none;
  overflow: visible;
}

.options-collapsible.collapsed {
  background: transparent;
  overflow: visible;
}

.options-toggle {
  width: 100%;
  padding: 12px 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  line-height: 1;
  border-radius: 12px;
  border: none;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  
  transition: all 0.4s cubic-bezier(0.25, 0.8, 0.25, 1);
  position: relative;
  z-index: 20;
}

/* Collapsed State: Prominent Action Button */
.options-collapsible.collapsed .options-toggle {
  background: linear-gradient(135deg, #6366f1, #a855f7); /* Indigo -> Purple */
  color: white;
  box-shadow: 0 10px 25px -5px rgba(99, 102, 241, 0.4);
  margin-bottom: 0;
}

.options-collapsible.collapsed .options-toggle:hover {
  transform: translateY(-3px);
  box-shadow: 0 15px 35px -5px rgba(99, 102, 241, 0.5);
  filter: brightness(1.1);
}

/* Expanded State: Subtle Control Button */
.options-collapsible:not(.collapsed) .options-toggle {
  background: var(--surface-2);
  color: var(--muted);
  border: 1px solid var(--border);
  box-shadow: 0 2px 8px rgba(0,0,0,0.05);
  margin-bottom: 24px; /* Distinct spacing from content */
}

.options-collapsible:not(.collapsed) .options-toggle:hover {
  background: var(--surface-3);
  color: var(--text);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.options-toggle i {
  font-size: 1.1em;
  transition: transform 0.5s cubic-bezier(0.34, 1.56, 0.64, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  vertical-align: middle;
  flex-shrink: 0;
}

.options-collapsible.collapsed .options-toggle i {
  transform: rotate(180deg);
}

.options-content {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 12px 32px -4px rgba(0, 0, 0, 0.12); /* Clean floating shadow */
  overflow: hidden;
  
  /* Initial State (Hidden) */
  max-height: 0;
  opacity: 0;
  transform: translateY(-12px) scale(0.98);
  transform-origin: top center;
  
  transition: 
    max-height 0.6s cubic-bezier(0.22, 1, 0.36, 1),
    opacity 0.4s ease,
    transform 0.4s cubic-bezier(0.22, 1, 0.36, 1);
}

.options-content:not(.collapsed) {
  max-height: 2500px;
  opacity: 1;
  transform: translateY(0) scale(1);
}

.options-content.collapsed {
  max-height: 0;
  opacity: 0;
}

.options-content .option-grid {
  padding: 16px;
}


.status-bar {
  text-align: center;
  height: 1.5em;
  color: var(--muted);
  font-size: 0.9rem;
  font-weight: 500;
}

@media (max-width: 768px) {
  :root {
    --dice-canvas-height: 400px;
  }
  
  .main-actions {
    flex-direction: column;
  }
  
  .main-actions button {
    width: 100%;
  }

  .controls {
    grid-template-columns: 1fr;
  }
  
  /* Responsive grid for mobile */
  .result-details {
    grid-template-columns: repeat(3, 70px); /* 3 columns on mobile */
  }

  /* 모바일 주사위 타입 선택 2개씩 배치 */
  .options-content .option-grid:has(.option-chip) {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
  }

  .field-label {
    grid-column: 1 / -1;
  }
}
