* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Hiragino Sans", "Noto Sans JP", sans-serif;
  background-color: #0f172a;
  color: #f8fafc;
  line-height: 1.5;
}

.app-container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 14px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-header {
  text-align: center;
  padding: 12px 0 18px;
  border-bottom: 1px solid #334155;
  margin-bottom: 18px;
}

.app-header h1 {
  font-size: 1.5rem;
  letter-spacing: 0.04em;
  background: linear-gradient(90deg, #38bdf8, #facc15, #f87171);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.subtitle {
  color: #94a3b8;
  font-size: 0.85rem;
  margin-top: 4px;
}

.screen {
  flex: 1;
}

.hidden {
  display: none !important;
}

.screen h2 {
  text-align: center;
  font-size: 1.2rem;
  margin-bottom: 6px;
}

.hint {
  text-align: center;
  color: #94a3b8;
  font-size: 0.85rem;
  margin-bottom: 18px;
}

/* チームカラー定義 */
.team-k4sen { --team-color: #3b82f6; --team-bg: rgba(59, 130, 246, 0.16); }
.team-shaka { --team-color: #ef4444; --team-bg: rgba(239, 68, 68, 0.16); }
.team-mokou { --team-color: #eab308; --team-bg: rgba(234, 179, 8, 0.16); }
.team-seki  { --team-color: #22c55e; --team-bg: rgba(34, 197, 94, 0.16); }

/* 1. リーダー選択グリッド */
.leader-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  max-width: 700px;
  margin: 0 auto;
}

.leader-card {
  background: #1e293b;
  border: 2px solid var(--team-color);
  border-radius: 12px;
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s, box-shadow 0.15s;
}

.leader-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.4);
}

.leader-team-name {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--team-color);
}

.leader-name {
  font-size: 1.45rem;
  font-weight: bold;
  margin: 6px 0;
}

.leader-select-hint {
  font-size: 0.78rem;
  color: #94a3b8;
}

/* 2. ドラフト画面 */
.draft-status-bar {
  background: #1e293b;
  padding: 10px 14px;
  border-radius: 10px;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
  border-left: 5px solid #38bdf8;
}

.round-badge {
  background: #38bdf8;
  color: #0f172a;
  font-weight: bold;
  padding: 3px 12px;
  border-radius: 20px;
  font-size: 0.9rem;
}

.instruction {
  font-weight: bold;
  font-size: 0.88rem;
}

.instruction.warning {
  color: #facc15;
}

.draft-log {
  background: #020617;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 14px;
  max-height: 105px;
  overflow-y: auto;
  font-size: 0.82rem;
  color: #e2e8f0;
}

.log-highlight {
  color: #facc15;
  font-weight: bold;
}

.teams-board {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 16px;
}

@media (min-width: 820px) {
  .teams-board {
    grid-template-columns: repeat(4, 1fr);
  }
}

.team-box {
  background: #1e293b;
  border-top: 4px solid var(--team-color);
  border-radius: 8px;
  padding: 8px 10px;
}

.team-box-header {
  display: flex;
  justify-content: space-between;
  font-weight: bold;
  font-size: 0.82rem;
  margin-bottom: 6px;
  color: var(--team-color);
}

.roster-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.roster-tag {
  background: #334155;
  font-size: 0.72rem;
  padding: 2px 6px;
  border-radius: 4px;
}

.roster-tag.leader-tag {
  background: var(--team-color);
  color: #fff;
  font-weight: bold;
}

.roster-tag.online-tag {
  border: 1px solid #38bdf8;
  color: #bae6fd;
}

.roster-tag.female-tag {
  border: 1px solid #f472b6;
  color: #fbcfe8;
}

.pool-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
  gap: 8px;
}

.pool-header h3 {
  font-size: 0.98rem;
}

.pool-controls {
  display: flex;
  gap: 6px;
}

.sort-btn {
  background: #1e293b;
  color: #f8fafc;
  border: 1px solid #475569;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.82rem;
  cursor: pointer;
}

.sort-btn:hover {
  background: #334155;
}

/* 横に2人並べるレイアウト */
.player-pool {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.player-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 8px;
  padding: 10px 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  text-align: left;
  transition: border-color 0.15s, background 0.15s;
}

.player-card:hover:not(.disabled-card) {
  border-color: #38bdf8;
  background: #243247;
}

.player-card.disabled-card {
  opacity: 0.38;
}

.player-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  text-align: left;
  min-width: 0;
}

