:root {
  --ink: #211b14;
  --muted: #6b6257;
  --paper: #f5efe3;
  --paper-soft: #faf7ef;
  --panel: #f8f3e9;
  --line: #211b14;
  --line-soft: rgba(33, 27, 20, 0.28);
  --shadow: rgba(33, 27, 20, 0.18);
  --warning-bg: #fff2cf;
  --warning-line: #8a5a00;
}

* {
  box-sizing: border-box;
}

html {
  min-height: 100%;
  background: var(--paper);
}

body {
  margin: 0;
  min-height: 100%;
  color: var(--ink);
  background:
    radial-gradient(circle at top, rgba(255, 255, 255, 0.38), transparent 24rem),
    var(--paper);
  font-family: Georgia, "Times New Roman", serif;
  font-size: 15px;
}

button,
input {
  font: inherit;
}

button {
  cursor: pointer;
}

.app-header {
  position: relative;
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  min-height: 4.8rem;
  padding: 0.45rem 1.2rem;
  border-bottom: 3px solid var(--line);
  background: rgba(245, 239, 227, 0.92);
}

.version-box {
  align-self: end;
  color: var(--muted);
  font-size: 0.78rem;
  line-height: 1.15;
}

.version-box p {
  margin: 0;
}

.logo-link {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  text-decoration: none;
}

.logo-image {
  display: block;
  width: min(11.5rem, 36vw);
  height: auto;
}

.layout {
  display: grid;
  grid-template-columns: minmax(20rem, 0.95fr) minmax(25rem, 1.08fr) minmax(19rem, 0.85fr);
  gap: 0.45rem;
  padding: 0.75rem 0.9rem 1.1rem;
}

.panel {
  min-width: 0;
}

.box {
  border: 2px solid var(--line);
  background: rgba(250, 247, 239, 0.72);
  box-shadow: 0.32rem 0.32rem 0 var(--shadow);
  padding: 0.75rem;
}

.box + .box {
  margin-top: 0.65rem;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 0.55rem;
  font-size: clamp(1.45rem, 2.1vw, 2.05rem);
  line-height: 1.02;
}

h2 {
  margin-bottom: 0.35rem;
  font-size: 1.02rem;
  line-height: 1.1;
}

h3 {
  margin-bottom: 0.25rem;
  font-size: 0.92rem;
  line-height: 1.1;
}

.rules-note,
.small-note,
.empty-note {
  color: var(--muted);
  line-height: 1.28;
}

.rules-note {
  margin-bottom: 0.75rem;
  font-size: 0.82rem;
}

.small-note {
  margin: 0.45rem 0 0;
  font-size: 0.8rem;
}

.empty-note {
  margin: 0;
  padding: 0.42rem;
  text-align: center;
  font-style: italic;
}

.message-box {
  min-height: 1.85rem;
  margin-bottom: 0.65rem;
  padding: 0.42rem 0.55rem;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.45);
  color: var(--muted);
  line-height: 1.25;
}

.message-warning {
  border-color: var(--warning-line);
  background: var(--warning-bg);
  color: var(--ink);
}

.selection-box {
  min-height: 3.2rem;
  margin-bottom: 0.65rem;
  padding: 0.4rem;
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.38);
}

.button-row {
  display: flex;
  justify-content: flex-end;
  gap: 0.45rem;
  flex-wrap: wrap;
}

.button-primary,
.button-secondary {
  border: 2px solid var(--line);
  padding: 0.42rem 0.7rem;
  font-weight: 700;
  line-height: 1.1;
  box-shadow: none;
}

.button-primary {
  background: var(--line);
  color: var(--paper-soft);
}

.button-secondary {
  background: var(--paper-soft);
  color: var(--ink);
}

.button-primary:hover,
.button-secondary:hover,
.symbol-button:hover,
.token:hover {
  transform: translateY(-1px);
}

.choice-group {
  margin: 0 0 0.65rem;
  padding: 0.55rem 0.55rem 0.65rem;
  border: 2px solid var(--line);
  background: rgba(245, 239, 227, 0.45);
}

.choice-group:last-child {
  margin-bottom: 0;
}

