/* Jeu de mains: mobile first (a 360px phone is the base); desktop and TV
   are added with min-width queries, short landscape phones with a
   max-height one. Page frame, Game Dashboard and buttons here; the match,
   pause and end screens in play.css. */
[hidden] {
  display: none !important;
}

body.game-body {
  display: flex;
  flex-direction: column;
  height: 100dvh;
  overscroll-behavior: none;
}

.game-nav {
  flex: 0 0 auto;
}

.back-button span {
  font-size: 1.1rem;
  line-height: 1;
}

/* Android bars can cover the bottom even when the safe-area inset is 0. */
.om-shell {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: 12px max(24px, env(safe-area-inset-right, 0px))
    max(40px, calc(env(safe-area-inset-bottom, 0px) + 24px))
    max(24px, env(safe-area-inset-left, 0px));
  font-size: max(1rem, 2.4dvh);
  color: #333;
}

.om-screen {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.om-dashboard,
.om-dashboard-head,
.om-dashboard-options {
  display: flex;
  flex-direction: column;
  gap: 0.8em;
}

.om-dashboard {
  width: min(100%, 26em);
}

.om-title {
  margin: 0;
  text-align: center;
  font-size: 1.6em;
  font-weight: 900;
}

.om-field {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.4em;
}

.om-label {
  margin: 0;
  font-size: 0.8em;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: #555;
}

.om-stepper {
  display: flex;
  align-items: center;
  gap: 0.5em;
}

.om-step {
  width: 2.4em;
  height: 2.4em;
  border: 2px solid #e0e0e0;
  border-radius: 50%;
  background: #fff;
  color: #007bff;
  font: inherit;
  font-size: 1.2em;
  font-weight: 900;
  cursor: pointer;
  touch-action: manipulation;
}

.om-timer-input {
  width: 3.5em;
  padding: 0.2em;
  border: 2px solid #e0e0e0;
  border-radius: 0.5em;
  background: #f8f9fa;
  color: #007bff;
  font: inherit;
  font-size: 1.6em;
  font-weight: 900;
  text-align: center;
}

.om-decks {
  display: flex;
  flex-wrap: wrap;
  justify-content: center;
  gap: 0.5em;
  width: 100%;
}

.om-deck {
  flex: 1 1 0;
  min-width: 5.5em;
  min-height: max(44px, 2.8em);
  padding: 0.3em 0.5em;
  border: 3px solid transparent;
  border-radius: 0.8em;
  color: #fff;
  font: inherit;
  font-weight: 800;
  text-transform: uppercase;
  text-shadow: 1px 1px 2px rgba(0, 0, 0, 0.25);
  opacity: 0.6;
  cursor: pointer;
  touch-action: manipulation;
}

.om-deck[aria-pressed="true"] {
  border-color: #333;
  opacity: 1;
  box-shadow: 0 0.3em 0.8em rgba(0, 0, 0, 0.2);
}

.om-button {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.15em;
  width: 100%;
  min-height: max(44px, 6dvh);
  padding: 0.45em 1em;
  border: none;
  border-radius: 0.8em;
  color: #fff;
  font: inherit;
  font-size: 1.15em;
  font-weight: 800;
  cursor: pointer;
  touch-action: manipulation;
}

.om-button:active {
  transform: scale(0.97);
}

.om-button:disabled {
  opacity: 0.5;
  cursor: default;
}

.om-start {
  background: #28a745;
}

.om-resume {
  background: #333;
}

.om-soft {
  background: #6c757d;
}

.resume-title {
  text-transform: uppercase;
}

.resume-info {
  font-size: 0.7em;
  font-weight: 600;
  opacity: 0.85;
}

.om-error {
  margin: 0;
  color: #b00020;
  font-weight: 700;
  text-align: center;
}

:focus-visible,
html.tv :focus {
  outline: max(3px, 0.4dvh) solid #ffcc00;
  outline-offset: max(2px, 0.3dvh);
}

html.tv :focus {
  box-shadow: 0 0 0 max(6px, 0.8dvh) rgba(0, 0, 0, 0.55);
}

/* Landscape phones are ~360px tall: the dashboard goes in two columns. */
@media (orientation: landscape) and (max-height: 500px) {
  .game-nav {
    height: 48px;
  }

  .om-shell {
    padding-top: 4px;
  }

  .om-dashboard:not(.om-end) {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    align-items: center;
    gap: 0.5em 1.2em;
    width: min(100%, 40em);
  }

  .om-dashboard-head {
    grid-column: 1;
    grid-row: 1;
  }

  .om-dashboard > .om-start {
    grid-column: 1;
    grid-row: 2;
  }

  .om-dashboard-options {
    grid-column: 2;
    grid-row: 1 / span 2;
    gap: 0.5em;
  }

  .om-error {
    grid-column: 1 / -1;
  }
}

/* Desktop and TV, 960x540 up to 3840x2160: sizes follow the screen and
   everything stays 3% away from the edges (TV overscan). */
@media (min-width: 960px) and (min-height: 500px) {
  .game-nav {
    height: auto;
    padding: 3dvh max(3vw, env(safe-area-inset-right, 0px)) 1dvh
      max(3vw, env(safe-area-inset-left, 0px));
  }

  .back-button,
  .options-button {
    width: max(36px, 6dvh);
    height: max(36px, 6dvh);
    font-size: max(1rem, 3dvh);
  }

  .back-button span {
    font-size: inherit;
  }

  .back-button svg,
  .options-button svg {
    width: 50%;
    height: 50%;
  }

  .nav-banner {
    max-height: max(45px, 7dvh);
  }

  .om-shell {
    padding: 2dvh max(3vw, env(safe-area-inset-right, 0px)) max(40px, 4dvh)
      max(3vw, env(safe-area-inset-left, 0px));
  }

  .om-dashboard {
    width: min(100%, 32em);
  }
}
