:root {
  color-scheme: dark;
  --ink: #edf1e8;
  --muted: #9ba69c;
  --paper: #151b18;
  --paper-2: #1c2420;
  --paper-3: #242e29;
  --line: #344139;
  --gold: #d8a94a;
  --gold-soft: #f0d28d;
  --green: #64b486;
  --red: #df786f;
  --text: var(--ink);
  --accent: var(--gold);
  --danger: var(--red);
  --panel: var(--paper);
  --shadow: 0 18px 48px rgb(0 0 0 / 28%);
  font-family: Inter, "Noto Sans JP", "Yu Gothic UI", sans-serif;
}

* { box-sizing: border-box; }
body { margin: 0; min-width: 320px; min-height: 100vh; color: var(--ink); background: radial-gradient(circle at 14% -10%, rgb(63 102 77 / 34%), transparent 32rem), radial-gradient(circle at 90% 10%, rgb(111 82 39 / 18%), transparent 30rem), #0d1210; }
a { color: var(--gold-soft); }
button, input, select, textarea, .button { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .45; }

.site-header { position: sticky; z-index: 10; top: 0; display: flex; min-height: 72px; padding: 12px clamp(18px, 4vw, 64px); border-bottom: 1px solid rgb(255 255 255 / 8%); align-items: center; justify-content: space-between; background: rgb(13 18 16 / 88%); backdrop-filter: blur(18px); }
.brand { display: flex; align-items: center; gap: 11px; color: var(--ink); text-decoration: none; letter-spacing: .08em; }
.brand-mark { display: grid; width: 40px; height: 40px; place-items: center; border: 1px solid var(--gold); border-radius: 50% 50% 46% 54%; color: var(--gold-soft); font-family: Georgia, serif; font-size: 24px; transform: rotate(-5deg); }
.brand b, .brand small { display: block; }
.brand b { font-family: Georgia, serif; font-size: 17px; }
.brand small { margin-top: 1px; color: var(--muted); font-size: 9px; letter-spacing: .2em; }
.header-label { color: var(--muted); font-size: 11px; letter-spacing: .14em; }

main { width: min(1200px, calc(100% - 32px)); min-height: calc(100vh - 132px); margin: 0 auto; padding: 40px 0 64px; }
footer { display: flex; justify-content: space-between; padding: 18px clamp(18px, 4vw, 64px); border-top: 1px solid rgb(255 255 255 / 6%); color: #657168; font-size: 10px; letter-spacing: .16em; }
footer a { color: #89958b; text-decoration: none; }
footer a:hover { color: var(--gold-soft); }

h1, h2, h3, p { margin-top: 0; }
h1, h2 { font-family: Georgia, "Yu Mincho", serif; font-weight: 500; }
h1 { margin-bottom: 18px; font-size: clamp(32px, 4vw, 48px); line-height: 1.08; }
h2 { margin: 30px 0 10px; font-size: clamp(24px, 3vw, 34px); }
h3 { margin-bottom: 12px; font-size: 14px; letter-spacing: .06em; }
p { color: var(--muted); line-height: 1.75; }
.eyebrow { display: block; margin-bottom: 12px; color: var(--gold); font-size: 11px; font-weight: 700; letter-spacing: .22em; text-transform: uppercase; }

.panel { padding: clamp(22px, 4vw, 36px); border: 1px solid var(--line); border-radius: 18px; background: linear-gradient(145deg, rgb(31 40 35 / 96%), rgb(20 27 24 / 96%)); box-shadow: var(--shadow); }
.two-columns { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 0; padding: 0; overflow: hidden; }
.two-columns form { padding: clamp(26px, 4vw, 48px); }
.two-columns form + form { border-left: 1px solid var(--line); }

label { display: grid; gap: 7px; margin: 16px 0; color: #bac3bb; font-size: 12px; }
input, select, textarea { width: 100%; padding: 12px 13px; border: 1px solid #3c4941; border-radius: 9px; outline: none; color: var(--ink); background: #101613; }
textarea { resize: vertical; }
input:focus, select:focus, textarea:focus { border-color: var(--gold); box-shadow: 0 0 0 3px rgb(216 169 74 / 12%); }
button, .button { display: inline-flex; min-height: 40px; padding: 9px 16px; border: 1px solid transparent; border-radius: 8px; align-items: center; justify-content: center; color: #111612; background: var(--gold); font-weight: 700; text-decoration: none; }
button:hover:not(:disabled), .button:hover { filter: brightness(1.08); }
.secondary { border-color: #48564d; color: var(--ink); background: #27322c; }
.danger { border-color: #70423f; color: #ffd3cf; background: #3b2422; }
.hidden { display: none !important; }

.room-heading, .draft-heading, .actions, .section-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.room-heading { align-items: end; margin-bottom: 18px; }
.room-heading h1 { margin-bottom: 0; }
.badge { padding: 7px 12px; border: 1px solid var(--line); border-radius: 999px; color: var(--gold-soft); background: #20271f; font-size: 11px; }
.players { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 10px; margin: 22px 0; }
.player { display: flex; min-height: 58px; padding: 12px; border: 1px solid var(--line); border-radius: 10px; align-items: center; justify-content: space-between; gap: 8px; background: #121915; }
.player-remove { min-height: 28px; padding: 4px 8px; border-color: #70423f; color: #ffd3cf; background: #3b2422; font-size: 11px; }
.player.waiting { border-color: var(--gold); }

.card-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 14px; }
.card { display: flex; min-width: 0; padding: 0; overflow: hidden; border: 1px solid #566258; border-radius: 10px; flex-direction: column; align-items: stretch; justify-content: flex-start; color: var(--ink); background: #121915; box-shadow: 0 8px 18px rgb(0 0 0 / 22%); text-align: left; font-weight: 400; transition: border-color .15s, transform .15s, box-shadow .15s; }
.card.selected { border-color: var(--gold); box-shadow: 0 0 0 2px rgb(216 169 74 / 35%), 0 10px 22px rgb(0 0 0 / 30%); }
@media (hover: hover) and (pointer: fine) { .card.selectable:hover { border-color: var(--gold); transform: translateY(-4px); box-shadow: 0 12px 24px rgb(0 0 0 / 34%); } }
.card img { display: block; width: 100%; max-width: 100%; height: auto; aspect-ratio: 63 / 88; flex: none; object-fit: cover; background: var(--paper-3); }
.card-info { display: grid; width: 100%; min-width: 0; gap: 4px; padding: 10px; overflow-wrap: anywhere; }
.card-info strong { line-height: 1.2; }
.card-meta { color: var(--muted); font-size: 12px; }
.compact { grid-template-columns: repeat(auto-fill, minmax(130px, 1fr)); }
.compact .card-info { padding: 8px; }
.grouped-cards { display: grid; grid-template-columns: minmax(0, 1fr); gap: 18px; }
.card-group { min-width: 0; padding: 16px; border: 1px solid var(--line); border-radius: 12px; background: rgb(12 16 15 / 60%); }
.card-group h3 { margin: 0 0 12px; color: var(--gold-soft); font-size: 16px; }
.card-group-count { color: var(--muted); font-size: 12px; font-weight: 400; }
.card-group .card-grid { grid-template-columns: repeat(auto-fill, minmax(125px, 170px)); justify-content: start; gap: 12px; }

#result-text { min-height: 180px; margin: 18px 0; }
#message { position: fixed; z-index: 50; left: 50%; bottom: 20px; max-width: calc(100vw - 32px); padding: 10px 16px; border: 1px solid #67502a; border-radius: 8px; color: #f6dfaa; background: #2e2618; box-shadow: var(--shadow); opacity: 0; pointer-events: none; transform: translateX(-50%); transition: opacity .2s; }
#message.visible { opacity: 1; }
#message.error { border-color: #6e3d3a; color: #ffd2cf; background: #321f1e; }
#confirm-dialog, #card-preview-dialog { padding: 0; border: 1px solid var(--line); border-radius: 14px; color: var(--ink); background: var(--paper); box-shadow: 0 24px 80px #000b; }
#confirm-dialog { width: min(420px, calc(100% - 32px)); }
#confirm-dialog::backdrop, #card-preview-dialog::backdrop { background: #000b; backdrop-filter: blur(4px); }
.confirm-dialog-content { padding: 24px; }
.confirm-dialog-content h2 { margin: 0 0 12px; }
.confirm-dialog-content p { color: var(--muted); line-height: 1.6; white-space: pre-wrap; }
.confirm-dialog-actions { display: flex; justify-content: flex-end; gap: 10px; margin-top: 24px; }
#card-preview-dialog { width: min(560px, calc(100% - 24px)); max-height: calc(100dvh - 24px); background: #090c0b; }
.card-preview-content { display: grid; gap: 12px; padding: 14px; }
.card-preview-heading { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.card-preview-heading button { min-height: 34px; flex: none; padding: 7px 11px; }
#card-preview-image { display: block; width: auto; max-width: 100%; max-height: calc(100dvh - 100px); margin: 0 auto; border-radius: 10px; object-fit: contain; }

@media (max-width: 680px) {
  .site-header { min-height: 64px; padding-inline: 12px; }
  .brand b { font-size: 14px; }
  .brand small { display: none; }
  .brand-mark { width: 34px; height: 34px; font-size: 20px; }
  main { width: min(100% - 20px, 1200px); padding-top: 18px; }
  .two-columns { grid-template-columns: 1fr; }
  .two-columns form { padding: 24px 20px; }
  .two-columns form + form { border-top: 1px solid var(--line); border-left: 0; }
  .panel { padding: 18px; }
  .two-columns.panel { padding: 0; }
  .card-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  footer { flex-direction: column; gap: 8px; }
}

@media (prefers-reduced-motion: reduce) { *, *::before, *::after { transition-duration: .01ms !important; animation-duration: .01ms !important; } }
