:root {
  /* Surfaces */
  --canvas: #f6f8fb;
  --surface: #ffffff;
  --surface-muted: #f5f7fb;

  /* Text */
  --text: #0f172a;
  --text-muted: #5f6b7a;
  --text-faint: #9ca3af;
  --text-inverse: #ffffff;

  /* Links and accents */
  --link: #2d2d2d;
  --accent: #3f5f94;
  --accent-strong: #4f6fa8;
  --accent-soft: #e9f0ff;
  --accent-soft-hover: #dbe7ff;
  --accent-surface: #eef7f8;
  --accent-border: #b9dbe1;

  /* Borders and shadows */
  --border: #d9dde5;
  --pressed-ring-color: rgba(255, 255, 255, 0.35);
  --raised-shadow-color: rgba(0, 0, 0, 0.08);
  --card-shadow-color: rgba(0, 0, 0, 0.04);

  /* Tables and lists */
  --table-row-odd: #f5f7fb;
  --table-row-even: #ffffff;
  --table-row-hover: #eef3f7;

  /* Gameplay */
  --team-home-bg: #e9f7f0;
  --team-away-bg: #eef2ff;
  --game-event-bg: #fff7e6;
  --halftime-bg: #fdecea;
  --game-card-bg: #f9fbff;
  --game-pending-bg: #f1f6ff;
  --game-ongoing-bg: #ffe7e7;
  --game-played-bg: #eef8f2;
  --gameclock-bg: #e6eef2;

  /* Secondary actions */
  --button-secondary-bg: #eef3f7;
  --button-secondary-hover-bg: #dde6ee;

  /* Notices */
  --status-error-bg: #fde8e8;
  --status-error-border: #f8b4b4;
  --status-error-text: #9b1c1c;
  --status-success-bg: #e3fcec;
  --status-success-border: #84e1bc;
  --status-success-text: #0f5132;
  --status-info-bg: #eef4ff;
  --status-info-border: #c3dafe;
  --status-info-text: #1f3a8a;
  --status-warning-bg: #fff7e6;
  --status-warning-border: #f7c566;
  --status-warning-text: #b54708;

  /* Timekeeper */
  --timer-warning-bg: #fff4d6;
  --timer-warning-text: #8a5a00;
  --timer-critical-bg: #fde0e0;
  --timer-critical-text: #b00020;
}

* {
  box-sizing: border-box;
}

html {
  font-size: 100%;
}

body {
  margin: 0;
  font-family: "Helvetica Neue", Arial, sans-serif;
  background: var(--canvas);
  color: var(--text);
  line-height: 1.5;
  font-size: 1rem;
}

p {
  margin: 6px 0;
}


a {
  color: var(--link);
}

h1,
h2,
h3 {
  margin: 0 0 8px;
  font-weight: 700;
}

h1 {
  font-size: 1.3rem;
}

h2 {
  font-size: 1.15rem;
}

h3 {
  font-size: 1.05rem;
}

label {
  display: block;
  font-weight: 600;
  margin: 12px 0 6px;
  color: var(--text-muted);
}

input,
select,
textarea {
  width: 100%;
  max-width: none;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 8px;
  font-size: 0.95rem;
  background: var(--surface);
}

input[type="radio"],
input[type="checkbox"] {
  width: auto;
  max-width: none;
}

[data-role="page"] {
  min-height: 100vh;
  background: var(--canvas);
  display: flex;
  flex-direction: column;
  padding-top: env(safe-area-inset-top);
  padding-bottom: env(safe-area-inset-bottom);
}

[data-role="header"] {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 8px 10px;
  position: sticky;
  top: 0;
  z-index: 10;
}

.sk-gameclock {
  float: left;
  margin: 0.2em 1.1em 0.25em 0.5ex;
  padding: 0.15em 0.4em;
  border-radius: 0.35em;
  background: var(--gameclock-bg);
  line-height: 1.3;
  font-size: 1.8em;
}

[data-role="content"] {
  padding: 16px;
  max-width: 980px;
  width: 100%;
  margin: 0 auto;
}

[data-role="footer"],
.ui-bar {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 8px 10px;
  position: sticky;
  bottom: 0;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  justify-content: center;
}

[data-role="footer"] a,
.ui-bar a {
  flex: 1;
  text-align: center;
}

