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

:root {
  --bg-primary: #e8e4dc;
  --bg-secondary: #f5f3ef;
  --bg-tertiary: #d8d4cc;
  --text-primary: #1a1a1a;
  --text-secondary: #4a4a4a;
  --text-muted: #7a7a7a;
  --accent: #2d5a9e;
  --accent-hover: #1e4580;
  --border-color: #c4c0b8;
  --shadow-soft: 0 2px 8px rgba(0,0,0,0.08);
  --shadow-medium: 0 4px 16px rgba(0,0,0,0.12);
}

html, body {
  font-family: 'IBM Plex Mono', monospace;
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
}

body {
  background-image: 
    radial-gradient(circle at 20% 50%, rgba(45, 90, 158, 0.03) 0%, transparent 50%),
    radial-gradient(circle at 80% 20%, rgba(45, 90, 158, 0.02) 0%, transparent 40%),
    repeating-linear-gradient(
      0deg,
      transparent,
      transparent 2px,
      rgba(0,0,0,0.01) 2px,
      rgba(0,0,0,0.01) 4px
    );
}

.app-container {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  text-align: center;
  padding: 24px 16px;
  background: linear-gradient(180deg, var(--bg-secondary) 0%, var(--bg-primary) 100%);
  border-bottom: 1px solid var(--border-color);
}

.app-title {
  font-family: 'VT323', monospace;
  font-size: clamp(24px, 5vw, 36px);
  font-weight: 400;
  letter-spacing: 1px;
  color: var(--text-primary);
  text-shadow: 2px 2px 0 rgba(255,255,255,0.8);
}

.app-subtitle {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 6px;
  letter-spacing: 0.5px;
}

.main-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0;
}

@media (min-width: 900px) {
  .main-content {
    flex-direction: row;
  }
}

.preview-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 32px 16px;
  background: repeating-conic-gradient(
    var(--bg-tertiary) 0deg 90deg,
    var(--bg-primary) 90deg 180deg
  ) 0 0/16px 16px;
  min-height: 400px;
  position: relative;
}

.preview-label {
  position: absolute;
  top: 16px;
  left: 16px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--text-muted);
  background: var(--bg-secondary);
  padding: 4px 8px;
  border-radius: 2px;
}

.calculator-wrapper {
  transition: all 0.2s ease;
}

.calculator {
  overflow: hidden;
  transition: all 0.2s ease;
}

.title-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 8px;
  font-size: 12px;
  font-weight: 600;
  height: 22px;
}

.close-box {
  width: 12px;
  height: 12px;
  border: 1px solid currentColor;
  opacity: 0.6;
}

.title-text {
  font-family: 'Chicago', 'VT323', system-ui;
  font-size: 12px;
  font-weight: 400;
}

.title-spacer {
  width: 12px;
}

.display {
  text-align: right;
  font-weight: 400;
  overflow: hidden;
  white-space: nowrap;
  border-top: 1px solid rgba(0,0,0,0.1);
  border-bottom: 1px solid rgba(0,0,0,0.1);
}

.button-grid {
  background: inherit;
}

.calc-button {
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.1s ease;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

.calc-button:hover {
  filter: brightness(calc(1 - var(--hover-intensity, 0.1)));
}

.calc-button:active {
  transform: translateY(calc(var(--active-effect, 2) * 1px));
  filter: brightness(0.85);
}

.controls-panel {
  width: 100%;
  max-width: 100%;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  max-height: 60vh;
}

@media (min-width: 900px) {
  .controls-panel {
    width: 340px;
    max-width: 340px;
    border-top: none;
    border-left: 1px solid var(--border-color);
    max-height: none;
  }
}

.controls-header {
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.controls-header h2 {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.controls-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.control-section {
  margin-bottom: 4px;
}

.section-header {
  width: 100%;
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: var(--bg-tertiary);
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  transition: background 0.15s ease;
}

.section-header:hover {
  background: var(--border-color);
}

.section-arrow {
  font-size: 10px;
  color: var(--text-muted);
}

.section-content {
  padding: 12px;
  background: var(--bg-primary);
  border-radius: 0 0 4px 4px;
  margin-top: 2px;
}

.control-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
}

.control-row:last-child {
  margin-bottom: 0;
}

.control-label {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.control-input-group {
  display: flex;
  align-items: center;
  gap: 8px;
}

.control-slider {
  flex: 1;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-color);
  border-radius: 3px;
  outline: none;
}

.control-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  background: var(--accent);
  border-radius: 50%;
  cursor: pointer;
  transition: transform 0.1s ease;
}

.control-slider::-webkit-slider-thumb:hover {
  transform: scale(1.15);
}

.control-value {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 40px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}

.control-value.color-hex {
  font-size: 10px;
  text-transform: uppercase;
}

.control-color {
  width: 32px;
  height: 24px;
  padding: 0;
  border: 2px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  background: none;
}

.control-color::-webkit-color-swatch-wrapper {
  padding: 0;
}

.control-color::-webkit-color-swatch {
  border: none;
  border-radius: 2px;
}

.control-select {
  flex: 1;
  padding: 6px 8px;
  font-family: inherit;
  font-size: 12px;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  background: var(--bg-secondary);
  color: var(--text-primary);
  cursor: pointer;
}

.presets-section {
  padding: 12px;
  border-top: 1px solid var(--border-color);
  background: var(--bg-tertiary);
}

.presets-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-muted);
  margin-bottom: 10px;
}

