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

body {
  background: radial-gradient(ellipse at top, #0d1a0d 0%, #060a0f 50%, #030508 100%);
  min-height: 100vh;
  font-family: 'Share Tech Mono', monospace;
  color: #8899aa;
  padding: 20px 16px 40px;
  position: relative;
  overflow-x: hidden;
}

/* Grid overlay */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image:
    linear-gradient(#39ff1406 1px, transparent 1px),
    linear-gradient(90deg, #39ff1406 1px, transparent 1px);
  background-size: 40px 40px;
  pointer-events: none;
  z-index: 0;
}

/* Scanline */
.scanline {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: linear-gradient(transparent, #39ff1422, transparent);
  animation: scanline 4s linear infinite;
  pointer-events: none;
  z-index: 100;
}

@keyframes scanline {
  0%   { transform: translateY(-4px); }
  100% { transform: translateY(100vh); }
}

@keyframes rollIn {
  0%   { transform: rotate(-20deg) scale(0.4) translateY(-20px); opacity: 0; }
  60%  { transform: rotate(5deg) scale(1.1); opacity: 1; }
  100% { transform: rotate(0deg) scale(1); opacity: 1; }
}

@keyframes pulseRed {
  0%, 100% { box-shadow: 0 0 24px #ff2d5544, inset 0 0 20px #ff2d5511; }
  50%       { box-shadow: 0 0 40px #ff2d5577, inset 0 0 30px #ff2d5522; }
}

/* Layout */
.container {
  max-width: 720px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Header */
.header { text-align: center; margin-bottom: 32px; padding-top: 8px; }
.header-sub {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  letter-spacing: 8px;
  color: #39ff1488;
  margin-bottom: 6px;
  text-transform: uppercase;
}
.header h1 {
  font-family: 'Orbitron', monospace;
  font-size: clamp(22px, 6vw, 32px);
  font-weight: 900;
  color: #39ff14;
  letter-spacing: 4px;
  text-shadow: 0 0 20px #39ff1466, 0 0 40px #39ff1422;
  line-height: 1;
  margin-bottom: 4px;
}
.header-version {
  font-family: 'Orbitron', monospace;
  font-size: 13px;
  letter-spacing: 10px;
  color: #39ff1455;
}

/* Panel */
.panel {
  background: linear-gradient(135deg, #0d1117, #0a0f14);
  border: 1px solid #1a2a3a;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 4px 24px #00000066;
  margin-bottom: 20px;
  position: relative;
}
.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, #39ff1444, transparent);
}
.panel-header {
  background: #0a0d10;
  border-bottom: 1px solid #1a2a3a;
  padding: 10px 16px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.panel-title {
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  letter-spacing: 4px;
  color: #446655;
  text-transform: uppercase;
}

/* Controls panel */
.controls-inner {
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 20px;
}
.pool-label {
  font-size: 11px;
  letter-spacing: 4px;
  color: #446655;
  margin-bottom: 10px;
  text-transform: uppercase;
}
.pool-row {
  display: flex;
  align-items: center;
  gap: 12px;
}
.pool-count {
  font-family: 'Orbitron', monospace;
  font-size: 40px;
  font-weight: 900;
  color: #39ff14;
  text-shadow: 0 0 16px #39ff1466;
  min-width: 56px;
  text-align: center;
  line-height: 1;
}
.pool-unit { font-size: 12px; color: #446655; }

.counter-btn {
  background: transparent;
  border: 1px solid #2a3a4a;
  color: #8899aa;
  font-family: 'Share Tech Mono', monospace;
  font-size: 22px;
  width: 38px; height: 38px;
  cursor: pointer;
  transition: all 0.15s;
  line-height: 1;
}
.counter-btn:hover {
  border-color: #39ff14;
  color: #39ff14;
  box-shadow: 0 0 8px #39ff1444;
}

.quick-select {
  display: flex;
  gap: 4px;
  margin-top: 10px;
  flex-wrap: wrap;
}
.quick-btn {
  background: transparent;
  border: 1px solid #1a2a3a;
  color: #446655;
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  padding: 3px 8px;
  cursor: pointer;
  transition: all 0.15s;
  border-radius: 2px;
}
.quick-btn:hover, .quick-btn.active {
  background: #39ff1422;
  border-color: #39ff14;
  color: #39ff14;
}

.roll-btn {
  background: linear-gradient(135deg, #0a1f0a, #051005);
  border: 2px solid #39ff14;
  color: #39ff14;
  font-family: 'Orbitron', monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 4px;
  padding: 14px 40px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 0 20px #39ff1433, inset 0 0 20px #39ff1411;
  text-transform: uppercase;
  clip-path: polygon(0 0, calc(100% - 12px) 0, 100% 12px, 100% 100%, 12px 100%, 0 calc(100% - 12px));
}
.roll-btn:hover {
  background: linear-gradient(135deg, #0f2e0f, #07180a);
  box-shadow: 0 0 32px #39ff1466, inset 0 0 30px #39ff1422;
  transform: scale(1.02);
}
.roll-btn:active { transform: scale(0.97); }
.roll-hint { font-size: 10px; color: #446655; margin-top: 8px; letter-spacing: 1px; text-align: center; }

/* Result panel */
.result-bar {
  background: #0a0d10;
  border-bottom: 1px solid #1a2a3a;
  padding: 12px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 12px;
}
.result-stats { display: flex; gap: 16px; font-size: 12px; color: #446655; flex-wrap: wrap; }
.stat-hit  { color: #39ff1488; }
.stat-one  { color: #ff2d5588; }

/* Status badge */
.badge {
  border-radius: 6px;
  padding: 8px 18px;
  font-family: 'Orbitron', monospace;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 2px;
  text-align: center;
}
.badge-hit {
  background: linear-gradient(135deg, #001a07, #000d04);
  border: 2px solid #39ff14;
  color: #39ff14;
  box-shadow: 0 0 20px #39ff1433, inset 0 0 20px #39ff1411;
}
.badge-none {
  background: linear-gradient(135deg, #0d1117, #0a0f14);
  border: 2px solid #2a3a4a;
  color: #44667766;
}
.badge-glitch {
  background: linear-gradient(135deg, #2a1500, #1a0d00);
  border: 2px solid #ff8c00;
  color: #ff8c00;
  box-shadow: 0 0 20px #ff8c0033, inset 0 0 20px #ff8c0011;
}
.badge-critglitch {
  background: linear-gradient(135deg, #3a0010, #1a0005);
  border: 2px solid #ff2d55;
  color: #ff2d55;
  box-shadow: 0 0 24px #ff2d5544, inset 0 0 20px #ff2d5511;
  animation: pulseRed 1s ease-in-out infinite;
}

/* Dice grid */
.dice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
  padding: 16px;
}
.die-wrap {
  display: inline-block;
}
.die-wrap.animate {
  animation: rollIn 0.4s cubic-bezier(.36,.07,.19,.97) both;
}

.dice-legend {
  border-top: 1px solid #1a2a3a;
  padding: 8px 16px;
  display: flex;
  gap: 20px;
  font-size: 11px;
  color: #446655;
  justify-content: center;
  flex-wrap: wrap;
}
.legend-hit  { color: #39ff1488; }
.legend-one  { color: #ff2d5588; }

/* History */
.history-list { max-height: 300px; overflow-y: auto; }
.history-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 14px;
  border-left: 3px solid transparent;
  border-bottom: 1px solid #0f1822;
  font-size: 12px;
  transition: background 0.15s;
}
.history-item:last-child { border-bottom: none; }
.history-item:hover { background: #ffffff08; }
.h-time   { color: #446655; min-width: 70px; font-size: 11px; }
.h-pool   { color: #2a3a4a; min-width: 36px; }
.h-dice   { flex: 1; display: flex; flex-wrap: wrap; gap: 2px; }
.h-d      { font-size: 11px; }
.h-result { text-align: right; min-width: 110px; font-size: 11px; }

.clear-btn {
  background: transparent;
  border: 1px solid #1a2a3a;
  color: #44556688;
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  padding: 3px 10px;
  cursor: pointer;
  letter-spacing: 2px;
  transition: all 0.15s;
}
.clear-btn:hover { border-color: #ff2d5588; color: #ff2d5588; }

/* Scrollbar */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: #0d1117; }
::-webkit-scrollbar-thumb { background: #2a3a4a; border-radius: 2px; }

.footer {
  text-align: center;
  margin-top: 24px;
  font-size: 10px;
  color: #2a3a4a;
  letter-spacing: 2px;
}
