:root {
  --dice-bg: #0e0b0b;
  --dice-surface: #141010;
  --dice-surface-2: #1a1515;
  --dice-surface-3: #221a1a;
  --dice-border: rgba(140,0,32,0.25);
  --dice-accent: #8C0020;
  --dice-accent-light: #b0002a;
  --dice-accent-dim: rgba(140,0,32,0.15);
  --dice-text: #d4c8c8;
  --dice-text-muted: #8a7a7a;
  --dice-text-faint: #5a4a4a;
  --dice-hunger-color: #8C0020;
  --dice-hunger-bg: rgba(140,0,32,0.18);
  --dice-success-color: #e8e0e0;
  --dice-font-display: "Cormorant Garamond", Georgia, serif;
  --dice-font-body: "Inter", sans-serif;
  --dice-radius: 6px;
  --dice-radius-lg: 12px;
  --dice-transition: 180ms cubic-bezier(0.16,1,0.3,1);
}







.mode-dice .header { text-align: center; margin-bottom: 36px; }

.mode-dice .header h1 {
  font-family: var(--dice-font-display);
  font-size: clamp(1.6rem, 4vw, 2.4rem);
  font-weight: 700;
  color: var(--dice-text);
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.mode-dice .header p { margin-top: 6px; font-size: 13px; color: var(--dice-text-muted); letter-spacing: 0.06em; text-transform: uppercase; }

.mode-dice .header-line { width: 60px; height: 1px; background: var(--dice-accent); margin: 12px auto 0; opacity: 0.6; }


.mode-dice .card {
  width: 100%;
  max-width: 100%; max-width: 560px;
  background: var(--dice-surface);
  border: 1px solid var(--dice-border);
  border-radius: var(--dice-radius-lg);
  padding: 28px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
}


.mode-dice .label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dice-text-muted);
  margin-bottom: 10px;
}


.mode-dice .stepper-row { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }

.mode-dice .stepper {
  display: flex; align-items: center; gap: 0;
  background: var(--dice-surface-2); border: 1px solid var(--dice-border);
  border-radius: var(--dice-radius); overflow: hidden; flex: 1;
}

.mode-dice .stepper button {
  width: 42px; height: 42px; background: transparent; border: none;
  color: var(--dice-text-muted); font-size: 20px; cursor: pointer;
  transition: background var(--dice-transition), color var(--dice-transition);
  font-family: var(--dice-font-body); display: flex; align-items: center; justify-content: center;
}

.mode-dice .stepper button:hover { background: var(--dice-accent-dim); color: var(--dice-text); }

.mode-dice .stepper button:active { background: rgba(140,0,32,0.3); }

.mode-dice .stepper .value {
  flex: 1; text-align: center; font-size: 20px; font-weight: 600;
  color: var(--dice-text); font-family: var(--dice-font-display); pointer-events: none;
}

.mode-dice .stepper.hunger-stepper .value { color: var(--dice-hunger-color); }


.mode-dice .dice-preview { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 24px; min-height: 36px; align-items: center; max-width: 100%; }

.mode-dice .die { width: 30px; height: 30px; border-radius: 5px; border: 1.5px solid rgba(140,0,32,0.3); background: var(--dice-surface-2); display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 600; font-family: var(--dice-font-display); color: var(--dice-text-muted); }

.mode-dice .die.hunger { border-color: rgba(140,0,32,0.5); background: var(--dice-hunger-bg); color: var(--dice-hunger-color); }

.mode-dice .die-svg { display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 48px; }

.mode-dice .dice-preview { flex-wrap: wrap; gap: 4px; }

.mode-dice .die-label { font-size: 11px; color: var(--dice-text-faint); width: 100%; margin-top: 4px; }


