:root {
  color-scheme: dark;
  --bg: #13060f;
  --panel: rgba(28, 18, 30, 0.86);
  --panel-strong: rgba(43, 24, 44, 0.94);
  --line: rgba(255, 255, 255, 0.14);
  --text: #fff7fb;
  --muted: #d8bac8;
  --red: #ff243d;
  --cyan: #17d6ff;
  --gold: #ffd35a;
}

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background: radial-gradient(circle at 24% 18%, #45111f 0, var(--bg) 42%, #08040b 100%);
  color: var(--text);
  font-family: "Segoe UI", "Yu Gothic UI", "Meiryo", sans-serif;
}

button {
  font: inherit;
}

.app {
  height: 100vh;
  display: grid;
  place-items: center;
  padding: 10px;
}

.screen {
  width: min(1400px, 100%);
}

.hidden {
  display: none !important;
}

.select-board {
  min-height: min(760px, calc(100vh - 40px));
  display: grid;
  grid-template-columns: minmax(300px, 0.9fr) minmax(320px, 0.95fr) minmax(340px, 1.05fr);
  align-items: stretch;
  gap: 14px;
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(120deg, rgba(61, 7, 21, 0.95), rgba(19, 6, 15, 0.96));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

.select-copy {
  padding: clamp(18px, 3vw, 34px);
}

.select-column,
.select-skill-panel {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.eyebrow {
  margin: 0 0 8px;
  color: var(--cyan);
  font-size: 13px;
  font-weight: 800;
  letter-spacing: 0;
  text-transform: uppercase;
}

h1,
h2,
h3,
p {
  margin-top: 0;
}

h1 {
  margin-bottom: 8px;
  font-size: clamp(44px, 5vw, 78px);
  line-height: 1;
}

.select-copy p:not(.eyebrow) {
  max-width: 440px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.55;
}

.select-role {
  display: inline-flex;
  width: fit-content;
  margin: 0 0 10px;
  border: 1px solid rgba(255, 255, 255, 0.26);
  border-radius: 999px;
  padding: 6px 12px;
  color: #fff;
  background: rgba(255, 36, 61, 0.22);
  font-weight: 900;
}

.select-sub-description {
  margin-bottom: 12px;
}

.select-stat-list {
  display: grid;
  gap: 4px;
  margin: 8px 0 10px;
  padding: 10px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.select-stat-row {
  display: grid;
  grid-template-columns: 88px 1fr;
  align-items: center;
  gap: 10px;
  font-size: 13px;
  font-weight: 800;
}

.select-critical {
  margin: 0 0 12px;
  color: #fff;
  font-weight: 900;
}

.character-options {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
  margin: auto 0 14px;
}

.character-option {
  min-height: 58px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  text-align: left;
  cursor: pointer;
  padding: 10px;
}

.character-option span,
.character-option small {
  display: block;
}

.character-option span {
  font-size: 20px;
  font-weight: 900;
}

.character-option small {
  margin-top: 4px;
  color: var(--muted);
  font-weight: 800;
}

.character-option.active {
  border-color: rgba(255, 255, 255, 0.72);
  background: linear-gradient(135deg, rgba(255, 36, 61, 0.34), rgba(23, 214, 255, 0.2));
}

.primary-button {
  min-width: 180px;
  min-height: 48px;
  border: 0;
  border-radius: 8px;
  background: linear-gradient(135deg, var(--red), #a910ff);
  color: white;
  font-weight: 800;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(255, 36, 61, 0.28);
}

.primary-button:hover {
  filter: brightness(1.08);
}

.secondary-button {
  min-width: 180px;
  min-height: 48px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  font-weight: 800;
  cursor: pointer;
}

.secondary-button:hover {
  background: rgba(255, 255, 255, 0.12);
}

.select-art {
  width: 100%;
  height: min(760px, calc(100vh - 42px));
  object-fit: contain;
  object-position: center bottom;
}

.select-art-wrap {
  min-width: 0;
  display: grid;
  place-items: end center;
  overflow: hidden;
}

.select-skill-panel {
  padding: clamp(18px, 3vw, 30px) clamp(16px, 2vw, 24px);
  border-left: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.035);
}

.select-skill-list {
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.select-skill-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 9px 10px;
  background: rgba(255, 255, 255, 0.06);
}

.select-skill-item b {
  display: block;
  margin-bottom: 4px;
  color: #fff;
  font-size: 14px;
}

.select-skill-item span {
  display: block;
  color: var(--muted);
  font-size: 13px;
  line-height: 1.45;
}

.mode-screen {
  width: min(920px, 100%);
}

.mode-board {
  min-height: min(520px, calc(100vh - 40px));
  display: grid;
  grid-template-rows: auto 1fr auto;
  gap: 18px;
  padding: clamp(22px, 4vw, 42px);
  border: 1px solid var(--line);
  border-radius: 8px;
  background: linear-gradient(120deg, rgba(38, 10, 48, 0.96), rgba(13, 6, 20, 0.98));
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.36);
}

.mode-copy h1 {
  margin-bottom: 12px;
}

.mode-copy p:not(.eyebrow) {
  max-width: 620px;
  color: var(--muted);
  font-size: 15px;
  line-height: 1.6;
}

.mode-options {
  display: grid;
  align-content: start;
  gap: 12px;
}

.mode-option {
  min-height: 132px;
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 20px;
  background: rgba(255, 255, 255, 0.07);
  color: var(--text);
  text-align: left;
  cursor: pointer;
}

.mode-option.active {
  border-color: rgba(255, 255, 255, 0.72);
  background:
    linear-gradient(135deg, rgba(255, 36, 61, 0.28), rgba(23, 214, 255, 0.16)),
    rgba(255, 255, 255, 0.07);
}

.mode-option span {
  display: block;
  margin-bottom: 8px;
  font-size: clamp(28px, 4vw, 44px);
  font-weight: 900;
}

.mode-option small {
  display: block;
  max-width: 620px;
  color: var(--muted);
  font-size: 15px;
  font-weight: 800;
  line-height: 1.5;
}

.mode-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 10px;
}

.game-screen {
  width: min(1320px, 100%);
  height: min(720px, calc(100vh - 20px));
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(300px, 340px);
  gap: 12px;
  align-items: stretch;
}

.play-panel {
  position: relative;
  min-height: 0;
  border: 1px solid var(--line);
  border-radius: 8px;
  overflow: hidden;
  background: #05050a;
}

canvas {
  display: block;
  width: 100%;
  height: 100%;
  cursor: crosshair;
}

.message-layer {
  position: absolute;
  inset: 0;
  display: grid;
  place-content: center;
  gap: 12px;
  padding: 24px;
  text-align: center;
  background: rgba(10, 5, 10, 0.78);
}

.message-layer h2 {
  margin: 0;
  font-size: 44px;
}

.message-layer p {
  color: var(--muted);
}

.result-card {
  width: min(520px, calc(100vw - 56px));
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 24px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(28, 18, 30, 0.94);
  box-shadow: 0 24px 70px rgba(0, 0, 0, 0.44);
}

.result-icon {
  width: 96px;
  aspect-ratio: 1;
  border: 2px solid rgba(255, 255, 255, 0.36);
  border-radius: 8px;
  object-fit: cover;
  object-position: center;
}

.result-name {
  margin: 0;
  color: #fff;
  font-size: 22px;
  font-weight: 900;
}

.result-stats {
  width: 100%;
  display: grid;
  gap: 8px;
  margin: 4px 0 8px;
}

.result-stats div {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: rgba(255, 255, 255, 0.06);
}

.result-stats span {
  color: var(--muted);
  font-weight: 800;
}

.result-stats b {
  color: #fff;
  font-size: 22px;
}

.side-panel {
  min-height: 0;
  display: grid;
  grid-template-rows: minmax(190px, 0.9fr) auto minmax(0, 2fr);
  gap: 8px;
  overflow: hidden;
}

.portrait-wrap,
.hud-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
  overflow: hidden;
}