.presets-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.preset-button {
  padding: 8px 4px;
  font-family: inherit;
  font-size: 10px;
  font-weight: 500;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
  color: var(--text-primary);
}

.preset-button:hover {
  background: var(--bg-primary);
  border-color: var(--accent);
}

.actions-section {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border-color);
}

.action-button {
  padding: 10px 8px;
  font-family: inherit;
  font-size: 11px;
  font-weight: 500;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.action-button.randomize {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
}

.action-button.export {
  background: linear-gradient(135deg, #4facfe 0%, #00f2fe 100%);
  color: white;
}

.action-button.import {
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.action-button:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow-soft);
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0,0,0,0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  z-index: 1000;
  animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.modal {
  background: var(--bg-secondary);
  border-radius: 12px;
  width: 100%;
  max-width: 500px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-medium);
  animation: slideUp 0.2s ease;
}

@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  font-size: 24px;
  color: var(--text-muted);
  cursor: pointer;
  border-radius: 4px;
  transition: all 0.15s ease;
}

.modal-close:hover {
  background: var(--bg-tertiary);
  color: var(--text-primary);
}

.json-preview {
  flex: 1;
  overflow: auto;
  padding: 16px 20px;
  font-family: 'IBM Plex Mono', monospace;
  font-size: 11px;
  line-height: 1.5;
  background: #1e1e2e;
  color: #cdd6f4;
  margin: 0;
  white-space: pre-wrap;
  word-break: break-all;
}

.modal-actions {
  display: flex;
  gap: 8px;
  padding: 16px 20px;
  border-top: 1px solid var(--border-color);
}

.modal-button {
  flex: 1;
  padding: 10px 16px;
  font-family: inherit;
  font-size: 13px;
  font-weight: 500;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.15s ease;
}

.modal-button:hover {
  background: var(--bg-tertiary);
}

.modal-button.primary {
  background: var(--accent);
  border-color: var(--accent);
  color: white;
}

.modal-button.primary:hover {
  background: var(--accent-hover);
}

.easter-egg {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0,0,0,0.9);
  color: white;
  padding: 24px 32px;
  border-radius: 8px;
  text-align: center;
  animation: easterEggPop 0.3s ease;
  z-index: 100;
}

@keyframes easterEggPop {
  0% { transform: translate(-50%, -50%) scale(0.5); opacity: 0; }
  50% { transform: translate(-50%, -50%) scale(1.1); }
  100% { transform: translate(-50%, -50%) scale(1); opacity: 1; }
}

.easter-egg-icon {
  font-size: 48px;
  display: block;
  margin-bottom: 12px;
}

.easter-egg-content p {
  font-family: 'VT323', monospace;
  font-size: 18px;
  font-style: italic;
  margin-bottom: 8px;
}

.easter-egg-content small {
  font-size: 12px;
  opacity: 0.7;
}

.app-footer {
  text-align: center;
  padding: 16px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--bg-tertiary);
  border-top: 1px solid var(--border-color);
}

.app-footer a {
  color: var(--accent);
  text-decoration: none;
}

.app-footer a:hover {
  text-decoration: underline;
}

/* Scrollbar styling */
.controls-scroll::-webkit-scrollbar {
  width: 6px;
}

.controls-scroll::-webkit-scrollbar-track {
  background: var(--bg-tertiary);
}

.controls-scroll::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 3px;
}

.controls-scroll::-webkit-scrollbar-thumb:hover {
  background: var(--text-muted);
}