/* === CSS Variables === */
:root {
  --bg-start: #0f0c29;
  --bg-mid:   #302b63;
  --bg-end:   #24243e;

  --green:    #1DB954;
  --purple:   #667eea;
  --orange:   #f46b45;
  --blue:     #4facfe;
  --pink:     #fe5196;
  --red:      #E53935;

  --text-white:    #ffffff;
  --text-dark:     #2c3e50;
  --text-gray:     #7f8c8d;
  --text-w70:      rgba(255,255,255,0.70);
  --text-w80:      rgba(255,255,255,0.80);
  --text-w90:      rgba(255,255,255,0.90);

  --card-bg:       rgba(255,255,255,0.12);
  --card-bg-hover: rgba(255,255,255,0.18);

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 20px;
  --radius-xl: 24px;
}

/* === Reset & Base === */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background: linear-gradient(to bottom, var(--bg-start), var(--bg-mid), var(--bg-end));
  color: var(--text-white);
  overscroll-behavior: none;
  -webkit-tap-highlight-color: transparent;
}

#app {
  height: 100%;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* === Screen container === */
.screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 600px;
  width: 100%;
  margin: 0 auto;
}

/* =============================================
   HEADER
   ============================================= */
.header {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
  padding: 12px 16px;
  padding-top: max(12px, env(safe-area-inset-top, 12px));
  flex-shrink: 0;
}
.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-left: auto;
}

.screen-title-wrap { display: flex; flex-direction: column; flex: 1; min-width: 120px; }
.screen-title { font-size: 22px; font-weight: 700; flex: 1; color: var(--text-white); }
.config-title-dice { width: 55px; height: 44px; flex-shrink: 0; }
.screen-title-wrap .screen-title { flex: none; }
.screen-subtitle { font-size: 13px; color: var(--text-w70); font-weight: 400; word-break: break-word; }
.rolling-screen .screen-title { font-size: 13px; font-weight: 400; color: var(--text-w70); }
.rolling-screen .screen-subtitle { font-size: 20px; font-weight: 700; color: var(--text-white); }

/* =============================================
   ICON BUTTON
   ============================================= */
.icon-btn {
  background: none;
  border: none;
  color: var(--text-white);
  cursor: pointer;
  padding: 7px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
}
.icon-btn:hover  { background: rgba(255,255,255,0.12); }
.icon-btn:active { background: rgba(255,255,255,0.20); }
.icon-btn svg    { width: 22px; height: 22px; }

.icon-btn.configurations-btn {
  width: auto;
  border-radius: 20px;
  padding: 7px 12px 7px 8px;
  gap: 6px;
  font-size: 13px;
  font-weight: 600;
}

.icon-btn.small  { width: 30px; height: 30px; font-size: 12px; }
.icon-btn.disabled,
.icon-btn:disabled { opacity: 0.35; cursor: not-allowed; }

/* =============================================
   BUTTONS
   ============================================= */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 700;
  color: var(--text-white);
  cursor: pointer;
  transition: filter 0.15s, transform 0.1s;
  flex: 1;
  min-width: 0;
}
.btn svg     { width: 20px; height: 20px; flex-shrink: 0; }
.btn:hover   { filter: brightness(1.1); }
.btn:active  { transform: scale(0.97); }
.btn:disabled,
.btn.disabled { opacity: 0.50; cursor: not-allowed; transform: none; filter: none; }

