/* mypage: unified light scoreboard theme; single clean stylesheet with no overrides or dead rules. */
* { box-sizing: border-box; }

:root {
  --bg: #f3f6f9;
  --panel: #ffffff;
  --panel-alt: #edf3f8;
  --border: #d7e1eb;
  --iwashi: #163a5f;
  --text: #142230;
  --muted: #5a6d80;
  --accent: #e0283e;
  --cta: #2563eb;
  --cta-hover: #1d4ed8;
  --font-jp: "Noto Sans JP", "Hiragino Kaku Gothic ProN", sans-serif;
  --font-en: "Raleway", "Noto Sans JP", sans-serif;
  --font-display: "Anton", "Noto Sans JP", sans-serif;
  color: var(--text);
  background: var(--bg);
  color-scheme: light;
  font-family: var(--font-jp);
  -webkit-font-smoothing: antialiased;
}

body { margin: 0; }
[hidden] { display: none !important; }
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

.screen {
  min-height: 100dvh;
  width: 100%;
  margin: 0 auto;
  padding: 16px 24px 36px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Header */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: var(--font-en);
  font-weight: 800;
  font-size: 14px;
  letter-spacing: 0.08em;
}

.brand-icon {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 1.5px solid var(--iwashi);
  background: #ffffff;
  object-fit: contain;
}

.page-badge {
  padding: 3px 10px;
  background: var(--accent);
  color: #ffffff;
  font-size: 11px;
  letter-spacing: 0.08em;
}

.button {
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel);
  color: var(--text);
  font-family: var(--font-jp);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.04em;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: border-color 0.12s, background-color 0.12s;
}

.button:hover {
  border-color: var(--iwashi);
  background: var(--panel-alt);
}

.button:disabled {
  opacity: 0.55;
  cursor: default;
}

.back {
  color: var(--muted);
  font-family: var(--font-en);
  font-weight: 700;
}

.back:hover {
  color: var(--text);
  border-color: var(--text);
  background: var(--panel);
}

/* Banner */
main {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.page-banner {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}

.banner-kicker {
  display: block;
  font-family: var(--font-en);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.16em;
  color: var(--accent);
}

.page-banner h1 {
  margin: 2px 0 0;
  font-family: var(--font-display);
  font-size: 42px;
  font-weight: 900;
  line-height: 0.95;
  letter-spacing: 0.02em;
  color: var(--text);
}

.banner-summary {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.sum-chip {
  padding: 8px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  min-width: 110px;
}

.sum-chip.is-accent {
  border-left: 3px solid var(--accent);
}

.sum-chip small {
  font-family: var(--font-en);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.sum-chip strong {
  font-family: var(--font-en);
  font-size: 15px;
  font-weight: 800;
  margin-top: 2px;
  color: var(--text);
}

#error {
  margin: 0;
  padding: 12px 16px;
  border: 1px solid var(--accent);
  background: #fff5f5;
  color: #9b1c2c;
  font-size: 12px;
  font-weight: 700;
}

/* Dashboard Grid */
.dashboard {
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.box {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 18px 20px;
  min-width: 0;
}

.panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 8px;
  padding-bottom: 8px;
  margin-bottom: 14px;
  border-bottom: 1px solid var(--border);
}

.panel-head h2,
.box > h2 {
  margin: 0;
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.04em;
  color: var(--text);
}

.box > h2 {
  margin-bottom: 14px;
}

.panel-head span {
  font-family: var(--font-en);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.14em;
  color: var(--muted);
}

.profile {
  grid-column: span 5;
  align-self: start;
  border-left: 3px solid var(--accent);
}

.calendar {
  grid-column: span 7;
}

.stats,
.bests {
  grid-column: span 6;
}

.trend {
  grid-column: span 7;
}

.history {
  grid-column: span 5;
}

.pro-test,
.battle {
  grid-column: 1 / -1;
}

/* Form & Inputs */
form {
  display: flex;
  gap: 8px;
}

input,
select {
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel-alt);
  color: var(--text);
  font-family: var(--font-jp);
  font-size: 13px;
  font-weight: 700;
  padding: 9px 12px;
  min-width: 0;
}

input {
  flex: 1;
  width: 100%;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--iwashi);
  background: #ffffff;
}

