/* =========================================================
   GRUNDLAYOUT
========================================================= */

.history-page{
  position: relative;
  min-height: 100vh;
}

/* Bakgrundsbild */
.history-page::before{
  content:"";
  position: fixed;
  inset: 0;
  background: url("/static/img/live_thl-bg.png") center / cover no-repeat;
  opacity: 0.75;
  z-index: -2;
  pointer-events: none;
}

/* Ljus overlay ovanpå bakgrunden */
.history-page::after{
  content:"";
  position: fixed;
  inset: 0;
  background: rgba(255,255,255,0.50);
  z-index: -1;
  pointer-events: none;
}

/* Innehållswrapper */
.history-page-wrap{
  position: relative;
  z-index: 2;
  padding: 28px 18px;
  max-width: 1200px;
  margin: 0 auto;
}

/* Tillbaka-länk */
.history-back-link{
  display: block;
  width: fit-content;
  margin: 0 0 8px 0;
  padding: 0;
  color: #1f2937;
  font-weight: 600;
  text-decoration: none;
  text-align: left;
}

.history-back-link:hover{
  text-decoration: underline;
}


/* =========================================================
   GEMENSAMMA KORT / TABELLER
========================================================= */

.history-card{
  background: rgba(255,255,255,0.92);
  border: 1px solid rgba(0,0,0,0.06);
  border-radius: 14px;
  padding: 14px 16px;
  margin-bottom: 14px;
  box-shadow: 0 4px 14px rgba(0,0,0,0.08);
  text-align: left;
  box-sizing: border-box;
}

.history-card h2,
.history-card h3{
  text-align: left;
}

.history-card h3{
  margin: 0 0 10px 0;
  font-family: var(--thl-display-font);
  letter-spacing: .5px;
}

.history-card p,
.history-card li{
  text-align: left;
}

.history-card .history-meta{
  font-size: 14px;
  line-height: 1.45;
  color: #374151;
}

.history-card .history-winner{
  font-weight: 700;
}

/* Mindre kort i t.ex. grupp-/slutspelsdelar */
.sub-card{
  background: #fff;
  border: 1px solid #e7e7e7;
  border-radius: 12px;
  padding: 14px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.04);
}

.sub-card h4{
  margin: 0 0 10px 0;
}

/* Grid / block / badges / listor */
.history-grid-2{
  display: grid;
  grid-template-columns: minmax(280px, 1fr) minmax(280px, 1fr);
  gap: 24px;
}

.history-grid-3{
  display: grid;
  grid-template-columns: minmax(260px, 1fr) minmax(260px, 1fr) minmax(260px, 1fr);
  gap: 24px;
}

.history-block{
  margin-top: 16px;
}

.history-game-type{
  margin-top: 8px;
}

.history-badge{
  display: inline-block;
  background: #66aee8;
  color: #fff;
  padding: 5px 10px;
  border-radius: 8px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1;
  white-space: nowrap;
}

/* 🔵 Mörkare för ProHockey */
.history-badge.pro{
  background: #2f6fa3;   /* mörkare blå */
}

.history-bullets{
  margin: 8px 0 0 18px;
  padding: 0;
}

.phase-subtitle{
  margin-top: 4px;
  color: #555;
  font-size: 14px;
}

/* Gemensamma tabeller */
.table-wrap{
  overflow-x: auto;
  margin-top: 8px;
}

.history-table{
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.history-table th,
.history-table td{
  border-bottom: 1px solid #eee;
  padding: 10px 12px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border-bottom: 1px solid #eee;
}

.history-table thead th{
  font-size:13px;
  text-transform:uppercase;
  letter-spacing:.6px;
  color:#333;
  font-weight:400;
}

.history-table tbody tr:hover{
  background: rgba(99,172,232,0.08);
}

.history-table thead tr{
  background: rgba(195,183,166,0.2);
  border-bottom: 2px solid rgba(0,0,0,0.05);
}

.history-table th,
.history-table td{
  padding:8px 10px;
  border-bottom:1px solid #eee;
}

.history-table tbody tr:last-child td{
  border-bottom: none;
}

.group-phase-block{
  margin-top: 22px;
}

.group-phase-block:first-of-type{
  margin-top: 14px;
}

.group-phase-block h4{
  margin: 0 0 10px 0;
  font-size: 28px;
  font-family: var(--thl-display-font);
  letter-spacing: .4px;
}

.group-phase-block .match-list{
  margin-bottom: 14px;
}

.history-date{
  color: #a74c3c; /*Färgen på datumer history-korten*/
  font-weight: 700;
}


/* =========================================================
   HISTORY-RUBRIKEN
========================================================= */
.history-list-top{
  margin-bottom: 18px;
}

.history-list-top .history-title{
  padding-bottom: 12px;
}

.history-list-top .history-sub{
  margin-top: 8px;
  min-height: auto;
}

.history-list-top .subtitle-main{
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.4px;
  margin-bottom: 4px;
  text-align: left;
}

.history-list-top .subtitle-sub{
  font-size: 13px;
  color: #806b71;
  font-weight: 500;
}


/* =========================================================
   HISTORY-LISTA
========================================================= */

.history-list{
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 22px;              /* ← detta skapar luft mellan korten */
  max-width: 1200px;
  margin: 0 auto;
}

/* Hover bara på översiktskorten */
#history-list .history-card{
  width: 100%;
  box-sizing: border-box;
  margin: 0;
  padding: 18px 20px;
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
  cursor: pointer;
}

