:root {
  color-scheme: dark;
  --bg: #0b1020;
  --card: #151d33;
  --accent: #6ea8fe;
  --accent-2: #8cffd5;
  --text: #ebf1ff;
  --muted: #9db0d6;
  --danger: #ff8686;
  --column-width: 390px;
  --card-min-height: 320px;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Segoe UI", sans-serif;
  background: radial-gradient(1200px 800px at 10% -10%, #1f315e, var(--bg));
  color: var(--text);
  min-width: 1240px;
}

header,
footer {
  text-align: center;
  padding: 16px;
}

header h1 {
  margin: 0 0 8px;
}

header p {
  margin: 0;
  color: var(--muted);
}

footer a {
  color: var(--accent);
  text-decoration: none;
  cursor: pointer;
  transition: color 0.2s ease;
}

footer a:hover {
  color: var(--accent-2);
  text-decoration: underline;
}

.tabs {
  width: 1200px;
  margin: 0 auto 16px;
  display: flex;
  gap: 4px;
  border-bottom: 2px solid #2d3f69;
  overflow-x: visible;
}

.tab-btn {
  width: auto;
  padding: 10px 16px;
  background: transparent;
  color: var(--muted);
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  font-weight: 600;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: var(--text);
  background: rgba(110, 168, 254, 0.1);
}

.tab-btn.active {
  color: var(--accent-2);
  border-bottom-color: var(--accent-2);
}

.grid {
  width: 1200px;
  margin: 0 auto 32px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  align-items: start;
  gap: 14px;
}

.tab-content {
  display: none;
  grid-column: 1 / -1;
}

.tab-content.active {
  display: grid;
  grid-template-columns: 1fr;
  justify-content: space-between;
  align-items: start;
  gap: 14px;
}

#tab-home.active {
  grid-template-columns: repeat(3, var(--column-width));
}

.tab-column {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 14px;
  min-height: 140px;
  width: 100%;
}

#tab-home .tab-column {
  width: var(--column-width);
}

.tab-column .card {
  width: 100%;
  margin: 0;
}