.btn-green   { background: var(--green); }
.btn-purple  { background: var(--purple); }
.btn-orange  { background: var(--orange); }
.btn-primary { background: var(--purple); }
.btn-danger  { background: #e53e3e; flex: 0 0 auto; }
.btn-sm      { padding: 6px 12px; font-size: 13px; font-weight: 600; border-radius: 6px; flex: 0 0 auto; }

/* Compact mystery button */
.btn-mystery {
  flex: 0 0 auto;
  padding: 10px 16px;
  min-width: 150px;
  width: 150px;
  max-width: 150px;
  height: 44px;
  font-size: 14px;
  justify-content: center;
  overflow: hidden;
}

/* =============================================
   BOTTOM ACTION BAR
   ============================================= */
.bottom-actions {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 600px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 14px 16px;
  padding-bottom: max(14px, env(safe-area-inset-bottom, 14px));
  background: linear-gradient(to top, var(--bg-end) 70%, transparent);
  z-index: 10;
}
.bottom-actions-row { display: flex; gap: 12px; }

/* Pip-count summary above the Restart/Roll buttons */
.pip-count-summary {
  background: none; border: none; color: var(--text-w80);
  font-size: 13px; font-weight: 600; cursor: pointer;
  padding: 2px 8px; align-self: center; border-radius: 6px;
}
.pip-count-summary:hover { background: rgba(255,255,255,0.10); color: var(--text-white); }
.pip-count-summary b { color: var(--text-white); font-size: 15px; margin-left: 4px; }

/* Pip-count modal body rows */
.count-total { font-size: 16px; margin: 8px 0 4px; }
.count-total b { font-size: 22px; }
.count-hidden { font-size: 12px; color: var(--text-w70); margin-left: 6px; }
.count-row { display: flex; align-items: center; gap: 10px; padding: 4px 0; }
.count-color-dot { width: 14px; height: 14px; border-radius: 50%; flex-shrink: 0; border: 1px solid rgba(255,255,255,0.20); }
.count-label { flex: 1; color: var(--text-w90); font-size: 14px; }
.count-val { font-weight: 700; }
/* Compact per-color chips that wrap to fill the available width */
.count-color-chips,
.count-value-chips { display: flex; flex-wrap: wrap; gap: 6px 10px; margin-top: 4px; }
.count-color-chip,
.count-value-chip {
  display: inline-flex; align-items: center; gap: 6px;
  font-size: 13px; color: var(--text-w90);
  background: rgba(255,255,255,0.06); border-radius: 999px;
  padding: 3px 9px;
}
/* Mini pip die used in the "Count by value" chips */
.count-pip-die {
  width: 24px; height: 24px;
  background: #ffffff; border-radius: 4px;
  display: inline-flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.count-pip-die .pip-grid { width: 18px; height: 18px; }

/* =============================================
   DIVIDER
   ============================================= */
.divider {
  height: 1px;
  background: rgba(255,255,255,0.18);
  margin: 8px 0 14px;
}

/* =============================================
   TOAST
   ============================================= */
#toast {
  position: fixed;
  bottom: 90px;
  left: 50%;
  transform: translateX(-50%) translateY(12px);
  background: var(--green);
  color: #fff;
  padding: 10px 22px;
  border-radius: 24px;
  font-size: 14px;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  z-index: 300;
  white-space: nowrap;
  max-width: 90vw;
  transition: opacity 0.25s, transform 0.25s;
}
#toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#toast.toast-error { background: #E53935; }

/* =============================================
   MODAL / OVERLAY
   ============================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 20px;
}

.modal {
  background: linear-gradient(160deg, #1e1b3a, #252047);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: var(--radius-xl);
  padding: 0;
  width: 100%;
  max-width: 420px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  gap: 0;
  color: var(--text-white);
}

.modal-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-white);
}
.modal-subtitle {
  font-size: 12px;
  font-weight: 400;
  color: var(--text-w70);
  margin-top: 2px;
}

.setting-group  { display: flex; flex-direction: column; gap: 6px; }
.setting-label  { font-size: 14px; font-weight: 600; color: var(--text-w90); }
.setting-label-row { display: flex; align-items: center; gap: 12px; }
.setting-label-wrap { display: flex; flex-direction: column; gap: 2px; flex: 1; min-width: 0; }
.settings-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-w70);
  margin: 8px 0 2px;
  padding-bottom: 4px;
  border-bottom: 1px solid rgba(255,255,255,0.12);
}
.setting-hint   { font-size: 12px; color: var(--text-w70); }

.toggle-switch { position: relative; display: inline-block; width: 44px; height: 26px; flex-shrink: 0; }
.toggle-switch input { position: absolute; opacity: 0; width: 0; height: 0; pointer-events: none; }
.toggle-slider {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.2);
  border-radius: 26px;
  cursor: pointer;
  transition: background 0.2s;
}
.toggle-slider::before {
  content: '';
  position: absolute;
  width: 20px; height: 20px;
  left: 3px; top: 3px;
  background: #fff;
  border-radius: 50%;
  transition: transform 0.2s;
}
.toggle-switch input:checked + .toggle-slider { background: var(--purple); }
.toggle-switch input:checked + .toggle-slider::before { transform: translateX(18px); }

.slider {
  width: 100%;
  accent-color: var(--purple);
  cursor: pointer;
  height: 4px;
}

.setting-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
}
.setting-num-inp {
  width: 64px;
  text-align: center;
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-sm);
  color: var(--text-white);
  font-size: 15px;
  font-weight: 600;
  padding: 6px 8px;
  -moz-appearance: textfield;
}
.setting-num-inp::-webkit-inner-spin-button,
.setting-num-inp::-webkit-outer-spin-button { display: none; }
.setting-num-inp:focus { outline: none; border-color: var(--purple); }

/* Rolls-list (Auto Mystery, Enforce Reveal): toggle-driven list of roll numbers */
.rolls-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; padding-left: 4px; }
.rolls-list-row { display: flex; align-items: center; gap: 8px; }
.rolls-list-prefix { font-size: 13px; color: var(--text-w70); }
.rolls-list-remove {
  background: none; border: none; color: var(--text-w70); cursor: pointer;
  font-size: 20px; line-height: 1; padding: 4px 8px; border-radius: 4px;
}
.rolls-list-remove:hover { color: var(--text-white); background: rgba(255,255,255,0.10); }
.rolls-list-add {
  background: rgba(255,255,255,0.08); border: 1px dashed rgba(255,255,255,0.25);
  color: var(--text-w90); cursor: pointer; padding: 6px 12px; border-radius: 6px;
  font-size: 13px; font-weight: 600; align-self: flex-start; margin-top: 2px;
}
.rolls-list-add:hover { background: rgba(255,255,255,0.15); }

