* { margin: 0; padding: 0; box-sizing: border-box; }
html, body {
  font-family: -apple-system, BlinkMacSystemFont, 'Hiragino Sans', 'Hiragino Kaku Gothic ProN', Meiryo, sans-serif;
  background: #1a1a2e;
  color: #e0e0e0;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-tap-highlight-color: transparent;
  -webkit-text-size-adjust: 100%;
}
.container {
  max-width: 480px;
  margin: 0 auto;
  padding: 12px;
}
h1 {
  text-align: center;
  font-size: 1.5em;
  color: #e94560;
  margin: 10px 0 16px;
  text-shadow: 0 0 20px rgba(233,69,96,0.5);
  letter-spacing: 2px;
}
.select-area {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  align-items: stretch;
}
.select-area > div { flex: 1; }
.select-area label {
  display: block;
  font-size: 0.75em;
  color: #aaa;
  margin-bottom: 4px;
  text-align: center;
}
.char-select-wrapper {
  position: relative;
}
.char-select-input {
  width: 100%;
  padding: 10px 8px;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  color: #e0e0e0;
  font-size: 14px;
  outline: none;
  cursor: pointer;
}
.char-select-input:focus {
  border-color: #e94560;
  box-shadow: 0 0 8px rgba(233,69,96,0.3);
}
.char-dropdown {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 250px;
  overflow-y: auto;
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 0 0 8px 8px;
  z-index: 100;
  -webkit-overflow-scrolling: touch;
}
.char-dropdown.open { display: block; }
.char-dropdown-item {
  padding: 10px 8px;
  font-size: 13px;
  cursor: pointer;
  border-bottom: 1px solid #0f3460;
}
.char-dropdown-item:active,
.char-dropdown-item.highlighted {
  background: #e94560;
  color: #fff;
}
.vs-label {
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2em;
  font-weight: bold;
  color: #e94560;
  padding-top: 20px;
  min-width: 36px;
}
.stats-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
}
.stat-card {
  flex: 1;
  background: linear-gradient(145deg, #16213e, #1a1a2e);
  border: 1px solid #0f3460;
  border-radius: 10px;
  padding: 10px;
  font-size: 0.72em;
  min-height: 80px;
}
.stat-card h3 {
  font-size: 1.1em;
  color: #e94560;
  margin-bottom: 6px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.stat-line {
  display: flex;
  justify-content: space-between;
  padding: 1px 0;
  color: #ccc;
}
.stat-line span:last-child {
  color: #fff;
  font-weight: bold;
}
.type-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 0.85em;
  font-weight: bold;
  margin-top: 4px;
}
.type-power { background: #c0392b; color: #fff; }
.type-agility { background: #27ae60; color: #fff; }
.type-dos { background: #8e44ad; color: #fff; }
.hp-section {
  margin-bottom: 10px;
}
.hp-row {
  display: flex;
  align-items: center;
  margin-bottom: 6px;
  gap: 6px;
}
.hp-name {
  font-size: 0.72em;
  width: 80px;
  text-align: right;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  flex-shrink: 0;
}
.hp-bar-outer {
  flex: 1;
  height: 22px;
  background: #0a0a1a;
  border-radius: 11px;
  overflow: hidden;
  border: 1px solid #333;
  position: relative;
}
.hp-bar-inner {
  height: 100%;
  border-radius: 10px;
  transition: width 0.6s ease-out, background-color 0.3s ease;
  width: 100%;
  position: relative;
}
.hp-bar-inner.green { background: linear-gradient(90deg, #27ae60, #2ecc71); }
.hp-bar-inner.orange { background: linear-gradient(90deg, #e67e22, #f39c12); }
.hp-bar-inner.red { background: linear-gradient(90deg, #c0392b, #e74c3c); }
.hp-text {
  font-size: 0.65em;
  width: 70px;
  text-align: left;
  flex-shrink: 0;
  font-variant-numeric: tabular-nums;
}
.btn-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.btn {
  flex: 1;
  min-width: 90px;
  padding: 14px 8px;
  border: none;
  border-radius: 10px;
  font-size: 0.9em;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s, box-shadow 0.2s;
  -webkit-appearance: none;
  touch-action: manipulation;
}
.btn:active {
  transform: scale(0.95);
}
.btn-battle {
  background: linear-gradient(135deg, #e94560, #c0392b);
  color: #fff;
  box-shadow: 0 4px 15px rgba(233,69,96,0.4);
}
.btn-random {
  background: linear-gradient(135deg, #0f3460, #16213e);
  color: #e0e0e0;
  border: 1px solid #0f3460;
  box-shadow: 0 4px 15px rgba(15,52,96,0.4);
}
.btn-tournament {
  background: linear-gradient(135deg, #f39c12, #e67e22);
  color: #fff;
  box-shadow: 0 4px 15px rgba(243,156,18,0.4);
}
.btn:disabled {
  opacity: 0.5;
  transform: none;
}
.battle-log {
  background: #0d1117;
  border: 1px solid #0f3460;
  border-radius: 10px;
  padding: 10px;
  max-height: 300px;
  overflow-y: auto;
  font-size: 0.78em;
  line-height: 1.6;
  -webkit-overflow-scrolling: touch;
  scroll-behavior: smooth;
}
.battle-log:empty::before {
  content: 'バトルログがここに表示されます...';
  color: #555;
  font-style: italic;
}
.log-turn { color: #888; font-size: 0.9em; }
.log-attack { color: #e0e0e0; }
.log-crit { color: #f1c40f; font-weight: bold; }
.log-dodge { color: #2ecc71; font-style: italic; }
.log-win { color: #e94560; font-weight: bold; font-size: 1.1em; text-align: center; margin-top: 6px; }
.log-info { color: #3498db; }
.log-bonus { color: #e67e22; }
.log-p1 { color: #ff6b6b; }
.log-p1-crit { color: #ff6b6b; font-weight: bold; }
.log-p1-skill { color: #ff9f43; }
.log-p2 { color: #54a0ff; }
.log-p2-crit { color: #54a0ff; font-weight: bold; }
.log-p2-skill { color: #ff9f43; }
.log-spacer { height: 1.5em; }
.log-block { margin-bottom: 0.3em; }
.log-sep { color: #333; text-align: center; }
.log-draw { color: #f39c12; font-weight: bold; text-align: center; margin-top: 6px; }

/* Tournament */
.tournament-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.92);
  z-index: 200;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.tournament-overlay.open { display: block; }
.tournament-content {
  max-width: 480px;
  margin: 0 auto;
  padding: 16px 12px;
}
.tournament-content h2 {
  text-align: center;
  color: #f39c12;
  font-size: 1.3em;
  margin-bottom: 16px;
  text-shadow: 0 0 15px rgba(243,156,18,0.5);
}
.bracket {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: 16px;
}
.bracket-round-label {
  text-align: center;
  color: #f39c12;
  font-weight: bold;
  font-size: 0.9em;
  margin: 10px 0 4px;
  border-bottom: 1px solid #333;
  padding-bottom: 4px;
}
.bracket-match {
  background: #16213e;
  border: 1px solid #0f3460;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 0.8em;
}
.bracket-match.active {
  border-color: #e94560;
  box-shadow: 0 0 10px rgba(233,69,96,0.3);
}
.bracket-match.done {
  opacity: 0.85;
}
.bracket-fighter {
  display: flex;
  justify-content: space-between;
  padding: 3px 0;
}
.bracket-fighter.winner {
  color: #f1c40f;
  font-weight: bold;
}
.bracket-fighter.loser {
  color: #666;
}
.bracket-vs {
  text-align: center;
  color: #e94560;
  font-size: 0.8em;
}
.champion-banner {
  text-align: center;
  padding: 20px;
  margin: 10px 0;
  background: linear-gradient(135deg, #f39c12, #e67e22);
  border-radius: 12px;
  animation: pulse 1.5s infinite;
}
.champion-banner h3 {
  font-size: 1.4em;
  color: #fff;
  margin-bottom: 4px;
}
.champion-banner p {
  color: #fff;
  font-size: 1em;
}
@keyframes pulse {
  0%, 100% { box-shadow: 0 0 20px rgba(243,156,18,0.5); }
  50% { box-shadow: 0 0 40px rgba(243,156,18,0.8); }
}
.close-btn {
  display: block;
  width: 100%;
  padding: 14px;
  background: #333;
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 1em;
  cursor: pointer;
  margin-top: 12px;
  -webkit-appearance: none;
  touch-action: manipulation;
}
.close-btn:active { background: #555; }

.pick-item {
  padding: 10px 12px;
  border-bottom: 1px solid #1a1a2e;
  color: #ccc;
  font-size: 0.95em;
  cursor: pointer;
  transition: background 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.pick-item:active { background: #1a1a2e; }
.pick-item.selected {
  background: #e94560;
  color: #fff;
  font-weight: bold;
}

.tournament-log {
  background: #0d1117;
  border: 1px solid #0f3460;
  border-radius: 10px;
  padding: 10px;
  max-height: 200px;
  overflow-y: auto;
  font-size: 0.75em;
  line-height: 1.5;
  margin-top: 10px;
  -webkit-overflow-scrolling: touch;
}
