:root {
  --bg-primary: #0f172a;
  --bg-secondary: #1e293b;
  --bg-card: rgba(30, 41, 59, 0.9);
  --border-color: rgba(255, 255, 255, 0.12);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-color: #6366f1;
  --accent-hover: #4f46e5;
  --accent-glow: rgba(99, 102, 241, 0.4);
  --danger-color: #ef4444;
  --danger-hover: #dc2626;
  --success-color: #10b981;
  --pointer-color: #f43f5e;
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --shadow-main: 0 20px 40px -15px rgba(0, 0, 0, 0.6);
  --font-main: 'Outfit', sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100%;
  min-height: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-main);
  background: radial-gradient(circle at 50% 15%, #1f1f3d 0%, #0c0f17 100%);
  background-attachment: fixed;
  color: var(--text-primary);
  display: flex;
  flex-direction: column;
}

.app-container {
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
  padding: 14px 20px 28px;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

/* Header */
.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 16px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 20px;
  gap: 12px;
}

.logo-area {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon {
  width: 44px;
  height: 44px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
  user-select: none;
  flex-shrink: 0;
}

.logo-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

.app-header h1 {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  background: linear-gradient(135deg, #ffffff 40%, #a5b4fc 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 0.85rem;
  margin-top: 1px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-color);
  color: var(--text-primary);
  width: 42px;
  height: 42px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  cursor: pointer;
  touch-action: manipulation;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.icon-btn img {
  width: 20px;
  height: 20px;
  object-fit: contain;
  display: block;
  pointer-events: none;
}

.btn-icon-inline {
  width: 16px;
  height: 16px;
  object-fit: contain;
  vertical-align: middle;
  pointer-events: none;
}

.btn-large .btn-icon-inline {
  width: 22px;
  height: 22px;
}

.icon-btn:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.3);
}

.icon-btn:active {
  transform: scale(0.95);
}

/* Main Grid Layout */
.main-content {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 32px;
  align-items: center;
  flex: 1;
  width: 100%;
}

/* When side panel is hidden -> Wheel takes full screen */
body.panel-hidden .main-content {
  grid-template-columns: 1fr;
}

body.panel-hidden .sidebar-section {
  display: none !important;
}

/* Wheel Section */
.wheel-section {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 18px;
  width: 100%;
  height: 100%;
}

.wheel-wrapper {
  position: relative;
  width: min(76vh, 700px, 90vw);
  height: min(76vh, 700px, 90vw);
  aspect-ratio: 1 / 1;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), height 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Expanded larger wheel when panel is hidden or fullscreen */
body.panel-hidden .wheel-wrapper {
  width: min(84vh, 860px, 94vw);
  height: min(84vh, 860px, 94vw);
}

.canvas-holder {
  position: relative;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  box-shadow: 0 0 50px rgba(0, 0, 0, 0.65), 0 0 25px rgba(99, 102, 241, 0.2);
  touch-action: manipulation;
  cursor: pointer;
}

#wheel-canvas {
  width: 100%;
  height: 100%;
  display: block;
  border-radius: 50%;
}

/* Pointer at top */
.wheel-pointer-container {
  position: absolute;
  top: -16px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 25;
  pointer-events: none;
}

.wheel-pointer {
  width: 34px;
  height: 44px;
  background: linear-gradient(180deg, #f43f5e 0%, #be123c 100%);
  clip-path: polygon(0% 0%, 100% 0%, 50% 100%);
  filter: drop-shadow(0 4px 10px rgba(0, 0, 0, 0.7));
  transform-origin: 50% 0%;
  transition: transform 0.08s ease-out;
}

.wheel-pointer.deflect {
  transform: rotate(-18deg);
}

/* Center Spin Button */
.center-spin-button {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, #ffffff 0%, #e2e8f0 45%, #94a3b8 100%);
  border: 5px solid #0f172a;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.55), inset 0 2px 4px rgba(255, 255, 255, 0.9);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 20;
  touch-action: manipulation;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  user-select: none;
}

.center-spin-button span {
  font-weight: 800;
  font-size: 0.95rem;
  color: #0f172a;
  letter-spacing: 0.5px;
}

.center-spin-button:hover {
  transform: translate(-50%, -50%) scale(1.06);
  box-shadow: 0 8px 24px rgba(99, 102, 241, 0.5), inset 0 2px 4px rgba(255, 255, 255, 0.9);
}

.center-spin-button:active {
  transform: translate(-50%, -50%) scale(0.93);
}

/* Controls */
.wheel-controls {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 100%;
}

.center-spin-button, .canvas-holder, #main-spin-btn {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
}

.discreet-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: transparent;
  transition: background-color 0.2s, box-shadow 0.2s;
}

.discreet-indicator.active-2 {
  background: #38bdf8;
  box-shadow: 0 0 6px #38bdf8;
}

.discreet-indicator.active-3 {
  background: #f43f5e;
  box-shadow: 0 0 6px #f43f5e;
}

.discreet-indicator.active-4 {
  background: #a855f7;
  box-shadow: 0 0 6px #a855f7;
}