/* Size +/- controls inside modal */
.size-controls {
  display: flex;
  align-items: center;
  gap: 14px;
}
.size-controls .counter-btn {
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.28);
  color: var(--text-white);
}
.size-controls .counter-value { color: var(--text-white); min-width: 44px; }

/* Dice order list inside modal */
.order-mode-btns { display: flex; gap: 6px; }
.order-mode-btn {
  flex: 1;
  padding: 7px 10px;
  background: rgba(255,255,255,0.08);
  border: 2px solid transparent;
  border-radius: 8px;
  color: var(--text-w90);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.order-mode-btn:hover { background: rgba(255,255,255,0.15); }
.order-mode-btn.active { border-color: var(--purple); background: rgba(102,126,234,0.18); color: var(--text-white); }
.order-list { display: flex; flex-direction: column; gap: 6px; margin-top: 8px; }
.order-item {
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: space-between;
  padding: 6px 12px;
  background: rgba(255,255,255,0.10);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-w90);
}
.order-item > span { flex: 1; }
.order-item .dice-content { transform: scale(0.4); width: 32px; height: 32px; }
.order-btns { display: flex; gap: 2px; }
.order-btns .icon-btn { color: var(--text-w90); width: 30px; height: 30px; }

.modal-actions { display: flex; justify-content: flex-end; }
.modal-actions .btn { flex: 0 0 auto; }

/* =============================================
   CONFIGURATION SCREEN
   ============================================= */
.config-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
}

.config-form {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-height: 0; /* allow flex child to shrink */
  overflow: hidden;
}

.form-scroll {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 4px 16px 90px;
}

/* Text input (config name) */
.text-input {
  width: 100%;
  padding: 13px 14px;
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.30);
  border-radius: var(--radius-md);
  color: var(--text-white);
  font-size: 17px;
  outline: none;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 14px;
}
.text-input::placeholder { color: var(--text-w70); }
.text-input:focus {
  border-color: var(--purple);
  background: rgba(255,255,255,0.22);
}

