/* =========================================================
   HOUSE RULES · v0.6
   Core UI
   ========================================================= */


/* =========================
   RESET / GLOBAL
========================= */

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html,
body {
  width: 100%;
  min-height: 100%;
}

html {
  background: #0d0d0d;
}

body {
  min-height: 100dvh;

  background: #0d0d0d;
  color: #f5f5f5;

  font-family: Arial, Helvetica, sans-serif;

  display: flex;
  justify-content: center;

  overflow-x: hidden;
}

button,
input {
  font: inherit;
}

button {
  -webkit-tap-highlight-color: transparent;
}

.app {
  width: 100%;
  max-width: 430px;

  min-height: 100dvh;

  padding:
    max(24px, env(safe-area-inset-top))
    28px
    max(20px, env(safe-area-inset-bottom));
}

.screen {
  width: 100%;
}

.hidden {
  display: none !important;
}


/* =========================================================
   SHARED CONTROLS
========================================================= */

label {
  display: block;

  margin-bottom: 12px;

  color: #aaa;

  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.7px;
}

input {
  width: 100%;
  height: 58px;

  padding: 0 18px;

  border: 1px solid #444;
  border-radius: 12px;

  outline: none;

  background: #151515;
  color: #fff;

  font-size: 17px;
}

input:focus {
  border-color: #888;
  background: #181818;
}

input::placeholder {
  color: #666;
}

button {
  width: 100%;
  min-height: 58px;

  border-radius: 999px;

  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;

  cursor: pointer;
}

button:disabled {
  opacity: 0.4;
  cursor: default;
}

button:active:not(:disabled) {
  transform: scale(0.985);
}

.primary {
  border: 1px solid #fff;

  background: #fff;
  color: #0d0d0d;
}

.secondary {
  border: 1px solid #555;

  background: transparent;
  color: #fff;
}

.message {
  min-height: 20px;

  margin-top: 16px;

  color: #999;

  text-align: center;

  font-size: 13px;
  line-height: 1.4;
}

.message.error {
  color: #ddd;
}


/* =========================================================
   HOME
========================================================= */

#homeScreen {
  min-height: calc(
    100dvh -
    max(24px, env(safe-area-inset-top)) -
    max(20px, env(safe-area-inset-bottom))
  );

  display: flex;
  flex-direction: column;
}

.brand {
  padding-top: clamp(34px, 6dvh, 70px);
}

.brand h1 {
  font-size: clamp(58px, 17vw, 78px);

  line-height: 0.86;
  letter-spacing: -4px;

  font-weight: 800;
}

.tagline {
  margin-top: clamp(28px, 3.5dvh, 42px);

  color: #999;

  font-size: 18px;
  line-height: 1.4;
}

.form {
  margin-top: clamp(60px, 9dvh, 105px);
}

.actions {
  display: grid;

  gap: clamp(14px, 2dvh, 22px);

  margin-top: clamp(24px, 3dvh, 34px);
}


/* =========================
   HOME STATUS
========================= */

.status {
  margin-top: clamp(58px, 8dvh, 96px);

  display: flex;
  align-items: center;
  justify-content: center;

  gap: 9px;

  color: #aaa;

  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.4px;
}

.status-dot {
  width: 7px;
  height: 7px;

  flex-shrink: 0;

  border-radius: 50%;

  background: #fff;

  box-shadow:
    0 0 12px rgba(255, 255, 255, 0.4);
}

.version {
  margin-top: 13px;

  text-align: center;

  color: #444;

  font-size: 11px;
  letter-spacing: 1px;
}


/* =========================================================
   LOBBY
========================================================= */

#lobbyScreen {
  min-height: calc(
    100dvh -
    max(24px, env(safe-area-inset-top)) -
    max(20px, env(safe-area-inset-bottom))
  );

  display: flex;
  flex-direction: column;
}

.lobby-top {
  padding-top: clamp(28px, 5dvh, 58px);
}

.eyebrow {
  color: #777;

  font-size: 12px;
  font-weight: 700;
  letter-spacing: 2px;
}

.lobby-title {
  margin-top: 14px;

  font-size: 46px;
  line-height: 0.95;
  letter-spacing: -2px;
}

.waiting {
  margin-top: 16px;

  color: #999;

  font-size: 16px;
}