/* Buttons */
.btn {
  font-family: var(--font-main);
  font-size: 0.95rem;
  font-weight: 600;
  padding: 10px 18px;
  border-radius: var(--radius-sm);
  border: none;
  cursor: pointer;
  touch-action: manipulation;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.btn-primary {
  background: linear-gradient(135deg, var(--accent-color) 0%, #4338ca 100%);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--accent-glow);
}

.btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #3730a3 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 20px var(--accent-glow);
}

.btn-primary:active {
  transform: translateY(1px) scale(0.98);
}

.btn-large {
  font-size: 1.15rem;
  padding: 14px 40px;
  border-radius: 40px;
  letter-spacing: 0.5px;
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
}

.btn-ghost:hover {
  background: rgba(239, 68, 68, 0.15);
  color: #fca5a5;
}

.btn-outline {
  background: transparent;
  border: 1px solid var(--border-color);
  color: var(--text-secondary);
}

.btn-outline:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-primary);
}

.btn-danger {
  background: var(--danger-color);
  color: #ffffff;
}

.btn-danger:hover {
  background: var(--danger-hover);
}

.btn-sm {
  font-size: 0.82rem;
  padding: 6px 12px;
}

/* Sidebar Section */
.sidebar-section {
  width: 100%;
}

.panel-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 20px;
  box-shadow: var(--shadow-main);
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}

.panel-header h2 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-primary);
}

.panel-header-buttons {
  display: flex;
  gap: 6px;
}

.panel-hint {
  font-size: 0.84rem;
  color: var(--text-secondary);
}

#items-textarea {
  width: 100%;
  font-family: inherit;
  font-size: 0.95rem;
  line-height: 1.5;
  color: var(--text-primary);
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 12px;
  resize: vertical;
  min-height: 240px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

#items-textarea:focus {
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.panel-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 4px;
}

/* Modal Overlay */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 1;
  transition: opacity 0.25s ease;
}

.modal-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.modal-card {
  background: var(--bg-secondary);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.7);
  animation: modalPop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

@keyframes modalPop {
  0% { transform: scale(0.92); opacity: 0; }
  100% { transform: scale(1); opacity: 1; }
}

/* Winner Modal */
.winner-card {
  text-align: center;
  padding: 34px 24px;
}

.winner-confetti-badge {
  display: inline-block;
  background: rgba(99, 102, 241, 0.2);
  color: #a5b4fc;
  border: 1px solid rgba(99, 102, 241, 0.4);
  font-size: 0.9rem;
  font-weight: 700;
  padding: 6px 16px;
  border-radius: 20px;
  margin-bottom: 14px;
}

.winner-title {
  font-size: 2.2rem;
  font-weight: 800;
  color: #f8fafc;
  word-break: break-word;
  margin-bottom: 10px;
  background: linear-gradient(135deg, #fef08a 0%, #fbbf24 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.winner-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
  margin-bottom: 24px;
}

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

/* Settings Modal */
.settings-card {
  max-width: 500px;
  padding: 24px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

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

.modal-header h2 {
  font-size: 1.25rem;
  font-weight: 700;
}

.close-x-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.8rem;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: var(--radius-sm);
}

.close-x-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.1);
}

.settings-body {
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 20px;
  margin-bottom: 20px;
}

.setting-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.setting-group label {
  font-size: 0.95rem;
  font-weight: 600;
  display: flex;
  justify-content: space-between;
}

.setting-desc {
  font-size: 0.8rem;
  color: var(--text-muted);
}

input[type="range"] {
  width: 100%;
  accent-color: var(--accent-color);
  cursor: pointer;
}

/* Confetti Overlay */
#confetti-canvas {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  pointer-events: none;
  z-index: 99;
}

/* ========================================================
   📱 RESPONSYWNOŚĆ NA TELEFONACH I TABLETACH
   ======================================================== */
@media (max-width: 900px) {
  .app-container {
    padding: 10px 12px 24px;
  }

  .app-header {
    margin-bottom: 14px;
    padding-bottom: 12px;
  }

  .logo-icon {
    font-size: 1.5rem;
    padding: 4px 8px;
  }

  .app-header h1 {
    font-size: 1.25rem;
  }

  .subtitle {
    display: none; /* Hide subtitle on phone to save precious vertical space */
  }

  .icon-btn {
    width: 38px;
    height: 38px;
    font-size: 1.05rem;
  }

  .main-content {
    grid-template-columns: 1fr;
    gap: 20px;
  }

  .wheel-section {
    gap: 14px;
  }

  .wheel-wrapper {
    width: min(88vw, 420px);
    height: min(88vw, 420px);
  }

  .center-spin-button {
    width: 72px;
    height: 72px;
  }

  .center-spin-button span {
    font-size: 0.82rem;
  }

  .btn-large {
    width: 90%;
    max-width: 340px;
    font-size: 1.05rem;
    padding: 12px 24px;
  }

  .sidebar-section {
    max-width: 540px;
    margin: 0 auto;
  }

  #items-textarea {
    min-height: 180px;
  }

  .winner-card {
    padding: 26px 18px;
  }

  .winner-title {
    font-size: 1.8rem;
  }

  .modal-actions {
    flex-direction: column;
  }
}

/* Very small phones (e.g. 360px) */
@media (max-width: 400px) {
  .wheel-wrapper {
    width: 86vw;
    height: 86vw;
  }

  .center-spin-button {
    width: 64px;
    height: 64px;
  }

  .center-spin-button span {
    font-size: 0.74rem;
  }
}