#history-list .history-card:hover{
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(0,0,0,0.14);
  background: rgba(255,255,255,0.97);
}

.history-inline-gap{
  display: inline-block;
  width: 18px;
}

.history-meta > div{
  margin-top: 4px;
}

.history-meta > div:first-child{
  margin-top: 0;
}


/* =========================================================
   HISTORY-DETAIL – TOPPSEKTION / TABS / FILTER
========================================================= */

.history-top{
  display: flex;
  gap: 14px;
  align-items: flex-end;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

/* Titelblock */
.history-title{
  position: relative;
  padding-bottom: 12px;
}

.history-title h1{
  margin: 0;
  font-family: var(--thl-display-font);
  letter-spacing: 1px;
}

.history-title::after{
  content: "";
  position: absolute;
  left: 0;
  bottom: 0;
  width: 60px;
  height: 3px;
  background: #63ace8;
  border-radius: 2px;
}

.history-sub{
  margin-top: 6px;
  min-height: 42px;
  line-height: 1.2;
  text-align: left;
}

.subtitle-main{
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.4px;
  margin-bottom: 2px;
  text-align: left;
}

.subtitle-sub{
  font-size: 13px;
  color: #6b7280;
  font-weight: 500;
}

/* Tabs */
.history-tabs{
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.history-tab-btn{
  border: 1px solid #ddd;
  background: #fff;
  padding: 8px 12px;
  border-radius: 10px;
  cursor: pointer;
}

.history-tab-btn:hover{
  filter: brightness(0.96);
}

.history-tab-btn.active{
  border-color: #9ecc71;
  background: #63ace8;
  color: #fff;
}

.history-tab{
  display: none;
}

.history-tab.active{
  display: block;
}

/* Filterkort */
.history-filters{
  display: none;
}

.history-card.history-filters{
  padding: 22px 26px;
  display: flex;
  align-items: center;
  gap: 24px;
}

.history-filters .history-help{
  margin-top: 8px;
  font-size: 12px;
  text-align: center;
  color: #6b7280;
}

.history-filters button{
  margin-left: auto;
}

.history-filters .filters{
  display: flex;
  align-items: center;
  gap: 16px;
  width: 100%;
  flex-wrap: wrap;
}

.history-filters .btn-primary{
  margin-left: auto;
}

.history-filters label:first-child{
  margin-right: 16px;
}

.btn-primary{
  background: #66aee8;
  border: none;
  color: white;
  padding: 8px 16px;
  border-radius: 10px;
  cursor: pointer;
}

.btn-primary:hover{
  filter: brightness(0.95);
}


/* =========================================================
   HISTORY-DETAIL – STANDINGS / LAGSTATISTIK
========================================================= */

.history-standings-table{
  table-layout: auto;
}

.history-standings-table th,
.history-standings-table td{
  text-align: center;
}

.history-standings-table th:first-child,
.history-standings-table td:first-child{
  width: 15%;
  white-space: nowrap;
  padding-left: 6px;
  padding-right: 6px;
}

.history-standings-table th:nth-child(2),
.history-standings-table td:nth-child(2){
  text-align: left;
  width: 180px;
}

/* Standings som stats-sidan */
.history-stats-standings{
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.history-stats-standings th,
.history-stats-standings td{
  border-bottom: 1px solid #eee;
  padding: 8px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/*.history-stats-standings tbody tr:nth-child(even){
  background: #f8fafc;
}*/

/* # */
.history-stats-standings th:nth-child(1),
.history-stats-standings td:nth-child(1){
  width: 5ch;
  min-width: 5ch;
  max-width: 5ch;
  text-align: left;
  padding-right: 8px;
  font-variant-numeric: tabular-nums;
}

/* Team */
.history-stats-standings th:nth-child(2),
.history-stats-standings td:nth-child(2){
  width: 180px;
  text-align: left;
}

/* Övriga kolumner */
.history-stats-standings th:nth-child(n+3),
.history-stats-standings td:nth-child(n+3){
  text-align: center;
}

/* Sektioner */
.history-stats-standings th:nth-child(7),
.history-stats-standings td:nth-child(7){
  padding-left: 30px;
  border-left: 1px solid #eee;
}

.history-stats-standings th:nth-child(10),
.history-stats-standings td:nth-child(10){
  padding-left: 30px;
  border-left: 1px solid #eee;
}

.history-stats-standings th:nth-child(13),
.history-stats-standings td:nth-child(13){
  padding-left: 30px;
  border-left: 1px solid #eee;
}

.history-stats-standings .pos{
  color: #17823b;
  font-weight: 500;
}

.history-stats-standings .neg{
  color: #d93025;
  font-weight: 500;
}

/* Gruppspelsrubrik på en rad */
.group-phase-table-title{
  margin: 0 0 10px 0;
  font-family: var(--thl-display-font);
  letter-spacing: .5px;
  font-size: 16px;
  text-align: left;
}

/* Samma tabellstil som facit */
.history-stats-standings th:last-child,
.history-stats-standings td:last-child{
  font-weight: 700;
}

/* Positiv/negativ +/- och S± */
.history-stats-standings .pos{
  color: #17823b;
  font-weight: 500;
}

.history-stats-standings .neg{
  color: #d93025;
  font-weight: 500;
}

/* =========================================================
   HISTORY – RUBRIKBAKGRUND FÖR TABELLRUBRIKER
========================================================= */

.history-stats-standings thead th,
.history-players-table thead th,
.history-goalies-table thead th,
#dangerTableHistory thead th,
.history-position-table thead th{
  background: rgba(195, 183, 166, 0.2);
  border-bottom: 2px solid rgba(0,0,0,0.05);
  color: #6b7280;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 400;
}


/* =========================================================
   HISTORY-DETAIL – SPELARSTATISTIK / MÅLVAKTSLIGA
========================================================= */

.filters{
  display:flex;
  gap:16px;
  align-items:center;
  flex-wrap:wrap;
}

#resetPlayers,
#resetPositions{
  margin-left: auto;
}

.history-players-table,
.history-goalies-table{
  table-layout: fixed;
}

/* SPELARSTATISTIK */
.history-players-table th:nth-child(1),
.history-players-table td:nth-child(1){
  width: 5ch;
  min-width: 5ch;
  max-width: 5ch;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.history-players-table th:nth-child(2),
.history-players-table td:nth-child(2){
  width: 7ch;
  text-align: left;
}

.history-players-table th:nth-child(3),
.history-players-table td:nth-child(3){
  width: 15%;
}

.history-players-table th:nth-child(4),
.history-players-table td:nth-child(4){
  width: 14%;
}

.history-players-table th:nth-child(5),
.history-players-table td:nth-child(5),
.history-players-table th:nth-child(6),
.history-players-table td:nth-child(6){
  width: 7ch;
  text-align: center;
}

.history-players-table th:nth-child(7),
.history-players-table td:nth-child(7),
.history-players-table th:nth-child(9),
.history-players-table td:nth-child(9),
.history-players-table th:nth-child(10),
.history-players-table td:nth-child(10){
  width: 8ch;
  text-align: center;
}

.history-players-table th:nth-child(8),
.history-players-table td:nth-child(8){
  width: 9ch;
  text-align: center;
}

.history-players-table td:nth-child(3),
.history-players-table td:nth-child(4){
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.history-players-table th:nth-child(n+5),
.history-players-table td:nth-child(n+5){
  text-align: center;
}

/* MÅLVAKTSLIGA */
.history-goalies-table th:nth-child(1),
.history-goalies-table td:nth-child(1){
  width: 5ch;
  min-width: 5ch;
  max-width: 5ch;
  text-align: left;
  font-variant-numeric: tabular-nums;
}

.history-goalies-table th:nth-child(2),
.history-goalies-table td:nth-child(2){
  width: 7ch;
  text-align: left;
}

.history-goalies-table th:nth-child(3),
.history-goalies-table td:nth-child(3){
  width: 15%;
}

.history-goalies-table th:nth-child(4),
.history-goalies-table td:nth-child(4){
  width: 14%;
}

.history-goalies-table th:nth-child(5),
.history-goalies-table td:nth-child(5),
.history-goalies-table th:nth-child(6),
.history-goalies-table td:nth-child(6){
  width: 7ch;
  text-align: center;
}

.history-goalies-table th:nth-child(7),
.history-goalies-table td:nth-child(7){
  width: 8ch;
  text-align: center;
}

.history-goalies-table th:nth-child(8),
.history-goalies-table td:nth-child(8),
.history-goalies-table th:nth-child(9),
.history-goalies-table td:nth-child(9){
  width: 10ch;
  text-align: center;
}

.history-goalies-table th:nth-child(10),
.history-goalies-table td:nth-child(10){
  width: 8ch;
  text-align: center;
  font-weight: 600;
}

.history-goalies-table td:nth-child(3),
.history-goalies-table td:nth-child(4){
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}


/* =========================================================
   HISTORY-DETAIL – MATCHLISTOR / NYCKELTAL / POSITIONER
========================================================= */

.match-list{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px 18px;
}

.match-row{
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  gap: 12px;
  align-items: center;
  padding: 10px 30px;
  border-radius: 8px;
  background: #f8fafc;
  border: 1px solid #e5e7eb;
}

.team-home{
  text-align: left;
  font-weight: 600;
}

.team-away{
  text-align: right;
  font-weight: 600;
}

.score{
  font-weight: 700;
  white-space: nowrap;
}

.tie-meta{
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  margin-bottom: 10px;
  font-size: 14px;
  color: #374151;
}

.history-keynumbers{
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.keyrow{
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 0;
  border-top: 1px solid #e5e7eb;
}

.keyrow:first-child{
  border-top: none;
  padding-top: 0;
}

.playoff-series-block{
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.playoff-series-card{
  margin-bottom: 0;
}

.playoff-series-card h4{
  margin-bottom: 12px;
}

.playoff-series-card{
  margin-bottom: 0;
  padding: 16px;
}

.playoff-series-card + .playoff-series-card{
  margin-top: 4px;
}

/* Positionstabeller */
.positions-grid{
  display: grid;
  grid-template-columns: auto auto;
  justify-content: center;
  gap: 80px;
  align-items: start;
}

.positions-grid h4{
  text-align: center;
}

.history-position-table{
  table-layout: fixed;
  width: 350px;
}

.positions-grid .history-position-table{
  width: 350px;
}

.history-position-table th:nth-child(1),
.history-position-table td:nth-child(1){
  width: 18%;
  text-align: left;
}

.history-position-table th:nth-child(2),
.history-position-table td:nth-child(2){
  width: 22%;
  text-align: center;
}

.history-position-table th:nth-child(3),
.history-position-table td:nth-child(3){
  width: 20%;
  text-align: center;
  font-weight: 600;
}

/* Målfarligaste lag */
#dangerTableHistory{
  table-layout: fixed;
}

#dangerTableHistory th:nth-child(1),
#dangerTableHistory td:nth-child(1){
  width: 3ch;
  text-align: center;
}

#dangerTableHistory th:nth-child(2),
#dangerTableHistory td:nth-child(2){
  width: 150px;
  text-align: left;
}

#dangerTableHistory th:nth-child(3),
#dangerTableHistory td:nth-child(3){
  width: 55px;
  text-align: center;
}

#dangerTableHistory th:nth-child(4),
#dangerTableHistory td:nth-child(4),
#dangerTableHistory th:nth-child(5),
#dangerTableHistory td:nth-child(5),
#dangerTableHistory th:nth-child(6),
#dangerTableHistory td:nth-child(6){
  width: 60px;
  text-align: center;
}

#dangerTableHistory th:nth-child(7),
#dangerTableHistory td:nth-child(7),
#dangerTableHistory th:nth-child(8),
#dangerTableHistory td:nth-child(8),
#dangerTableHistory th:nth-child(9),
#dangerTableHistory td:nth-child(9){
  width: 95px;
  text-align: center;
}

#dangerTableHistory th:nth-child(10),
#dangerTableHistory td:nth-child(10){
  width: 105px;
  text-align: center;
}

