/* =========================================================
   DESKTOP
   ========================================================= */

@media (min-width: 901px) {
  :root {
    --card-width: clamp(45px, 5vw, 110px);
  }

  body {
    background: #075437;
    overflow-y: auto;
    overflow-x: auto;
  }

  .app {
    height: 100vh;
    min-height: 100vh;
    grid-template-rows: 54px minmax(0, 1fr);
    padding: 8px;
    gap: 8px;
  }

  .topbar {
    min-height: 0;
    padding: 6px 12px;
    border-radius: 8px;
  }

  .topbar h1 {
    font-size: 18px;
  }

  .help-link {
    font-size: 13px;
    padding: 4px 8px;
  }

  /* Layout */

  .table-layout {
    position: relative;
    height: calc(100vh - 72px);
    min-height: 0;
    display: grid;
    grid-template-columns: 185px minmax(760px, 1fr) 185px;
    min-width: 1140px;
    grid-template-rows: minmax(0, 1fr);
    grid-template-areas: "infoCurrent table infoTotal";
    column-gap: 10px;
  }

  .info-current {
    grid-area: infoCurrent;
  }

  .info-total {
    grid-area: infoTotal;
  }

  .info-current,
  .info-total {
    align-self: start;
    max-height: 46vh;
  }

  .info-box {
    height: auto;
    min-height: 0;
    padding: 8px;
    border-radius: 10px;
    background: rgba(0, 0, 0, 0.32);
    font-size: 13px;
    overflow-y: auto;
    overflow-x: auto;
  }

  .info-box h2 {
    margin: 0 0 8px 0;
    font-size: 16px;
  }

  #status,
  #score {
    background: rgba(255, 255, 255, 0.16);
    padding: 5px;
    border-radius: 10px;
    font-size: 11px;
  }

  /* Tisch */

  .center-table {
    grid-area: table;
    position: relative;
    container-type: size;
    height: calc(100vh - 170px);
    min-height: 480px;
    margin: 0 0 92px 0;
    overflow: visible;
    padding: 0;
    
    border-radius: 18px;
    border: 6px solid #5b3217;
    
    box-shadow:
      inset 0 0 30px rgba(0, 0, 0, 0.45),
      0 0 10px rgba(0, 0, 0, 0.55);
  }

  .center-table > h2 {
    display: none;
  }

  #table-area {
    position: absolute;
    inset: 0;
  }

  #table {
    position: absolute;
    inset: 10px;
    display: block;
  }

  .table-card-player-0,
  .table-card-player-1,
  .table-card-player-2,
  .table-card-player-3 {
    position: absolute;
    transform: translate(-50%, -50%);
  }

  .table-card-player-0 {
    left: 50%;
    top: 58%;
  }

  .table-card-player-1 {
    left: 43%;
    top: 50%;
  }

  .table-card-player-2 {
    left: 50%;
    top: 42%;
  }

  .table-card-player-3 {
    left: 57%;
    top: 50%;
  }

  /* Spieler */
  .player {
      position: absolute;

      display: flex;
      flex-direction: column;

      overflow: visible;

      padding: 8px;
      box-sizing: border-box;
  }
  
  /* aktiver Spieler */
  .player.active {
    box-sizing: border-box;
    background: rgba(130,140,140,.35);
    border: none;
    outline: 2px solid #ffd400;
    outline-offset: -2px;
    border-radius: 12px;
    box-shadow: 0 0 10px rgba(255,215,0,.35);
  }

  .player.active::before {
    display: none;
  }

  .player-top,
  .player-bottom {
      width: 33.333333%;
      height: 28%;
  }

  .player-left,
  .player-right {
      width: 28cqh;
      height: 33.333333cqw;
  }

  .player-top {
      left: 50%;
      top: 2%;
      transform: translateX(-50%);
  }

  .player-bottom {
      left: 50%;
      bottom: 2%;
      transform: translateX(-50%);
  }

  .player-left {
      left: 2%;
      top: 50%;
      transform: translateY(-50%);
  }

  .player-right {
      right: 2%;
      top: 50%;
      transform: translateY(-50%);
  }

  .player h2 {
    position: absolute;
    margin: 0;
    color: #fff000;
    font-size: clamp(10px, 1.8vw, 18px);
    font-weight: bolder;
    line-height: 1;
    text-shadow: 0 2px 3px rgba(0,0,0,.35);
    white-space: nowrap;
    z-index: 30;
    pointer-events: none;
  }

  .player-top h2 {
    left: 50%;
    top: 6px;
    transform: translateX(-50%);
  }

    .player-bottom h2 {
    left: 50%;
    bottom: 6px;
    top: auto;
    transform: translateX(-50%);
    }

  .player-left h2 {
    left: 5px;
    top: 50%;
    transform: translateY(-50%);
    writing-mode: vertical-rl;
    text-orientation: mixed;
    transform-origin: center;
  }

  .player-right h2 {
    right: 5px;
    top: 50%;
    transform: translateY(-50%) rotate(180deg);
    writing-mode: vertical-lr;
    text-orientation: mixed;
    transform-origin: center;
  }

  .player .player-info {
    display: block;
  }

  /* KI-Hinweise */
  .ai-suggestion {
    position: absolute;
    text-align: center;
    color: #d8ffd8;
    text-shadow: none;
    font-size: 12px;
    font-weight: normal;
    line-height: 1.3;
    width: max-content;
    max-width: min(320px, 42vw);
    margin: 0;
    padding: 0;
    min-height: 0;
    z-index: 1000;
  }

  .ai-suggestion-toggle {
    min-width: 120px;
    max-width: 220px;
  }

  .ai-suggestion-details {
    position: absolute;
    width: min(320px, 38vw);
    max-height: 240px;
    overflow-y: auto;
    font-size: 12px;
    line-height: 1.4;
  }

  .player-bottom .ai-suggestion {
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
  }

  .player-bottom .ai-suggestion-details {
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
  }

  .player-top .ai-suggestion {
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
  }

  .player-top .ai-suggestion-details {
    top: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
  }

  .player-left .ai-suggestion {
    top: 50%;
    left: calc(100% + 8px);
    transform: translateY(-50%);
  }

  .player-left .ai-suggestion-details {
    top: 50%;
    left: calc(100% + 8px);
    transform: translateY(-50%);
  }

  .player-right .ai-suggestion {
    top: 50%;
    right: calc(100% + 8px);
    transform: translateY(-50%);
  }

  .player-right .ai-suggestion-details {
    top: 50%;
    right: calc(100% + 8px);
    transform: translateY(-50%);
  }

  /* Karten */

  .player-hand {
    position: absolute;
    display: block;
    overflow: visible;
    margin: 0;
    gap: 0;
    z-index: 20;
  }

  .player-top .player-hand,
  .player-bottom .player-hand {
    width: 100%;
    height: 100%;

    left: 0;
    top: 0;
    transform: none;
  }

  .player-bottom .player-hand {
      bottom: auto;
  }

  .player-left .player-hand,
  .player-right .player-hand {
      width: 100%;
      height: 100%;

      left: 0;
      top: 0;
      transform: none;
  }

  .player-left .player-hand {
      right: auto;
  }

  .player-right .player-hand {
      left: 0;
      right: 0;
  }

  .karte,
  .played-card {
    width: var(--card-width);
    aspect-ratio: 2 / 3;
    border: none;
    padding: 0;
    background: transparent;
    box-shadow: none;
    border-radius: 0;
    overflow: hidden;
  }

  /* Handkarten folgen der verfuegbaren Tischhoehe. Der Faecher wird in
     app.js bereits anhand des Spielercontainers berechnet. */
  .player .karte {
    width: clamp(40px, 10cqh, 90px);
  }

  /* Ausgespielte Karten bleiben auch bei niedrigen Desktopfenstern
     getrennt und ueberdecken sich in der Tischmitte nicht. */
  .played-card {
    width: clamp(36px, 9cqh, 72px);
  }

  .karte {
    cursor: pointer;
    transition: transform 0.15s ease;
  }

  .karte:disabled {
    opacity: 0.35;
    cursor: not-allowed;
    transform: none;
  }

  .player-top .karte,
  .player-bottom .karte {
      position: absolute;
      left: 50%;
      top: 50%;
      margin-left: 0;
      transform-origin: 50% 50%;
  }

  .player-bottom .karte {
      bottom: auto;
      transition: transform .15s ease;
  }


  .player-bottom .karte:hover {
      filter: brightness(1.08);
      position: absolute;
      z-index: 1;
      box-shadow:
          0 10px 18px rgba(0,0,0,.35);

      z-index: 10000;
  }

  .player-bottom .karte:first-child,
  .player-top .karte:first-child {
    margin-left: 0;
  }

  .player-left .karte {
    position: absolute;
    left: 50%;
    top: 50%;
    margin: 0;
    transform-origin: 50% 50%;
  }

  .player-right .karte {
    position: absolute;
    right: auto;
    left: 50%;
    top: 50%;
    margin: 0;
    transform-origin: 50% 50%;
  }

  .ausgewaehlt {
    border-color: #ffd700;
    box-shadow:
      0 0 12px rgba(255, 215, 0, 0.9),
      0 4px 8px rgba(0, 0, 0, 0.35);
  }

  .trumpfwahl-spieler {
    display: none;
  }

  /* Button und Meldungen */

  #play-button {
    position: absolute;
    left: 50%;
    bottom: -60px;
    transform: translateX(-50%);
    min-width: 220px;
    padding: 12px 22px;
    border: none;
    font-size: 15px;
    font-weight: bold;
    cursor: pointer;
    border-radius: 5px;
    background: #2f9d35;
    color: white;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.35);
    z-index: 60;
  }

  #table-message {
    position: absolute;
    left: 50%;
    top: 50%;
    bottom: auto;
    transform: translate(-50%, -50%);
    z-index: 500;
    padding: 12px;
    max-width: 72%;
    min-height: 140px;
    font-size: 9px;
    background: rgba(3, 25, 18, 0.96);
    color: white;
    border: 1px solid rgba(180, 255, 195, 0.62);
    border-radius: 16px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.48);
    text-align: center;
    display: none;
    line-height: 1.15;
    flex-direction: column;
    align-items: center;
  }

  #table-message:empty {
    display: none !important;
  }

  .table-message-text {
    margin-bottom: 10px;
    font-size: 11px;
    line-height: 1.4;
  }

  #table-message.matchende-message {
    box-sizing: border-box;
    width: min(520px, 72%);
    max-width: 520px;
    min-height: 0;
    padding: 34px 28px;
    border: 3px solid #ffd700;
    background: linear-gradient(160deg, #073f2c, #021b13);
    box-shadow: 0 0 0 6px rgba(255, 215, 0, 0.14),
      0 22px 55px rgba(0, 0, 0, 0.68);
  }

  #table-message.matchende-message .table-message-text {
    margin-bottom: 16px;
    color: #fff6a8;
    font-size: clamp(25px, 3vw, 38px);
    font-weight: 900;
    line-height: 1.25;
    text-wrap: balance;
  }

  #table-message.matchende-message #message-ok-button {
    min-width: 130px;
    margin-top: 12px;
    padding: 10px 24px;
    font-size: 14px;
  }

  #table-message.rundenende-message.matsch-message {
    box-sizing: border-box;
    width: min(300px, 72%);
    min-height: 0;
    padding: 10px 14px;
    border-color: rgba(255, 215, 0, 0.75);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.48);
  }

  #table-message.rundenende-message.matsch-message .table-message-text {
    margin-bottom: 6px;
    line-height: 1.2;
  }

  #table-message.rundenende-message.matsch-message .matsch-hinweis {
    color: #ffd700;
    font-size: 13px;
  }

  #table-message.rundenende-message.matsch-message .matsch-detail {
    color: #d8ffd8;
    font-size: 10px;
  }

  #table-message.rundenende-message.matsch-message #message-ok-button {
    margin-top: 8px;
  }

  #message-ok-button {
    margin-top: 12px;
    padding: 6px 14px;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 10px;
    font-weight: bold;
    background: #ffd700;
    color: black;
    transition: 0.2s;
  }

  #message-ok-button:hover {
    background: #ffec80;
  }
}