/* Counter row (Number of dice) */
/* Dice preview strip */
.dice-preview-strip {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 8px;
  padding: 6px 0 10px;
}

.mini-dice-chip {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 5px;
  cursor: pointer;
  flex-shrink: 0;
}

.mini-dice-face {
  width: 54px;
  height: 54px;
  border-radius: 12px;
  background: linear-gradient(135deg, rgba(102,126,234,0.35), rgba(118,75,162,0.35));
  border: 1.5px solid rgba(255,255,255,0.25);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.15s, transform 0.1s;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.mini-dice-chip:hover .mini-dice-face {
  border-color: var(--purple);
  transform: translateY(-2px);
  box-shadow: 0 4px 14px rgba(102,126,234,0.45);
}
.mini-dice-chip:active .mini-dice-face { transform: translateY(0); }

.mini-dice-label {
  font-size: 11px;
  color: var(--text-w70);
  font-weight: 500;
}

.mini-dice-text {
  font-size: 0.85rem;
  font-weight: 700;
  color: var(--text-white);
  letter-spacing: 0.5px;
}

/* Dice config modal */
.modal-header-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  padding: 22px 20px 0 20px;
}
.modal-body {
  overflow-x: hidden;
  overflow-y: auto;
  padding: 18px 20px 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  flex: 1 1 auto;
}
.modal-header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
}
.dice-config-modal {
  max-width: 480px;
}
.dice-config-modal .dice-config-expanded {
  border-top: 1px solid rgba(0,0,0,0.12);
  margin-top: 0;
  padding-top: 10px;
}

.dice-count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.counter {
  display: flex;
  align-items: center;
  gap: 10px;
}

.counter-btn {
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.28);
  border-radius: 50%;
  color: var(--text-white);
  width: 34px;
  height: 34px;
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  flex-shrink: 0;
}
.counter-btn:hover  { background: rgba(255,255,255,0.25); }
.counter-btn:active { background: rgba(255,255,255,0.35); }

.counter-value {
  font-size: 20px;
  font-weight: 700;
  min-width: 30px;
  text-align: center;
}
.accent-purple { color: var(--purple); }
.accent-blue   { color: var(--blue); }

.label-text    { color: var(--text-w90); font-size: 15px; }
.label-text-sm { color: var(--text-w80); font-size: 13px; margin-bottom: 6px; display: block; }

/* Advanced Settings card */
.settings-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  cursor: pointer;
  margin-bottom: 14px;
  transition: background 0.2s;
}
.settings-card:hover    { background: var(--card-bg-hover); }
.settings-card-text     { font-size: 15px; font-weight: 600; }
.settings-icon          { width: 20px; height: 20px; opacity: 0.8; flex-shrink: 0; }

/* =============================================
   DICE CONFIG CARDS
   ============================================= */
.dice-configs { display: flex; flex-direction: column; gap: 10px; padding-bottom: 8px; }

.dice-card {
  background: var(--card-bg);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.dice-card-header {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  gap: 8px;
}
.dice-card-title { font-size: 15px; font-weight: 700; }
.expand-btn      { margin-left: auto; }

/* Preview elements inside card header */
.preview-text   { font-size: 12px; color: var(--text-w80); }
.preview-colors { display: flex; gap: 4px; align-items: center; }
.preview-icon   { width: 18px; height: 18px; opacity: 0.8; }
.color-dot {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  border: 1px solid rgba(255,255,255,0.45);
  flex-shrink: 0;
}

/* =============================================
   EXPANDED DICE CONFIG
   ============================================= */
.dice-config-expanded {
  padding: 0 14px 14px;
  border-top: 1px solid rgba(255,255,255,0.14);
}

.sides-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0;
}

/* Sides counter row inside expanded card */
.sides-count-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 10px 0 12px;
}

