:root {
  --bg: #171325;
  --bg-2: #211a35;
  --panel: rgba(255, 255, 255, 0.09);
  --panel-strong: rgba(255, 255, 255, 0.14);
  --line: rgba(255, 255, 255, 0.16);
  --text: #fffaf0;
  --muted: #d6cde5;
  --accent: #ffd46f;
  --accent-2: #9ee8ff;
  --danger: #ff8b8b;
  --good: #9df0aa;
  --shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
  --radius: 22px;
  --radius-sm: 14px;
}

* { box-sizing: border-box; }

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

body {
  min-height: 100%;
  margin: 0;
  color: var(--text);
  font-family: system-ui, -apple-system, BlinkMacSystemFont, "Hiragino Sans", "Yu Gothic", "Noto Sans JP", sans-serif;
  background:
    radial-gradient(circle at 15% 10%, rgba(158, 232, 255, .22), transparent 30%),
    radial-gradient(circle at 85% 5%, rgba(255, 212, 111, .18), transparent 28%),
    linear-gradient(135deg, #171325 0%, #2a1f45 48%, #142d3b 100%);
}

button, input { font: inherit; }
button { cursor: pointer; }
button:disabled { cursor: not-allowed; opacity: .52; }

.app-shell {
  width: min(1180px, calc(100% - 28px));
  margin: 0 auto;
  padding: 24px 0 44px;
}

.hero {
  position: relative;
  overflow: hidden;
  display: grid;
  grid-template-columns: minmax(0, 1fr) 310px;
  gap: 20px;
  align-items: stretch;
  padding: 26px;
  border: 1px solid var(--line);
  border-radius: 30px;
  background: linear-gradient(135deg, rgba(255,255,255,.13), rgba(255,255,255,.05));
  box-shadow: var(--shadow);
}

.hero__glow {
  position: absolute;
  inset: -30% auto auto -10%;
  width: 360px;
  height: 360px;
  border-radius: 999px;
  background: rgba(255, 212, 111, .18);
  filter: blur(12px);
}

.hero__text, .hero__card { position: relative; z-index: 1; }

.eyebrow {
  display: inline-flex;
  gap: 8px;
  margin: 0 0 8px;
  padding: 6px 12px;
  border: 1px solid rgba(255, 212, 111, .42);
  border-radius: 999px;
  color: var(--accent);
  font-size: .88rem;
  background: rgba(255, 212, 111, .08);
}

h1, h2, p { margin-top: 0; }
h1 { margin-bottom: 10px; font-size: clamp(2.1rem, 6vw, 4.4rem); line-height: 1; letter-spacing: .04em; }
h2 { margin-bottom: 12px; font-size: 1.08rem; }
.lead { max-width: 720px; margin-bottom: 18px; color: var(--muted); font-size: 1.04rem; line-height: 1.8; }
.muted { color: var(--muted); line-height: 1.7; }

.hero__actions { display: flex; flex-wrap: wrap; gap: 10px; }
.hero__actions--center { justify-content: center; }

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255,255,255,.1);
  box-shadow: 0 10px 22px rgba(0,0,0,.16);
  transition: transform .15s ease, background .15s ease, border-color .15s ease;
}
.btn:hover { transform: translateY(-1px); background: rgba(255,255,255,.16); }
.btn--primary { color: #24192e; background: linear-gradient(135deg, #ffe49d, #ffbd62); border-color: transparent; font-weight: 800; }
.btn--ghost { background: transparent; box-shadow: none; }

.hero__card {
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 16px;
  min-height: 210px;
  padding: 22px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 26px;
  background: rgba(0,0,0,.18);
}
.shop-window { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.shop-window span {
  display: grid;
  place-items: center;
  min-height: 66px;
  border-radius: 18px;
  font-size: 2rem;
  background: rgba(255,255,255,.1);
}

.game-layout {
  display: grid;
  grid-template-columns: minmax(0, 300px) minmax(0, 1fr) minmax(280px, 340px);
  gap: 16px;
  margin-top: 18px;
  align-items: start;
}

.panel {
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 18px;
  background: var(--panel);
  backdrop-filter: blur(14px);
  box-shadow: 0 16px 36px rgba(0,0,0,.18);
}

.panel__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}
.panel__head h2 { margin: 0; }
.pill, .sub-count {
  display: inline-flex;
  align-items: center;
  min-height: 28px;
  padding: 4px 10px;
  border-radius: 999px;
  color: var(--accent);
  font-size: .82rem;
  background: rgba(255,212,111,.12);
  border: 1px solid rgba(255,212,111,.18);
  white-space: nowrap;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin: 14px 0;
}
.stat {
  padding: 12px;
  border-radius: 16px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
}
.stat span { display: block; color: var(--muted); font-size: .78rem; }
.stat strong { display: block; margin-top: 4px; font-size: 1.35rem; }

.combo-box {
  margin: 14px 0;
  padding: 12px;
  border-radius: 16px;
  color: #25182f;
  background: linear-gradient(135deg, rgba(255,228,157,.92), rgba(158,232,255,.86));
  line-height: 1.55;
  font-weight: 700;
}

.status-actions { display: grid; gap: 9px; }
.orders { display: grid; gap: 12px; }

.order-card {
  position: relative;
  overflow: hidden;
  padding: 16px;
  border: 1px solid rgba(255,255,255,.16);
  border-radius: 18px;
  background: rgba(255,255,255,.08);
}
.order-card::before {
  content: "";
  position: absolute;
  inset: 0 auto 0 0;
  width: 5px;
  background: var(--accent);
  opacity: .8;
}
.order-card h3 { margin: 0 0 8px; font-size: 1.06rem; }
.order-card p { margin-bottom: 10px; color: var(--muted); line-height: 1.65; }
.order-meta { display: flex; flex-wrap: wrap; gap: 7px; margin-bottom: 10px; }
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(255,255,255,.1);
  color: var(--muted);
  font-size: .8rem;
}
.recipe-row { display: flex; flex-wrap: wrap; gap: 6px; margin: 10px 0; }
.recipe-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 6px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.16);
  font-size: .88rem;
}
.recipe-chip.is-lack { color: var(--danger); border-color: rgba(255,139,139,.36); }
.card-actions { display: flex; align-items: center; gap: 8px; justify-content: space-between; }
.reward-text { color: var(--accent); font-weight: 800; }

