:root {
  --paper: #f4ecd8;
  --paper-deep: #e8dcc2;
  --ink: #221b17;
  --muted: #6f6258;
  --red: #7f1d1d;
  --red-deep: #4f1111;
  --border: #b8a88a;
  --shadow: rgba(35, 24, 21, 0.18);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  padding: 24px;
  color: var(--ink);
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif;
  line-height: 1.8;
  background:
    radial-gradient(circle at 20% 20%, rgba(255,255,255,0.45), transparent 22%),
    radial-gradient(circle at 80% 10%, rgba(127,29,29,0.08), transparent 25%),
    linear-gradient(135deg, #f7efd9, #e7dcc3);
}

body::before {
  content: "";
  position: fixed;
  inset: 0;
  pointer-events: none;
  opacity: 0.22;
  background-image:
    repeating-linear-gradient(0deg, rgba(60,45,30,0.10) 0 1px, transparent 1px 6px),
    repeating-linear-gradient(90deg, rgba(60,45,30,0.06) 0 1px, transparent 1px 8px);
  mix-blend-mode: multiply;
}

#app {
  max-width: 920px;
  margin: 0 auto;
}

h1,
h2,
h3 {
  font-family: "Hiragino Mincho ProN", "Yu Mincho", "YuMincho", serif;
  letter-spacing: 0.08em;
}

h1 {
  text-align: center;
  font-size: 2.2rem;
  margin: 16px 0 6px;
  color: var(--red-deep);
  text-shadow: 1px 1px 0 rgba(255,255,255,0.5);
}

h2 {
  margin-top: 0;
  padding-left: 12px;
  border-left: 6px solid var(--red);
  color: var(--red-deep);
}

h3 {
  color: var(--red-deep);
  border-bottom: 1px solid var(--border);
  padding-bottom: 4px;
}

.panel,
.card {
  position: relative;
  background:
    linear-gradient(180deg, rgba(255,255,255,0.36), rgba(255,255,255,0.08)),
    var(--paper);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-shadow: 0 8px 24px var(--shadow);
  padding: 22px;
  margin: 18px 0;
}

.panel::after,
.card::after {
  content: "";
  position: absolute;
  inset: 8px;
  border: 1px solid rgba(127, 29, 29, 0.14);
  pointer-events: none;
}

.card-list {
  display: grid;
  gap: 14px;
}

.character-card {
  display: flex;
  gap: 18px;
  align-items: center;
}

.character-card-body {
  flex: 1;
}

.row {
  display: flex;
  align-items: center;
  gap: 12px;
  margin: 10px 0;
}

label {
  width: 130px;
  color: var(--red-deep);
  font-weight: bold;
}

input,
textarea {
  width: 100%;
  border: 1px solid var(--border);
  background: rgba(255,255,255,0.55);
  color: var(--ink);
  padding: 9px 10px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 1rem;
}

input[type="number"] {
  max-width: 100px;
}

textarea {
  min-height: 190px;
  resize: vertical;
}

input:focus,
textarea:focus {
  outline: 2px solid rgba(127, 29, 29, 0.28);
  border-color: var(--red);
}

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

button,
.button-link {
  display: inline-block;
  border: 1px solid var(--red-deep);
  background: var(--red);
  color: #fff8ea;
  padding: 9px 16px;
  border-radius: 3px;
  font-family: inherit;
  font-size: 0.95rem;
  text-decoration: none;
  cursor: pointer;
  transition: transform 0.08s ease, filter 0.12s ease;
}

button:hover,
.button-link:hover {
  filter: brightness(1.08);
  transform: translateY(-1px);
}

button.secondary,
.button-link.secondary {
  background: #efe3c9;
  color: var(--red-deep);
  border-color: var(--border);
}

button.danger {
  background: #3a0d0d;
}

button:disabled {
  cursor: not-allowed;
  opacity: 0.55;
  transform: none;
}

.muted {
  color: var(--muted);
  font-size: 0.92rem;
}

.message {
  font-weight: bold;
}

.message.ok {
  color: #255c35;
}

.message.bad {
  color: #9d1c1c;
}

.icon-preview-area {
  display: flex;
  gap: 18px;
  align-items: center;
}

.icon-wrap {
  border: 1px solid var(--border);
  background: var(--paper-deep);
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--muted);
  box-shadow: inset 0 0 12px rgba(40, 25, 20, 0.12);
}

.icon-wrap img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.icon-wrap.small {
  width: 74px;
  height: 74px;
  border-radius: 8px;
}

.icon-wrap.large {
  width: 144px;
  height: 144px;
  border-radius: 10px;
  font-size: 32px;
}

.share-header {
  display: flex;
  gap: 22px;
  align-items: center;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(110px, 1fr));
  gap: 12px;
}

.stat-box {
  background: rgba(255,255,255,0.35);
  border: 1px solid var(--border);
  padding: 12px;
  text-align: center;
}

.stat-box strong {
  display: block;
  color: var(--red-deep);
}

@media (max-width: 640px) {
  body {
    padding: 12px;
  }

  h1 {
    font-size: 1.7rem;
  }

  .panel,
  .card {
    padding: 16px;
  }

  .row {
    display: block;
  }

  label {
    display: block;
    width: auto;
    margin-bottom: 4px;
  }

  input[type="number"] {
    max-width: none;
  }

  .character-card,
  .share-header,
  .icon-preview-area {
    align-items: flex-start;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .toolbar {
    display: grid;
    grid-template-columns: 1fr;
  }

  button,
  .button-link {
    width: 100%;
    text-align: center;
  }
}