.ui-bar .footer-compact,
[data-role="footer"] .footer-compact {
  flex: 0 0 auto;
  margin: 0;
  padding: 4px 8px;
  min-height: 30px;
  font-size: 0.85rem;
  letter-spacing: 0;
  min-width: 0;
}

.ui-bar .footer-icon,
[data-role="footer"] .footer-icon {
  width: 34px;
  padding-inline: 8px;
}

.ui-bar .footer-compact[aria-pressed="true"],
[data-role="footer"] .footer-compact[aria-pressed="true"] {
  background: var(--accent-strong);
  box-shadow: inset 0 0 0 2px var(--pressed-ring-color);
}

.tk-clock-icon {
  position: relative;
  display: block;
  width: 16px;
  height: 16px;
  border: 2px solid currentColor;
  border-radius: 50%;
}

.tk-clock-icon::before,
.tk-clock-icon::after {
  position: absolute;
  left: 6px;
  bottom: 6px;
  width: 2px;
  background: currentColor;
  border-radius: 1px;
  content: "";
  transform-origin: 50% 100%;
}

.tk-clock-icon::before {
  height: 5px;
}

.tk-clock-icon::after {
  height: 4px;
  transform: rotate(120deg);
}

[data-role="button"],
button,
input[type="submit"],
input[type="button"],
input[type="reset"] {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 12px 14px;
  margin: 6px 6px 6px 0;
  border-radius: 10px;
  border: 1px solid var(--accent);
  background: var(--accent);
  color: var(--text-inverse);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.95rem;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  text-align: center;
  cursor: pointer;
  transition: transform 120ms ease, box-shadow 120ms ease, background 120ms ease;
}

.back-resp-button {
  margin-top: 24px;
  width: 50%;
  margin-left: auto;
  display: flex;
  justify-content: center;
}

.back-score-button {
  width: 100%;
  display: flex;
  justify-content: center;
}

[data-role="button"]:hover,
button:hover,
input[type="submit"]:hover,
input[type="button"]:hover,
input[type="reset"]:hover {
  background: var(--accent-strong);
  transform: translateY(-1px);
  box-shadow: 0 6px 18px var(--raised-shadow-color);
}

[data-role="button"]:active,
button:active,
input[type="submit"]:active,
input[type="button"]:active,
input[type="reset"]:active {
  transform: translateY(0);
  box-shadow: none;
}

/* Submitting: the double-submit guard disables the buttons until the page
   navigates, so make that state read as "working" rather than as broken. */
button:disabled,
input[type="submit"]:disabled,
input[type="button"]:disabled {
  opacity: 0.55;
  cursor: progress;
  transform: none;
  box-shadow: none;
}

[data-role="controlgroup"] {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  margin: 12px 0;
}

[data-role="controlgroup"][data-type="horizontal"] {
  flex-direction: row;
}

#teamselection {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 10px;
}

#teamselection .control-option {
  display: flex;
  align-items: center;
  gap: 8px;
}

#teamselection .control-option label {
  display: inline-flex;
  align-items: center;
  margin: 0;
  width: 100%;
  font-size: 1rem;
}

#teamselection .control-option input[type="radio"] {
  margin: 0;
  width: 1.1rem;
  height: 1.1rem;
}

.spirit-controlgroup {
  display: grid;
  grid-template-columns: repeat(5, minmax(0, 1fr));
  gap: 0;
  width: 100%;
}

.spirit-controlgroup .spirit-choice {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  padding: 4px 2px;
  border-left: 1px solid var(--border);
}

.spirit-controlgroup .spirit-choice:first-child {
  border-left: none;
}

.spirit-controlgroup .spirit-choice label {
  margin: 0;
  font-weight: 600;
  font-size: 0.9rem;
}

.spirit-controlgroup .spirit-choice input[type="radio"] {
  margin: 0;
  width: 1.0rem;
  height: 1.0rem;
}

.spirit-table {
  width: 100%;
  table-layout: fixed;
}

.spirit-table td,
.spirit-table th {
  width: auto;
}

.spirit-control-cell {
  width: 100%;
}

.scoreboard-table {
  width: 100%;
  border-collapse: collapse;
}

.scoreboard-table td {
  padding: 8px 10px;
}

.scoreboard-table tr:nth-child(odd) {
  background: var(--table-row-odd);
}

.scoreboard-table tr:nth-child(even) {
  background: var(--table-row-even);
}