/* =========================
   HOUSE CODE
========================= */

.code-card {
  margin-top: clamp(42px, 6dvh, 70px);

  padding: clamp(28px, 4dvh, 38px) 24px;

  border: 1px solid #444;
  border-radius: 18px;

  text-align: center;

  background: #121212;
}

.code-label {
  color: #777;

  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
}

.house-code {
  margin-top: 12px;

  font-size: 52px;
  font-weight: 800;
  letter-spacing: 8px;
}

.code-help {
  margin-top: 10px;

  color: #777;

  font-size: 12px;
}


/* =========================
   PLAYERS
========================= */

.players {
  margin-top: clamp(38px, 5dvh, 60px);
}

.section-heading {
  color: #777;

  font-size: 11px;
  font-weight: 700;
  letter-spacing: 2px;
}

.player-card {
  min-height: 68px;

  margin-top: 15px;

  padding: 0 18px;

  border: 1px solid #333;
  border-radius: 14px;

  display: flex;
  align-items: center;
  justify-content: space-between;

  gap: 12px;

  background: #121212;
}

.player-name {
  min-width: 0;

  font-size: 17px;
  font-weight: 700;

  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.player-badges {
  display: flex;
  align-items: center;
  justify-content: flex-end;

  gap: 7px;

  flex-shrink: 0;
}

.host-badge,
.ready-badge {
  padding: 7px 10px;

  border: 1px solid #555;
  border-radius: 999px;

  color: #aaa;

  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.1px;

  white-space: nowrap;
}

.ready-badge.ready {
  border-color: #888;
  color: #fff;
}


/* =========================
   LOBBY CONTROLS
========================= */

.lobby-bottom {
  margin-top: clamp(46px, 7dvh, 84px);
  padding-bottom: 8px;

  display: grid;

  gap: 14px;
}

.leave {
  color: #777;
  border-color: #333;
}

.lobby-message {
  min-height: 18px;

  color: #999;

  text-align: center;

  font-size: 12px;
  line-height: 1.4;
}


/* =========================================================
   GAME LIBRARY
========================================================= */

#gameScreen {
  min-height: calc(
    100dvh -
    max(24px, env(safe-area-inset-top)) -
    max(20px, env(safe-area-inset-bottom))
  );

  display: flex;
  flex-direction: column;
}

.library-screen {
  padding-top: clamp(28px, 5dvh, 58px);
}


/* =========================
   LIBRARY HEADER
========================= */

.library-header {
  flex-shrink: 0;
}

.library-title {
  margin-top: 14px;

  font-size: clamp(48px, 14vw, 62px);

  line-height: 0.9;
  letter-spacing: -3px;

  font-weight: 800;
}

.library-copy {
  margin-top: 18px;

  color: #999;

  font-size: 16px;
  line-height: 1.4;
}


/* =========================
   GAME CARDS
========================= */

.game-library {
  margin-top: clamp(38px, 5dvh, 56px);

  display: grid;

  gap: 12px;
}

.game-card {
  width: 100%;
  min-height: 92px;

  padding: 18px;

  border: 1px solid #333;
  border-radius: 18px;

  background: #121212;
  color: #fff;

  display: grid;

  grid-template-columns:
    34px
    minmax(0, 1fr)
    22px;

  align-items: center;

  gap: 14px;

  text-align: left;

  transition:
    border-color 120ms ease,
    background 120ms ease,
    transform 120ms ease;
}

.game-card:active:not(:disabled) {
  transform: scale(0.985);
}

.game-card-number {
  align-self: start;

  padding-top: 3px;

  color: #555;

  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.2px;
}

.game-card-content {
  min-width: 0;

  display: flex;
  flex-direction: column;

  gap: 7px;
}

.game-card-name {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.4px;
}

.game-card-tagline {
  color: #777;

  font-size: 13px;
  font-weight: 400;
  line-height: 1.35;

  letter-spacing: 0;
}

.game-card-arrow {
  color: #555;

  font-size: 20px;
  font-weight: 400;

  text-align: right;
}


/* -------------------------
   SELECTED GAME

   app.js will add this class.
------------------------- */

.game-card.selected {
  border-color: #aaa;

  background: #181818;
}

