.trpg-shell {
  display: grid;
  grid-template-columns: 1.4fr 1fr;
  gap: 20px;
  align-items: flex-start;
}

@media (max-width: 960px) {
  .trpg-shell {
    grid-template-columns: 1fr;
  }
}

.trpg-tabs {
  display: inline-flex;
  padding: 4px;
  border-radius: 999px;
  background: #eef2ff;
  border: 1px solid #d7ddeb;
  margin-bottom: 16px;
}

.trpg-tab {
  border: none;
  background: transparent;
  padding: 6px 14px;
  border-radius: 999px;
  font-weight: 600;
  color: #334155;
  cursor: pointer;
}

.trpg-tab.is-active {
  background: #0b57d0;
  color: #ffffff;
  box-shadow: 0 8px 18px rgba(11, 87, 208, 0.25);
}

.trpg-panel {
  margin-top: 6px;
}

.trpg-panel[hidden] {
  display: none;
}

.trpg-field {
  margin-top: 12px;
}

.trpg-field label {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

.trpg-number-input {
  display: flex;
  align-items: stretch;
  gap: 6px;
}

.trpg-number-input input[type='number'] {
  flex: 1;
  min-width: 0;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid #d7ddeb;
  font-size: 1rem;
}

.trpg-step-btn {
  border-radius: 999px;
  border: 1px solid #cdd4e5;
  background: #ffffff;
  padding: 6px 10px;
  cursor: pointer;
  min-width: 34px;
  font-weight: 700;
  color: #1f2937;
}

.trpg-step-btn.is-active {
  background: #0b57d0;
  color: #ffffff;
  border-color: #0b57d0;
}

.trpg-adv-toggle {
  margin-top: 10px;
}

.trpg-adv-toggle-label {
  display: block;
  font-weight: 700;
  margin-bottom: 4px;
}

.trpg-adv-group {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: #f3f5fb;
  border: 1px solid #d7ddeb;
}

.trpg-adv-btn {
  border: none;
  background: transparent;
  padding: 5px 12px;
  border-radius: 999px;
  font-weight: 600;
  cursor: pointer;
  color: #374151;
}

.trpg-adv-btn.is-active {
  background: #0b57d0;
  color: #ffffff;
  box-shadow: 0 6px 14px rgba(11, 87, 208, 0.25);
}

.trpg-inline-toggle {
  margin-top: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.trpg-inline-toggle input {
  margin: 0;
}

.trpg-actions {
  margin-top: 16px;
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.trpg-actions button {
  min-width: 140px;
}

.trpg-actions .primary {
  flex: 1 1 160px;
}

.form-error {
  color: #c62828;
  font-size: 0.9rem;
  margin-top: 4px;
}

.trpg-result {
  background: linear-gradient(135deg, #0f172a, #0b57d0);
  color: #ffffff;
  padding: 18px;
  border-radius: 14px;
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.12);
}

.trpg-result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.trpg-result-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 700;
  background: rgba(15, 118, 110, 0.12);
  color: #a7f3d0;
}

.trpg-result-badge--fail {
  background: rgba(220, 38, 38, 0.16);
  color: #fecaca;
}

.trpg-result-badge--neutral {
  background: rgba(148, 163, 184, 0.2);
  color: #e5e7eb;
}

.trpg-result-badge--crit {
  background: rgba(22, 163, 74, 0.25);
  color: #bbf7d0;
}

.trpg-result-badge--fumble {
  background: rgba(220, 38, 38, 0.25);
  color: #fecaca;
}

.trpg-result-main {
  font-size: clamp(2.2rem, 3.6vw, 3.2rem);
  font-weight: 800;
  margin: 6px 0;
}

.trpg-result-main--crit {
  color: #bbf7d0;
}

.trpg-result-main--fumble {
  color: #fecaca;
}

.trpg-result-detail {
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  opacity: 0.92;
  font-size: 0.98rem;
  margin: 0 0 4px;
}

.trpg-meaning {
  opacity: 0.86;
  font-size: 0.94rem;
  margin: 6px 0 0;
}

.trpg-share {
  margin-top: 16px;
}

.trpg-share-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}

.trpg-share-actions button {
  flex: 1 1 150px;
}

#shareTextPreview {
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
  background: #f5f7fb;
  border-radius: 10px;
  padding: 10px;
  margin-top: 10px;
  color: #1f2a44;
}

#statusMsg {
  margin-top: 8px;
  font-weight: 700;
  color: #0b57d0;
}

.history-list {
  list-style: none;
  padding: 0;
  margin: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.history-item {
  width: 100%;
}

.history-button {
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  background: #f7f8fc;
  border: 1px solid #e4e8f2;
  border-radius: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: border-color 120ms ease, transform 120ms ease;
}

.history-button:hover,
.history-button:focus-visible {
  border-color: #0b57d0;
  transform: translateY(-1px);
}

.history-time {
  color: #5b6478;
  font-size: 0.9rem;
}

.history-summary {
  flex: 1;
  text-align: left;
}

.history-mode {
  font-size: 0.85rem;
  font-weight: 600;
  color: #0b57d0;
}

.trpg-steps-list {
  display: grid;
  gap: 8px;
  padding-left: 20px;
  margin: 14px 0 0;
}

.trpg-steps-list strong {
  color: #0b57d0;
}

.muted {
  color: #5b6478;
}

.mono {
  font-family: ui-monospace, SFMono-Regular, Consolas, 'Liberation Mono', Menlo, monospace;
}

@media (max-width: 640px) {
  .trpg-share-actions button,
  .trpg-actions button {
    flex: 1 1 100%;
  }
}