.card {
  background: linear-gradient(180deg, #1a2747, var(--card));
  border: 1px solid #2d3f69;
  border-radius: 14px;
  padding: 0;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  overflow: hidden;
  min-width: 0;
  min-height: var(--card-min-height);
  align-self: start;
  transition: transform 0.18s ease, box-shadow 0.18s ease, opacity 0.18s ease;
}

.card > * {
  padding: 0 14px;
}

.card > h2 {
  padding: 12px 14px;
}

.card > div {
  padding: 0 14px 14px 14px;
}

.card > div:last-child {
  padding-bottom: 14px;
}

h2 {
  margin-top: 0;
  margin-bottom: 12px;
  font-size: 1.1rem;
  cursor: move;
  user-select: none;
  -webkit-user-select: none;
  background: linear-gradient(180deg, #1f2d4d, #1a2747);
  border-bottom: 1px solid #2d3f69;
  position: relative;
}

h2::before {
  content: "⠿";
  position: absolute;
  left: 8px;
  opacity: 0.3;
  font-size: 1.2rem;
}

.stats {
  display: grid;
  gap: 8px;
}

.stats > div {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px dashed #324772;
  padding-bottom: 5px;
  gap: 8px;
}

.stats span {
  color: var(--muted);
}

.stats strong {
  color: var(--accent-2);
  flex: 1;
  text-align: right;
}

.stats small {
  font-size: 0.82rem;
  white-space: nowrap;
}

button {
  width: 100%;
  border: 0;
  border-radius: 10px;
  padding: 10px 12px;
  color: #041226;
  background: linear-gradient(180deg, #a5c6ff, var(--accent));
  cursor: pointer;
  font-weight: 700;
  white-space: pre-wrap;
  line-height: 1.4;
}

button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.actions {
  margin-top: 0;
  display: grid;
  gap: 8px;
}

.actions.row {
  grid-template-columns: 1fr;
}

.actions.column {
  grid-template-columns: 1fr;
}

.actions.column button {
  min-height: 50px;
  padding: 8px 12px;
}

.actions button {
  min-height: 44px;
}

.purchase-multiplier,
#engineer-multiplier,
#rocket-multiplier {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}

.purchase-multiplier span,
#engineer-multiplier span,
#rocket-multiplier span {
  color: var(--muted);
  font-size: 0.9rem;
  margin-right: 4px;
}

.multiplier-btn,
.engineer-multiplier-btn,
.rocket-multiplier-btn {
  width: auto;
  min-width: 54px;
  padding: 6px 10px;
  border-radius: 999px;
  background: #2a3d66;
  color: var(--text);
}

.multiplier-btn.active,
.engineer-multiplier-btn.active,
.rocket-multiplier-btn.active {
  background: linear-gradient(180deg, #a5c6ff, var(--accent));
  color: #041226;
}

small {
  color: var(--muted);
}

.actions small,
#quests-content p {
  white-space: normal;
  overflow-wrap: anywhere;
  word-break: break-word;
}

.mission {
  border: 1px solid #324772;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
}

.mission h3 {
  margin: 0 0 6px;
  font-size: 1rem;
}

.mission p {
  margin: 2px 0;
  color: var(--muted);
  font-size: 0.92rem;
}

.mission button {
  margin-top: 8px;
}

.tech {
  border: 1px solid #324772;
  border-radius: 10px;
  padding: 8px;
  margin-bottom: 8px;
}

.tech h3 {
  margin: 0;
  font-size: 0.98rem;
}

.tech p {
  margin: 4px 0;
  color: var(--muted);
  font-size: 0.88rem;
}

/* ── Patch Notes ── */
.patch-note {
  border: 1px solid #324772;
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  background: linear-gradient(180deg, rgba(26, 39, 71, 0.5), rgba(21, 29, 51, 0.3));
}

.patch-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  padding-bottom: 8px;
  border-bottom: 1px solid #324772;
}

.patch-header strong {
  font-size: 1.05rem;
  color: var(--accent);
}

.patch-date {
  color: var(--muted);
  font-size: 0.85rem;
}

.patch-changes {
  margin: 0;
  padding-left: 20px;
  list-style: disc;
}

.patch-changes li {
  color: var(--text);
  margin: 4px 0;
  font-size: 0.9rem;
  line-height: 1.5;
}

#log {
  margin: 0;
  padding-left: 20px;
  max-height: 800px;
  overflow-y: auto;
}

#log li {
  color: var(--muted);
  margin: 4px 0;
}

.warn {
  color: var(--danger);
}

h2[draggable="true"] {
  cursor: move;
}

.card.dragging {
  opacity: 0.5;
  background: rgba(26, 39, 71, 0.5);
}

.card.dragging h2 {
  background: rgba(140, 255, 213, 0.15);
}

.card.drag-over {
  border: 2px dashed var(--accent-2);
  background: rgba(140, 255, 213, 0.05);
  transform: translateX(6px);
}

.tab-content.is-sorting .card:not(.dragging):not(.drag-over) {
  transform: translateY(2px);
}

.tab-content.is-sorting .tab-column {
  outline: 1px dashed rgba(140, 255, 213, 0.25);
  outline-offset: -6px;
}

/* ── Prestige Card ── */
#prestige-home-card {
  min-height: auto;
}

#prestige-home-card > p {
  color: var(--muted);
  font-size: 0.95rem;
  line-height: 1.6;
  margin: 0;
  padding: 0 14px 8px;
}

#prestige-home-card > button {
  width: calc(100% - 28px);
  margin: 0 14px 14px;
  padding: 16px 14px;
  min-height: 54px;
  border-radius: 12px;
  border: none;
  background: linear-gradient(180deg, #a5c6ff, #6a86d6);
  color: #041226;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  cursor: pointer;
  white-space: pre-wrap;
  word-break: break-word;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

#prestige-home-card > button:hover:not(:disabled) {
  transform: translateY(-1px);
  box-shadow: 0 8px 20px rgba(16, 78, 222, 0.35);
}

#prestige-home-card > button:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* 固定レイアウト: 画面が狭い場合は横スクロールで表示 */
@media (max-width: 1240px) {
  body {
    overflow-x: auto;
  }
}