.player-name {
  display: block;
  width: 100%;
  text-align: left;
  font-weight: bold;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.badge-row {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 2px;
}

.online-badge {
  display: inline-block;
  font-size: 0.66rem;
  color: #38bdf8;
  background: rgba(56, 189, 248, 0.15);
  border: 1px solid rgba(56, 189, 248, 0.4);
  padding: 0 5px;
  border-radius: 4px;
}

.female-badge {
  display: inline-block;
  font-size: 0.66rem;
  color: #f472b6;
  background: rgba(244, 114, 182, 0.15);
  border: 1px solid rgba(244, 114, 182, 0.4);
  padding: 0 5px;
  border-radius: 4px;
}

.pick-btn {
  flex-shrink: 0;
  padding: 7px 12px;
  border: none;
  border-radius: 6px;
  background: #38bdf8;
  color: #0f172a;
  font-weight: bold;
  font-size: 0.8rem;
  cursor: pointer;
}

.pick-btn:hover:not(:disabled) {
  background: #7dd3fc;
}

.pick-btn:disabled {
  background: #475569;
  color: #94a3b8;
  cursor: not-allowed;
}

/* 3. 出場種目オーダー編成画面 */
.lineup-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 12px;
}

.lineup-header h2 {
  text-align: left;
}

.lineup-rule {
  font-size: 0.8rem;
  color: #cbd5e1;
}

.lineup-actions {
  display: flex;
  gap: 8px;
}

.validation-msg {
  background: #1e293b;
  border-left: 4px solid #facc15;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 0.85rem;
  margin-bottom: 12px;
  color: #fef08a;
}

.validation-msg.ok {
  border-left-color: #22c55e;
  color: #86efac;
}

.table-wrapper {
  overflow-x: auto;
  border: 1px solid #334155;
  border-radius: 8px;
  background: #1e293b;
}

.lineup-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.8rem;
  text-align: center;
}

.lineup-table th,
.lineup-table td {
  border: 1px solid #334155;
  padding: 7px 6px;
}

.lineup-table th {
  background: #0f172a;
  color: #e2e8f0;
  font-weight: bold;
  min-width: 78px;
}

.lineup-table th.sticky-col,
.lineup-table td.sticky-col {
  position: sticky;
  left: 0;
  background: #1e293b;
  z-index: 2;
  text-align: left;
  min-width: 145px;
  padding-left: 10px;
  font-weight: bold;
}

.lineup-table th.sticky-col {
  background: #0f172a;
  z-index: 3;
}

.slot-count {
  display: block;
  font-size: 0.75rem;
  margin-top: 2px;
  color: #facc15;
}

.slot-count.complete {
  color: #4ade80;
}

.slot-count.over {
  color: #f87171;
}

.player-count-badge {
  float: right;
  font-size: 0.72rem;
  padding: 1px 6px;
  border-radius: 10px;
  background: #334155;
  color: #facc15;
}

.player-count-badge.complete {
  background: rgba(34, 197, 94, 0.2);
  color: #4ade80;
}

.player-count-badge.over {
  background: rgba(239, 68, 68, 0.25);
  color: #f87171;
}

.lineup-check {
  width: 20px;
  height: 20px;
  accent-color: #38bdf8;
  cursor: pointer;
}

.cell-disabled {
  background: rgba(15, 23, 42, 0.65);
  color: #475569;
  font-size: 0.72rem;
}

.lineup-footer {
  margin-top: 16px;
  text-align: center;
}

/* 4. 対抗戦画面 */
.match-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 16px;
}

.primary-btn {
  background: #facc15;
  color: #0f172a;
  border: none;
  padding: 11px 22px;
  border-radius: 8px;
  font-weight: bold;
  font-size: 0.98rem;
  cursor: pointer;
}

.primary-btn:hover:not(:disabled) {
  background: #fde047;
}

.primary-btn:disabled {
  background: #475569;
  color: #94a3b8;
  cursor: not-allowed;
}

.scoreboard {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
  margin-bottom: 18px;
}

@media (min-width: 768px) {
  .scoreboard {
    grid-template-columns: repeat(4, 1fr);
  }
}