#dangerTableHistory th:nth-child(11),
#dangerTableHistory td:nth-child(11){
  width: 105px;
  text-align: center;
}

/* Sortering */
#teamsContent th.sortable{
  cursor: pointer;
  white-space: nowrap;
}

#teamsContent th.sortable:hover{
  text-decoration: underline;
}

#teamsContent th.sortable.is-active{
  font-weight: 700;
}

#teamsContent th.sortable::after{
  content: " ⇅";
  opacity: 0.45;
}

#teamsContent th.sortable.is-active.is-desc::after{
  content: " ▼";
  opacity: 0.85;
}

#teamsContent th.sortable.is-active.is-asc::after{
  content: " ▲";
  opacity: 0.85;
}


/* =========================================================
   MATCHMODAL
========================================================= */

.match-modal{
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.40);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 2000;
}

.match-modal-content{
  position: relative;
  background: #fff;
  border-radius: 14px;
  padding: 24px 28px;
  width: 900px;
  max-width: 96vw;
  max-height: 88vh;
  overflow-y: auto;
  box-shadow: 0 10px 30px rgba(0,0,0,0.18);
}

.match-modal-content{
  position: relative;
  overflow: hidden;
}

/* gemensam stil */
.match-bg-logo{
  position: absolute;
  top: 20px;
  width: 200px;
  height: 120px;
  background-size: contain;
  background-repeat: no-repeat;
  background-position: center;
  opacity: 0.12; /* 🔥 viktigt – subtil */
  pointer-events: none;
}

