*, 
*::before, 
*::after {
  box-sizing: border-box;
}

html, 
body {
  margin: 0;
  padding: 0;
  height: 100%;
  background: #0e0f10;
  color: #f5f5f5;
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

body {
  -webkit-font-smoothing: antialiased;
}

.app {
  height: 100vh;
  max-height: 100vh;
  display: flex;
  flex-direction: column;
  background: radial-gradient(circle at top left, #272b2f 0, #050607 55%, #000 100%);
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left);
}

/* Top bar */

.top-bar {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.4rem 0.6rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  background: rgba(5, 6, 7, 0.9);
  backdrop-filter: blur(14px);
}

.brand {
  font-weight: 700;
  letter-spacing: 0.12em;
  font-size: 0.7rem;
  text-transform: uppercase;
  color: #fdfdfd;
  padding-right: 0.4rem;
}

.file-btn, 
.icon-btn {
  position: relative;
  border: none;
  border-radius: 999px;
  padding: 0.28rem 0.7rem;
  font-size: 0.68rem;
  background: #f24822;
  color: #fff;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.25rem;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease, opacity 0.15s ease;
  white-space: nowrap;
}

.file-btn:hover:not(:disabled), 
.icon-btn:hover:not(:disabled), 
.effect-btn:hover:not(:disabled) {
  background: #ff5c35;
}

.file-btn:active:not(:disabled), 
.icon-btn:active:not(:disabled), 
.effect-btn:active:not(:disabled) {
  transform: translateY(1px) scale(0.98);
}

.file-btn input {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.icon-btn {
  background: #22252a;
  color: #ddd;
}

.icon-btn:disabled, 
.file-btn:disabled {
  opacity: 0.4;
  cursor: default;
}

/* Layout */

.main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  padding: 0.4rem 0.6rem 0.6rem;
  gap: 0.4rem;
}

/* Canvas */

.canvas-wrap {
  flex: 1;
  min-height: 0;
  border-radius: 0.6rem;
  border: 1px solid rgba(255, 255, 255, 0.07);
  background: radial-gradient(circle at center, #1d2126 0, #060708 55%, #000 100%);
  box-shadow: 0 14px 30px rgba(0, 0, 0, 0.8);
  overflow: hidden;
  position: relative;
}

canvas {
  width: 100%;
  height: 100%;
  display: block;
  image-rendering: auto;
}

.canvas-overlay {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: rgba(255, 255, 255, 0.25);
  pointer-events: none;
}

/* Controls */

.controls {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.controls-row {
  display: flex;
  gap: 0.3rem;
}

.effect-btn {
  flex: 1;
  border: none;
  border-radius: 999px;
  padding: 0.35rem 0.4rem;
  font-size: 0.68rem;
  background: #171a1f;
  color: #f5f5f5;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.05s ease, opacity 0.15s ease;
  white-space: nowrap;
}

.effect-btn:disabled {
  opacity: 0.25;
  cursor: default;
}

.effect-btn.havoc {
  background: linear-gradient(130deg, #f24822, #ffb000, #ff2d55);
  background-size: 160% 160%;
  animation: havocPulse 3s ease-in-out infinite;
  color: #050608;
  font-weight: 700;
}

.effect-btn.havoc:disabled {
  animation: none;
}

@keyframes havocPulse {
  0% {
    background-position: 0% 50%;
  }
  50% {
    background-position: 100% 50%;
  }
  100% {
    background-position: 0% 50%;
  }
}

/* Slider row */

.controls-row-slider {
  align-items: center;
}

.slider-label {
  font-size: 0.66rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.7;
  flex: 0 0 auto;
}

#intensitySlider {
  -webkit-appearance: none;
  appearance: none;
  flex: 1;
  height: 0.4rem;
  border-radius: 999px;
  background: #15171c;
  outline: none;
}

#intensitySlider:disabled {
  opacity: 0.3;
}

#intensitySlider::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f24822;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 4px rgba(242, 72, 34, 0.3);
  cursor: pointer;
}

#intensitySlider::-moz-range-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #f24822;
  border: 2px solid #ffffff;
  box-shadow: 0 0 0 4px rgba(242, 72, 34, 0.3);
  cursor: pointer;
}

/* Small screens tweaks */

@media (max-width: 480px) {
  .top-bar {
    gap: 0.3rem;
  }

  .brand {
    display: none;
  }

  .slider-label {
    font-size: 0.6rem;
  }

  #intensitySlider {
    height: 0.32rem;
  }
}