.score-card {
  background: #1e293b;
  border-left: 5px solid var(--team-color);
  padding: 10px 12px;
  border-radius: 8px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.score-pts {
  font-size: 1.25rem;
  font-weight: bold;
  color: #facc15;
}

.match-results {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.match-card {
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 14px;
  animation: fadeIn 0.25s ease-out;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(-6px); }
  to { opacity: 1; transform: translateY(0); }
}

.match-card-title {
  font-weight: bold;
  font-size: 1.02rem;
  color: #38bdf8;
  margin-bottom: 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
}

.mvp-badge {
  background: linear-gradient(90deg, #f59e0b, #eab308);
  color: #0f172a;
  font-size: 0.8rem;
  font-weight: bold;
  padding: 3px 10px;
  border-radius: 20px;
}

.match-ranking-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 10px;
  border-radius: 4px;
  margin-bottom: 4px;
  font-size: 0.88rem;
  background: var(--team-bg);
}

/* 共通モーダル・抽選画面 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(2, 6, 23, 0.88);
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 18px;
  z-index: 100;
  cursor: pointer;
}

.modal-card {
  background: #1e293b;
  border: 2px solid #facc15;
  border-radius: 16px;
  padding: 22px 18px;
  max-width: 500px;
  width: 100%;
  text-align: center;
  box-shadow: 0 12px 35px rgba(0, 0, 0, 0.75);
  animation: popModal 0.2s ease-out;
}

.lottery-card {
  border-color: #38bdf8;
}

@keyframes popModal {
  from { transform: scale(0.88); opacity: 0; }
  to { transform: scale(1); opacity: 1; }
}

.modal-badge {
  display: inline-block;
  background: #facc15;
  color: #0f172a;
  font-weight: bold;
  font-size: 0.9rem;
  padding: 4px 14px;
  border-radius: 20px;
  margin-bottom: 14px;
}

.lottery-badge {
  background: #38bdf8;
}

.lottery-body {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-bottom: 14px;
}

.lottery-clash-box {
  background: #0f172a;
  border: 1px solid #334155;
  border-radius: 10px;
  padding: 12px;
}

.lottery-target-name {
  font-size: 1.2rem;
  font-weight: bold;
  color: #fff;
  margin-bottom: 4px;
}

.lottery-bidders {
  font-size: 0.82rem;
  color: #94a3b8;
  margin-bottom: 10px;
}

.lottery-drum {
  background: #1e293b;
  border: 2px dashed #475569;
  border-radius: 8px;
  padding: 10px;
  font-size: 1.15rem;
  font-weight: bold;
  color: #cbd5e1;
  transition: all 0.2s;
}

.lottery-drum.decided {
  border: 2px solid #facc15;
  background: rgba(250, 204, 21, 0.15);
  color: #facc15;
  transform: scale(1.03);
}

.lottery-sub-msg {
  font-size: 0.8rem;
  margin-top: 6px;
  color: #38bdf8;
}

.modal-events-body {
  text-align: left;
  background: #0f172a;
  border-radius: 10px;
  padding: 14px;
  font-size: 0.95rem;
  line-height: 1.6;
  color: #fef08a;
  margin-bottom: 16px;
}

.modal-events-body div + div {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px dashed #334155;
}

.modal-tap-hint {
  font-size: 0.85rem;
  color: #38bdf8;
  font-weight: bold;
  animation: pulse 1.4s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* 5. 最終結果画面 */
.result-card {
  background: #1e293b;
  border-radius: 14px;
  padding: 24px;
  max-width: 650px;
  margin: 0 auto;
  text-align: center;
  border: 1px solid #475569;
}

.result-label {
  color: #38bdf8;
  font-weight: bold;
  letter-spacing: 0.15em;
  font-size: 0.85rem;
}

#final-rank-title {
  font-size: 1.7rem;
  margin: 8px 0 20px;
  color: #facc15;
}

.final-standings {
  text-align: left;
  margin-bottom: 20px;
}

.standing-row {
  display: flex;
  justify-content: space-between;
  padding: 10px 14px;
  background: #0f172a;
  border-left: 5px solid var(--team-color);
  border-radius: 6px;
  margin-bottom: 8px;
  font-weight: bold;
}

.my-roster-summary {
  background: #0f172a;
  padding: 14px;
  border-radius: 8px;
  text-align: left;
  font-size: 0.85rem;
  margin-bottom: 20px;
}

.action-buttons {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.share-btn {
  background: #000;
  color: #fff;
  border: 1px solid #64748b;
  padding: 12px;
  border-radius: 30px;
  font-size: 1rem;
  font-weight: bold;
  cursor: pointer;
}

.secondary-btn {
  background: #334155;
  color: #f8fafc;
  border: none;
  padding: 10px;
  border-radius: 30px;
  font-size: 0.95rem;
  cursor: pointer;
}

.app-footer {
  margin-top: 28px;
  padding-top: 14px;
  border-top: 1px solid #1e293b;
  text-align: center;
  font-size: 0.74rem;
  color: #64748b;
}