.gameplay-table {
  width: 100%;
  border-collapse: collapse;
}

.gameplay-table td {
  padding: 8px 10px;
}

.gameplay-row--goal.gameplay-row--home {
  background: var(--team-home-bg);
}

.gameplay-row--goal.gameplay-row--away {
  background: var(--team-away-bg);
}

.gameplay-row--event {
  background: var(--game-event-bg);
}

.gameplay-row--halftime {
  background: var(--halftime-bg);
  font-weight: 700;
}

[data-role="listview"] {
  list-style: none;
  margin: 12px 0;
  padding: 0;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

[data-role="listview"] li {
  border-bottom: 1px solid var(--border);
}

[data-role="listview"] li:last-child {
  border-bottom: none;
}

[data-role="listview"] a {
  display: block;
  padding: 14px 16px;
  color: var(--text);
  text-decoration: none;
}

[data-role="listview"] a:hover {
  background: var(--table-row-hover);
}

.resp-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.resp-list[data-role="listview"] {
  background: none;
  border: none;
  box-shadow: none;
}

.resp-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 8px 10px;
  box-shadow: 0 6px 18px var(--card-shadow-color);
}

.resp-group-toggle,
.resp-location-toggle {
  display: block;
}

.resp-group-title,
.resp-location-title {
  cursor: pointer;
  list-style: none;
  position: relative;
  padding-right: 18px;
}

.resp-group-title::-webkit-details-marker,
.resp-location-title::-webkit-details-marker {
  display: none;
}

.resp-group-title::after,
.resp-location-title::after {
  content: "▸";
  position: absolute;
  right: 0;
  top: 0;
  color: var(--text-muted);
  transition: transform 0.15s ease;
}

.resp-group-toggle[open] > .resp-group-title::after,
.resp-location-toggle[open] > .resp-location-title::after {
  transform: rotate(90deg);
}

.resp-group-title {
  font-weight: 700;
  margin-bottom: 6px;
  color: var(--text);
}

.resp-location-title {
  font-weight: 600;
  color: var(--text-muted);
  margin: 6px 0;
}

.resp-location-list,
.resp-game-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.resp-location {
  border-top: 1px solid var(--border);
  padding-top: 6px;
}

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

.resp-game {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 8px 10px 6px;
  background: var(--game-card-bg);
}

.resp-game.resp-game--pending {
  background: var(--game-pending-bg);
}

.resp-game.resp-game--ongoing {
  background: var(--game-ongoing-bg);
}

.resp-game.resp-game--played {
  background: var(--game-played-bg);
}

.resp-game-meta {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 0;
  font-size: 0.95rem;
}

.resp-time {
  font-weight: 700;
  color: var(--accent-strong);
}

.resp-teams {
  flex: 1 1 auto;
  min-width: 160px;
}

.resp-score {
  font-weight: 700;
  line-height: 1.1;
}

.resp-score a {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 8px;
  background: var(--accent-soft);
  color: var(--accent-strong);
  text-decoration: none;
  transition: background 0.15s ease, transform 0.15s ease;
}

.resp-score a:hover {
  background: var(--accent-soft-hover);
  transform: translateY(-1px);
}

.resp-score a:focus {
  outline: 2px solid var(--accent-strong);
  outline-offset: 2px;
}

.resp-status a {
  color: var(--accent-strong);
  font-weight: 600;
}

.resp-status {
  flex-basis: 100%;
  margin-top: 0;
  text-align: right;
  font-size: 0.8rem;
  font-variant: small-caps;
}

.resp-actions {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 4px;
  margin-top: 4px;
  margin-bottom: 0;
}

.resp-actions [data-role="button"] {
  width: 100%;
  font-size: 0.8rem;
  padding: 8px 6px;
  white-space: normal;
  line-height: 1.2;
  text-transform: none;
  letter-spacing: 0;
}