/* Die Basic Settings — shared baseline applied to all sides */
.basic-settings-section {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  margin: 4px 0 12px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 8px;
}
.basic-settings-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  color: var(--text-w70);
  margin: 0 0 2px;
}
.basic-settings-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 14px;
}
.basic-settings-field {
  display: flex;
  align-items: center;
  gap: 8px;
}
.basic-settings-label {
  font-size: 13px;
  color: var(--text-w80);
  font-weight: 600;
}
.basic-settings-field .side-type-btn,
.basic-settings-field .side-shape-btn,
.basic-settings-field .side-color-dot-btn { width: auto; padding: 6px 10px; }

/* Unified sides table */
.sides-table {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 4px;
  margin: 4px auto 0;
  max-width: 330px;
}

/* Flex layout per row so each row's value cell hugs its own content
   (a NUMBER row's −/+ buttons no longer force TEXT/PIPPED rows to share width). */
.sides-hdr, .side-row {
  display: flex;
  align-items: center;
  gap: 5px;
}
.sides-hdr { padding: 0 2px 2px; }
.sides-hdr > span {
  font-size: 11px;
  font-weight: 700;
  color: var(--text-w70);
  text-transform: uppercase;
  letter-spacing: 0.4px;
  text-align: center;
  flex-shrink: 0;
}
.sides-hdr > span:nth-child(1),
.side-row  > .side-num         { width: 22px; }
.sides-hdr > span:nth-child(2),
.side-row  > .side-type-btn    { width: 60px; }
.sides-hdr > span:nth-child(3),
.side-row  > .side-shape-btn   { width: 50px; }
.sides-hdr > span:nth-child(4),
.side-row  > .side-color-dot-btn { width: 50px; }
.side-row  > .side-num,
.side-row  > .side-type-btn,
.side-row  > .side-shape-btn,
.side-row  > .side-color-dot-btn { flex-shrink: 0; }

.side-num {
  font-size: 13px;
  color: var(--text-w70);
  text-align: center;
}

.side-sel {
  width: 100%;
  min-width: 0;
  padding: 6px 4px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 6px;
  color: var(--text-white);
  font-size: 14px;
  outline: none;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  text-align: center;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='rgba(255,255,255,0.5)'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 5px center;
  padding-right: 18px;
}
.side-sel:focus { border-color: var(--purple); }
.side-sel option { background: #2a2550; color: #fff; }

/* Shared pick-button shell — used by Type / Shape / Color cells. */
.side-type-btn,
.side-shape-btn,
.side-color-dot-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  width: 100%;
  padding: 6px 4px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 6px;
  color: var(--text-white);
  font-size: 14px;
  cursor: pointer;
  transition: background 0.15s;
}
.side-type-btn:hover,
.side-shape-btn:hover,
.side-color-dot-btn:hover { background: rgba(255,255,255,0.18); }
.side-type-label { display: inline-flex; align-items: center; }
.side-type-label .type-pick-pip-svg { width: 18px; height: 18px; }

/* Type picker modal */
.type-picker-modal { max-width: 300px; padding: 20px; }
.type-pick-grid {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 16px;
}
.type-pick-card {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px;
  height: 72px;
  background: rgba(255,255,255,0.08);
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  width: 100%;
  box-sizing: border-box;
}
.type-pick-card:hover { background: rgba(255,255,255,0.15); }
.type-pick-card.active { border-color: var(--purple); background: rgba(102,126,234,0.18); }
.type-pick-icon { font-size: 22px; font-weight: 700; color: var(--text-white); min-width: 32px; text-align: center; }
.type-pick-pip-svg { width: 42px; height: 42px; color: var(--text-white); display: block; }
.type-pick-label { font-size: 15px; font-weight: 600; color: var(--text-white); }

/* Color cell — colored dot inside the shared pick-button shell */
.side-color-dot {
  display: block;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: transform 0.12s, box-shadow 0.12s;
}
.side-color-dot-btn:hover .side-color-dot { transform: scale(1.18); box-shadow: 0 0 0 2px rgba(255,255,255,0.35); }