.game-card.selected
.game-card-number {
  color: #aaa;
}

.game-card.selected
.game-card-tagline {
  color: #aaa;
}

.game-card.selected
.game-card-arrow {
  color: #fff;
}


/* -------------------------
   NON-HOST VIEW

   Guests can see the Host's
   selection but cannot choose.
------------------------- */

.game-library.guest-view
.game-card {
  cursor: default;
}

.game-library.guest-view
.game-card:not(.selected) {
  opacity: 0.55;
}


/* =========================
   LIBRARY CONTROLS
========================= */

.library-bottom {
  margin-top: clamp(38px, 6dvh, 64px);

  padding-bottom: 8px;

  display: grid;

  gap: 14px;
}

.library-message {
  min-height: 18px;

  color: #777;

  text-align: center;

  font-size: 12px;
  line-height: 1.4;
}

#launchGame {
  margin-top: 2px;
}

.game-leave {
  color: #777;
  border-color: #333;
}


/* =========================================================
   GAME MOUNT

   Individual games render inside this area.
========================================================= */

#gameMountScreen {
  min-height: calc(
    100dvh -
    max(24px, env(safe-area-inset-top)) -
    max(20px, env(safe-area-inset-bottom))
  );
}

.game-mount-screen {
  width: 100%;
}

.game-mount {
  width: 100%;
  min-height: inherit;
}


/* =========================================================
   SHORT PHONES
========================================================= */

@media (max-height: 740px) {

  .app {
    padding-top:
      max(18px, env(safe-area-inset-top));

    padding-bottom:
      max(14px, env(safe-area-inset-bottom));
  }


  /* Home */

  .brand {
    padding-top: 16px;
  }

  .brand h1 {
    font-size: clamp(
      52px,
      15vw,
      66px
    );
  }

  .tagline {
    margin-top: 20px;
  }

  .form {
    margin-top: 34px;
  }

  input,
  button {
    min-height: 54px;
  }

  input {
    height: 54px;
  }

  .actions {
    margin-top: 18px;
    gap: 10px;
  }

  .message {
    margin-top: 10px;
  }

  .status {
    margin-top: 34px;
  }

  .version {
    margin-top: 9px;
  }


  /* Lobby */

  .lobby-top {
    padding-top: 18px;
  }

  .code-card {
    margin-top: 30px;

    padding: 24px 20px;
  }

  .players {
    margin-top: 30px;
  }

  .lobby-bottom {
    margin-top: 34px;
  }


  /* Library */

  .library-screen {
    padding-top: 18px;
  }

  .library-title {
    font-size: 46px;
  }

  .library-copy {
    margin-top: 14px;
  }

  .game-library {
    margin-top: 30px;

    gap: 10px;
  }

  .game-card {
    min-height: 80px;

    padding: 15px 16px;
  }

  .game-card-name {
    font-size: 17px;
  }

  .library-bottom {
    margin-top: 32px;
  }
}


/* =========================================================
   TALL PHONES
========================================================= */

@media (min-height: 900px) {

  /* Home */

  .brand {
    padding-top: 64px;
  }

  .tagline {
    margin-top: 38px;
  }

  .form {
    margin-top: 90px;
  }

  .actions {
    margin-top: 30px;

    gap: 18px;
  }

  .status {
    margin-top: 82px;
  }


  /* Lobby */

  .lobby-top {
    padding-top: 54px;
  }

  .code-card {
    margin-top: 62px;
  }

  .players {
    margin-top: 52px;
  }

  .lobby-bottom {
    margin-top: 68px;
  }


  /* Library */

  .library-screen {
    padding-top: 54px;
  }

  .game-library {
    margin-top: 52px;

    gap: 14px;
  }

  .game-card {
    min-height: 96px;
  }

  .library-bottom {
    margin-top: 58px;
  }
}


/* =========================================================
   VERY NARROW PHONES
========================================================= */

@media (max-width: 350px) {

  .app {
    padding-left: 20px;
    padding-right: 20px;
  }

  .house-code {
    font-size: 46px;
    letter-spacing: 6px;
  }

  .game-card {
    grid-template-columns:
      28px
      minmax(0, 1fr)
      18px;

    gap: 10px;
  }

  .game-card-tagline {
    font-size: 12px;
  }
}