@media (max-width: 520px) {
  .resp-actions {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.resp-filter label {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-weight: 600;
  font-size: 0.85rem;
}

.resp-filter input[type="checkbox"] {
  width: 1rem;
  height: 1rem;
}

.resp-filter-row {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.ui-grid-b {
  display: grid;
  grid-template-columns: minmax(0, 1.4fr) repeat(2, minmax(0, 0.8fr));
  gap: 10px;
  align-items: center;
  margin: 8px 0 14px;
}

.ui-grid-b [data-role="button"] {
  width: 100%;
}

.ui-grid-solo {
  margin: 6px 0 2px;
}

.ui-block-a,
.ui-block-b,
.ui-block-c {
  min-width: 0;
}

.player-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.player-row {
  display: grid;
  grid-template-columns: 2.2rem minmax(0, 1fr) 3.9rem 3.2rem;
  align-items: center;
  gap: 10px;
  font-size: 1rem;
  width: 100%;
  padding: 6px 8px;
  border-radius: 8px;
}

.player-row:not(.player-row--header):nth-child(odd) {
  background: var(--table-row-odd);
}

.player-row:not(.player-row--header):nth-child(even) {
  background: var(--table-row-even);
}

.player-row--header {
  font-size: 1rem;
  background: transparent;
}

.player-check {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.player-check input[type="checkbox"] {
  width: 1.4rem;
  height: 1.4rem;
}

.player-name {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.goal-players-hint {
  color: var(--text-muted);
  font-style: italic;
}

.player-not-accredited {
  display: block;
  color: var(--status-warning-text);
  font-size: 0.8rem;
}

.player-number select {
  width: 100%;
}

.player-number {
  padding-right: 2px;
}

.player-role select {
  width: 100%;
  padding-left: 4px;
  padding-right: 4px;
}

.action-row {
  display: grid;
  gap: 10px;
  margin: 10px 0;
}

.action-row--half {
  grid-template-columns: repeat(2, minmax(0, 1fr));
}

/* 8.5rem, not less: the longest single-word button label has to fit on one
   line, and translations run longer than the English ones (the Finnish
   "Pisteenpitäjä(t)" needs 134px). A narrower minimum clips labels that have
   no space to wrap at. */
.action-row--even {
  grid-template-columns: repeat(auto-fit, minmax(8.5rem, 1fr));
}

.action-row--stacked {
  grid-template-columns: minmax(0, 1fr);
}

.action-row--spaced {
  gap: 18px;
}

.action-row [data-role="button"] {
  width: 100%;
}

.action-row input[type="submit"] {
  width: 100%;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  box-shadow: 0 6px 18px var(--card-shadow-color);
  margin: 0 0 14px;
}

.spiritkeeper-team-card {
  background: var(--accent-surface);
  border-color: var(--accent-border);
}

.mobile-header-subtitle {
  margin-top: 4px;
  color: var(--text-muted);
}

.mobile-meta,
.mobile-status {
  color: var(--text-muted);
}

.mobile-summary {
  margin: 8px 0;
}

.mobile-total {
  font-size: 1.05rem;
  font-weight: 700;
}

.mobile-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 14px;
}

.mobile-actions [data-role="button"],
.mobile-actions button,
.mobile-actions input[type="submit"],
.mobile-actions input[type="button"],
.mobile-actions input[type="reset"] {
  width: 100%;
  margin: 0;
}

.button-secondary[data-role="button"],
a.button-secondary,
button.button-secondary,
input.button-secondary[type="submit"],
input.button-secondary[type="button"],
input.button-secondary[type="reset"] {
  background: var(--button-secondary-bg);
  border-color: var(--border);
  color: var(--text);
}

.button-secondary[data-role="button"]:hover,
a.button-secondary:hover,
button.button-secondary:hover,
input.button-secondary[type="submit"]:hover,
input.button-secondary[type="button"]:hover,
input.button-secondary[type="reset"]:hover {
  background: var(--button-secondary-hover-bg);
}

.mobile-notice {
  padding: 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  margin: 0 0 14px;
}

.mobile-notice p:last-child {
  margin-bottom: 0;
}

.mobile-notice--error {
  background: var(--status-error-bg);
  border-color: var(--status-error-border);
  color: var(--status-error-text);
}

.mobile-notice--success {
  background: var(--status-success-bg);
  border-color: var(--status-success-border);
  color: var(--status-success-text);
}

.mobile-notice--info {
  background: var(--status-info-bg);
  border-color: var(--status-info-border);
  color: var(--status-info-text);
}

.warning {
  color: var(--status-warning-text);
  background: var(--status-warning-bg);
  border: 1px solid var(--status-warning-border);
  padding: 10px 12px;
  border-radius: 8px;
}

form {
  margin: 0;
}

fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin: 12px 0;
  background: var(--surface);
}

.form-actions {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 12px 0 4px;
}

.timeout-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin: 8px 0 14px;
}

.timeout-pair {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: none;
}

.timeout-pair .ui-block-a,
.timeout-pair .ui-block-b {
  flex: 1 1 0;
  min-width: 0;
}

.timeout-pair select {
  width: 100%;
  min-width: 0;
}

.timeout-separator {
  font-weight: 700;
  color: var(--text-muted);
}

@media (min-width: 900px) {
  [data-role="content"] {
    padding: 24px;
  }
}

/* Mobile language selection ---------------------------------------------- */

.mobile-language-flags {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
  align-items: center;
}

.mobile-language-flags img {
  border: 1px solid var(--border);
  border-radius: 4px;
  display: block;
  width: 48px;
  height: 30px;
  object-fit: cover;
}

/* Timekeeper -------------------------------------------------------------- */

.tk-hidden {
  display: none;
}

.tk-config-group {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin: 0 0 14px;
  padding: 8px 12px 12px;
}

.tk-config-group legend {
  font-weight: 700;
  padding: 0 6px;
}

.tk-config-row {
  display: flex;
  align-items: center;
  gap: 10px;
}

.tk-config-row label {
  flex: 1;
  margin: 8px 0;
}

.tk-config-row input {
  width: 5rem;
  flex: 0 0 auto;
  text-align: right;
}

.tk-config-row select {
  width: 10rem;
  flex: 0 0 auto;
}

.tk-unit {
  flex: 0 0 auto;
  color: var(--text-muted);
  font-weight: 600;
}

.tk-display,
.tk-matchclock-body {
  display: flex;
  gap: 14px;
  align-items: flex-start;
}

.tk-display-main,
.tk-matchclock-main {
  flex: 1 1 auto;
  min-width: 0;
  text-align: center;
}

/* Light-grey side information inside a clock area (limits, marks). */
.tk-side {
  flex: 0 0 38%;
  max-width: 42%;
  text-align: left;
  color: var(--text-faint);
  font-size: 0.85rem;
  line-height: 1.5;
}

.tk-side:empty {
  display: none;
}

.tk-side-row {
  display: flex;
  justify-content: space-between;
  gap: 8px;
}

.tk-side-row--done {
  opacity: 0.55;
  text-decoration: line-through;
}

.tk-side-time {
  font-variant-numeric: tabular-nums;
}

.tk-display-scenario {
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  min-height: 1.2em;
}

.tk-display-time {
  font-size: 3.6rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.1;
  margin: 6px 0;
}

.tk-display-signal {
  font-size: 1.3rem;
  font-weight: 700;
  min-height: 1.4em;
  margin-bottom: 8px;
}

.tk-display-actions {
  display: flex;
  justify-content: center;
  gap: 10px;
}

.tk-state-ready .tk-display-time {
  color: var(--text-muted);
}

.tk-state-warn {
  background: var(--timer-warning-bg);
}

.tk-state-warn .tk-display-signal {
  color: var(--timer-warning-text);
}

.tk-state-zero {
  background: var(--timer-critical-bg);
}

.tk-state-zero .tk-display-time,
.tk-state-zero .tk-display-signal {
  color: var(--timer-critical-text);
}

.tk-actions {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
}

.tk-actions .tk-action {
  margin: 0;
  width: 100%;
}

.tk-matchclock {
  font-size: 2.4rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  text-align: center;
  margin: 4px 0 10px;
}

.tk-cap-alert {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  margin: 0 0 10px;
}

.tk-cap-alert.tk-hidden {
  display: none;
}

.tk-cap-half {
  background: var(--timer-warning-bg);
}

.tk-cap-half .tk-cap-alert {
  color: var(--timer-warning-text);
}

.tk-cap-time {
  background: var(--timer-critical-bg);
}

.tk-cap-time .tk-cap-alert,
.tk-cap-time .tk-matchclock {
  color: var(--timer-critical-text);
}

.tk-clock-start-warning {
  background: var(--timer-critical-bg);
}

.tk-clock-start-warning .tk-matchclock {
  color: var(--timer-critical-text);
}

.tk-matchclock-actions {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
}

@media (max-width: 480px) {
  .tk-display,
  .tk-matchclock-body {
    flex-direction: column;
    align-items: stretch;
  }

  .tk-side {
    flex-basis: auto;
    max-width: none;
  }

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