/* vänster */
.match-bg-logo.left{
  left: 65px;
}

/* höger */
.match-bg-logo.right{
  right: 65px;
}

.match-modal-close{
  position: absolute;
  top: 10px;
  right: 14px;
  border: none;
  background: transparent;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  color: #374151;
}

.match-header{
  text-align: center;
  margin-bottom: 14px;
}

.match-header h2{
  margin: 0;
  font-family: var(--thl-display-font);
}

#modalMatchScore{
  margin-top: 6px;
  font-size: 18px;
  font-weight: 700;
  margin-left: 12px;
}

.match-summary{
  text-align: center;
  margin-bottom: 16px;
  font-size: 14px;
  color: #374151;
  line-height: 1.7;
}

.match-score-home{
  margin-right: 6px;
}

.match-score-away{
  margin-left: 6px;
}

.match-score-home,
.match-score-away{
  font-size: 22px;
}

.match-score-home,
.match-score-away,
.match-period-score,
.match-shot-total,
.match-shot-period{
  color: #63ace8;
  font-weight: 700;
}

.match-goals-table{
  width: 100%;
  border-collapse: collapse;
  table-layout: fixed;
}

.match-goals-table thead th{
  background: rgba(195, 183, 166, 0.2);
  border-bottom: 2px solid rgba(0,0,0,0.05);
  color: #6b7280;
  font-size: 13px;
  text-transform: uppercase;
  letter-spacing: .5px;
  font-weight: 700;
}

