/* LINGO WAR landscape-first layout */
html, body { min-width: 100%; min-height: 100%; }
body { overflow-x: hidden; }

.rotate-device { display: none; }

@media (orientation: portrait) and (max-width: 900px) {
  body { overflow: hidden; }
  #app, #overlay, #toast { display: none !important; }
  .rotate-device {
    position: fixed;
    inset: 0;
    z-index: 100;
    display: grid;
    place-items: center;
    padding: 28px;
    background: var(--paper);
    color: var(--ink);
    text-align: center;
  }
  .rotate-device-inner { display: grid; justify-items: center; gap: 14px; }
  .rotate-device-icon {
    width: 78px;
    height: 48px;
    border: 4px solid var(--blue);
    border-radius: 10px;
    position: relative;
    animation: rotate-hint 1.8s ease-in-out infinite;
  }
  .rotate-device-icon::after {
    content: '';
    position: absolute;
    width: 5px;
    height: 5px;
    right: 5px;
    top: 50%;
    margin-top: -2.5px;
    border-radius: 50%;
    background: var(--blue);
  }
  .rotate-device strong { font-size: 20px; letter-spacing: -.3px; }
  .rotate-device span { color: var(--muted); font-size: 13px; }
}

@keyframes rotate-hint {
  0%, 22% { transform: rotate(90deg); }
  55%, 100% { transform: rotate(0); }
}