.choice-group legend {
  padding: 0 0.55rem;
  font-size: 1.28rem;
  font-weight: 700;
  line-height: 1;
}

.color-row {
  margin-bottom: 0.45rem;
  padding: 0.42rem 0.55rem;
  background: rgba(255, 255, 255, 0.24);
}

.color-row:last-child {
  margin-bottom: 0;
}

.color-row h3 {
  margin-bottom: 0.3rem;
  font-size: 1.06rem;
}

.choice-strip {
  display: flex;
  align-items: center;
  gap: 0.32rem;
  flex-wrap: wrap;
}

.choice-separator {
  display: inline-block;
  width: 0;
  height: 2.35rem;
  margin: 0 0.22rem;
  border-left: 4px solid var(--line);
}

.symbol-button,
.token {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 2.55rem;
  height: 2.55rem;
  border: 2px solid var(--line);
  background: rgba(255, 255, 255, 0.54);
  color: var(--ink);
  position: relative;
}

.symbol-button .symbol,
.token .symbol,
.result-name .symbol,
.reroll-option .symbol {
  font-family: "ZdH Symbols", Georgia, serif;
  color: var(--die-color);
  text-shadow: var(--die-outline);
  line-height: 1;
}

.symbol-button .symbol {
  font-size: 2rem;
}

.token {
  margin: 0.2rem;
}

.token .symbol {
  font-size: 1.8rem;
}

.remove-mark {
  position: absolute;
  right: -0.36rem;
  top: -0.36rem;
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 1rem;
  height: 1rem;
  border: 1px solid var(--line);
  background: var(--paper-soft);
  color: var(--ink);
  font-family: Arial, sans-serif;
  font-size: 0.8rem;
  line-height: 1;
}

.result-box {
  border: 1px solid var(--line-soft);
  background: rgba(255, 255, 255, 0.38);
  padding: 0.42rem;
}

.result-line {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.75rem;
  align-items: center;
  padding: 0.32rem 0.15rem;
  border-bottom: 1px solid rgba(33, 27, 20, 0.18);
}

.result-line:last-of-type {
  border-bottom: 0;
}

.result-name {
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  min-width: 0;
}

.result-name .symbol {
  font-size: 1.2rem;
}

.result-value {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}

.reroll-note {
  color: var(--muted);
  font-size: 0.82rem;
  font-style: italic;
}

.success-box {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 0.75rem;
  margin-top: 0.5rem;
  padding: 0.55rem 0.65rem;
  border: 2px solid var(--line);
  background: rgba(245, 239, 227, 0.7);
  font-weight: 700;
}

.success-box strong {
  font-size: 1.75rem;
  line-height: 1;
}

.reroll-list {
  display: grid;
  gap: 0.45rem;
  margin: 0.65rem 0;
}

.reroll-option {
  display: grid;
  grid-template-columns: auto auto minmax(0, 1fr);
  gap: 0.5rem;
  align-items: center;
  padding: 0.4rem;
  border: 1px solid rgba(33, 27, 20, 0.2);
  background: rgba(255, 255, 255, 0.3);
}

.reroll-option .symbol {
  font-size: 1.15rem;
}

.history-list {
  margin: 0;
  padding-left: 0;
  list-style: none;
}

.history-list li {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.5rem;
  padding: 0.28rem 0;
  border-bottom: 1px solid rgba(33, 27, 20, 0.16);
}

.history-list li:last-child {
  border-bottom: 0;
}


.history-set {
  display: inline-flex;
  align-items: center;
  gap: 0.16rem;
  min-width: 0;
  flex-wrap: wrap;
}

.history-token {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  width: 1.35rem;
  height: 1.35rem;
}

.history-token .symbol {
  font-family: "ZdH Symbols", Georgia, serif;
  color: var(--die-color);
  text-shadow: var(--die-outline);
  font-size: 1.08rem;
  line-height: 1;
}

.history-separator {
  display: inline-block;
  width: 0;
  height: 1.2rem;
  margin: 0 0.12rem;
  border-left: 2px solid var(--line);
}

