/* display:flex 等を指定したクラスより [hidden] を必ず優先させる */
[hidden] {
  display: none !important;
}

/* ---- アプリ全体のタブ切り替え ---- */
.app-tabs {
  display: flex;
  background: #111;
  border-bottom: 1px solid #000;
  position: sticky;
  top: 0;
  z-index: 20;
  padding-top: env(safe-area-inset-top);
}

.app-tab-btn {
  flex: 1;
  padding: 14px 8px;
  background: none;
  border: none;
  color: #999;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 3px solid transparent;
}

.app-tab-btn.active {
  color: #fff;
  border-bottom-color: var(--accent);
}

.app-tab-panel {
  display: none;
}

.app-tab-panel.active {
  display: block;
}

/* ---- アカウントバー ---- */
.account-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 10px;
  font-size: 12px;
  color: #aaa;
}

.account-bar .btn {
  min-height: 30px;
  padding: 0 10px;
  font-size: 12px;
}

/* ---- ログイン / アカウント作成 ---- */
.auth-gate {
  max-width: 360px;
  margin: 30px auto 0;
}

.auth-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 16px;
}

.auth-tab-btn {
  flex: 1;
  min-height: 40px;
  background: var(--btn-bg);
  color: #ccc;
  border: none;
  border-radius: 8px;
  font-size: 14px;
}

.auth-tab-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.auth-panel {
  display: none;
}

.auth-panel.active {
  display: block;
}

.auth-panel .btn {
  width: 100%;
  margin-top: 6px;
}

/* ---- サブタブ (対戦記録内) ---- */
.subtabs {
  display: flex;
  gap: 6px;
  margin-top: 10px;
}

.subtab-btn {
  flex: 1;
  min-height: 36px;
  background: var(--btn-bg);
  color: #ccc;
  border: none;
  border-radius: 8px;
  font-size: 13px;
}

.subtab-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.subtab-panel {
  display: none;
}

.subtab-panel.active {
  display: block;
}

.battle-main {
  /* style.css の汎用 main セレクタ (display:flex; align-items:center) は
     カードチェック画面用の指定。align-items:center だと子要素が
     "内容に合わせた幅" になってしまい、相性マトリクスのような横長の
     子孫があると全体が押し広げられるため、ここで通常のブロック表示に戻す。 */
  display: block;
  padding: 14px;
  padding-bottom: max(24px, env(safe-area-inset-bottom));
}

.section-title {
  font-size: 15px;
  margin: 22px 0 10px;
  color: #ddd;
}

/* ---- 入力タブ ---- */
.point-banner {
  background: var(--panel);
  border-radius: 12px;
  padding: 16px;
  text-align: center;
  margin-bottom: 16px;
}

.point-value {
  font-size: 36px;
  font-weight: 700;
  color: #ffd23f;
}

.rank-name {
  font-size: 15px;
  font-weight: 600;
  color: var(--accent);
  margin-top: 2px;
}

.point-sub {
  font-size: 13px;
  color: #aaa;
  margin-top: 4px;
}

.field-group {
  margin-bottom: 12px;
}

.field-group label {
  display: block;
  font-size: 13px;
  color: #aaa;
  margin-bottom: 4px;
}

.field-group select,
.field-group input[type="text"] {
  width: 100%;
  min-height: 42px;
  padding: 0 10px;
  background: var(--btn-bg);
  color: var(--text);
  border: 1px solid #444;
  border-radius: 8px;
  font-size: 15px;
}

.result-buttons {
  display: flex;
  gap: 8px;
  margin-top: 16px;
}

.result-btn {
  flex: 1;
  min-height: 52px;
  border: none;
  border-radius: 10px;
  font-size: 16px;
  font-weight: 700;
  color: #fff;
}

.result-btn.win {
  background: #2e7d32;
}

.result-btn.loss {
  background: #c62828;
}

.result-btn.draw {
  background: #555;
}

.result-btn:disabled {
  opacity: 0.4;
}

.recent-list {
  list-style: none;
  margin: 0;
  padding: 0;
}

.recent-list li.rm-item {
  background: var(--panel);
  border-radius: 8px;
  margin-bottom: 6px;
  overflow: hidden;
}

.rm-summary {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  font-size: 13px;
  cursor: pointer;
}

