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

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  min-height: 100vh;
  padding: 20px;
  color: #333;
}

.app-container {
  max-width: 1200px;
  margin: 0 auto;
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
  overflow: hidden;
}

header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 30px;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: 1200px;
  margin: 0 auto;
}

.header-title {
  text-align: center;
  flex: 1;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 15px;
}

.language-switcher {
  display: flex;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 6px;
  padding: 2px;
  gap: 2px;
}

.lang-btn {
  padding: 6px 12px;
  background: transparent;
  color: white;
  border: none;
  border-radius: 4px;
  font-size: 0.9em;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.lang-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}

.lang-btn.active {
  background: rgba(255, 255, 255, 0.3);
  font-weight: 600;
}

header h1 {
  font-size: 2.5em;
  margin-bottom: 10px;
}

header p {
  font-size: 1.1em;
  opacity: 0.9;
}

.btn-start-over {
  padding: 10px 20px;
  background: rgba(255, 255, 255, 0.2);
  color: white;
  border: 2px solid white;
  border-radius: 6px;
  font-size: 1em;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
  white-space: nowrap;
}

.btn-start-over:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: translateY(-2px);
}

main {
  padding: 30px;
}

/* Upload Section */
.upload-section {
  text-align: center;
  padding: 40px 20px;
}

#image-upload {
  display: none;
}

.upload-label {
  display: inline-block;
  padding: 15px 30px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.1em;
  transition: transform 0.2s, box-shadow 0.2s;
}

.upload-label:hover {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

#upload-preview {
  margin-top: 20px;
}

#upload-preview img {
  max-width: 100%;
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Grid Selector */
.grid-selector-container {
  padding: 20px;
}

.grid-selector-container h2 {
  margin-bottom: 10px;
  color: #333;
}

.info-note {
  background: #e3f2fd;
  padding: 12px;
  border-radius: 6px;
  margin-bottom: 15px;
  color: #1976d2;
  font-size: 0.95em;
}

.warning-note {
  color: #f57c00;
  font-size: 0.85em;
  margin-top: 5px;
  font-weight: 500;
}

.grid-options {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 20px;
  margin-top: 20px;
}

.grid-option {
  border: 2px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
  cursor: pointer;
  transition: all 0.3s;
  background: white;
}

.grid-option:hover {
  border-color: #667eea;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.grid-option.selected {
  border-color: #667eea;
  background: #f0f4ff;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.grid-option h3 {
  color: #667eea;
  margin-bottom: 10px;
}

.grid-option p {
  margin: 5px 0;
  color: #666;
}

.dice-count {
  font-weight: bold;
  color: #333;
}

.preview-canvas-container {
  margin-top: 15px;
  display: flex;
  justify-content: center;
  background: #f5f5f5;
  border-radius: 4px;
  padding: 10px;
}

.preview-canvas {
  max-width: 100%;
  height: auto;
}

/* Preview Section */
.preview-section {
  padding: 20px;
}

.preview-section h2 {
  margin-bottom: 20px;
  color: #333;
}

.preview-stats {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.preview-stats p {
  margin: 8px 0;
}

.face-counts,
.rotation-counts {
  margin-top: 15px;
}

.face-counts h3,
.rotation-counts h3 {
  font-size: 1em;
  margin-bottom: 8px;
  color: #555;
}

.face-counts ul,
.rotation-counts ul {
  list-style: none;
  padding-left: 20px;
}

.face-counts li,
.rotation-counts li {
  margin: 4px 0;
  color: #666;
}

.preview-canvas-wrapper {
  margin: 20px 0;
  text-align: center;
  background: #f5f5f5;
  padding: 20px;
  border-radius: 8px;
  overflow-x: auto;
}

#preview-canvas {
  max-width: 100%;
  height: auto;
}

/* Buttons */
.btn-primary,
.btn-secondary {
  padding: 12px 24px;
  border: none;
  border-radius: 6px;
  font-size: 1em;
  cursor: pointer;
  transition: all 0.2s;
  font-weight: 500;
}

.btn-primary {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
}

.btn-primary:hover:not(:disabled) {
  transform: translateY(-2px);
  box-shadow: 0 5px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

.btn-secondary:hover:not(:disabled) {
  background: #d0d0d0;
}

.btn-secondary:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Build Mode */
.build-mode {
  padding: 20px;
}

.build-header {
  margin-bottom: 30px;
}

.build-header h2 {
  margin-bottom: 15px;
  color: #333;
}

.progress-bar {
  position: relative;
  width: 100%;
  height: 30px;
  background: #e0e0e0;
  border-radius: 15px;
  overflow: hidden;
  margin-bottom: 10px;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  transition: width 0.3s;
}

.progress-text {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-weight: bold;
  color: #333;
  z-index: 1;
}

.row-info {
  text-align: center;
  font-size: 1.1em;
  color: #666;
  margin-top: 10px;
}

.current-row-section {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
  margin-bottom: 20px;
}

.current-row-section h3 {
  margin-bottom: 15px;
  color: #333;
}

.row-canvas-wrapper {
  text-align: center;
  background: white;
  padding: 15px;
  border-radius: 6px;
  margin-bottom: 15px;
  overflow-x: auto;
}

#row-canvas {
  max-width: 100%;
  height: auto;
}

.row-instructions {
  margin-top: 15px;
}

.row-instructions p {
  margin-bottom: 10px;
  font-weight: 500;
}

#row-dice-list {
  list-style: none;
  padding-left: 20px;
}

#row-dice-list li {
  margin: 5px 0;
  color: #666;
}

.build-controls {
  display: flex;
  gap: 10px;
  justify-content: center;
  margin-bottom: 30px;
  flex-wrap: wrap;
}

.completed-rows {
  background: #f8f9fa;
  padding: 20px;
  border-radius: 8px;
}

.completed-rows h3 {
  margin-bottom: 15px;
  color: #333;
}

.completed-list {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.completed-badge {
  display: inline-block;
  padding: 6px 12px;
  background: #667eea;
  color: white;
  border-radius: 4px;
  font-size: 0.9em;
}

/* Responsive */
@media (max-width: 768px) {
  header h1 {
    font-size: 2em;
  }
  
  .grid-options {
    grid-template-columns: 1fr;
  }
  
  .build-controls {
    flex-direction: column;
  }
  
  .build-controls button {
    width: 100%;
  }
}