.history-prefix {
  margin-right: 0.28rem;
  color: var(--muted);
  font-size: 0.78rem;
  font-style: italic;
}

@media (max-width: 1180px) {
  .layout {
    grid-template-columns: 1fr 1fr;
  }

  .side-panel {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.45rem;
  }

  .side-panel .box {
    margin-top: 0;
  }
}

@media (max-width: 760px) {
  .app-header {
    grid-template-columns: 1fr;
    justify-items: center;
    gap: 0.4rem;
  }

  .version-box {
    justify-self: start;
  }

  .layout,
  .side-panel {
    grid-template-columns: 1fr;
  }

  .layout {
    padding: 0.75rem;
  }

  .box {
    padding: 0.42rem;
  }

  .choice-group legend {
    font-size: 1.35rem;
  }

  .symbol-button,
  .token {
    width: 2.35rem;
    height: 2.35rem;
  }

  .symbol-button .symbol {
    font-size: 1.8rem;
  }
}

/* Version 0.2c: dichteres Layout und Ergebnis-Neuwürfe */
body {
  font-size: 14px;
}

.app-header {
  min-height: 4.3rem;
  padding: 0.25rem 1rem;
}

.logo-image {
  width: 180px;
  height: 80px;
  max-width: 180px;
  max-height: 80px;
  object-fit: contain;
}

.layout {
  gap: 0.35rem;
  padding: 0.55rem 0.75rem 0.9rem;
}

.box {
  padding: 0.58rem;
  box-shadow: 0.24rem 0.24rem 0 var(--shadow);
}

.box + .box {
  margin-top: 0.5rem;
}

h1 {
  margin-bottom: 0.42rem;
  font-size: clamp(1.2rem, 1.55vw, 1.55rem);
  line-height: 1.02;
}

h2 {
  margin-bottom: 0.28rem;
  font-size: 0.94rem;
}

h3 {
  margin-bottom: 0.22rem;
  font-size: 0.86rem;
}

.rules-note {
  margin-bottom: 0.55rem;
  font-size: 0.76rem;
}

.message-box {
  min-height: 1.6rem;
  margin-bottom: 0.5rem;
  padding: 0.32rem 0.45rem;
}

.selection-box {
  min-height: 2.7rem;
  margin-bottom: 0.5rem;
  padding: 0.3rem;
}

.choice-group {
  margin-bottom: 0.48rem;
  padding: 0.42rem 0.42rem 0.48rem;
}

.choice-group legend {
  padding: 0 0.45rem;
  font-size: 1.06rem;
}

.color-row {
  margin-bottom: 0.32rem;
  padding: 0.3rem 0.42rem;
}

.color-row h3 {
  margin-bottom: 0.22rem;
  font-size: 0.94rem;
}

.choice-strip {
  gap: 0.22rem;
}

.choice-separator {
  height: 2.25rem;
  margin: 0 0.16rem;
  border-left-width: 3px;
}

.symbol-button,
.token {
  width: 2.42rem;
  height: 2.42rem;
}

.symbol-button .symbol {
  font-size: 1.92rem;
}

.token .symbol {
  font-size: 1.74rem;
}

.special-rule-grid {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(8rem, auto);
  gap: 1rem;
  align-items: start;
  padding: 0.42rem 0.55rem;
  background: rgba(255, 255, 255, 0.24);
}

.special-rule-block h3 {
  margin-bottom: 0.28rem;
  padding-bottom: 0.18rem;
  border-bottom: 1px solid rgba(33, 27, 20, 0.12);
  font-size: 1.02rem;
}

.special-rule-heavy {
  justify-self: end;
  text-align: center;
}

.special-rule-heavy .choice-strip {
  justify-content: center;
}

.result-line {
  grid-template-columns: minmax(0, 1fr) auto auto;
  gap: 0.5rem;
  padding: 0.28rem 0.12rem;
}

.result-actions {
  display: inline-flex;
  justify-content: center;
  align-items: center;
  min-width: 0;
}

.inline-reroll-button {
  border: 2px solid var(--line);
  padding: 0.22rem 0.45rem;
  background: var(--line);
  color: var(--paper-soft);
  font-size: 0.72rem;
  font-weight: 700;
  line-height: 1.05;
  white-space: nowrap;
}