/* Color picker modal */
.color-picker-modal {
  max-width: 280px;
  padding: 20px;
}
.color-swatches-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 12px;
}
.color-swatch {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: 2px solid transparent;
  cursor: pointer;
  transition: transform 0.12s, border-color 0.12s;
}
.color-swatch:hover { transform: scale(1.15); }
.color-swatch.active { border-color: #fff; box-shadow: 0 0 0 2px rgba(255,255,255,0.5); }
.color-none-btn {
  width: 100%;
  padding: 8px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 8px;
  color: var(--text-w70);
  font-size: 13px;
  cursor: pointer;
  text-align: center;
}
.color-none-btn:hover { background: rgba(255,255,255,0.18); color: #fff; }

/* Shape cell — shape icon inside the shared pick-button shell */
.side-shape-icon {
  display: block;
  width: 20px;
  height: 20px;
  background: #ffffff;
  transition: transform 0.12s;
}
.side-shape-btn:hover .side-shape-icon { transform: scale(1.18); }

/* Shape picker modal */
.shape-picker-modal { max-width: 500px; padding: 20px; }
.shape-pick-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 16px;
}
.shape-pick-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  width: 60px;
  background: rgba(255,255,255,0.08);
  border: 2px solid transparent;
  border-radius: 10px;
  padding: 10px 6px 8px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
}
.shape-pick-btn:hover { background: rgba(255,255,255,0.15); }
.shape-pick-btn.active { border-color: var(--purple); background: rgba(102,126,234,0.18); }
.shape-pick-icon {
  display: block;
  width: 32px;
  height: 32px;
  background: #ffffff;
}
.shape-pick-label {
  font-size: 10px;
  color: var(--text-w70);
  text-align: center;
  line-height: 1.2;
}

/* Dice shape wrapper on rolling screen */
.dice-shape-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72%;
  aspect-ratio: 1;
  overflow: hidden;
}

.side-val-wrap { min-width: 0; display: flex; align-items: center; justify-content: center; }

.side-num-wrap {
  display: flex;
  align-items: center;
  gap: 3px;
  width: fit-content;
}
.side-num-btn {
  flex-shrink: 0;
  width: 22px;
  height: 26px;
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 5px;
  color: var(--text-white);
  font-size: 14px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
}
.side-num-btn:active { background: rgba(255,255,255,0.25); }

.side-inp {
  width: 120px;
  padding: 5px 6px;
  background: rgba(255,255,255,0.10);
  border: 1px solid rgba(255,255,255,0.22);
  border-radius: 6px;
  color: var(--text-white);
  font-size: 12px;
  outline: none;
  text-align: center;
}
.side-inp[type="text"] { text-align: left; }
.side-inp-num { -moz-appearance: textfield; }
.side-inp-num::-webkit-inner-spin-button,
.side-inp-num::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.side-none {
  display: block;
  text-align: center;
  color: var(--text-w70);
  font-size: 12px;
}

/* Keep active-* classes for any remaining uses */
.active-blue   { background: var(--blue)   !important; color: #fff !important; }
.active-purple { background: var(--purple) !important; color: #fff !important; }
.active-orange { background: var(--orange) !important; color: #fff !important; }
.active-pink   { background: var(--pink)   !important; color: #fff !important; }
.active-green  { background: var(--green)  !important; color: #fff !important; }

/* =============================================
   HISTORY (Saved Configurations)
   ============================================= */
.configurations-sort-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-bottom: 10px;
  flex-shrink: 0;
}
.configurations-sort-label {
  font-size: 13px;
  color: var(--text-w70);
  white-space: nowrap;
}
.configurations-sort-btn {
  background: var(--card-bg);
  border: 1px solid rgba(255,255,255,0.15);
  color: var(--text-w70);
  border-radius: var(--radius-sm);
  padding: 4px 10px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  white-space: nowrap;
}
.configurations-sort-btn:hover { background: var(--card-bg-hover); color: var(--text-white); }
.configurations-sort-btn.active { background: var(--purple); color: var(--text-white); border-color: transparent; }

.configurations-list {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 0 16px 16px;
}

.section-title {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 12px;
}

.configurations-card {
  display: flex;
  align-items: center;
  background: var(--card-bg);
  border-radius: var(--radius-md);
  padding: 13px 14px;
  margin-bottom: 9px;
  gap: 10px;
  transition: background 0.18s;
}
.configurations-card:hover    { background: var(--card-bg-hover); }
.configurations-card-new      { cursor: pointer; border: 1px dashed rgba(255,255,255,0.2); }
.configurations-card-info     { flex: 1; cursor: pointer; }
.configurations-name          { font-size: 15px; font-weight: 600; display: block; }
.configurations-meta          { font-size: 12px; color: var(--text-w70); }

.empty-configurations {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-w70);
  font-size: 16px;
  padding: 40px 16px;
}

/* =============================================
   ROLLING SCREEN
   ============================================= */
.rolling-screen {
  display: flex;
  flex-direction: column;
  height: 100%;
  overflow: hidden;
}

/* Mystery + roll-counter row */
.mystery-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 0 16px 10px;
  flex-shrink: 0;
}

.round-count {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-w70);
  flex-shrink: 0;
}

.roll-count {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-white);
  flex-shrink: 0;
}