@media (orientation: landscape), (min-width: 901px) {
  .home {
    width: min(1180px, 100%);
    max-width: none;
    min-height: 100svh;
    padding: clamp(18px, 3vh, 32px) clamp(24px, 4vw, 54px);
    display: grid;
    grid-template-columns: minmax(210px, .85fr) minmax(220px, .85fr) minmax(340px, 1.2fr);
    grid-template-rows: auto auto auto 1fr auto auto auto auto;
    column-gap: clamp(22px, 4vw, 58px);
    align-content: center;
  }
  .home-top { grid-column: 1 / 3; grid-row: 1; }
  .home h1 { grid-column: 1; grid-row: 2; align-self: end; margin-top: 18px; font-size: clamp(56px, 8vw, 88px); }
  .home .intro { grid-column: 1; grid-row: 3; margin-top: 14px; font-size: clamp(15px, 2vw, 20px); }
  .home .hero.original-cards { grid-column: 2; grid-row: 2 / 5; align-self: center; width: 100%; height: 220px; margin: 0; }
  .original-cards > img { width: clamp(88px, 10vw, 122px); }
  .original-cards > img:nth-child(1) { transform: translateX(-68px) rotate(-15deg); }
  .original-cards > img:nth-child(3) { transform: translateX(68px) rotate(16deg); }
  .home .settings { grid-column: 3; grid-row: 1 / 5; align-self: end; margin: 0 0 14px; padding: 16px; gap: 12px; }
  .home > .resume { grid-column: 3; grid-row: 5; }
  .home > .primary { grid-column: 3; grid-row: 6; }
  .home > .multiplayer-entry { grid-column: 3; grid-row: 7; }
  .home .home-links { grid-column: 1 / 3; grid-row: 7; align-self: center; }
  .home .mode-note { grid-column: 1 / 4; grid-row: 8; margin-top: 8px; }
  .home .primary, .home .resume { margin-bottom: 9px; padding: 12px 16px; }
  .home .multiplayer-entry { padding: 11px 16px; }

  .game {
    max-width: none;
    width: 100%;
    height: 100svh;
    min-height: 0;
    display: grid;
    grid-template-columns: minmax(0, 1fr) clamp(250px, 29vw, 340px);
    grid-template-rows: auto minmax(0, 1fr) auto;
    position: relative;
    overflow: hidden;
  }
  .scores, .board, .board-footer { grid-column: 1; }
  .scores { grid-row: 1; padding: 8px 12px 6px; }
  .score { padding: 6px 8px; }
  .score.active { padding: 5px 7px; }
  .avatar { width: 24px; height: 24px; }
  .score strong { font-size: 19px; }
  .board {
    grid-row: 2;
    min-height: 0;
    padding: 0 12px 7px;
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: clamp(7px, 1.3vw, 14px);
    align-items: stretch;
  }
  .word-card { min-height: 0; display: flex; flex-direction: column; justify-content: center; padding: 7px 7px 9px; }
  .picture-row { height: clamp(58px, 15vh, 96px); flex-direction: row; justify-content: center; margin-bottom: 5px; }
  .picture-button { width: clamp(54px, 13vh, 88px); height: clamp(54px, 13vh, 88px); }
  .word-label { text-align: left; }
  .ownership { justify-content: flex-start; margin-top: 3px; }
  .slots { gap: clamp(2px, .45vw, 5px); }
  .slot { height: clamp(40px, 10vh, 54px); font-size: clamp(18px, 2.8vw, 24px); line-height: 1; }
  .board-footer { grid-row: 3; padding: 4px 10px 7px; }
  .hand-panel {
    grid-column: 2;
    grid-row: 1 / 4;
    min-width: 0;
    height: 100svh;
    margin: 0;
    padding: clamp(14px, 4vh, 28px) 14px;
    position: relative;
    bottom: auto;
    border-top: 0;
    border-left: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    justify-content: center;
  }
  .hand-title { margin: 0 0 10px; }
  .hand-panel-top { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 10px; }
  .hand-panel-top .attempts { margin-bottom: 0; flex: 1; }
  .hand-panel-controls { display: flex; align-items: center; gap: 7px; white-space: nowrap; }
  .hand-panel-controls .icon-btn { min-width: 36px; width: 36px; height: 36px; }
  .hand-panel-controls .settings-btn {
    font-size: 22px;
    line-height: 1;
    padding: 0;
    border: 2px solid var(--ink);
    outline: 1px solid var(--ink);
    outline-offset: -5px;
  }
  .turn-overlay {
    position: absolute;
    inset: 0;
    z-index: 15;
    display: grid;
    place-items: center;
    pointer-events: none;
    color: var(--player);
    background: rgba(255, 248, 232, .72);
    font-size: clamp(44px, 10vw, 86px);
    font-weight: 950;
    letter-spacing: 3px;
    animation: turn-overlay 1s ease-out forwards;
  }
  @keyframes turn-overlay {
    0%, 62% { opacity: 1; transform: scale(1); }
    100% { opacity: 0; transform: scale(1.04); visibility: hidden; }
  }
  .hand { width: 100%; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 8px; flex-shrink: 0; }
  .hand-card, .hand-gap { height: clamp(62px, 17vh, 98px); }
  .hand-card { font-size: clamp(30px, 7vh, 46px); }
  .hand-card.special .main { font-size: clamp(10px, 2.5vh, 16px); }
  .hand-card.change .main { font-size: clamp(28px, 6vh, 42px); }
  .actions { width: 100%; margin: 12px 0 0; flex-direction: column; gap: 7px; flex-shrink: 0; }
  .actions button { min-height: 38px; padding: 8px 6px; }
  #toast { bottom: 22px; }

  .modal { max-width: min(860px, 92vw); max-height: 90svh; padding: 20px 24px; }
  .modal:has(.tutorial) { max-width: min(850px, 94vw); }
  .tutorial {
    display: grid;
    grid-template-columns: 180px minmax(0, 1fr);
    grid-template-rows: auto auto 1fr auto;
    column-gap: 22px;
    align-items: center;
  }
  .tutorial-top { grid-column: 1 / 3; }
  .tutorial .parrot { grid-column: 1; grid-row: 2 / 4; margin: 0 auto; width: 130px; height: 130px; }
  .tutorial .speech-bubble { grid-column: 2; grid-row: 2; }
  .tutorial-example, .tutorial-specials, .tutorial > .tutorial-note:not(:last-child) { grid-column: 2; }
  .tutorial > .text-btn { grid-column: 1; grid-row: 4; }
  .tutorial-nav { grid-column: 2; grid-row: 4; }
  .tutorial > .tutorial-note:last-child { grid-column: 1 / 3; }
  .gallery { grid-template-columns: repeat(6, 1fr); }
  .detail-image { width: 150px; height: 150px; }
}

@media (orientation: landscape) and (max-height: 430px) {
  .home { height: 100svh; min-height: 0; overflow: hidden; padding: 10px 16px; grid-template-columns: 160px 170px minmax(410px, 430px); column-gap: 14px; }
  .home h1 { font-size: 54px; margin-top: 8px; }
  .home .intro { font-size: 14px; margin-top: 8px; }
  .home .hero.original-cards { height: 150px; }
  .home .settings { grid-template-columns: 1.1fr 1fr .9fr; padding: 11px 14px; gap: 9px 12px; margin-bottom: 7px; }
  .home .settings .colors { grid-column: 1 / 3; gap: 7px; }
  .home .settings .language-setting { grid-column: 3; }
  .settings label { margin-bottom: 4px; }
  .settings select, .settings input { padding: 6px; min-height: 32px; }
  .color-pick { width: 29px; height: 29px; }
  .home .primary, .home .resume, .home .multiplayer-entry { min-height: 0; padding-block: 8px; margin-bottom: 5px; }
  .home-links .text-btn { padding: 6px; }
  .mode-note { display: none; }
  .picture-row { height: 44px; }
  .picture-button { width: 42px; height: 42px; }
  .slot { height: 30px; }
}

@media (prefers-reduced-motion: reduce) {
  .rotate-device-icon { animation: none; transform: rotate(0); }
}
