:root {
  --bg-1: #040611;
  --bg-2: #0e1635;
  --panel: rgba(10, 18, 40, 0.7);
  --line: rgba(180, 205, 255, 0.28);
  --text: #f3f7ff;
  --muted: #c4d3ff;
  --accent: #7dd3fc;
  --good: #86efac;
  --warn: #fca5a5;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  color: var(--text);
  font-family: "Segoe UI", "Hiragino Kaku Gothic ProN", Meiryo, sans-serif;
  background:
    radial-gradient(circle at 12% 10%, #263d87 0%, transparent 28%),
    radial-gradient(circle at 84% 18%, #4e1e70 0%, transparent 24%),
    linear-gradient(160deg, var(--bg-1), var(--bg-2));
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

#starfield {
  position: fixed;
  inset: 0;
  z-index: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.drop-shell {
  position: relative;
  z-index: 1;
  height: 100dvh;
  display: grid;
  grid-template-rows: auto minmax(0, 1fr) auto;
  gap: 10px;
  padding: 10px;
  overflow: hidden;
}

.hud,
.actions {
  width: min(760px, 100%);
  margin: 0 auto;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  backdrop-filter: blur(8px);
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.34);
}

.hud {
  padding: 10px 12px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.hud h1 {
  margin: 0 0 4px;
  font-size: clamp(1.05rem, 3vw, 1.35rem);
}

.hud p {
  margin: 0;
  color: var(--muted);
  line-height: 1.45;
  font-size: clamp(0.75rem, 2vw, 0.9rem);
}

.stats {
  display: grid;
  gap: 4px;
  min-width: 142px;
  color: var(--muted);
  font-size: 0.84rem;
  text-align: right;
}

.stats strong {
  color: var(--accent);
  font-size: 1.02rem;
}

.play-layout {
  min-height: 0;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  justify-items: center;
  gap: 10px;
}

.stage-column {
  min-width: 0;
  min-height: 0;
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  height: 100%;
}

.side-panel {
  display: none;
}

.stage-wrap {
  position: relative;
  width: 420px;
  height: 640px;
  min-height: 0;
  margin: 0 auto;
  border: 1px solid rgba(180, 205, 255, 0.22);
  border-radius: 28px 28px 14px 14px;
  overflow: hidden;
  background: rgba(4, 8, 20, 0.58);
  box-shadow: inset 0 0 60px rgba(125, 211, 252, 0.08), 0 18px 54px rgba(0, 0, 0, 0.4);
  align-self: center;
  justify-self: center;
}

#dropCanvas {
  display: block;
  width: 100%;
  height: 100%;
  background: rgba(4, 8, 20, 0.72);
}

.drop-guide {
  position: absolute;
  top: 0;
  bottom: 0;
  width: 2px;
  transform: translateX(-1px);
  border-left: 1px dashed rgba(125, 211, 252, 0.72);
  pointer-events: none;
  opacity: 0;
  transition: opacity 100ms ease;
}

.drop-guide.visible {
  opacity: 1;
}

.message-panel {
  position: absolute;
  left: 50%;
  top: 50%;
  width: min(340px, calc(100% - 28px));
  transform: translate(-50%, -50%);
  padding: 18px;
  border: 1px solid rgba(180, 205, 255, 0.3);
  border-radius: 8px;
  background: rgba(10, 18, 40, 0.92);
  text-align: center;
  box-shadow: 0 16px 50px rgba(0, 0, 0, 0.52);
}

.danger-countdown {
  position: absolute;
  left: 50%;
  top: 18%;
  transform: translate(-50%, -50%);
  z-index: 2;
  width: 92px;
  height: 92px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  border: 2px solid rgba(252, 165, 165, 0.75);
  background: rgba(70, 12, 24, 0.72);
  color: #fff2f2;
  font-size: 2.4rem;
  font-weight: 900;
  text-shadow: 0 0 12px rgba(252, 165, 165, 0.65);
  pointer-events: none;
}

.danger-countdown.hidden {
  display: none;
}

.message-panel.hidden {
  display: none;
}

.message-panel h2 {
  margin: 0 0 8px;
  font-size: 1.25rem;
}

.message-panel p {
  margin: 0 0 14px;
  color: var(--muted);
  line-height: 1.55;
}

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

.actions {
  min-height: 56px;
  padding: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  flex-wrap: wrap;
}

.icon-button,
.text-button {
  min-height: 42px;
  border-radius: 8px;
  border: 1px solid rgba(180, 205, 255, 0.28);
  background: rgba(15, 25, 55, 0.88);
  color: var(--text);
  font: inherit;
  font-weight: 700;
  text-decoration: none;
  cursor: pointer;
  touch-action: manipulation;
}

.icon-button {
  width: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--accent);
}

.text-button {
  padding: 9px 12px;
}

.text-button--primary {
  border-color: rgba(125, 211, 252, 0.65);
  background: linear-gradient(180deg, #2a4fc0, #223688);
}

.text-button--wide {
  width: 100%;
}

.evolution-strip {
  flex: 1 1 100%;
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  gap: 8px;
  min-width: 0;
  padding: 2px 4px 0;
}

.evolution-strip__label {
  color: var(--muted);
  font-size: 0.78rem;
  font-weight: 700;
}

.evolution-list {
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 5px;
  overflow-x: auto;
  scrollbar-width: none;
  padding: 2px 0;
}

.evolution-list::-webkit-scrollbar {
  display: none;
}

.evolution-item {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  gap: 5px;
  color: var(--muted);
  font-size: 0.72rem;
  white-space: nowrap;
}

.evolution-item img {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 1px solid rgba(236, 243, 255, 0.36);
}

.evolution-item::after {
  content: ">";
  color: rgba(196, 211, 255, 0.55);
  font-size: 0.72rem;
}

.evolution-item:last-child::after {
  content: "";
}

.evolution-list--vertical {
  display: grid;
  gap: 7px;
  overflow: visible;
}

.evolution-list--vertical .evolution-item {
  display: grid;
  grid-template-columns: 28px 16px 1fr;
  gap: 8px;
  min-width: 0;
}

.evolution-list--vertical .evolution-item::after {
  content: "↓";
  display: inline-grid;
  place-items: center;
  color: rgba(196, 211, 255, 0.7);
}

.evolution-list--vertical .evolution-item:last-child::after {
  content: "";
}

.top-ranker-list {
  display: grid;
  gap: 10px;
}

.top-ranker {
  display: grid;
  grid-template-columns: 28px 1fr;
  gap: 8px;
  align-items: baseline;
}

.top-ranker__rank {
  color: var(--accent);
  font-weight: 900;
}

.top-ranker__name {
  min-width: 0;
  color: var(--text);
  font-weight: 800;
  line-height: 1.35;
  overflow-wrap: anywhere;
}

.top-ranker__score {
  grid-column: 2;
  color: var(--good);
  font-size: 0.85rem;
  font-weight: 800;
}

.modal {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal.hidden {
  display: none;
}

.modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(4, 8, 20, 0.72);
  backdrop-filter: blur(4px);
}

.modal__box {
  position: relative;
  z-index: 1;
  width: min(380px, 100%);
  padding: 18px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(10, 18, 40, 0.96);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.55);
}

.modal__box h2 {
  margin: 0 0 12px;
}

.modal__lead {
  margin: 0 0 12px;
  color: var(--muted);
  line-height: 1.5;
}

.name-field {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  font-weight: 700;
}

.name-field input {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid rgba(180, 205, 255, 0.32);
  background: rgba(4, 8, 20, 0.86);
  color: var(--text);
  font: inherit;
  user-select: text;
  -webkit-user-select: text;
  touch-action: manipulation;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  flex-wrap: wrap;
}

.ranking-list {
  display: grid;
  gap: 6px;
  margin-bottom: 14px;
  color: var(--muted);
  max-height: min(62vh, 560px);
  overflow-y: auto;
  padding-right: 4px;
  scrollbar-width: thin;
}

.ranking-row {
  display: grid;
  grid-template-columns: 34px 1fr auto;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid rgba(180, 205, 255, 0.14);
}

.ranking-row strong {
  color: var(--text);
}

@media (max-width: 620px) {
  .drop-shell {
    padding: 8px;
    gap: 8px;
  }

  .hud {
    align-items: stretch;
    flex-direction: column;
  }

  .stats {
    grid-template-columns: repeat(3, 1fr);
    min-width: 0;
    text-align: left;
  }

  .actions {
    gap: 7px;
  }

  .evolution-strip {
    grid-template-columns: 1fr;
    gap: 4px;
  }

  .evolution-list {
    display: grid;
    grid-auto-flow: column;
    grid-template-rows: 24px;
    grid-auto-columns: minmax(86px, calc((100% - 24px) / 4));
    gap: 8px;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 1px;
  }

  .evolution-item {
    min-width: 0;
    display: grid;
    grid-template-columns: 20px 1fr;
    gap: 4px;
    font-size: 0.68rem;
  }

  .evolution-item span {
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .evolution-item img {
    width: 20px;
    height: 20px;
  }

  .evolution-item::after {
    content: "";
  }
}

@media (max-width: 420px) {
  .evolution-list {
    grid-template-rows: 22px;
    grid-auto-columns: minmax(78px, calc((100% - 18px) / 4));
    gap: 6px;
  }

  .evolution-item {
    grid-template-columns: 22px 1fr;
    font-size: 0.68rem;
  }

  .evolution-item img {
    width: 22px;
    height: 22px;
  }

  .evolution-item::after {
    content: "";
  }
}

@media (min-width: 880px) and (min-aspect-ratio: 11 / 9) {
  .drop-shell {
    grid-template-rows: auto minmax(0, 1fr) auto;
  }

  .hud,
  .actions {
    width: min(760px, calc(100vw - 140px));
  }

  .play-layout {
    width: min(1160px, 100%);
    margin: 0 auto;
    grid-template-columns: minmax(170px, 220px) minmax(420px, 1fr) minmax(190px, 240px);
    align-items: center;
  }

  .side-panel {
    display: grid;
    align-content: start;
    gap: 8px;
    width: 100%;
    max-height: 100%;
    padding: 12px;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: var(--panel);
    backdrop-filter: blur(8px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.34);
    overflow: hidden;
  }

  .side-panel__label {
    color: var(--muted);
    font-size: 0.82rem;
    font-weight: 800;
  }

  .evolution-panel {
    max-height: min(640px, 100%);
  }

  .evolution-panel .evolution-list {
    overflow-y: auto;
    padding-right: 2px;
    scrollbar-width: thin;
  }

  .actions .evolution-strip {
    display: none;
  }
}