.portrait-wrap {
  display: grid;
  place-items: center;
  padding: 14px;
  background: linear-gradient(180deg, rgba(23, 214, 255, 0.18), rgba(255, 31, 59, 0.16), rgba(28, 18, 30, 0.96));
}

.portrait-wrap img {
  width: min(58%, 150px);
  aspect-ratio: 1;
  max-height: 100%;
  object-fit: cover;
  object-position: center;
}

.hud-card {
  padding: 12px;
}

.character-head,
.live-stats div,
.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.character-head h2 {
  margin: 0;
  font-size: 30px;
}

.badge {
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  padding: 7px 12px;
  background: rgba(255, 36, 61, 0.24);
  color: #fff;
  font-weight: 800;
}

.live-stats {
  margin: 8px 0 0;
  display: grid;
  gap: 6px;
}

.live-stats div {
  min-height: 34px;
  padding: 0 10px;
  border-radius: 6px;
  background: rgba(255, 255, 255, 0.06);
}

dt {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
}

dd {
  margin: 0;
  font-weight: 900;
}

.skills-card h3 {
  margin-bottom: 8px;
  font-size: 15px;
}

.stat-list {
  display: grid;
  gap: 5px;
}

.stat-row {
  min-height: 22px;
}

.stars {
  color: var(--gold);
  font-size: 16px;
  white-space: nowrap;
}

.skills-card {
  min-height: 0;
  display: flex;
  flex-direction: column;
}

#skillDescription {
  min-height: 0;
  display: grid;
  gap: 8px;
  overflow: auto;
  padding-right: 4px;
}

.play-skill-item {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 8px 9px;
  background: rgba(255, 255, 255, 0.06);
}

.play-skill-item b {
  display: block;
  margin-bottom: 4px;
  color: #fff;
  font-size: 13px;
}

.play-skill-item span {
  display: block;
  color: var(--muted);
  font-size: 12px;
  line-height: 1.38;
}

.skills-card b {
  color: #fff;
}

@media (max-width: 1060px) {
  html,
  body {
    overflow: auto;
  }

  .app {
    min-height: 100vh;
    height: auto;
    padding: 10px;
  }

  .select-board,
  .mode-board,
  .game-screen {
    grid-template-columns: 1fr;
    height: auto;
  }

  .mode-board {
    min-height: auto;
  }

  .select-skill-panel {
    border-left: 0;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
  }

  .character-options {
    margin-top: 16px;
  }

  .select-art {
    max-height: 560px;
  }

  .side-panel {
    min-height: 0;
    grid-template-columns: minmax(220px, 0.7fr) 1fr;
    grid-template-rows: auto auto;
  }

  .portrait-wrap {
    grid-row: span 2;
  }
}
