.tool-page { padding: 120px 0 80px; min-height: 100vh; }
.tool-header { margin-bottom: 48px; }
.back-link {
  display: inline-flex; align-items: center; gap: 8px;
  color: var(--text-muted); font-size: 13px; font-family: var(--font-head);
  margin-bottom: 24px; transition: color var(--transition);
}
.back-link:hover { color: var(--cyan); }
.tool-title { font-family: var(--font-head); font-size: clamp(28px, 5vw, 44px); font-weight: 700; margin: 12px 0 16px; }
.tool-desc { color: var(--text-muted); font-size: 16px; max-width: 540px; }

.dice-layout { display: grid; grid-template-columns: 1fr 300px; gap: 24px; align-items: start; }
@media (max-width: 800px) { .dice-layout { grid-template-columns: 1fr; } }

.calc-card {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius-lg); padding: 28px;
}
.calc-card h3 {
  font-family: var(--font-head); font-size: 13px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-muted);
  margin-bottom: 20px;
}

/* Dice type selector */
.dice-types { display: flex; flex-wrap: wrap; gap: 10px; margin-bottom: 24px; }
.dice-type-btn {
  padding: 10px 18px; border: 1.5px solid var(--border);
  background: var(--bg-3); border-radius: var(--radius);
  color: var(--text-muted); font-family: var(--font-head); font-size: 13px;
  font-weight: 600; cursor: pointer; transition: all var(--transition);
}
.dice-type-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.dice-type-btn.active { border-color: var(--cyan); color: var(--cyan); background: rgba(0,255,209,0.06); }

/* Count selector */
.count-row { display: flex; align-items: center; gap: 12px; margin-bottom: 24px; flex-wrap: wrap; }
.count-row label { font-size: 13px; color: var(--text-muted); }
.count-btn {
  width: 36px; height: 36px; border: 1px solid var(--border);
  background: var(--bg-3); color: var(--text); border-radius: var(--radius);
  font-family: var(--font-head); font-size: 16px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition);
}
.count-btn:hover { border-color: var(--cyan); color: var(--cyan); }
.count-display { font-family: 'Press Start 2P', monospace; font-size: 16px; color: var(--cyan); min-width: 24px; text-align: center; }

/* Dice display area */
.dice-area {
  min-height: 140px; display: flex; flex-wrap: wrap; gap: 20px;
  align-items: center; justify-content: center;
  padding: 24px; background: var(--bg-3); border-radius: var(--radius);
  margin-top: 8px;
}

/* D6 face */
.die {
  width: 80px; height: 80px; border-radius: 12px;
  background: linear-gradient(145deg, #1e2428, #0f1214);
  border: 2px solid rgba(0,255,209,0.25);
  box-shadow: 0 0 20px rgba(0,255,209,0.15), 0 4px 16px rgba(0,0,0,0.5);
  display: grid; grid-template-columns: repeat(3, 1fr);
  grid-template-rows: repeat(3, 1fr);
  padding: 10px; gap: 4px;
  position: relative;
}
.dot {
  border-radius: 50%; background: var(--cyan);
  box-shadow: 0 0 6px rgba(0,255,209,0.7);
}
.dot.hidden { background: transparent; box-shadow: none; }

/* Polygon dice (D4, D8, etc.) */
.die-poly {
  width: 80px; height: 80px;
  display: flex; align-items: center; justify-content: center;
  position: relative;
}
.die-poly svg { position: absolute; }
.die-poly__num {
  position: relative; z-index: 1;
  font-family: 'Press Start 2P', monospace; font-size: 18px;
  color: #000; text-shadow: none;
}

@keyframes diceShake {
  0%   { transform: rotate(0deg) scale(1); }
  15%  { transform: rotate(-20deg) scale(0.9); }
  30%  { transform: rotate(20deg) scale(1.1); }
  45%  { transform: rotate(-15deg) scale(0.95); }
  60%  { transform: rotate(15deg) scale(1.05); }
  75%  { transform: rotate(-8deg) scale(0.98); }
  90%  { transform: rotate(8deg) scale(1.02); }
  100% { transform: rotate(0deg) scale(1); }
}
.die.rolling, .die-poly.rolling { animation: diceShake 0.5s ease; }

/* History */
.history-list { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; }
.history-item {
  background: var(--bg-3); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 12px 16px;
  display: flex; justify-content: space-between; align-items: center;
}
.history-item__desc { font-size: 13px; color: var(--text-muted); }
.history-item__total { font-family: var(--font-head); font-size: 18px; font-weight: 700; color: var(--cyan); }
.history-item__detail { font-size: 11px; color: var(--text-muted); margin-top: 2px; }

.total-display {
  padding: 20px; background: linear-gradient(135deg, rgba(0,255,209,0.08), transparent);
  border: 1px solid var(--border-bright); border-radius: var(--radius);
  text-align: center; margin-bottom: 20px;
}
.total-display__label { font-size: 11px; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 8px; }
.total-display__num { font-family: 'Press Start 2P', monospace; font-size: 32px; color: var(--cyan); }
.total-display__rolls { font-size: 13px; color: var(--text-muted); margin-top: 8px; }

/* Content + FAQ section */
.tool-content-section {
  padding: 64px 0 80px;
  border-top: 1px solid var(--border);
}
.tool-content-section h2 {
  font-family: var(--font-head); font-size: clamp(18px, 3vw, 26px); font-weight: 700;
  margin: 40px 0 12px;
}
.tool-content-section h2:first-child { margin-top: 0; }
.tool-content-section p {
  color: var(--text-muted); font-size: 15px; line-height: 1.75; max-width: 1200px;
  margin-bottom: 12px;
}
.tool-content-section code {
  font-family: 'Press Start 2P', monospace; font-size: 11px;
  background: var(--bg-3); border: 1px solid var(--border);
  padding: 2px 6px; border-radius: 4px; color: var(--cyan);
}

.faq-list { display: flex; flex-direction: column; gap: 8px; margin-top: 20px; max-width: 1200px; }
.faq-item {
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); overflow: hidden;
}
.faq-item summary {
  padding: 16px 20px; font-family: var(--font-head); font-size: 14px; font-weight: 600;
  cursor: pointer; list-style: none; display: flex; justify-content: space-between; align-items: center;
  transition: color var(--transition);
}
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after {
  content: '+'; font-size: 18px; color: var(--cyan); transition: transform var(--transition);
  flex-shrink: 0; margin-left: 16px;
}
.faq-item[open] summary::after { transform: rotate(45deg); }
.faq-item summary:hover { color: var(--cyan); }
.faq-item p {
  padding: 0 20px 16px; margin: 0;
  border-top: 1px solid var(--border);
}
