* { box-sizing: border-box; }
body { margin: 0; padding: 8px; background: #f5f7fa; color: #20364c; font-family: system-ui, sans-serif; }
#site-header { padding: 0 4px 4px; }
#site-header .site-header-logo img { height: 32px !important; }
#site-footer-el { display: none; }
.tc-header { display: flex; align-items: center; gap: 12px; margin: 4px 0 8px; }
.tc-header > div:first-child { flex: 1; min-width: 0; }
.tc-header h1 { margin: 0; text-align: left; font-size: 1.3rem; line-height: 1.2; color: #1565c0; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.tc-header p { margin: 2px 0 0; font-size: .75rem; }
.tc-status { display: flex; flex-wrap: wrap; gap: 2px 12px; }
.tc-columns-control { display: flex; align-items: center; gap: 5px; font-size: .8rem; white-space: nowrap; }
#tc-columns { width: auto; margin: 0; padding: 5px; font: inherit; }
#tc-fullscreen { margin: 0; padding: 6px 10px; font-size: .8rem; }
#tc-qr-open { display: flex; flex-direction: column; align-items: center; padding: 0; margin: 0; background: #fff; color: #20364c; border: 1px solid #c7d3df; border-radius: 4px; font: inherit; font-size: .9rem; cursor: pointer; }
#tc-qr-open > span:last-child { padding-bottom: 3px; }
#tc-qr-open img { width: 144px !important; height: 144px !important; max-width: none; }
#tc-club-standings { display: inline-block; margin-top: 5px; font-size: .85rem; font-weight: 700; color: #125ba6; }
#tc-club-error { color: #8d2222; }
#tc-qr-dialog { width: min(94vw, 640px); max-width: 94vw; padding: 20px; border: 1px solid #c7d3df; border-radius: 8px; text-align: center; }
#tc-qr-dialog::backdrop { background: #20364c99; }
#tc-qr-dialog h2 { font-size: 1.2rem; }
#tc-qr-dialog p { font-size: .85rem; }
#tc-qr-large img { width: min(100%, 55vh) !important; height: auto !important; }
#tc-qr-error { color: #8d2222; }
#tc-error, #conflict-banner { padding: 6px 10px; margin: 4px 0 8px; font-size: .85rem; background: #fff3da; border: 1px solid #ac680f; border-radius: 5px; }
#tc-error { color: #8d2222; border-color: #bd4444; background: #fff0ef; }
.tc-board { display: grid; gap: 5px; }
.tc-court { min-width: 0; padding: 3px 8px; border: 1px solid #c7d3df; border-radius: 6px; background: #fff; }
.tc-court-heading { display: flex; align-items: center; gap: 6px; line-height: 1.2; }
.tc-court-heading > strong { color: #125ba6; font-size: 1rem; white-space: nowrap; }
.tc-event { display: flex; flex: 1; min-width: 0; white-space: nowrap; font-size: .75rem; color: #53677c; }
.tc-event-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.tc-stage { flex: none; white-space: pre; }
.tc-badges { display: flex; gap: 5px; flex: none; font-size: .65rem; font-weight: 800; }
.new-label { color: #765300; }
.my-label { color: #12552f; }
.conflict-label { color: #9c3300; }
.tc-clock { font-size: .8rem; font-variant-numeric: tabular-nums; white-space: nowrap; }
.tc-match { display: grid; grid-template-columns: minmax(0, 1fr) 18px minmax(0, 1fr); align-items: center; gap: 4px; }
.tc-side { min-width: 0; }
.tc-court .player-name { display: block; min-width: 0; max-width: none; margin: 0; padding: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: .85rem; line-height: 1.1; }
.player-me { font-weight: 800; text-decoration: underline; text-decoration-thickness: 2px; }
.vs-sep { text-align: center; color: #63788d; font-size: .7rem; }
.row-new { background: #fff6bd; }
.row-new { animation: tc-new-pulse 3s ease-in-out infinite; }
@keyframes tc-new-pulse {
  0%, 100% { box-shadow: inset 0 0 0 1px rgba(183, 128, 0, .15); }
  50% { box-shadow: inset 0 0 0 3px rgba(183, 128, 0, .55); }
}
@media (prefers-reduced-motion: reduce) {
  .row-new { animation: none; }
}
.my-court { border: 3px solid #21814c; padding: 1px 6px; box-shadow: inset 0 0 0 1px #fff; }
.conflict-row { border-color: #c85b00; background: #fff0d9; }
.tc-empty { padding: 35px; text-align: center; background: #fff; border-radius: 6px; }
#tc-personal { position: relative; margin-bottom: 8px; }
#tc-personal h2, #tc-all-title { margin: 4px 0; font-size: .95rem; color: #12552f; }
#tc-all-title { color: #20364c; }
#tc-personal-content { display: grid; gap: 5px; }
#tc-personal-content > p { margin: 0; padding: 8px 10px; background: #e9f8ef; border: 1px solid #21814c; border-radius: 5px; }
#tc-personal .player-name { white-space: normal; overflow-wrap: anywhere; }
#tc-personal .tc-event { white-space: normal; flex-wrap: wrap; }
#tc-personal .tc-event-name { overflow: visible; }
#tc-personal .tc-stage { white-space: normal; }
#tc-personal .tc-court-heading { flex-wrap: wrap; }
[hidden] { display: none !important; }
:fullscreen #site-header { display: none; }
@media (min-width: 900px) and (orientation: landscape) {
  main { position: relative; padding-right: 256px; min-height: 270px; }
  .tc-header { min-height: 44px; margin-bottom: 4px; }
  #tc-qr-open { position: absolute; right: 0; top: 0; }
  #tc-qr-open img { width: 240px !important; height: 240px !important; }
  .tc-court { padding: 2px 8px; }
  .my-court { padding: 0 6px; }
  #tc-personal { margin-bottom: 4px; }
  #tc-personal-content { width: calc((100% - 5px) / 2); }
  body[data-columns="3"] #tc-personal-content { width: calc((100% - 10px) / 3); }
  .tc-board { grid-template-columns: repeat(2, minmax(0, 1fr)); grid-template-rows: repeat(var(--court-rows-2), minmax(54px, auto)); grid-auto-flow: column; }
  body[data-columns="3"] .tc-board { grid-template-columns: repeat(3, minmax(0, 1fr)); grid-template-rows: repeat(var(--court-rows-3), minmax(54px, auto)); }
}
@media (max-width: 899px), (orientation: portrait) {
  .tc-columns-control { display: none; }
}
@media (min-width: 1400px) and (min-height: 850px) {
  main { padding-right: 336px; min-height: 350px; }
  #tc-qr-open img { width: 320px !important; height: 320px !important; }
  #tc-qr-open { font-size: 1.1rem; }
  .tc-court .player-name { font-size: 1.2rem; }
  .tc-court { padding: 8px 12px; }
  .tc-court-heading > strong { font-size: 1.4rem; }
  .tc-event, .tc-clock { font-size: .95rem; }
}
@media (max-width: 550px) {
  .tc-header { flex-wrap: wrap; }
  .tc-header > div:first-child { flex-basis: calc(100% - 164px); }
  .tc-header h1 { font-size: 1.1rem; }
}
