
:root {
  color-scheme: dark;
  --background: #191e2c;
  --panel: #242938;
  --border: #454b60;
  --accent: #a18ce8;
  --button: #575589;
  --text: #ffffff;
  --subtext: #b5b8c9;
  --success: #81d6a3;
  --failure: #ff8585;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 12px;
  background: var(--background);
  color: var(--text);
  font-family: Arial, "Noto Sans JP", sans-serif;
  font-size: 14px;
}

header {
  padding: 8px 4px 14px;
  border-bottom: 1px solid var(--border);
}

h1 {
  margin: 0;
  font-size: 24px;
}

header p {
  margin: 6px 0 0;
  color: var(--subtext);
  font-size: 12px;
}

section {
  margin-top: 12px;
  padding: 12px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 8px;
}

h2 {
  margin: 0 0 12px;
  color: var(--accent);
  font-size: 15px;
}

label {
  display: block;
  margin-bottom: 6px;
  color: var(--subtext);
}

input,
select,
button {
  font: inherit;
  min-height: 36px;
  border: 1px solid var(--border);
  border-radius: 5px;
}

input,
select {
  width: 100%;
  padding: 8px;
  background: var(--background);
  color: var(--text);
}

input:focus,
select:focus {
  outline: 2px solid var(--accent);
}

button {
  width: 100%;
  padding: 8px;
  background: var(--button);
  color: var(--text);
  cursor: pointer;
  touch-action: manipulation;
}

button:hover {
  background: #7067a8;
}

button:active {
  transform: scale(0.97);
}

#attributes {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.attribute {
  min-width: 0;
  padding: 8px;
  background: var(--background);
  border: 1px solid var(--border);
  border-radius: 6px;
  text-align: center;
}

.attribute label {
  color: var(--text);
  font-weight: bold;
}

.attribute input {
  margin: 6px 0;
  text-align: center;
  font-size: 18px;
}

.attribute small {
  display: block;
  margin-bottom: 5px;
  color: var(--subtext);
  font-size: 11px;
}

#rollResult {
  min-height: 90px;
  padding: 16px;
  background: var(--background);
  border-radius: 6px;
  text-align: center;
  overflow-wrap: anywhere;
}

.roll-number {
  margin: 8px 0;
  font-size: 36px;
  font-weight: bold;
}

.success {
  color: var(--success);
}

.failure {
  color: var(--failure);
}

.critical {
  color: #ffd76a;
  font-weight: bold;
}

.fumble {
  color: #ff5555;
  font-weight: bold;
}

#rollHistory {
  max-height: 200px;
  overflow-y: auto;
  overflow-wrap: anywhere;
}

.history-item {
  padding: 8px 4px;
  border-bottom: 1px solid var(--border);
}

@media (max-width: 420px) {
  body {
    padding: 6px;
  }

  section {
    padding: 8px;
  }

  #attributes {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  input,
  select,
  button {
    min-height: 44px;
    font-size: 16px;
  }
}