.mode-dice .btn-roll {
  width: 100%; padding: 13px;
  background: linear-gradient(135deg, #6a0018, #8C0020);
  border: none; border-radius: var(--dice-radius); color: #fff;
  font-family: var(--dice-font-display); font-size: 15pt; font-weight: 600;
  letter-spacing: 3px; text-transform: uppercase; cursor: pointer;
  transition: all var(--dice-transition); margin-bottom: 24px;
}

.mode-dice .btn-roll:hover { background: linear-gradient(135deg, #8C0020, #b0002a); box-shadow: 0 0 24px rgba(140,0,32,0.4); transform: translateY(-1px); }

.mode-dice .btn-roll:active { transform: translateY(0); }


.mode-dice /* Results */
.results { display: none; }

.mode-dice .results.visible { display: block; animation: fadeIn 0.3s ease both; }


.mode-dice .dice-result-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 20px; }


.mode-dice .die-result {
  width: 44px; height: 44px; border-radius: 7px;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; font-weight: 700; font-family: var(--dice-font-display);
  border: 2px solid transparent; position: relative;
  transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
  cursor: default;
}

.mode-dice .die-result.normal { cursor: pointer; }

.mode-dice .die-result.normal:hover { transform: translateY(-2px); }

.mode-dice .die-result-svg {
  display: inline-flex; align-items: center; justify-content: center;
  width: 44px; height: 48px; cursor: default; position: relative;
  transition: transform 0.15s, filter 0.15s;
}

.mode-dice .die-result-svg.normal { cursor: pointer; }

.mode-dice .die-result-svg.normal:hover { transform: translateY(-2px); }

.mode-dice .die-result-svg.normal.selected svg polygon { stroke: #fff !important; stroke-width: 2.5 !important; filter: drop-shadow(0 0 4px rgba(255,255,255,0.4)); }

.mode-dice .die-result-svg.selected { transform: translateY(-3px); }


.mode-dice /* Selected for reroll */
.die-result.normal.selected {
  border-color: #fff !important;
  box-shadow: 0 0 10px rgba(255,255,255,0.25);
  transform: translateY(-3px);
}


.mode-dice .die-result.normal-fail { background: var(--dice-surface-3); border-color: rgba(100,80,80,0.3); color: var(--dice-text-faint); }

.mode-dice .die-result.normal-win { background: rgba(60,60,70,0.3); border-color: rgba(120,120,140,0.5); color: #e8e0e0; }

.mode-dice .die-result.normal-crit { background: rgba(60,60,70,0.3); border-color: rgba(120,120,140,0.5); color: var(--dice-success-color); }

.mode-dice .die-result.hunger-fail { background: rgba(140,0,32,0.12); border-color: rgba(140,0,32,0.3); color: #cc6655; }

.mode-dice .die-result.hunger-win { background: rgba(140,0,32,0.15); border-color: rgba(140,0,32,0.45); color: #e87c6a; }

.mode-dice .die-result.hunger-crit { background: rgba(140,0,32,0.25); border-color: rgba(140,0,32,0.7); color: var(--dice-hunger-color); }

.mode-dice .die-result.hunger-bestial { background: rgba(140,0,0,0.35); border-color: #8c0000; color: #ff4444; }

.mode-dice .die-result .die-type-dot { position: absolute; bottom: 3px; right: 3px; width: 5px; height: 5px; border-radius: 50%; background: var(--dice-hunger-color); }


.mode-dice .result-summary { background: var(--dice-surface-2); border: 1px solid var(--dice-border); border-radius: var(--dice-radius); padding: 16px 20px; margin-bottom: 16px; }

.mode-dice .result-outcome { font-family: var(--dice-font-display); font-size: clamp(1.2rem, 3vw, 1.7rem); font-weight: 700; letter-spacing: 0.04em; margin-bottom: 6px; }

.mode-dice .outcome-success { color: #e8e0e0; }

.mode-dice .outcome-fail { color: var(--dice-text-muted); }

.mode-dice .outcome-crit { color: var(--dice-success-color); }

.mode-dice .outcome-mez { color: var(--dice-hunger-color); }

.mode-dice .outcome-bestial { color: var(--dice-hunger-color); }

.mode-dice .result-detail { font-size: 12px; color: var(--dice-text-muted); line-height: 1.7; }

.mode-dice .result-detail span { color: var(--dice-text); font-weight: 500; }




.mode-dice .stepper-input {
  background: transparent;
  border: none;
  color: inherit;
  font-size: inherit;
  font-family: inherit;
  font-weight: inherit;
  text-align: center;
  width: 48px;
  -moz-appearance: textfield;
  outline: none;
}

.mode-dice .stepper-input::-webkit-outer-spin-button, .mode-dice .stepper-input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }


.mode-dice .outcome-or { font-size: 0.7em; font-style: italic; color: var(--dice-text-muted); vertical-align: middle; }


.mode-dice #rouse-card { margin-top: 12px; }

.mode-dice .rouse-row { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; }

.mode-dice .rouse-stepper { max-width: 110px; }

.mode-dice .rouse-dice { display: flex; gap: 6px; margin-bottom: 6px; flex-wrap: wrap; }

.mode-dice .rouse-outcome { font-size: 14px; font-weight: 600; }




.mode-dice .btn-rouse {
  background: transparent;
  border: 1px solid var(--dice-border);
  color: var(--dice-text-muted);
  border-radius: var(--dice-radius);
  padding: 5px 14px;
  font-size: 12px;
  cursor: pointer;
  font-family: inherit;
  letter-spacing: 0.05em;
  transition: border-color 0.2s, color 0.2s;
}

.mode-dice .btn-rouse:hover { border-color: var(--dice-hunger-color); color: var(--dice-text); }

.mode-dice .rouse-dice { display: flex; gap: 4px; }

.mode-dice .rouse-outcome { font-size: 12px; font-weight: 600; color: var(--dice-text-muted); }



.mode-dice .surge-combined-row { display: flex; gap: 0; align-items: stretch; }

.mode-dice .surge-left { flex: 1; padding-right: 14px; }

.mode-dice .surge-right { flex: 0 0 auto; min-width: 130px; padding-left: 14px; }

.mode-dice .surge-divider { width: 1px; background: var(--dice-border); align-self: stretch; }

.mode-dice .surge-label { font-size: 9px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dice-text-muted); margin-bottom: 8px; }

.mode-dice .surge-controls { display: flex; align-items: center; gap: 8px; }

.mode-dice .rouse-btn { width: 100%; }

.mode-dice .rouse-result-row { margin-top: 8px; display: flex; align-items: center; gap: 6px; font-size: 12px; font-weight: 600; }




.mode-dice .app-layout-wrapper { max-width: 100%; max-width: 960px; margin: 0 auto; padding: 0 16px; }

.mode-dice .app-layout { display: flex; gap: 16px; align-items: flex-start; padding-bottom: 40px; }

.mode-dice .app-left { flex: 1; min-width: 0; }

.mode-dice .app-right { flex: 0 0 280px; min-width: 220px; }


.mode-dice .log-card {
  background: var(--dice-surface);
  border: 1px solid var(--dice-border);
  border-radius: var(--dice-radius);
  overflow: hidden;
}

.mode-dice .log-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px;
  border-bottom: 1px solid var(--dice-border);
}

.mode-dice .log-title { font-size: 10px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; color: var(--dice-text-muted); }

.mode-dice .log-clear {
  background: none; border: none; color: var(--dice-text-faint); font-size: 11px;
  cursor: pointer; font-family: inherit; padding: 2px 6px;
  border-radius: 4px; transition: color 0.2s;
}

.mode-dice .log-clear:hover { color: var(--dice-hunger-color); }

.mode-dice .log-list { max-height: 520px; overflow-y: auto; padding: 6px 0; }

.mode-dice .log-empty { padding: 16px 14px; font-size: 12px; color: var(--dice-text-faint); font-style: italic; }

.mode-dice .log-entry {
  padding: 8px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 12px;
  line-height: 1.5;
}

.mode-dice .log-entry:last-child { border-bottom: none; }

.mode-dice .log-entry-header { display: flex; justify-content: space-between; margin-bottom: 2px; }

.mode-dice .log-pool { color: var(--dice-text-muted); font-size: 11px; }

.mode-dice .log-outcome { font-weight: 700; font-size: 12px; }

.mode-dice .log-outcome.win { color: var(--dice-text); }

.mode-dice .log-outcome.crit { color: var(--dice-text); }

.mode-dice .log-outcome.fail { color: var(--dice-text-faint); }

.mode-dice .log-outcome.mez { color: var(--dice-hunger-color); }
.log-outcome.bestial { color: var(--dice-text); }

.mode-dice .log-details { color: var(--dice-text-faint); font-size: 11px; }



.mode-dice .dual-section {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.mode-dice .dual-half {
  flex: 1;
  background: var(--dice-surface-2);
  border: 1px solid var(--dice-border);
  border-radius: var(--dice-radius);
  padding: 14px 16px;
}

.mode-dice .dual-divider { display: none; }



.mode-dice .unified-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 20px;
}

.mode-dice .grid-cell {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mode-dice .grid-cell .label { margin-bottom: 0; }

.mode-dice .grid-cell .stepper { width: 100%; }

.mode-dice .grid-surge-cell {
  background: var(--dice-surface-2);
  border: 1px solid var(--dice-border);
  border-radius: var(--dice-radius);
  padding: 14px 16px;
  gap: 0;
}


.mode-dice /* Willpower section */
.willpower-section { border-top: 1px solid var(--dice-border); padding-top: 16px; }

.mode-dice .wp-hint { font-size: 11px; color: var(--dice-text-faint); font-style: italic; margin-bottom: 10px; line-height: 1.5; }

.mode-dice .wp-hint b { color: var(--dice-text-muted); font-style: normal; }

.mode-dice .wp-actions { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }

.mode-dice .btn-willpower {
  padding: 8px 18px; background: linear-gradient(135deg, #6a0018, #8C0020); border: none;
  border-radius: var(--dice-radius); color: #fff;
  font-family: var(--dice-font-display); font-size: 11pt; font-style: italic;
  letter-spacing: 0.05em; cursor: pointer; transition: all var(--dice-transition);
}

.mode-dice .btn-willpower:hover { background: linear-gradient(135deg, #8C0020, #b0002a); box-shadow: 0 0 24px rgba(140,0,32,0.4); transform: translateY(-1px); }

.mode-dice .btn-willpower:disabled { opacity: 0.35; cursor: not-allowed; pointer-events: none; }

.mode-dice .selected-count { font-size: 11px; color: var(--dice-text-muted); }

.mode-dice .reroll-notice { font-size: 11px; color: var(--dice-text-faint); font-style: italic; margin-top: 8px; }


.mode-dice /* Legend */
.legend { width: 100%; max-width: 100%; max-width: 560px; margin-top: 24px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }

.mode-dice .legend-item { display: flex; align-items: center; gap: 8px; font-size: 11px; color: var(--dice-text-muted); }

.mode-dice .legend-dot { width: 10px; height: 10px; border-radius: 3px; flex-shrink: 0; }

.mode-dice .ld-fail { background: var(--dice-surface-3); border: 1px solid rgba(100,80,80,0.3); }

.mode-dice .ld-win { background: rgba(80,120,80,0.25); border: 1px solid rgba(120,120,140,0.5); }

.mode-dice .ld-crit { background: rgba(200,168,75,0.25); border: 1px solid rgba(120,120,140,0.5); }

.mode-dice .ld-hfail { background: rgba(140,0,32,0.15); border: 1px solid rgba(140,0,32,0.4); }

.mode-dice .ld-hwin { background: rgba(140,0,32,0.2); border: 1px solid rgba(140,0,32,0.5); }

.mode-dice .ld-hcrit { background: rgba(140,0,32,0.3); border: 1px solid rgba(140,0,32,0.7); }

.mode-dice .ld-bestial { background: rgba(140,0,0,0.4); border: 1px solid #8c0000; }

@keyframes dieRoll {
  0%   { transform: scale(0.5) rotate(-20deg); opacity: 0; }
  60%  { transform: scale(1.12) rotate(3deg); }
  100% { transform: scale(1) rotate(0deg); opacity: 1; }
}

.mode-dice .die-result.animate { animation: dieRoll 0.35s cubic-bezier(0.34,1.56,0.64,1) both; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }


.mode-dice /* Blood Surge */
.controls-row {
  display: flex;
  gap: 16px;
  margin-bottom: 20px;
}

.mode-dice .control-group {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.mode-dice .control-group .label { margin-bottom: 0; }

.mode-dice .control-group .stepper { width: 100%; }


.mode-dice .surge-section {
  background: var(--dice-surface-2);
  border: 1px solid var(--dice-border);
  border-radius: var(--dice-radius);
  padding: 14px 16px;
  margin-bottom: 20px;
}

.mode-dice .surge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 10px;
}

.mode-dice .surge-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--dice-text-muted);
  white-space: nowrap;
}

.mode-dice .surge-bonus {
  font-size: 11px;
  color: var(--dice-text-faint);
  font-style: italic;
}

.mode-dice .surge-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.mode-dice .stepper.surge-stepper {
  max-width: 140px;
}

.mode-dice .btn-surge {
  flex: 1;
  padding: 9px 14px;
  background: transparent;
  border: 1px solid rgba(140,0,32,0.4);
  border-radius: var(--dice-radius);
  color: #c07070;
  font-family: var(--dice-font-display);
  font-size: 11pt;
  font-style: italic;
  letter-spacing: 0.05em;
  cursor: pointer;
  transition: all var(--dice-transition);
}

.mode-dice .btn-surge:hover { border-color: var(--dice-accent); color: var(--dice-text); background: var(--dice-accent-dim); }

.mode-dice .surge-result {
  margin-top: 10px;
  font-size: 11px;
  line-height: 1.6;
  display: none;
}

.mode-dice .surge-result.visible { display: block; }

.mode-dice .surge-ok { color: #e8e0e0; }

.mode-dice .surge-bad { color: var(--dice-hunger-color); }

.mode-dice .btn-surge:disabled { opacity: 0.4; cursor: not-allowed !important; }

.mode-dice .btn-surge:disabled:hover { border-color: rgba(140,0,32,0.4); color: #c07070; background: transparent; }


/* Dice mode layout override */
.mode-dice {
  width: 100%;
}


/* DicePlus pointer fix + reset button styling */
.mode-dice .stepper input.value.stepper-input{pointer-events:auto;user-select:text;cursor:text;}

.mode-dice .btn-reset{
  margin-top:10px;
  width:100%;
  padding:8px 16px;
  background:transparent;
  border:1px solid var(--dice-border);
  border-radius:var(--dice-radius);
  color:var(--dice-text-muted);
  font-family:inherit;
  font-size:12px;
  letter-spacing:0.06em;
  text-transform:uppercase;
  cursor:pointer;
  transition:border-color var(--dice-transition),color var(--dice-transition),background var(--dice-transition);
}
.mode-dice .btn-reset:hover{
  border-color:var(--dice-hunger-color);
  color:var(--dice-text);
  background:var(--dice-accent-dim);
}
/* ===== Мобильная адаптация ===== */
@media (max-width: 640px) {
  .mode-dice .app-layout-wrapper { padding: 0 12px; }
  .mode-dice .app-layout { flex-direction: column; gap: 20px; }
  .mode-dice .app-left,
  .mode-dice .app-right { flex: 1 1 100%; width: 100%; min-width: 0; max-width: 100%; }
  .mode-dice .unified-grid { grid-template-columns: 1fr; gap: 12px; }
  .mode-dice .stepper-row { flex-wrap: wrap; }
  .mode-dice .card { box-sizing: border-box; padding: 20px 16px; }
}