.inline-reroll-button:hover {
  transform: translateY(-1px);
}

.inline-symbol {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 1em;
  height: 1em;
  vertical-align: -0.1em;
}

.inline-symbol .symbol {
  font-family: "ZdH Symbols", Georgia, serif;
  color: var(--die-color);
  text-shadow: var(--die-outline);
  font-size: 1.18em;
  line-height: 1;
}

.evaluation-notes {
  margin-top: 0.45rem;
  padding-top: 0.42rem;
  border-top: 1px solid rgba(33, 27, 20, 0.18);
  color: var(--muted);
  font-size: 0.82rem;
  line-height: 1.25;
}

.evaluation-notes p,
.evaluation-notes ul {
  margin-bottom: 0;
}

.ones-note ul {
  margin: 0.24rem 0 0;
  padding-left: 1.1rem;
}

.botch-note {
  color: var(--ink);
}

.success-botch {
  border-color: #6b1a12;
}

.compact-reroll-list {
  gap: 0.28rem;
}

.compact-reroll-list .reroll-option {
  grid-template-columns: auto minmax(0, auto) minmax(0, 1fr);
  gap: 0.35rem;
  padding: 0.28rem;
  font-size: 0.8rem;
}

@media (max-width: 760px) {
  .logo-image {
    width: 180px;
    height: 80px;
  }

  .special-rule-grid {
    grid-template-columns: 1fr;
  }

  .special-rule-heavy {
    justify-self: stretch;
    text-align: left;
  }

  .special-rule-heavy .choice-strip {
    justify-content: flex-start;
  }

  .result-line {
    grid-template-columns: 1fr auto;
  }

  .result-actions {
    grid-column: 1 / -1;
    justify-content: flex-start;
  }
}


/* Version 0.2d: direkte Neuwürfe, schwarze Einsenhinweise und mobile Modifikator-Zeile */
.side-panel {
  display: block;
}

.result-line {
  grid-template-columns: minmax(0, 1fr) minmax(8.8rem, 10rem) minmax(3.5rem, auto);
}

.result-actions {
  justify-content: center;
}

.ones-note,
.ones-note strong {
  color: var(--ink);
}

.botch-note {
  color: var(--ink);
}

@media (max-width: 760px) {
  .choice-separator {
    flex-basis: 100%;
    width: 100%;
    height: 0;
    margin: 0.18rem 0 0.1rem;
    border-left: 0;
    border-top: 3px solid var(--line);
  }

  .result-line {
    grid-template-columns: 1fr auto;
  }

  .result-actions {
    grid-column: 1 / -1;
    justify-content: center;
  }
}


/* Einheitlicher Generator-Kopfbereich */

.app-header {
  position: relative;
  display: grid !important;
  grid-template-columns: 1fr minmax(0, auto) 1fr !important;
  grid-template-areas:
    "left center right"
    "left meta right";
  align-items: center !important;
  justify-items: center !important;
  gap: 0.18rem 1rem !important;
  min-height: 6rem;
  padding: 0.55rem 1.25rem 0.45rem !important;
  border-bottom: 3px solid var(--line) !important;
  background: var(--paper) !important;
  color: var(--ink) !important;
  overflow: hidden;
}

.header-center {
  grid-area: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.05rem;
  text-align: center;
  min-width: 0;
}

.header-meta {
  grid-area: meta;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.06rem;
  text-align: center;
  min-width: 0;
}

.header-action {
  grid-area: right;
  justify-self: end;
  align-self: center;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  min-width: 0;
}

