:root {
  --bg-deep: #050a25;
  --bg-night: #080f38;
  --panel: #0d1748;
  --panel-soft: #111e57;
  --blue-top: #124bc1;
  --blue-bottom: #07318f;
  --blue-bright: #2878ff;
  --line: #557ee8;
  --line-soft: rgba(132, 165, 255, 0.34);
  --text: #f7f9ff;
  --muted: #aab8e4;
  --gold: #ffda6b;
  --green: #36d59a;
  --red: #ff526d;
  --orange: #ffac4b;
}

* {
  box-sizing: border-box;
}

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

body {
  background: var(--bg-deep);
  color: var(--text);
  font-family: Arial, Helvetica, sans-serif;
  -webkit-font-smoothing: antialiased;
}

button,
input {
  font: inherit;
}

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

.hidden {
  display: none !important;
}

.brand-label,
.panel-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 800;
  letter-spacing: 0.13em;
}

.button {
  min-height: 44px;
  border: 1px solid transparent;
  border-radius: 10px;
  padding: 10px 14px;
  color: #fff;
  font-weight: 800;
  cursor: pointer;
}

.button:disabled {
  cursor: default;
  opacity: 0.38;
}

.button-primary {
  border-color: #72a1ff;
  background: linear-gradient(180deg, #2d7bff 0%, #1454d5 100%);
  box-shadow: 0 7px 18px rgba(15, 73, 194, 0.34);
}

.button-large {
  min-height: 54px;
  padding-left: 28px;
  padding-right: 28px;
  font-size: 16px;
}

.button-small {
  min-height: 34px;
  padding: 7px 10px;
  font-size: 11px;
}

.button-quiet,
.button-undo {
  border-color: var(--line-soft);
  background: #18255c;
}

.button-correct {
  border-color: #64edbd;
  background: #168960;
}

.button-incorrect {
  border-color: #ff8798;
  background: #b52d47;
}

.button-answer {
  grid-column: 1 / 3;
  border-color: #87a8ff;
  background: #24479f;
}

.button-timer {
  width: 100%;
  border-color: #ffc778;
  background: #8e5314;
}

.button-cat {
  width: 100%;
  margin-bottom: 9px;
  border-color: #ffb4d1;
  background: #7d3761;
}

.panel {
  overflow: hidden;
  border: 1px solid var(--line-soft);
  border-radius: 14px;
  background: linear-gradient(180deg, rgba(18, 31, 88, 0.98), rgba(9, 17, 58, 0.98));
  box-shadow: 0 10px 26px rgba(0, 0, 0, 0.22);
}

.panel-heading {
  min-height: 42px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 9px 12px;
  border-bottom: 1px solid var(--line-soft);
}

.panel-heading strong {
  display: block;
  margin-top: 3px;
  font-size: 14px;
}

/* Экран телевизора */

.screen-page {
  overflow: hidden;
  background:
    radial-gradient(circle at 50% -20%, rgba(47, 99, 240, 0.28), transparent 42%),
    linear-gradient(180deg, #08113d 0%, #04081f 100%);
}

.screen-app,
.screen-layer {
  width: 100vw;
  height: 100vh;
}

.screen-layer {
  position: absolute;
  inset: 0;
}

.pairing-layer,
#waiting-view,
.results-layer {
  display: table;
}

.pairing-card,
.message-card {
  display: table-cell;
  padding: 4vh 6vw;
  text-align: center;
  vertical-align: middle;
}

.pairing-card h1,
.message-card h1 {
  margin: 2.2vh 0;
  font-size: clamp(30px, 4.8vw, 70px);
  line-height: 1.1;
}

.pairing-card p,
.message-card p {
  color: var(--muted);
  font-size: clamp(16px, 2vw, 28px);
}

.room-code-input {
  width: min(440px, 62vw);
  display: block;
  margin: 3vh auto;
  border: 2px solid var(--line);
  border-radius: 14px;
  outline: none;
  background: rgba(2, 7, 31, 0.72);
  color: var(--gold);
  font-size: clamp(42px, 7vw, 92px);
  font-weight: 800;
  letter-spacing: 0.24em;
  line-height: 1.25;
  text-align: center;
  text-indent: 0.24em;
}

.connection-status {
  min-height: 24px;
  margin: 2vh 0 0;
  color: var(--muted);
}

#board-view {
  padding: 1.8vh 1.4vw 0.9vh;
}

.round-title {
  height: 5vh;
  color: var(--muted);
  font-size: clamp(14px, 1.7vw, 25px);
  font-weight: 800;
  letter-spacing: 0.12em;
  line-height: 5vh;
  text-align: center;
}

.board-wrap {
  height: 80vh;
}

.game-board {
  width: 100%;
  height: 100%;
  border-collapse: separate;
  border-spacing: 5px;
  table-layout: fixed;
}

.game-board th,
.game-board td {
  overflow: hidden;
  border: 1px solid var(--line);
  border-radius: 7px;
  background: linear-gradient(180deg, var(--blue-top), var(--blue-bottom));
  box-shadow: inset 0 0 18px rgba(1, 9, 43, 0.28);
  text-align: center;
  vertical-align: middle;
}

.game-board th {
  width: 31%;
  padding: 0.8vh 0.8vw;
  background: linear-gradient(180deg, #111b50, #080f39);
  color: var(--text);
  font-size: clamp(17px, 2.35vw, 38px);
  line-height: 1.06;
  text-transform: uppercase;
  word-break: break-word;
}

.game-board td {
  color: #ffffff;
  font-size: clamp(24px, 4.4vw, 64px);
  font-weight: 900;
  text-shadow: 0 3px 4px rgba(0, 0, 0, 0.55);
}

.game-board td.used {
  color: transparent;
  text-shadow: none;
}

.screen-scoreboard {
  height: 12vh;
  display: table;
  width: 100%;
  border-spacing: 7px 0;
  table-layout: fixed;
}

.screen-team {
  display: table-cell;
  overflow: hidden;
  padding: 0.9vh 0.6vw;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  background: rgba(10, 19, 60, 0.9);
  text-align: center;
  vertical-align: middle;
}

.screen-team-name {
  overflow: hidden;
  color: #f4dce7;
  font-size: clamp(12px, 1.45vw, 22px);
  font-weight: 700;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.screen-team-score {
  margin-top: 0.4vh;
  color: #ff9fc5;
  font-size: clamp(20px, 2.7vw, 42px);
  font-weight: 900;
}

.cat-layer {
  display: table;
  padding: 3vh 5vw;
  background:
    radial-gradient(circle at 50% 5%, rgba(255, 159, 197, 0.2), transparent 42%),
    linear-gradient(180deg, #10184b 0%, #071033 100%);
}

.cat-content {
  display: table-cell;
  text-align: center;
  vertical-align: middle;
}

.cat-content h1 {
  margin: 0;
  color: #ffffff;
  font-size: clamp(38px, 6vw, 88px);
  line-height: 1;
}

.cat-content p {
  margin: 1.6vh 0 2.2vh;
  color: #f4dce7;
  font-size: clamp(22px, 3.3vw, 50px);
  font-weight: 800;
}

.cat-image {
  display: block;
  max-width: 68vw;
  max-height: 66vh;
  margin: 0 auto;
  border: 3px solid rgba(255, 180, 209, 0.7);
  border-radius: 15px;
  object-fit: contain;
  box-shadow: 0 16px 42px rgba(0, 0, 0, 0.34);
}

.question-layer {
  padding: 4vh 5vw 5vh;
  background:
    radial-gradient(circle at 50% 10%, rgba(53, 109, 255, 0.34), transparent 44%),
    linear-gradient(180deg, #1045b4 0%, #082c83 100%);
}

.question-meta {
  height: 7vh;
  color: #d7e2ff;
  font-size: clamp(15px, 1.9vw, 28px);
  font-weight: 800;
  letter-spacing: 0.08em;
  text-align: center;
  text-transform: uppercase;
}

.question-content {
  height: 82vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2.2vh;
  text-align: center;
}

.question-text {
  max-width: 92vw;
  font-size: clamp(38px, 5.2vw, 96px);
  font-weight: 800;
  line-height: 1.13;
}

.image-caption {
  max-width: 90vw;
  font-size: clamp(18px, 2.3vw, 34px);
  font-weight: 700;
  line-height: 1.18;
}

.question-image-frame,
.feedback-answer-image-frame {
  width: 100%;
  min-height: 0;
  background-position: center;
  background-repeat: no-repeat;
  background-size: contain;
}

.question-image-frame {
  flex: 1 1 0;
  margin: 1.6vh 0;
}

.question-image,
.feedback-answer-image {
  width: 100%;
  height: 100%;
  display: block;
  object-fit: contain;
}

.question-layer.has-image {
  padding: 2vh 3vw;
}

.question-layer.has-image .question-meta {
  height: 5vh;
}

.question-layer.has-image .question-content {
  height: 91vh;
  justify-content: flex-start;
  gap: 0.8vh;
  padding: 0;
}

.question-layer.has-image .question-text {
  flex: 0 0 auto;
  max-width: 94vw;
}

.question-layer.has-image .image-caption {
  flex: 0 0 auto;
}

.feedback-card {
  height: 82vh;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 5px solid transparent;
  border-radius: 18px;
  text-align: center;
}

.feedback-card.is-correct {
  border-color: var(--green);
  box-shadow: inset 0 0 80px rgba(54, 213, 154, 0.13);
}

.feedback-card.is-incorrect {
  border-color: var(--red);
  box-shadow: inset 0 0 80px rgba(255, 82, 109, 0.16);
}

.feedback-card.is-answer {
  border-color: #91adff;
}

.feedback-text {
  max-width: 90%;
  font-size: clamp(38px, 6vw, 94px);
  font-weight: 900;
  line-height: 1.08;
}

.feedback-card.has-answer-image {
  padding: 2vh 2vw;
}

.feedback-card.has-answer-image .feedback-text {
  flex: 0 0 auto;
  max-height: 18vh;
  margin-bottom: 1.5vh;
  font-size: clamp(28px, 4vw, 62px);
  overflow: hidden;
}

.feedback-answer-image-frame {
  flex: 1 1 0;
  margin: 1.5vh 0;
}

.is-incorrect .feedback-text {
  color: #ffd3da;
}

.results-layer {
  padding: 5vh 8vw;
  text-align: center;
}

.results-layer > * {
  display: block;
}

.results-layer h1 {
  margin: 2vh 0 4vh;
  font-size: clamp(34px, 5vw, 76px);
}

.results-ranking {
  width: min(900px, 84vw);
  margin: 0 auto;
}

.ranking-row {
  display: grid;
  grid-template-columns: 70px 1fr auto;
  gap: 18px;
  align-items: center;
  margin: 1.4vh 0;
  padding: 1.5vh 2vw;
  border: 1px solid var(--line-soft);
  border-radius: 12px;
  background: rgba(13, 25, 75, 0.9);
  font-size: clamp(18px, 2.5vw, 38px);
  font-weight: 800;
  text-align: left;
}

.ranking-place {
  color: var(--gold);
  text-align: center;
}

.ranking-score {
  color: var(--gold);
}

.results-note {
  margin-top: 4vh;
  color: var(--muted);
  font-size: clamp(15px, 1.7vw, 25px);
}

/* Экран ведущего */

.host-page {
  min-width: 900px;
  min-height: 650px;
  overflow: auto;
  background:
    radial-gradient(circle at 20% -30%, rgba(50, 103, 241, 0.24), transparent 38%),
    #050920;
}

.host-header {
  height: 70px;
  display: grid;
  grid-template-columns: 1fr auto 250px;
  align-items: center;
  gap: 20px;
  padding: 9px 18px;
  border-bottom: 1px solid var(--line-soft);
  background: #091033;
}

.host-title {
  margin-top: 4px;
  font-size: 22px;
  font-weight: 800;
}

.room-badge {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 7px 14px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #111d52;
  color: var(--muted);
  font-size: 12px;
}

.room-badge strong {
  color: var(--gold);
  font-size: 28px;
  letter-spacing: 0.16em;
}

.host-connection-status {
  color: var(--muted);
  font-size: 13px;
  text-align: right;
}

.host-header-actions {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 10px;
}

.host-header-actions .host-connection-status {
  flex: 1 1 auto;
}

.setup-panel {
  min-height: calc(100vh - 70px);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 30px;
}

.setup-card {
  width: min(760px, 90vw);
  padding: 28px;
  border: 1px solid var(--line-soft);
  border-radius: 18px;
  background: linear-gradient(180deg, #111d56, #091038);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.32);
}

.setup-card h1 {
  margin: 0 0 8px;
  font-size: 32px;
}

.setup-card > p {
  margin: 0 0 22px;
  color: var(--muted);
}

.team-inputs {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
  margin-bottom: 18px;
}

.team-inputs label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.team-inputs input,
.manual-score input {
  width: 100%;
  display: block;
  margin-top: 5px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  outline: none;
  background: #080f36;
  color: var(--text);
}

.team-inputs input {
  height: 46px;
  padding: 0 12px;
  font-size: 17px;
}

.team-inputs input:focus,
.manual-score input:focus {
  border-color: var(--blue-bright);
}

.setup-error {
  min-height: 24px;
  color: #ff9aaa;
}

.host-game {
  height: calc(100vh - 70px);
  min-height: 580px;
  display: grid;
  grid-template-columns: minmax(0, 3fr) minmax(280px, 1fr);
  gap: 10px;
  padding: 10px;
}

.host-left-column {
  min-width: 0;
  display: grid;
  grid-template-rows: minmax(340px, 56%) minmax(210px, 44%);
  gap: 10px;
}

.host-board-panel,
.host-question-panel {
  min-height: 0;
}

.host-board-wrap {
  height: calc(100% - 43px);
  padding: 5px;
}

.host-results {
  height: 100%;
  overflow: auto;
  padding: 14px 9%;
  text-align: center;
}

.host-results h2 {
  margin: 4px 0 12px;
}

.host-results .ranking-row {
  grid-template-columns: 42px 1fr auto;
  margin: 7px 0;
  padding: 8px 12px;
  font-size: 18px;
}

.host-board {
  border-spacing: 3px;
}

.host-board th {
  width: 31%;
  padding: 4px;
  font-size: clamp(12px, 1.42vw, 22px);
}

.host-board td {
  font-size: clamp(17px, 2.35vw, 36px);
}

.host-board td:not(.used) {
  cursor: pointer;
}

.host-board td:not(.used):active {
  transform: translateY(1px);
  background: linear-gradient(180deg, #1d65e6, #0a3b9f);
}

.host-question-panel {
  display: flex;
  flex-direction: column;
}

.host-question-meta {
  color: var(--gold);
  font-size: 13px;
  font-weight: 800;
}

.host-question-empty,
.host-question-content {
  min-height: 0;
  flex: 1;
}

.host-question-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted);
}

.host-question-content {
  overflow: auto;
  padding: 14px 18px;
  text-align: center;
}

.host-question-text {
  font-size: clamp(20px, 2.25vw, 34px);
  font-weight: 800;
  line-height: 1.15;
}

.host-image-caption {
  margin-top: 10px;
  color: #dce5ff;
  font-size: 17px;
  font-weight: 700;
}

.host-question-image {
  max-width: 90%;
  max-height: 155px;
  margin-top: 10px;
  border-radius: 8px;
  object-fit: contain;
}

.host-control-column {
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-right: 4px;
  padding-bottom: 44px;
  -webkit-overflow-scrolling: touch;
}

.host-control-column > .panel {
  flex: 0 0 auto;
}

.answer-panel,
.teams-panel,
.history-panel,
.round-control-panel {
  padding: 12px;
}

.host-answer {
  min-height: 78px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 9px 0;
  padding: 10px;
  border: 1px solid var(--line-soft);
  border-radius: 10px;
  background: #080f35;
  font-size: 19px;
  font-weight: 800;
  line-height: 1.15;
  text-align: center;
}

.timer-row {
  display: grid;
  grid-template-columns: 1fr 62px;
  gap: 8px;
  align-items: stretch;
  margin-bottom: 9px;
}

.timer-display {
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(255, 199, 120, 0.55);
  border-radius: 10px;
  background: #2c1b0b;
  color: #ffd58f;
  font-size: 25px;
  font-weight: 900;
}

.timer-display.expired {
  border-color: var(--red);
  color: #ff9cac;
}

.answer-actions {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.award-prompt {
  min-height: 22px;
  margin-top: 9px;
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
  text-align: center;
}

.award-prompt.active {
  color: var(--gold);
}

.host-teams {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 8px;
}

.host-team {
  width: 100%;
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 8px;
  align-items: center;
  min-height: 46px;
  border: 1px solid var(--line-soft);
  border-radius: 9px;
  padding: 6px 10px;
  background: #101b4d;
  color: #fff;
  text-align: left;
  cursor: pointer;
}

.host-team.selected {
  border-color: var(--gold);
  box-shadow: inset 0 0 0 1px rgba(255, 218, 107, 0.35);
}

.host-team.awaiting {
  border-color: #82a6ff;
  background: #173071;
}

.host-team-name {
  overflow: hidden;
  font-weight: 800;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.host-team-score {
  color: var(--gold);
  font-size: 21px;
  font-weight: 900;
}

.manual-score {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--line-soft);
}

.manual-score label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 700;
}

.manual-score input {
  height: 40px;
  padding: 0 10px;
  font-size: 17px;
}

.manual-buttons {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 7px;
  margin-top: 7px;
}

.manual-buttons .button {
  min-height: 38px;
  padding: 6px;
  font-size: 11px;
}

.manual-score-hint,
.last-action {
  margin-top: 7px;
  color: var(--muted);
  font-size: 11px;
  line-height: 1.3;
}

.button-undo {
  width: 100%;
  font-size: 11px;
}

.round-control-panel {
  border-color: rgba(255, 218, 107, 0.45);
}

.round-control-text {
  margin-bottom: 10px;
  color: var(--gold);
  font-weight: 800;
  line-height: 1.3;
  text-align: center;
}

.round-control-panel .button {
  width: 100%;
}

@media (max-height: 700px) {
  .host-header {
    height: 60px;
  }

  .host-game {
    height: calc(100vh - 60px);
    grid-template-columns: minmax(0, 3.1fr) minmax(270px, 1fr);
  }

  .host-left-column {
    grid-template-rows: minmax(300px, 58%) minmax(190px, 42%);
  }

  .host-answer {
    min-height: 60px;
    font-size: 16px;
  }

  .button {
    min-height: 38px;
    padding-top: 7px;
    padding-bottom: 7px;
  }

  .host-team {
    min-height: 40px;
  }

  .answer-panel,
  .teams-panel,
  .history-panel,
  .round-control-panel {
    padding: 8px;
  }

  .host-teams {
    gap: 4px;
  }

  .manual-score {
    margin-top: 7px;
    padding-top: 7px;
  }
}

@media (max-width: 940px) {
  .host-page {
    min-width: 0;
  }

  .host-header {
    grid-template-columns: 1fr auto;
  }

  .host-connection-status {
    display: none;
  }

  .host-game {
    grid-template-columns: minmax(0, 2.1fr) minmax(250px, 1fr);
  }

  .button {
    padding-left: 8px;
    padding-right: 8px;
    font-size: 11px;
  }
}
