:root {
  color-scheme: light;
  --bg: #f7f8fb;
  --ink: #172033;
  --muted: #5b6578;
  --line: #cfd6e3;
  --panel: #ffffff;
  --accent: #2364aa;
  --accent-strong: #174a80;
  --danger: #9f1f32;
  --ok: #1e7046;
  --gold: #916314;
}

* {
  box-sizing: border-box;
}

[hidden] {
  display: none !important;
}

body {
  margin: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: "Yu Gothic UI", "Meiryo", system-ui, sans-serif;
  line-height: 1.6;
}

button,
input,
select,
textarea {
  font: inherit;
}

button {
  border: 1px solid var(--accent);
  border-radius: 6px;
  background: var(--accent);
  color: #fff;
  padding: 0.55rem 0.75rem;
  cursor: pointer;
}

button:hover,
button:focus {
  background: var(--accent-strong);
}

button:disabled {
  border-color: #aab2c0;
  background: #d8dde6;
  color: #596273;
  cursor: not-allowed;
}

input,
select,
textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.5rem;
  background: #fff;
  color: var(--ink);
}

input[type="checkbox"] {
  width: auto;
}

label {
  display: grid;
  gap: 0.25rem;
  font-weight: 700;
}

.app-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem clamp(1rem, 4vw, 2rem);
  background: #11213d;
  color: #fff;
}

.app-header h1 {
  margin: 0;
  font-size: clamp(1.5rem, 3vw, 2.4rem);
  letter-spacing: 0;
}

.eyebrow {
  margin: 0 0 0.2rem;
  color: #b9c8e8;
  font-size: 0.9rem;
}

nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

nav a {
  border: 1px solid #64799d;
  border-radius: 6px;
  color: #fff;
  padding: 0.35rem 0.55rem;
  text-decoration: none;
}

main {
  width: min(1180px, calc(100% - 2rem));
  margin: 1rem auto 3rem;
}

.status,
.panel {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.status {
  padding: 0.75rem 1rem;
}

.menu-screen {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  padding: 1rem;
}

.menu-screen h2 {
  margin: 0 0 0.75rem;
}

.menu-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 0.75rem;
}

.menu-actions button {
  min-height: 4rem;
  font-size: 1.1rem;
  font-weight: 700;
}

.panel {
  margin-top: 1rem;
  padding: 1rem;
}

.panel h2 {
  margin: 0 0 0.75rem;
}

.panel h3 {
  margin: 1.25rem 0 0.35rem;
}

.grid-form {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 0.8rem;
}

.wide {
  grid-column: 1 / -1;
}

.back-button {
  margin-bottom: 0.75rem;
}

.keyword-panel,
.template-panel {
  display: grid;
  gap: 0.5rem;
}

.keyword-panel > button,
.template-panel > button {
  justify-self: start;
}

.keyword-options {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
  gap: 0.5rem;
  margin: 0;
  padding: 0.75rem;
}

.keyword-options label {
  align-items: center;
  display: flex;
  gap: 0.45rem;
  font-weight: 700;
}

.template-options {
  display: grid;
  gap: 0.75rem;
}

.template-options fieldset {
  border: 1px solid var(--line);
  border-radius: 8px;
  display: grid;
  gap: 0.6rem;
  margin: 0;
  padding: 0.75rem;
}

.template-options fieldset > label {
  align-items: center;
  display: flex;
  gap: 0.45rem;
}

.template-options select,
.template-options textarea,
.template-options input[type="text"],
.template-options input[type="number"] {
  max-width: 520px;
}

.effect-row {
  border: 1px solid var(--line);
  border-radius: 6px;
  display: grid;
  grid-template-columns: minmax(220px, 1fr) minmax(180px, 1fr);
  gap: 0.6rem;
  padding: 0.6rem;
}

.effect-row label {
  align-content: start;
}

.approval-list {
  display: grid;
  gap: 0.75rem;
  margin-top: 0.75rem;
}

.approval-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fbfcff;
  padding: 0.75rem;
}

.approval-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-top: 0.6rem;
}

.sub-panel {
  border-top: 1px solid var(--line);
  margin-top: 1.25rem;
  padding-top: 1rem;
}

.hint {
  margin: 0.25rem 0 0.65rem;
  color: var(--muted);
}

.file-label {
  max-width: 420px;
}

.deck-toolbar,
.battle-actions {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  align-items: end;
  gap: 0.75rem;
}

.count {
  display: inline-block;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 0.35rem 0.65rem;
  font-weight: 700;
}

.card-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 0.75rem;
}

.card-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  background: #fbfcff;
}

.card-summary {
  width: 100%;
  border-color: var(--line);
  background: #eef4fb;
  color: var(--ink);
  text-align: left;
}

.card-details {
  margin-top: 0.65rem;
}

.card-meta {
  margin: 0.2rem 0;
  color: var(--muted);
}

.stepper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.5rem;
}

.stepper button {
  min-width: 2.5rem;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.battle-log {
  min-height: 3rem;
  max-height: 12rem;
  overflow: auto;
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 0.75rem 0;
  padding: 0.75rem;
  background: #fdfaf2;
}

.battle-layout,
.battle-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 0.75rem;
}

.battle-section {
  border: 1px solid var(--line);
  border-radius: 8px;
  margin-top: 0.75rem;
  padding: 0.75rem;
  background: #fff;
}

.battle-section h3,
.battle-section summary {
  font-weight: 700;
}

.battle-section h3 {
  margin: 0 0 0.65rem;
}

.zone {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 0.75rem;
  background: #fff;
}

.zone h3 {
  margin-top: 0;
}

.mini-card {
  border: 1px solid var(--line);
  border-radius: 6px;
  margin: 0.4rem 0;
  padding: 0.55rem;
  background: #f8fbff;
}

.mini-card button {
  margin: 0.25rem 0.25rem 0 0;
}

.mini-card.is-hidden {
  opacity: 0.58;
}

.enemy {
  border-color: #d7a1aa;
  background: #fff7f8;
}

.friendly {
  border-color: #9ccbb1;
  background: #f5fff8;
}

.hero-select {
  border: 1px solid var(--gold);
  border-radius: 8px;
  padding: 0.75rem;
  margin-top: 0.75rem;
  background: #fff9e8;
}

.notification-list {
  padding-left: 1.3rem;
}

.modal-backdrop {
  align-items: center;
  background: rgba(14, 24, 43, 0.58);
  display: flex;
  inset: 0;
  justify-content: center;
  padding: 1rem;
  position: fixed;
  z-index: 50;
}

.target-modal {
  background: #fff;
  border: 2px solid var(--accent);
  border-radius: 8px;
  max-height: min(80vh, 720px);
  max-width: 620px;
  overflow: auto;
  padding: 1rem;
  width: min(100%, 620px);
}

.target-modal h2 {
  margin-top: 0;
}

.target-options {
  display: grid;
  gap: 0.5rem;
  margin: 0.75rem 0;
}

.target-options button {
  text-align: left;
}

@media (max-width: 720px) {
  .app-header {
    align-items: flex-start;
    flex-direction: column;
  }

  .effect-row {
    grid-template-columns: 1fr;
  }
}