:focus-visible {
  outline: 2px solid var(--iwashi);
  outline-offset: 2px;
}

#save-player {
  padding: 9px 20px;
  border-color: #1e40af;
  background: var(--cta);
  color: #ffffff;
  font-family: var(--font-en);
  font-weight: 800;
  letter-spacing: 0.08em;
}

#save-player:hover {
  background: var(--cta-hover);
  border-color: #1e40af;
}

.status {
  font-size: 11px;
  color: var(--muted);
  margin: 8px 0 0;
  min-height: 15px;
}

.preferences {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  font-family: var(--font-en);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.auto-save-control {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text);
}

.auto-save-control input {
  flex: none;
  width: 16px;
  height: 16px;
  margin: 0;
  accent-color: var(--iwashi);
}

.rating-sync {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.rating-sync-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-family: var(--font-en);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: var(--muted);
}

.rating-flight {
  padding: 2px 8px;
  background: var(--accent);
  color: #ffffff;
  font-size: 11px;
  font-weight: 900;
}

.rating-sync-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 6px;
}

.rating-mini {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
}

.rating-mini.is-main {
  border-left: 3px solid var(--accent);
}

.rating-mini small {
  font-family: var(--font-en);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.rating-mini strong {
  font-family: var(--font-en);
  font-size: 15px;
  font-weight: 900;
  margin-top: 2px;
  color: var(--text);
}

.rating-sync-btn {
  width: 100%;
  background: var(--iwashi);
  border-color: var(--iwashi);
  color: #ffffff;
}

.rating-sync-btn:hover {
  background: #0f2944;
  border-color: #0f2944;
}

/* Calendar */
.section-heading {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 8px;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.calendar-nav .button {
  padding: 4px 10px;
  min-height: 30px;
  font-size: 16px;
}

#calendar-month {
  min-width: 96px;
  text-align: center;
  font-family: var(--font-en);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.06em;
  color: var(--text);
}

.calendar-weekdays,
.calendar-days {
  display: grid;
  grid-template-columns: repeat(7, minmax(0, 1fr));
  gap: 4px;
}

.calendar-weekdays {
  margin: 12px 0 6px;
  text-align: center;
  font-family: var(--font-en);
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.calendar-day {
  position: relative;
  min-height: 36px;
  padding: 6px 2px 12px;
  border: 1px solid transparent;
  background: var(--panel-alt);
  color: var(--text);
  font-family: var(--font-en);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
}

.calendar-day:hover {
  border-color: var(--iwashi);
  background: #e4edf5;
}

.calendar-day.today {
  border-color: var(--cta);
}

.calendar-day[aria-pressed="true"] {
  background: var(--iwashi);
  border-color: var(--iwashi);
  color: #ffffff;
}

.calendar-day.has-records::after {
  content: "";
  position: absolute;
  bottom: 4px;
  left: calc(50% - 2.5px);
  width: 5px;
  height: 5px;
  background: var(--accent);
  border-radius: 50%;
}

.calendar-day[aria-pressed="true"].has-records::after {
  background: #ffd900;
}

.calendar h3 {
  margin: 14px 0 8px;
  font-family: var(--font-en);
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.08em;
  color: var(--muted);
}

.day-results {
  max-height: 170px;
  overflow: auto;
}

.day-results .data-row {
  align-items: flex-start;
}

.day-results time {
  display: block;
  font-size: 10px;
  margin-top: 4px;
  color: var(--muted);
}

/* Data rows & charts */
.empty {
  color: var(--muted);
  font-size: 12px;
}

.data-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  border-top: 1px solid var(--border);
  padding: 10px 0;
  font-size: 12px;
}

.data-row:last-child {
  padding-bottom: 0;
}

.game-name {
  font-weight: 700;
  font-size: 12px;
}

.values {
  text-align: right;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.6;
}

.values p {
  margin: 0;
}

.filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.filters select {
  font-size: 11px;
  padding: 6px 8px;
  max-width: 150px;
}

.plot {
  height: 190px;
  display: grid;
  place-items: center;
  margin-top: 10px;
}

.plot svg {
  width: 100%;
  height: 100%;
  overflow: visible;
}

.plot text {
  font: 10px var(--font-jp);
  fill: var(--muted);
}

.history-list {
  max-height: 240px;
  overflow: auto;
}

.history-list time {
  display: block;
  color: var(--muted);
  font-size: 10px;
  margin-top: 4px;
}

/* Records Selector Tabs */
.records-menu {
  grid-column: 1 / -1;
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 16px 20px;
}

.record-buttons {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 8px;
}

.card {
  position: relative;
  display: flex;
  align-items: center;
  gap: 10px;
  min-width: 0;
  min-height: 54px;
  padding: 10px 12px;
  text-align: left;
  background: var(--panel-alt);
  border: 1px solid var(--border);
  border-radius: 0;
  color: var(--text);
  font-family: var(--font-en);
  cursor: pointer;
  transition: background-color 0.12s, border-color 0.12s;
}

.card:hover {
  background: #e4edf5;
  border-color: var(--iwashi);
}

.card[aria-pressed="true"] {
  background: var(--iwashi);
  border-color: var(--iwashi);
  color: #ffffff;
  box-shadow: inset 3px 0 0 var(--accent);
}

.card .number {
  font-size: 10px;
  font-weight: 800;
  color: var(--muted);
  flex-shrink: 0;
}

.card[aria-pressed="true"] .number,
.card[aria-pressed="true"] .card-bottom {
  color: rgba(255, 255, 255, 0.75);
}

.card .icon {
  width: 22px;
  height: 22px;
  flex-shrink: 0;
  color: var(--accent);
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.card.match .icon { color: #2f7d4b; }
.card.cricket .icon { color: #2563eb; }
.card.exam .icon { color: #c77b32; }
.card[aria-pressed="true"] .icon { color: #ffd900; }

.card-title {
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.03em;
  line-height: 1.25;
  flex: 1;
}

.card-bottom {
  font-size: 12px;
  color: var(--muted);
  flex-shrink: 0;
}

/* Record Details */
.record-details {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(12, minmax(0, 1fr));
  gap: 16px;
}

.selected-game {
  grid-column: 1 / -1;
  margin: 0;
  padding: 10px 14px;
  background: var(--panel);
  border: 1px solid var(--border);
  border-left: 3px solid var(--iwashi);
  font-family: var(--font-en);
  font-size: 14px;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--text);
}

/* Practice, Battle, Pro Test */
.practice-records {
  grid-column: 1 / -1;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 16px;
}

.practice-records h3,
.pro-test h3,
.battle h3 {
  font-size: 12px;
  font-weight: 800;
  margin: 16px 0 8px;
  color: var(--text);
}

.practice-record details {
  margin: 8px 0 14px;
  font-size: 12px;
}

.pro-test label,
.virtual-note,
.virtual-total {
  font-size: 11px;
  color: var(--muted);
}

.virtual-total strong {
  color: var(--text);
  margin-left: 10px;
  font-size: 14px;
}

.pro-tables {
  overflow-x: auto;
}

.pro-tables table {
  width: 100%;
  min-width: 390px;
  border-collapse: collapse;
  font-size: 12px;
}

.pro-tables th,
.pro-tables td {
  padding: 10px 8px;
  border-bottom: 1px solid var(--border);
  text-align: right;
}

.pro-tables th:first-child,
.pro-tables td:first-child {
  text-align: left;
}

.battle label,
.battle-record {
  font-size: 12px;
  color: var(--text);
}

.battle-record {
  border-top: 1px solid var(--border);
  padding: 12px 0;
}

.battle-record time {
  display: block;
  margin-top: 4px;
  font-size: 11px;
  color: var(--muted);
}

.battle-record p {
  margin: 6px 0;
}

.battle-record summary {
  cursor: pointer;
  margin-top: 8px;
  color: var(--iwashi);
  font-weight: 700;
}

/* Unified Analysis Panels (#cu-analysis & #ga-analysis) */
.cu-analysis {
  grid-column: 1 / -1;
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 14px;
  color: var(--text);
}

.cu-analysis .panel {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 0;
  padding: 18px 20px;
}

.cu-analysis .title {
  margin: 0 0 12px;
  font-size: 13px;
  font-weight: 900;
  letter-spacing: 0.06em;
  color: var(--text);
}

.cu-analysis .modeButtons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.cu-analysis button {
  min-height: 42px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  border-radius: 0;
  background: var(--panel-alt);
  color: var(--text);
  font-family: var(--font-jp);
  font-size: 13px;
  font-weight: 700;
  cursor: pointer;
}

.cu-analysis button:hover {
  border-color: var(--iwashi);
}

.cu-analysis .modeButtons button.selected {
  background: var(--iwashi);
  border-color: var(--iwashi);
  color: #ffffff;
  font-weight: 900;
}

.cu-analysis .hidden {
  display: none !important;
}

.cu-analysis .aggregate-controls {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 8px;
  margin-bottom: 14px;
}

.cu-analysis .aggregate-controls #cu-metricGroup,
.cu-analysis.keypadAnalysis #cu-analysisGame {
  grid-column: 1 / -1;
}

.cu-analysis select,
.cu-analysis input {
  width: 100%;
  min-height: 40px;
}

.cu-analysis .stat-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 8px;
}

.cu-analysis .stat-card {
  background: var(--panel-alt);
  border: 1px solid var(--border);
  padding: 12px 10px;
  text-align: center;
}

.cu-analysis .stat-card span {
  display: block;
  min-height: 28px;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
}

.cu-analysis .stat-card strong {
  font-family: var(--font-en);
  font-size: 22px;
  font-weight: 900;
  color: var(--text);
}

.cu-analysis .summary-line {
  text-align: center;
  font-size: 13px;
  font-weight: 700;
  margin-bottom: 12px;
  color: var(--text);
}

.cu-analysis .chart-wrap {
  position: relative;
  height: 290px;
  border: 1px solid var(--border);
  padding: 10px;
  background: #fafcfe;
}

.cu-analysis .chart-wrap canvas {
  width: 100%;
  height: 100%;
}

.cu-analysis .legend {
  display: flex;
  flex-wrap: wrap;
  gap: 14px;
  margin-top: 10px;
  font-size: 11px;
  color: var(--muted);
}

.cu-analysis .legend span::before {
  content: "";
  display: inline-block;
  width: 12px;
  height: 3px;
  margin-right: 6px;
  vertical-align: middle;
  background: var(--color);
}

.cu-analysis .history-list {
  display: grid;
  gap: 8px;
  max-height: none;
  overflow: visible;
}

.cu-analysis .history-item {
  border: 1px solid var(--border);
  background: var(--panel-alt);
  padding: 12px 14px;
}

.cu-analysis .history-head {
  display: flex;
  justify-content: space-between;
  gap: 8px;
  align-items: center;
}

.cu-analysis .history-head strong {
  font-size: 13px;
}

.cu-analysis .history-meta {
  font-size: 12px;
  line-height: 1.7;
  margin-top: 6px;
  color: var(--muted);
}

.cu-analysis .empty {
  text-align: center;
  font-size: 13px;
  padding: 14px;
}

.cu-analysis .awardTable {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 6px;
  font-size: 13px;
}

.cu-analysis .awardTable th {
  color: var(--muted);
  font-size: 11px;
  font-weight: 700;
}

.cu-analysis .awardTable td {
  background: var(--panel-alt);
  border-top: 1px solid var(--border);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  text-align: center;
  font-weight: 800;
}

.cu-analysis .awardTable td:first-child {
  border-left: 1px solid var(--border);
  text-align: left;
}

.cu-analysis .awardTable td:last-child {
  border-right: 1px solid var(--border);
}

.ga-chart svg {
  width: 100%;
  height: 100%;
}

.ga-chart text {
  font: 10px var(--font-jp);
  fill: var(--muted);
}

#ga-analysis .history-meta p {
  margin: 6px 0;
}

#ga-analysis details summary {
  cursor: pointer;
}

/* Responsive */
@media (min-width: 821px) {
  .dashboard {
    grid-template-columns: 320px 250px minmax(0, 1fr);
    align-items: start;
  }

  .col-left {
    grid-column: 1;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
  }

  .col-mid {
    grid-column: 2;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-width: 0;
  }

  .calendar-day {
    aspect-ratio: 1 / 1;
    min-height: 0;
    padding: 0;
    display: grid;
    place-items: center;
  }

  .calendar-day.has-records::after {
    bottom: 3px;
  }

  .records-menu {
    padding: 16px;
  }

  .record-buttons {
    grid-template-columns: 1fr;
  }

  .mid-analysis-history {
    display: flex;
    flex-direction: column;
    gap: 12px;
  }

  .mid-analysis-history .panel {
    background: var(--panel);
    border: 1px solid var(--border);
    padding: 16px;
  }

  .mid-analysis-history .title {
    margin: 0 0 10px;
    font-size: 13px;
    font-weight: 900;
    letter-spacing: 0.06em;
    color: var(--text);
  }

  .mid-analysis-history .history-list {
    display: grid;
    gap: 8px;
    max-height: 420px;
    overflow: auto;
  }

  .mid-analysis-history .history-item {
    border: 1px solid var(--border);
    background: var(--panel-alt);
    padding: 10px 12px;
  }

  .mid-analysis-history .history-head {
    display: flex;
    justify-content: space-between;
    gap: 8px;
    align-items: center;
  }

  .mid-analysis-history .history-head strong {
    font-size: 12px;
  }

  .mid-analysis-history .history-meta {
    font-size: 11px;
    line-height: 1.6;
    margin-top: 4px;
    color: var(--muted);
  }

  .mid-analysis-history .empty {
    text-align: center;
    font-size: 12px;
    padding: 10px;
  }

  .record-details {
    grid-column: 3;
    align-self: start;
    min-width: 0;
  }
}

@media (max-width: 820px) {
  .screen {
    padding: 14px;
  }

  .col-left,
  .col-mid,
  .profile,
  .calendar,
  .stats,
  .bests,
  .trend,
  .history,
  .practice-records {
    grid-column: 1 / -1;
  }

  .col-left,
  .col-mid {
    display: flex;
    flex-direction: column;
    gap: 16px;
  }

  .practice-records {
    grid-template-columns: 1fr;
  }

  .record-buttons {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }

  .cu-analysis .stat-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .cu-analysis .chart-wrap {
    height: 250px;
  }
}

@media (max-width: 480px) {
  .record-buttons {
    grid-template-columns: 1fr;
  }

  .header-brand {
    font-size: 12px;
    gap: 6px;
  }

  .page-badge {
    font-size: 10px;
    padding: 3px 7px;
    white-space: nowrap;
  }

  .back {
    font-size: 11px;
    padding: 6px 10px;
    white-space: nowrap;
  }

  .cu-analysis .panel {
    padding: 14px;
  }
}