#back-btn {
  background: rgba(255,255,255,0.1);
  color: var(--text-white);
}
#back-btn:hover  { background: rgba(255,255,255,0.32); }
#back-btn:active { background: rgba(255,255,255,0.45); }

/* Dice grid scroll area */
.dice-grid-wrapper {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 6px 10px 90px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
}

.dice-grid {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  justify-content: center;
  width: 100%;
}
.dice-grid.cols-2 { }
.dice-grid.cols-3 { }
.dice-grid.cols-4 { }
.dice-face {
  width: 150px;
  height: 150px;
  flex-shrink: 0;
  background: rgba(255,255,255,0.12);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  padding: 8px;
  box-shadow: 0 4px 18px rgba(0,0,0,0.30);
  transition: background 0.18s, box-shadow 0.18s;
  user-select: none;
  -webkit-user-select: none;
  position: relative;
  gap: 4px;
}
.dice-face:hover  { background: rgba(255,255,255,0.18); }
.dice-face:active { background: rgba(255,255,255,0.22); }

.dice-face.locked {
  box-shadow: 0 2px 8px rgba(0,0,0,0.20);
}

/* Roll animation */
@keyframes roll {
  0%   { transform: rotate(0deg)   scale(1.00); }
  30%  { transform: rotate(120deg) scale(1.18); }
  70%  { transform: rotate(300deg) scale(1.10); }
  100% { transform: rotate(360deg) scale(1.00); }
}
.dice-face.rolling .dice-shape-wrap { animation: roll 0.5s ease-out forwards; }

/* Dice label, content, lock icon */
.dice-label    { font-size: 11px; color: var(--text-w70); }
.dice-content  {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  width: 100%;
}
.lock-indicator {
  position: absolute;
  bottom: 4px;
  right: 6px;
  font-size: 50px;
  line-height: 1;
}

