:root {
  --bg-dark: #070a1a;
  --bg-panel: rgba(16, 22, 45, 0.7);
  --border-light: rgba(77, 136, 255, 0.3);
  --neon-blue: #00f0ff;
  --neon-blue-dim: rgba(0, 240, 255, 0.2);
  --neon-purple: #b520ff;
  --neon-red: #ff2a2a;
  --text-main: #e2f1ff;
  --text-dim: #889ec4;
  --font-title: 'Orbitron', sans-serif;
  --font-body: 'Roboto', sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
  background-color: var(--bg-dark);
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(0, 240, 255, 0.05) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(181, 32, 255, 0.05) 0%, transparent 40%);
  color: var(--text-main);
  font-family: var(--font-body);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 20px;
}

.app-container {
  width: 100%;
  max-width: 1200px;
  height: 90vh;
  display: flex;
  flex-direction: column;
  background: var(--bg-panel);
  border: 1px solid var(--border-light);
  border-radius: 16px;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 0 30px rgba(0, 240, 255, 0.1), inset 0 0 10px rgba(77, 136, 255, 0.05);
  overflow: hidden;
}

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

h1 { font-family: var(--font-title); font-size: 1.8rem; letter-spacing: 2px; }
.neon-text.blue { color: #fff; text-shadow: 0 0 5px var(--neon-blue), 0 0 10px var(--neon-blue), 0 0 20px var(--neon-blue); }

.tabs { display: flex; gap: 15px; }
.tab-btn {
  background: transparent; color: var(--text-dim); border: 1px solid transparent;
  font-family: var(--font-title); font-size: 0.9rem; padding: 10px 20px;
  cursor: pointer; border-radius: 8px; transition: all 0.3s;
}
.tab-btn:hover { color: var(--text-main); }
.tab-btn.active {
  color: var(--neon-blue); border-color: var(--neon-blue); background: var(--neon-blue-dim);
  box-shadow: inset 0 0 10px var(--neon-blue-dim);
}

main { flex: 1; position: relative; overflow: hidden; }

.module {
  position: absolute; top: 0; left: 0; width: 100%; height: 100%;
  display: flex; opacity: 0; pointer-events: none; transition: opacity 0.4s ease;
  padding: 20px; gap: 20px;
}
.module.active { opacity: 1; pointer-events: all; position: relative; }

/* Penetration Module */
#penetration { flex-direction: column; }

.simulation-area {
  flex: 1; display: flex; position: relative; background: rgba(0,0,0,0.4);
  border-radius: 12px; border: 1px solid var(--border-light); overflow: hidden;
}

.emitter {
  width: 100px; height: 100%; background: linear-gradient(90deg, #101525, #1e2640);
  border-right: 2px solid #334466; display: flex; align-items: center; justify-content: flex-end; z-index: 10;
}
.emitter-core {
  width: 20px; height: 60px; background: #fff; border-radius: 10px 0 0 10px; box-shadow: 0 0 15px var(--neon-blue);
}

.radiation-canvas-container { flex: 1; position: relative; }
canvas { width: 100%; height: 100%; display: block; }

.barrier {
  position: absolute; top: 10%; right: 20%; width: 30px; height: 80%;
  border-radius: 4px; transition: all 0.3s ease;
}
.barrier.none { display: none; }
.barrier.paper { background: #e0e0e0; box-shadow: -2px 0 5px rgba(255,255,255,0.2); width: 15px; }
.barrier.aluminum { background: linear-gradient(90deg, #bbbbbb, #ffffff, #aaaaaa); box-shadow: -2px 0 10px rgba(255,255,255,0.4); width: 30px; }
.barrier.lead { background: #333; width: 70px; box-shadow: -5px 0 15px rgba(0,0,0,0.8); border: 2px solid #111; }
.barrier.concrete { background: #777; width: 100px; box-shadow: -5px 0 15px rgba(0,0,0,0.5); border: 3px solid #555; background-image: radial-gradient(#666 10%, transparent 10%); background-size: 5px 5px;}

.controls-panel {
  display: flex; gap: 15px; background: rgba(0,0,0,0.2); border-radius: 12px;
  padding: 15px 20px; border: 1px solid var(--border-light);
}
.controls-panel.horizontal { 
  flex-direction: row; 
  justify-content: space-between; 
  align-items: center; 
  flex-wrap: wrap;
}

.control-group { flex: 1; display: flex; flex-direction: column; gap: 15px; }
h3 { font-family: var(--font-title); font-size: 1rem; color: var(--text-dim); }

/* Toggles */
.toggle-switch { display: flex; align-items: center; cursor: pointer; gap: 15px; }
.toggle-switch input { display: none; }
.slider {
  width: 40px; height: 20px; background: #2a3454; border-radius: 20px; position: relative; transition: 0.3s;
}
.slider::before {
  content: ""; position: absolute; width: 16px; height: 16px; border-radius: 50%;
  background: var(--text-dim); top: 2px; left: 2px; transition: 0.3s;
}
.toggle-switch input:checked + .slider::before { transform: translateX(20px); background: #fff; }

.toggle-switch.neon-red input:checked + .slider { background: var(--neon-red); box-shadow: 0 0 10px var(--neon-red); }
.toggle-switch.neon-blue input:checked + .slider { background: var(--neon-blue); box-shadow: 0 0 10px var(--neon-blue); }
.toggle-switch.neon-purple input:checked + .slider { background: var(--neon-purple); box-shadow: 0 0 10px var(--neon-purple); }

.material-selector { display: flex; gap: 10px; flex-wrap: wrap; }
.material-btn {
  padding: 8px 15px; background: transparent; border: 1px solid var(--border-light);
  color: var(--text-dim); border-radius: 6px; cursor: pointer; transition: 0.3s; font-family: var(--font-body);
}
.material-btn:hover { border-color: var(--neon-blue); color: #fff; }
.material-btn.active { background: var(--neon-blue-dim); border-color: var(--neon-blue); color: var(--neon-blue); text-shadow: 0 0 5px var(--neon-blue); }

/* Decay Module Layout */
#decay .row-layout { flex: 1; display: flex; flex-direction: row; gap: 20px; min-height: 0; }

.theory-panel {
  flex: 0.6; background: rgba(0,0,0,0.3); padding: 15px; border-radius: 12px;
  border: 1px solid var(--border-light); display: flex; flex-direction: column; gap: 10px;
  font-size: 0.85rem; min-width: 180px;
}
.formula-box {
  background: rgba(0, 240, 255, 0.05); border: 1px dashed var(--neon-blue);
  padding: 10px; border-radius: 8px; text-align: center; font-family: var(--font-title);
  font-size: 1rem; color: var(--neon-blue); margin: 5px 0;
}
.formula-legend { list-style: none; font-size: 0.8rem; color: var(--text-dim); }
.formula-legend li { margin-bottom: 3px; }
.theory-note { font-size: 0.75rem; color: var(--text-dim); font-style: italic; line-height: 1.3; border-top: 1px solid var(--border-light); padding-top: 10px; }

.atoms-container {
  flex: 1.08; background: rgba(0,0,0,0.4); border-radius: 12px; border: 1px solid var(--border-light);
  display: grid; grid-template-columns: repeat(10, 1fr); gap: 5px; padding: 15px;
  box-shadow: inset 0 0 20px rgba(0, 0, 0, 0.5);
  max-width: 400px;
}
.atom {
  width: 100%; aspect-ratio: 1; border-radius: 50%; background: rgba(255, 255, 255, 0.05);
  position: relative; transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid rgba(255,255,255,0.08);
}
.atom.unstable {
  background: #fff; 
  box-shadow: 0 0 10px var(--neon-blue), 0 0 20px var(--neon-blue);
  animation: pulse-glow 2s infinite alternate;
  border: none;
}
.atom.decaying {
  animation: decay-flash 0.8s ease-out forwards;
}

@keyframes pulse-glow {
  0% { box-shadow: 0 0 8px var(--neon-blue); transform: scale(0.95); opacity: 0.8; }
  100% { box-shadow: 0 0 15px var(--neon-blue), 0 0 30px var(--neon-blue); transform: scale(1.05); opacity: 1; }
}

@keyframes decay-flash {
  0% { transform: scale(1); background: #fff; box-shadow: 0 0 20px #fff; }
  50% { transform: scale(1.5); background: var(--neon-purple); box-shadow: 0 0 40px var(--neon-purple); opacity: 1; }
  100% { transform: scale(1); background: rgba(255, 255, 255, 0.2); box-shadow: 0 0 0px transparent; opacity: 0.5; }
}

.chart-container {
  flex: 1; background: rgba(0,0,0,0.4); border-radius: 12px; border: 1px solid var(--border-light); padding: 20px;
  display: flex; flex-direction: column; min-height: 300px;
}

.stats { display: flex; gap: 20px; }
.stat-box { display: flex; flex-direction: column; gap: 5px; min-width: 100px; }
.stat-label { font-size: 0.75rem; color: var(--text-dim); text-transform: uppercase; letter-spacing: 1.5px; }
.stat-value { font-family: var(--font-title); font-size: 2.2rem; font-weight: bold; background: linear-gradient(to bottom, #fff, #889ec4); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }
.neon-blue-text { text-shadow: 0 0 15px var(--neon-blue); color: var(--neon-blue) !important; -webkit-text-fill-color: initial !important; background: none !important;}

.action-buttons { display: flex; gap: 15px; }
button.primary-btn {
  background: linear-gradient(135deg, rgba(0, 240, 255, 0.2), rgba(0, 240, 255, 0.1)); 
  border: 1px solid var(--neon-blue); color: var(--neon-blue);
  padding: 12px 25px; border-radius: 8px; font-family: var(--font-title); cursor: pointer; transition: 0.3s;
  text-shadow: 0 0 5px var(--neon-blue); box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px;
}
button.primary-btn:hover { background: var(--neon-blue); color: #000; box-shadow: 0 0 25px var(--neon-blue); text-shadow: none; transform: translateY(-2px); }
button.primary-btn:active { transform: translateY(0); }

button.secondary-btn {
  background: transparent; border: 1px solid rgba(255, 255, 255, 0.2); color: var(--text-dim);
  padding: 12px 25px; border-radius: 8px; font-family: var(--font-title); cursor: pointer; transition: 0.3s;
  text-transform: uppercase; font-size: 0.8rem; letter-spacing: 1px;
}
button.secondary-btn:hover { border-color: #fff; color: #fff; background: rgba(255, 255, 255, 0.05); }

/* Scrollbar Stylized */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: var(--border-light); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--neon-blue); }

@media (max-width: 900px) {
    #decay .row-layout { flex-direction: column; height: auto; overflow: auto; }
    .theory-panel { flex: none; width: 100%; }
    .app-container { height: auto; min-height: 100vh; }
}