.side-stack { display: grid; gap: 16px; }
.materials, .upgrades, .shop-list { display: grid; gap: 10px; }
.material-item, .upgrade-item, .shop-item {
  display: grid;
  grid-template-columns: auto 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border-radius: 16px;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
}
.material-icon { font-size: 1.45rem; }
.item-name { font-weight: 800; }
.item-sub { color: var(--muted); font-size: .82rem; line-height: 1.45; }
.item-count { font-weight: 900; color: var(--accent-2); }
.upgrade-item { grid-template-columns: 1fr auto; }
.upgrade-item p { margin: 2px 0 0; }

.log-list {
  display: grid;
  gap: 8px;
  max-height: 250px;
  overflow: auto;
  margin: 0;
  padding: 0;
  list-style: none;
}
.log-list li {
  padding: 9px 10px;
  border-radius: 12px;
  color: var(--muted);
  background: rgba(0,0,0,.14);
  line-height: 1.5;
}

.guide-panel { margin-top: 16px; }
.guide-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 12px; }
.guide-grid p {
  margin: 0;
  padding: 14px;
  border-radius: 16px;
  color: var(--muted);
  background: rgba(255,255,255,.07);
  line-height: 1.7;
}
.guide-grid strong { color: var(--accent); }

.modal[hidden] { display: none; }
.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: grid;
  place-items: center;
  padding: 18px;
}
.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(8, 7, 14, .72);
  backdrop-filter: blur(8px);
}
.modal__card {
  position: relative;
  z-index: 1;
  width: min(620px, 100%);
  max-height: min(760px, calc(100vh - 36px));
  overflow: auto;
  padding: 20px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 24px;
  background: #241b39;
  box-shadow: var(--shadow);
}
.modal__head { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.icon-btn {
  width: 42px;
  height: 42px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  color: var(--text);
  background: rgba(255,255,255,.08);
  font-size: 1.4rem;
}
.result-card { text-align: center; }
.result-score { margin: 10px 0; color: var(--accent); font-size: clamp(2.4rem, 11vw, 4.4rem); font-weight: 900; line-height: 1; }
.name-label { display: grid; gap: 8px; margin: 16px auto; text-align: left; max-width: 340px; color: var(--muted); }
.name-label input {
  width: 100%;
  border: 1px solid rgba(255,255,255,.2);
  border-radius: 14px;
  padding: 12px 14px;
  color: var(--text);
  background: rgba(255,255,255,.08);
}

.ranking-list { display: grid; gap: 8px; }
.ranking-row {
  display: grid;
  grid-template-columns: 44px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 11px;
  border-radius: 14px;
  background: rgba(255,255,255,.08);
}
.rank-no { color: var(--accent); font-weight: 900; }
.rank-name { font-weight: 800; }
.rank-sub { color: var(--muted); font-size: .8rem; }
.rank-score { font-weight: 900; color: var(--accent-2); }

.notice {
  padding: 12px 14px;
  border-radius: 14px;
  background: rgba(255,255,255,.1);
}
.notice--danger { color: #ffe8e8; background: rgba(255,139,139,.18); border: 1px solid rgba(255,139,139,.24); }
.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  z-index: 30;
  transform: translateX(-50%) translateY(120px);
  max-width: min(480px, calc(100% - 28px));
  padding: 12px 16px;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 999px;
  color: #24192e;
  background: #ffe49d;
  box-shadow: var(--shadow);
  opacity: 0;
  transition: transform .18s ease, opacity .18s ease;
  font-weight: 800;
}
.toast.is-show { opacity: 1; transform: translateX(-50%) translateY(0); }

.empty-state {
  padding: 20px;
  border-radius: 18px;
  color: var(--muted);
  text-align: center;
  background: rgba(255,255,255,.07);
  line-height: 1.7;
}

@media (max-width: 980px) {
  .hero { grid-template-columns: 1fr; }
  .hero__card { min-height: auto; }
  .shop-window { grid-template-columns: repeat(4, 1fr); }
  .game-layout { grid-template-columns: 1fr; }
  .status-panel { position: sticky; top: 0; z-index: 5; }
  .guide-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
  .app-shell { width: min(100% - 18px, 1180px); padding-top: 9px; }
  .hero, .panel { border-radius: 20px; padding: 15px; }
  .hero__actions .btn, .status-actions .btn { width: 100%; }
  .shop-window { grid-template-columns: repeat(2, 1fr); }
  .stats-grid, .guide-grid { grid-template-columns: 1fr 1fr; }
  .material-item, .shop-item { grid-template-columns: auto 1fr; }
  .material-item .item-count, .shop-item .btn { grid-column: 1 / -1; }
  .shop-item .btn { width: 100%; }
  .card-actions { display: grid; gap: 10px; justify-items: stretch; }
  .card-actions .btn { width: 100%; }
  .guide-grid { grid-template-columns: 1fr; }
  .ranking-row { grid-template-columns: 34px 1fr; }
  .rank-score { grid-column: 2; }
}