.logo-link {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.logo-image {
  display: block;
  width: auto;
  max-width: 135px;
  max-height: 60px;
  height: auto;
}

.generator-name {
  margin: 0;
  color: var(--ink);
  font-size: 1.08rem;
  font-weight: 700;
  line-height: 1.05;
}

.version-label,
.site-link {
  color: var(--muted);
  font-size: 0.72rem;
  line-height: 1.05;
}

.site-link {
  text-decoration: none;
  white-space: nowrap;
}

.site-link:hover,
.site-link:focus {
  text-decoration: underline;
}

.app-header .print-button {
  border: 2px solid var(--line) !important;
  background: #ffffff;
  padding: 0.42rem 0.72rem;
  font-family: inherit;
  font-size: 0.78rem;
  font-weight: bold;
  line-height: 1;
  cursor: pointer;
  white-space: nowrap;
}

@media (max-width: 720px) {
  .app-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.28rem !important;
    min-height: auto;
    padding: 0.65rem 0.8rem 0.55rem !important;
    text-align: center;
  }

  .header-action {
    order: 1;
    justify-content: center;
  }

  .header-center {
    order: 2;
  }

  .header-meta {
    order: 3;
  }

  .logo-image {
    max-width: 135px;
    max-height: 60px;
  }

  .generator-name {
    font-size: 1.12rem;
  }

  .site-link,
  .version-label {
    font-size: 0.72rem;
  }
}


/* Mobile Sonderregeln: Goldener Würfel, Stern und schwere Probe bleiben nebeneinander */

@media (max-width: 760px) {
  .special-rule-grid {
    grid-template-columns: minmax(0, 1fr) minmax(0, auto) !important;
    gap: 0.55rem !important;
    align-items: start !important;
  }

  .special-rule-heavy {
    justify-self: end !important;
    text-align: center !important;
  }

  .special-rule-heavy .choice-strip {
    justify-content: center !important;
  }

  .special-rule-block h3 {
    font-size: 0.95rem !important;
    white-space: nowrap;
  }

  .special-rule-grid .choice-strip {
    flex-wrap: nowrap !important;
  }
}

/* Version 0.2f/008: gemeinsamer Generator-Header und Footer */
.app-header {
  display: grid !important;
  grid-template-columns: 1fr auto 1fr !important;
  grid-template-areas: "left center right" !important;
  align-items: center !important;
  justify-items: center !important;
  min-height: 5.1rem !important;
  padding: 0.55rem 1.25rem 0.45rem !important;
  border-bottom: 3px solid var(--line) !important;
  background: var(--paper) !important;
  overflow: visible !important;
}

.header-center {
  grid-area: center !important;
  display: flex !important;
  flex-direction: column !important;
  align-items: center !important;
  justify-content: center !important;
  gap: 0.06rem !important;
  text-align: center !important;
  min-width: 0 !important;
}

.header-meta {
  display: none !important;
}

.logo-image {
  display: block !important;
  width: auto !important;
  max-width: 135px !important;
  max-height: 60px !important;
  height: auto !important;
  object-fit: contain !important;
}

.generator-name {
  margin: 0 !important;
  color: var(--ink) !important;
  font-size: 1.42rem !important;
  font-weight: 700 !important;
  line-height: 1.05 !important;
}

.generator-footer {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.08rem;
  padding: 0.55rem 1rem 0.8rem;
  color: var(--muted);
  text-align: center;
  font-size: 0.78rem;
  line-height: 1.1;
}

.generator-footer .site-link {
  color: var(--muted);
  text-decoration: none;
}

.generator-footer .site-link:hover,
.generator-footer .site-link:focus {
  text-decoration: underline;
}

.generator-footer .version-label {
  color: var(--muted);
}

.exception-note {
  font-weight: 700;
}

@media (max-width: 720px) {
  .app-header {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    gap: 0.28rem !important;
    min-height: auto !important;
    padding: 0.65rem 0.8rem 0.55rem !important;
    text-align: center !important;
  }

  .generator-name {
    font-size: 1.42rem !important;
  }

  .generator-footer {
    font-size: 0.76rem;
    padding-bottom: 0.7rem;
  }
}

/* Mobile Sonderregeln: Goldener Würfel und Goldener Stern mit vertikalem Trenner */
@media (max-width: 760px) {
  .special-group .choice-separator {
    flex-basis: auto !important;
    width: 0 !important;
    height: 2.25rem !important;
    margin: 0 0.16rem !important;
    border-top: 0 !important;
    border-left: 3px solid var(--line) !important;
  }
}