.rm-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.rm-right {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.recent-list .rm-result {
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 6px;
  font-size: 12px;
  flex-shrink: 0;
}

.rm-result.win { background: #2e7d32; }
.rm-result.loss { background: #c62828; }
.rm-result.draw { background: #555; }

.recent-list .rm-point {
  color: #ffd23f;
  font-weight: 600;
  flex-shrink: 0;
}

.deck-dot {
  display: inline-block;
  width: 9px;
  height: 9px;
  border-radius: 50%;
  margin-right: 4px;
  vertical-align: middle;
  flex-shrink: 0;
}

.rm-edit {
  display: none;
  padding: 4px 12px 12px;
  border-top: 1px solid #3a3a3a;
}

.rm-edit.open {
  display: block;
}

.result-buttons.small .result-btn {
  min-height: 40px;
  font-size: 13px;
  opacity: 0.5;
}

.result-buttons.small .result-btn.selected {
  opacity: 1;
  outline: 2px solid #fff;
}

.rm-edit-actions {
  display: flex;
  gap: 8px;
  margin-top: 12px;
}

.rm-edit-actions .btn {
  flex: 1;
}

.rm-delete {
  background: #7a1f1f;
  color: #fff;
}

/* ---- 分析タブ ---- */
.winrate-cards {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 8px;
}

.wr-card {
  background: var(--panel);
  border-radius: 10px;
  padding: 12px;
  text-align: center;
  cursor: pointer;
  border: 2px solid transparent;
}

.wr-card.active {
  border-color: var(--accent);
}

.wr-card .wr-label {
  font-size: 12px;
  color: #aaa;
}

.wr-card .wr-value {
  font-size: 22px;
  font-weight: 700;
  margin: 4px 0;
}

.wr-card .wr-record {
  font-size: 11px;
  color: #999;
}

.point-trend-chart {
  background: var(--panel);
  border-radius: 10px;
  padding: 12px;
  margin-top: 10px;
}

.chart-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 6px;
  font-size: 12px;
}

.chart-title {
  color: #ddd;
  font-weight: 600;
}

.chart-summary {
  color: #ffd23f;
}

.trend-svg {
  width: 100%;
  height: auto;
  display: block;
}

.appearance-tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.appearance-tab-btn {
  flex: 1;
  min-height: 32px;
  background: var(--btn-bg);
  color: #ccc;
  border: none;
  border-radius: 8px;
  font-size: 12px;
}

.appearance-tab-btn.active {
  background: var(--accent);
  color: #fff;
  font-weight: 600;
}

.bar-row {
  display: grid;
  grid-template-columns: 90px 1fr 44px;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 13px;
}

.bar-row .bar-label {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bar-track {
  background: #333;
  border-radius: 5px;
  height: 16px;
  overflow: hidden;
}

.bar-fill {
  height: 100%;
  border-radius: 5px;
}

.bar-row .bar-pct {
  text-align: right;
  color: #ccc;
}

.matchup-matrix-wrap {
  overflow-x: auto;
  max-width: 100%;
  background: var(--panel);
  border-radius: 10px;
  padding: 8px;
  -webkit-overflow-scrolling: touch;
}

.matchup-matrix {
  border-collapse: collapse;
  font-size: 11px;
  white-space: nowrap;
}

.matchup-matrix th,
.matchup-matrix td {
  padding: 6px 8px;
  text-align: center;
}

.matchup-matrix thead th {
  color: #aaa;
  font-weight: 600;
  border-bottom: 1px solid #3a3a3a;
}

.mm-corner {
  position: sticky;
  left: 0;
  background: var(--panel);
  z-index: 1;
}

.mm-row-head {
  position: sticky;
  left: 0;
  background: var(--panel);
  text-align: left !important;
  font-weight: 600;
  border-right: 1px solid #3a3a3a;
  z-index: 1;
}

.matchup-matrix td {
  border-radius: 4px;
  color: #fff;
}

.matchup-matrix td.mm-empty {
  color: #555;
  background: transparent;
}

.mm-rate {
  font-weight: 700;
}

.mm-record {
  font-size: 9px;
  opacity: 0.85;
}

/* ---- デッキタブ ---- */
.deck-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.deck-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--panel);
  border-radius: 8px;
  padding: 6px 8px;
}

.deck-row-order {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.deck-move-btn {
  width: 26px;
  height: 20px;
  padding: 0;
  background: var(--btn-bg);
  color: #ccc;
  border: none;
  border-radius: 4px;
  font-size: 10px;
  line-height: 1;
}

.deck-move-btn:disabled {
  opacity: 0.25;
}

.deck-chip {
  padding: 6px 12px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 600;
  color: #fff;
}

.deck-meta-btn {
  margin-left: auto;
  width: 32px;
  height: 32px;
  background: var(--btn-bg);
  color: #666;
  border: none;
  border-radius: 50%;
  font-size: 16px;
}

.deck-meta-btn.active {
  background: #7a5c00;
  color: #ffd23f;
}

/* ---- 環境デッキへの対策 ---- */
.counter-deck-block {
  background: var(--panel);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}

.counter-deck-title {
  font-weight: 700;
  font-size: 14px;
  margin-bottom: 6px;
}

.counter-row {
  display: grid;
  grid-template-columns: 1fr 70px 50px;
  gap: 8px;
  font-size: 12px;
  padding: 5px 0;
  border-top: 1px solid #3a3a3a;
}

.counter-row.header {
  color: #888;
  border-top: none;
}