/* Circular face (all content types) */
.face-circle {
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 72%;
  aspect-ratio: 1;
  overflow: hidden;
}
.white-circle  { background: #ffffff; }
.locked-circle { background: #888888; opacity: 0.65; }
.color-circle  {}  /* background set inline */

/* Number / text inside face */
.face-number {
  font-weight: 700;
  font-size: clamp(18px, 5.5vw, 46px);
  line-height: 1;
}
.face-text {
  font-weight: 700;
  line-height: 1.15;
  text-align: center;
  padding: 4px;
  word-break: break-word;
}
.text-lg { font-size: clamp(14px, 4.5vw, 30px); }
.text-md { font-size: clamp(11px, 3.2vw, 18px); }
.text-sm { font-size: clamp(9px,  2.5vw, 13px); }

.dark-text       { color: #2c3e50; }
.dark-text-muted { color: #666;    }
.white-text      { color: #ffffff; }

/* Mystery question mark */
.mystery-icon {
  font-size: clamp(48px, 13vw, 80px);
  font-weight: 900;
  color: var(--purple);
  line-height: 1;
}
.mystery-icon.individual { color: var(--blue); }
/* Mystery dice get the same shape-wrap so they pick up the roll animation,
   but rendered as a transparent square with a white frame. */
.mystery-wrap {
  background: transparent;
  border: 2px solid var(--text-white);
  border-radius: 12%;
  box-sizing: border-box;
}

/* === Pip grid (PIPPED content type) === */
.pip-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8%;
  width: 72%;
  aspect-ratio: 1;
  padding: 8%;
}
.pip-slot {
  display: flex;
  align-items: center;
  justify-content: center;
}
.pip-dot {
  width: 85%;
  aspect-ratio: 1;
  border-radius: 50%;
  background: #ffffff;
  box-shadow: 0 1px 3px rgba(0,0,0,0.35);
}
.pip-dot.locked {
  background: #888;
  opacity: 0.55;
}

/* Pip grid inside mini-dice-face (strip) */
.mini-dice-face .pip-grid {
  width: 80%;
  padding: 6%;
  gap: 6%;
}

/* Pip preview in config editor */
.pipped-editor { display: flex; flex-direction: column; gap: 10px; }
.pipped-preview {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.pipped-preview-face {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.12);
  border: 1.5px solid rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
}
.pipped-preview-face .pip-grid {
  width: 80%;
  padding: 5%;
  gap: 6%;
}

/* =============================================
   SCROLLBAR (Webkit)
   ============================================= */
::-webkit-scrollbar       { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 2px; }

/* =============================================
   RESPONSIVE
   ============================================= */
@media (min-width: 601px) {
  /* Show a subtle border on wider screens */
  .screen {
    border-left:  1px solid rgba(255,255,255,0.08);
    border-right: 1px solid rgba(255,255,255,0.08);
  }
}

.info-list { display: flex; flex-direction: column; gap: 10px; margin-top: 12px; }
.info-item { display: flex; align-items: flex-start; gap: 12px; }
.info-icon { font-size: 20px; flex-shrink: 0; width: 28px; text-align: center; }
.info-text { font-size: 14px; color: var(--text-w90); line-height: 1.5; }
.info-text b { color: var(--text-white); font-weight: 700; }
.info-sections { display: flex; flex-direction: column; gap: 16px; margin-top: 12px; }
.info-section { display: flex; flex-direction: column; gap: 4px; }
.info-section-title { font-size: 13px; font-weight: 700; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-w50); margin-bottom: 2px; }
.info-p { font-size: 14px; color: var(--text-w90); line-height: 1.6; margin: 0; }
.info-p b { color: var(--text-white); font-weight: 700; }
.info-ul { font-size: 14px; color: var(--text-w90); line-height: 1.6; margin: 4px 0 0 0; padding-left: 20px; }
.info-ul li { margin-bottom: 4px; }
.info-ul b { color: var(--text-white); font-weight: 700; }

/* Roll history modal */
.history-scroll { overflow-x: auto; overflow-y: auto; max-height: 60vh; }
.history-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.history-table thead th { position: sticky; top: 0; background: #1e1b3a; z-index: 1; padding: 8px 12px; text-align: left; font-weight: 700; color: var(--text-w70); border-bottom: 1px solid rgba(255,255,255,0.12); }
.history-cell { padding: 6px 12px; vertical-align: middle; }
.history-cell-num { width: 56px; font-weight: 600; color: var(--text-w70); }
.history-row { border-bottom: 1px solid rgba(255,255,255,0.06); }
.history-row:last-child { border-bottom: none; }
.history-round-start td { border-top: 4px solid var(--purple); padding-top: 8px; }
.history-dice-row { display: flex; gap: 6px; align-items: center; justify-content: center; flex-wrap: wrap; padding: 2px 0; }
.info-btn {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  vertical-align: middle;
  white-space: nowrap;
}
.info-btn-purple { background: var(--purple); }
.info-btn-green  { background: var(--green); }
.info-btn-orange { background: var(--orange); }