.match-goals-table th,
.match-goals-table td{
  border-bottom: 1px solid #eee;
  padding: 8px 10px;
  text-align: left;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Period */
.match-goals-table th:nth-child(1),
.match-goals-table td:nth-child(1){
  width: 10%;
  text-align: center;
}

/* Tid */
.match-goals-table th:nth-child(2),
.match-goals-table td:nth-child(2){
  width: 10%;
  text-align: center;
}

/* Lag */
.match-goals-table th:nth-child(3),
.match-goals-table td:nth-child(3){
  width: 15%;
  text-align: left;
}

/* Målskytt */
.match-goals-table th:nth-child(4),
.match-goals-table td:nth-child(4){
  width: 25%;
}

/* Assist */
.match-goals-table th:nth-child(5),
.match-goals-table td:nth-child(5){
  width: 40%;
}

.match-row-btn{
  width: 100%;
  border: 1px solid #e5e7eb;
  cursor: pointer;
  font: inherit;
  color: inherit;
  text-align: inherit;
}

.match-row-btn:hover{
  background: #f1f5f9;
}

.match-goals-table tbody tr:hover{
  background: #f1f5f9;
}

.match-row-btn:focus{
  outline: 2px solid #63ace8;
  outline-offset: 2px;
}

/* Periodavdelare */
.match-goals-table tr.period-break td{
  border-top: 3px solid #9ca3af;
  padding-top: 12px;
}


/* =========================================================
   RESPONSIVE
========================================================= */

@media (max-width: 1100px){
  .history-grid-3{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 900px){
  .history-grid-2{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 700px){
  .match-row{
    grid-template-columns: 1fr;
    text-align: left;
  }

  .team-away{
    text-align: left;
  }

  .score{
    justify-self: start;
  }
}

@media (max-width: 700px){
  .match-list{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 1000px){
  .history-list{
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (max-width: 600px){
  .history-list{
    grid-template-columns: 1fr;
  }
}


/* =========================================================
   HISTORIKÖVERSIKT · STATISTIK-DNA
========================================================= */

.history-page--overview,
.history-page--overview *{
  box-sizing: border-box;
}

.history-page--overview .history-page-wrap{
  width: 100% !important;
  max-width: none;
  padding-top: clamp(26px, 4vw, 48px);
  padding-bottom: 72px;
}

.history-overview-frame{
  width: min(1350px, 100%);
  margin: 0 auto;
}

.history-overview-topbox{
  position: relative;
  display: grid;
  grid-template-columns: minmax(300px, .7fr) minmax(760px, 1.3fr);
  align-items: end;
  gap: 28px;
  min-height: 159px;
  margin-bottom: 18px;
  padding: 20px 22px;
  overflow: hidden;
  color: #fff;
  border: 1px solid rgba(255,255,255,.14);
  border-radius: 22px;
  background:
    radial-gradient(circle at 82% -40%, rgba(36,118,173,.38), transparent 44%),
    linear-gradient(145deg, rgba(16,25,34,.985), rgba(31,45,58,.98));
  box-shadow: 0 22px 54px rgba(12,20,28,.24);
}

.history-overview-topbox:not(.has-workflow){
  grid-template-columns: 1fr;
}

.history-overview-topbox::before,
.history-archive::before{
  position: absolute;
  z-index: 2;
  top: 0;
  right: 0;
  left: 0;
  height: 4px;
  background: linear-gradient(90deg, var(--thl-blue, #2476ad) 0 76%, var(--thl-orange, #f26445) 76%);
  content: "";
}

.history-overview-topbox .page-header-wrap{
  width: auto;
  margin: 0;
}

.history-overview-topbox .page-header{
  display: block;
  max-width: none;
  padding-left: 16px;
}

.history-overview-topbox .page-header::before{
  box-shadow: none;
}

.history-overview-topbox .page-header__title{
  color: #fff;
  font-size: clamp(34px, 3.2vw, 44px);
}

.history-overview-topbox .page-header__line{
  margin-top: 9px;
}

.history-overview-topbox .page-header__sub{
  margin-top: 7px;
}

.history-overview-topbox .page-header__sub-main{
  color: rgba(255,255,255,.82);
  font-size: 11px;
}

.history-overview-topbox .page-header__sub-sub{
  color: rgba(255,255,255,.5);
  font-size: 12px;
}

/* Turneringsflödet använder samma visuella språk som statistikflikarna. */
.history-overview-topbox .workflow-nav{
  z-index: 1;
  width: auto;
  margin: 0;
  padding: 0;
  overflow-x: auto;
  border: 0;
  border-radius: 0;
  background: transparent;
  box-shadow: none;
  backdrop-filter: none;
  scrollbar-width: none;
}

.history-overview-topbox .workflow-nav::-webkit-scrollbar{
  display: none;
}

.history-overview-topbox .workflow-nav__list{
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 7px;
  width: 100%;
}

.history-overview-topbox .workflow-nav__item::after{
  display: none;
}

.history-overview-topbox .workflow-nav__item a{
  display: flex;
  justify-content: flex-start;
  gap: 8px;
  min-height: 52px;
  padding: 7px 10px;
  color: rgba(255,255,255,.66);
  border: 1px solid rgba(255,255,255,.08);
  border-radius: 11px;
  background: rgba(255,255,255,.035);
  transition: color 180ms ease, border-color 180ms ease, background 180ms ease, transform 180ms ease;
}

.history-overview-topbox .workflow-nav__item a:hover{
  color: #fff;
  border-color: rgba(120,200,245,.22);
  background: rgba(255,255,255,.065);
  transform: translateY(-1px);
}

.history-overview-topbox .workflow-nav__number{
  flex: 0 0 28px;
  width: 28px;
  height: 28px;
  color: #8bd0f5;
  border-color: rgba(120,200,245,.22);
  background: rgba(255,255,255,.055);
  font-size: 9px;
  font-weight: 850;
}

.history-overview-topbox .workflow-nav__copy{
  gap: 1px;
}

.history-overview-topbox .workflow-nav__copy strong{
  color: inherit;
  font-size: 10px;
  font-weight: 750;
}

.history-overview-topbox .workflow-nav__copy small{
  color: inherit;
  font-size: 8px;
  font-weight: 550;
  opacity: .62;
}

.history-overview-topbox .workflow-nav__item.is-complete .workflow-nav__number{
  color: #fff;
  border-color: rgba(66,190,143,.7);
  background: rgba(37,139,102,.82);
}

.history-overview-topbox .workflow-nav__item.is-active a{
  color: #fff;
  border-color: rgba(76,162,217,.46);
  background: linear-gradient(135deg, var(--thl-blue, #2476ad), var(--thl-blue-deep, #15527e));
  box-shadow: 0 8px 20px rgba(12,74,116,.3);
}

.history-overview-topbox .workflow-nav__item.is-active .workflow-nav__number{
  color: var(--thl-blue-deep, #15527e);
  border-color: #fff;
  background: #fff;
}

/* Arkivbox */
.history-archive{
  position: relative;
  overflow: hidden;
  border: 1px solid rgba(255,255,255,.82);
  border-radius: 22px;
  background: rgba(255,255,255,.93);
  box-shadow: 0 18px 42px rgba(20,32,44,.14);
}

.history-archive__header{
  display: grid;
  grid-template-columns: 50px auto 1fr;
  align-items: center;
  gap: 15px;
  min-height: 78px;
  padding: 15px 22px;
  color: #fff;
  background:
    radial-gradient(circle at 82% -40%, rgba(36,118,173,.35), transparent 44%),
    linear-gradient(145deg, #111b25, #22313e);
}

.history-archive__mark{
  display: grid;
  place-items: center;
  width: 50px;
  height: 50px;
  color: #78c8f5;
  border: 1px solid rgba(120,200,245,.28);
  border-radius: 14px;
  background: rgba(255,255,255,.06);
  font-family: var(--thl-display-font);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .5px;
}

.history-archive__heading small{
  display: block;
  margin-bottom: 2px;
  color: #78c8f5;
  font-size: 9px;
  font-weight: 850;
  letter-spacing: 1.15px;
  text-transform: uppercase;
}

.history-archive__heading h2{
  margin: 0;
  color: #fff;
  font-family: var(--thl-display-font);
  font-size: 22px;
  font-weight: 750;
  letter-spacing: .15px;
  line-height: 1.05;
}

.history-archive__header > p{
  justify-self: end;
  max-width: 430px;
  margin: 0;
  color: rgba(255,255,255,.56);
  font-size: 11px;
  font-weight: 550;
  text-align: right;
}

.history-archive__body{
  padding: 20px 22px 22px;
}

.history-page--overview .history-list{
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px !important;
  width: 100%;
  max-width: none;
  margin: 0;
}

.history-page--overview #history-list .history-card{
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 250px;
  margin: 0;
  padding: 18px;
  overflow: hidden;
  color: var(--thl-ink, #111820);
  text-decoration: none;
  border: 1px solid rgba(36,118,173,.12) !important;
  border-radius: 17px !important;
  background: linear-gradient(145deg, rgba(255,255,255,.99), rgba(246,250,252,.98)) !important;
  box-shadow: 0 10px 24px rgba(20,32,44,.08) !important;
  backdrop-filter: none;
  transition: transform 180ms ease, border-color 180ms ease, box-shadow 180ms ease !important;
}

.history-page--overview #history-list .history-card::before{
  position: absolute;
  top: 0;
  right: 0;
  left: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--thl-blue, #2476ad) 0 76%, var(--thl-orange, #f26445) 76%);
  content: "";
}

.history-page--overview #history-list .history-card:hover{
  transform: translateY(-3px);
  border-color: rgba(36,118,173,.28) !important;
  background: #fff !important;
  box-shadow: 0 18px 36px rgba(20,32,44,.14) !important;
}

.history-page--overview #history-list .history-card:focus-visible{
  outline: 3px solid rgba(36,118,173,.32);
  outline-offset: 3px;
}

.history-card__header{
  display: grid;
  grid-template-columns: 44px minmax(0, 1fr) 34px;
  align-items: center;
  gap: 12px;
}

.history-card__index{
  display: grid;
  place-items: center;
  width: 44px;
  height: 44px;
  color: var(--thl-blue-deep, #15527e);
  border: 1px solid rgba(36,118,173,.16);
  border-radius: 12px;
  background: rgba(36,118,173,.075);
  font-family: var(--thl-display-font);
  font-size: 10px;
  font-weight: 800;
}

.history-card__identity{
  min-width: 0;
}

.history-card__identity small{
  display: block;
  overflow: hidden;
  margin-bottom: 3px;
  color: var(--thl-blue-deep, #15527e);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: 1px;
  text-overflow: ellipsis;
  text-transform: uppercase;
  white-space: nowrap;
}

.history-page--overview #history-list .history-card h3{
  display: -webkit-box;
  margin: 0;
  overflow: hidden;
  color: var(--thl-ink, #111820);
  font-family: var(--thl-display-font);
  font-size: 19px;
  font-weight: 750;
  letter-spacing: .1px;
  line-height: 1.08;
  -webkit-box-orient: vertical;
  -webkit-line-clamp: 2;
}

.history-card__arrow{
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  color: var(--thl-blue-deep, #15527e);
  border-radius: 10px;
  background: rgba(36,118,173,.075);
  transition: color 180ms ease, background 180ms ease, transform 180ms ease;
}

.history-card__arrow svg{
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.history-card:hover .history-card__arrow{
  color: #fff;
  background: var(--thl-blue, #2476ad);
  transform: translateX(2px);
}

.history-card__facts{
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1px;
  margin-top: 15px;
  overflow: hidden;
  border: 1px solid rgba(17,24,32,.07);
  border-radius: 12px;
  background: rgba(17,24,32,.07);
}

.history-card__facts > span{
  display: flex;
  min-width: 0;
  min-height: 55px;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 9px 11px;
  background: rgba(248,251,253,.98);
}

.history-card__facts small,
.history-card__winner small{
  color: var(--thl-slate, #667281);
  font-size: 8px;
  font-weight: 900;
  letter-spacing: .75px;
  text-transform: uppercase;
}

.history-card__facts strong{
  overflow: hidden;
  color: var(--thl-ink-soft, #283545);
  font-size: 11px;
  font-weight: 750;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card__winner{
  display: grid;
  grid-template-columns: 1fr;
  gap: 1px;
  margin-top: 10px;
  overflow: hidden;
  border: 1px solid rgba(36,118,173,.1);
  border-radius: 12px;
  background: rgba(36,118,173,.08);
}

.history-card__winner--split{
  grid-template-columns: 1fr 1fr;
}

.history-card__winner > span{
  display: flex;
  min-width: 0;
  min-height: 48px;
  flex-direction: column;
  justify-content: center;
  gap: 3px;
  padding: 8px 11px;
  background: rgba(235,246,252,.95);
}

.history-card__winner strong{
  overflow: hidden;
  color: var(--thl-ink, #111820);
  font-size: 12px;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.history-card__footer{
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px;
  margin-top: auto;
  padding-top: 14px;
}

.history-card__badges{
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.history-page--overview .history-badge{
  margin: 0;
  padding: 5px 8px;
  color: var(--thl-blue-deep, #15527e);
  border: 1px solid rgba(36,118,173,.12);
  border-radius: 999px;
  background: rgba(36,118,173,.085);
  font-size: 9px;
  font-weight: 800;
}

.history-page--overview .history-badge.is-thl{
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--thl-blue, #2476ad), var(--thl-blue-deep, #15527e));
}

.history-page--overview .history-badge.pro{
  color: #fff;
  border-color: transparent;
  background: #2f6fa3;
}

/* Varje administrerbar speltyp får en stabil egen identitetsfärg. */
.history-badge.game-type--ice,
.history-page--overview .history-badge.game-type--ice {
  color: #fff;
  border-color: transparent;
  background: #2b89bd;
}

.history-badge.game-type--orange,
.history-page--overview .history-badge.game-type--orange {
  color: #fff;
  border-color: transparent;
  background: #d86442;
}

.history-badge.game-type--green,
.history-page--overview .history-badge.game-type--green {
  color: #fff;
  border-color: transparent;
  background: #258b66;
}

.history-badge.game-type--purple,
.history-page--overview .history-badge.game-type--purple {
  color: #fff;
  border-color: transparent;
  background: #7353a6;
}

.history-badge.game-type--gold,
.history-page--overview .history-badge.game-type--gold {
  color: #49370a;
  border-color: transparent;
  background: #ddb84b;
}

.history-badge.game-type--red,
.history-page--overview .history-badge.game-type--red {
  color: #fff;
  border-color: transparent;
  background: #ad4a3b;
}

.history-badge.game-type--teal,
.history-page--overview .history-badge.game-type--teal {
  color: #fff;
  border-color: transparent;
  background: #24858a;
}

.history-badge.game-type--navy,
.history-page--overview .history-badge.game-type--navy {
  color: #fff;
  border-color: transparent;
  background: #294f73;
}

.history-card__cta{
  flex: 0 0 auto;
  color: var(--thl-slate, #667281);
  font-size: 9px;
  font-weight: 800;
  letter-spacing: .25px;
}

.history-list__empty{
  grid-column: 1 / -1;
  margin: 0;
  padding: 28px;
  color: var(--thl-slate, #667281);
  border: 1px dashed rgba(36,118,173,.22);
  border-radius: 14px;
  background: rgba(36,118,173,.04);
  text-align: center;
}

.history-list__empty.is-error{
  color: #9f3e38;
  border-color: rgba(185,72,72,.2);
  background: rgba(185,72,72,.05);
}

@media (max-width: 1180px){
  .history-overview-topbox{
    grid-template-columns: 1fr;
    gap: 18px;
  }

  .history-overview-topbox .workflow-nav{
    width: 100%;
  }

  .history-overview-topbox .workflow-nav__list{
    width: max-content;
    min-width: 100%;
    grid-template-columns: repeat(5, minmax(158px, 1fr));
  }
}

@media (max-width: 1050px){
  .history-page--overview .history-list{
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

@media (max-width: 760px){
  .history-archive__header{
    grid-template-columns: 50px 1fr;
    padding: 15px 14px 13px;
  }

  .history-archive__header > p{
    grid-column: 2;
    justify-self: start;
    text-align: left;
  }

  .history-archive__body{
    padding: 14px;
  }
}

@media (max-width: 700px){
  .history-page--overview .history-list{
    grid-template-columns: 1fr;
  }
}

@media (max-width: 620px){
  .history-page--overview .history-page-wrap{
    padding-top: 24px;
    padding-bottom: 48px;
  }

  .history-overview-topbox,
  .history-archive{
    border-radius: 17px;
  }

  .history-overview-topbox{
    padding: 18px 14px;
  }

  .history-overview-topbox .page-header{
    padding-left: 14px;
  }

  .history-overview-topbox .workflow-nav__list{
    grid-template-columns: repeat(5, minmax(150px, 1fr));
  }

  .history-page--overview #history-list .history-card{
    min-height: 244px;
    padding: 16px;
  }
}

@media (max-width: 390px){
  .history-card__facts{
    grid-template-columns: 1fr;
  }
}
