:root {
  color-scheme: dark;
  --bg: #111318;
  --panel: #1b2028;
  --line: #343b47;
  --text: #f3f5f8;
  --muted: #9ca6b4;
  --accent: #4cc9a6;
  --danger: #ff6b6b;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  min-height: 100vh;
  min-height: 100svh;
  background: var(--bg);
  color: var(--text);
  font-family: "Microsoft YaHei", "Segoe UI", Arial, sans-serif;
  overflow: hidden;
}

.shell {
  display: grid;
  grid-template-columns: minmax(320px, 1fr) 360px;
  min-height: 100vh;
  min-height: 100svh;
}

.stage {
  display: grid;
  place-items: center;
  min-width: 0;
  padding: 24px;
  background: #08090c;
}

.phone {
  position: relative;
  height: min(94vh, 980px);
  max-width: 100%;
  aspect-ratio: 1200 / 2652;
  overflow: hidden;
  border: 1px solid #2b313b;
  border-radius: 8px;
  background: #000;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.4);
  touch-action: none;
}

#screen {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
}

.stage:fullscreen,
.stage:-webkit-full-screen,
.shell:fullscreen .stage,
.shell:-webkit-full-screen .stage {
  display: grid;
  place-items: center;
  width: 100vw;
  height: 100vh;
  padding: 0;
  background: #000;
}

.stage:fullscreen .phone,
.stage:-webkit-full-screen .phone,
.shell:fullscreen .phone,
.shell:-webkit-full-screen .phone {
  width: min(100vw, calc(100vh * 1200 / 2652));
  height: auto;
  max-height: 100vh;
  border: 0;
  border-radius: 0;
  box-shadow: none;
}

.touch-dot {
  position: absolute;
  width: 34px;
  height: 34px;
  border: 2px solid var(--accent);
  border-radius: 999px;
  pointer-events: none;
  opacity: 0;
  transform: translate(-50%, -50%) scale(0.75);
  transition: opacity 160ms ease, transform 160ms ease;
}

.touch-dot.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

.panel {
  display: flex;
  flex-direction: column;
  gap: 22px;
  padding: 28px;
  border-left: 1px solid var(--line);
  background: var(--panel);
}

.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
}

h1 {
  margin: 0 0 8px;
  font-size: 24px;
  line-height: 1.2;
}

p {
  margin: 0;
  color: var(--muted);
}

.status-light {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  margin-top: 8px;
  border-radius: 50%;
  background: var(--danger);
  box-shadow: 0 0 0 5px rgba(255, 107, 107, 0.14);
}

.status-light.ok {
  background: var(--accent);
  box-shadow: 0 0 0 5px rgba(76, 201, 166, 0.14);
}

.panel > .header,
.panel > .facts,
.panel > .controls,
.panel > .text-box,
.panel > .message {
  transition: opacity 140ms ease;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 9px;
}

.mini-link,
.auth-link {
  color: var(--accent);
  text-decoration: none;
}

.mini-button {
  width: auto;
  min-width: 42px;
  height: 30px;
  padding: 0 9px;
  font-size: 12px;
}

.panel-handle {
  display: none;
}

.facts {
  display: grid;
  gap: 12px;
  margin: 0;
}

.facts div {
  padding-bottom: 12px;
  border-bottom: 1px solid var(--line);
}

dt {
  margin-bottom: 5px;
  color: var(--muted);
  font-size: 13px;
}

dd {
  margin: 0;
  min-width: 0;
  overflow-wrap: anywhere;
  font-size: 15px;
}

.controls {
  display: grid;
  grid-template-columns: repeat(5, 54px);
  gap: 12px;
}

button,
.button {
  display: grid;
  place-items: center;
  width: 54px;
  height: 44px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #242b35;
  color: var(--text);
  font: 700 22px/1 "Segoe UI Symbol", "Microsoft YaHei", sans-serif;
  text-decoration: none;
  cursor: pointer;
}

button:hover,
.button:hover {
  border-color: var(--accent);
}

.text-box {
  display: grid;
  gap: 8px;
  color: var(--muted);
  font-size: 13px;
}

.text-box div {
  display: flex;
  gap: 8px;
}

input {
  min-width: 0;
  flex: 1;
  height: 42px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10141b;
  color: var(--text);
  padding: 0 12px;
  font-size: 15px;
}

.message {
  margin-top: auto;
  line-height: 1.6;
}

@media (max-width: 880px) {
  body {
    overflow: hidden;
  }

  .shell {
    display: block;
    position: relative;
    min-height: 100svh;
    overflow: hidden;
  }

  .stage {
    width: 100vw;
    height: 100svh;
    padding: 0;
  }

  .phone {
    width: min(100vw, calc(100svh * 1200 / 2652));
    height: auto;
    max-height: 100svh;
    border: 0;
    border-radius: 0;
    box-shadow: none;
  }

  .panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 5;
    gap: 10px;
    padding: 30px 12px 12px;
    border-left: 0;
    border-top: 1px solid var(--line);
    border-radius: 8px 8px 0 0;
    box-shadow: 0 -14px 42px rgba(0, 0, 0, 0.42);
    transform: translateY(calc(100% - 56px));
    transition: transform 180ms ease;
    will-change: transform;
  }

  .panel.open {
    transform: translateY(0);
  }

  .panel-handle {
    position: absolute;
    top: 0;
    left: 0;
    display: grid;
    place-items: center;
    width: 100%;
    height: 56px;
    border: 0;
    border-radius: 8px 8px 0 0;
    background: transparent;
    cursor: grab;
    touch-action: none;
  }

  .panel-handle span {
    width: 52px;
    height: 5px;
    border-radius: 999px;
    background: #616b7b;
  }

  .panel.open .panel-handle span {
    background: var(--accent);
  }

  .shell:fullscreen .panel,
  .shell:-webkit-full-screen .panel {
    left: var(--float-x, auto);
    right: auto;
    bottom: auto;
    top: var(--float-y, calc(100vh - 76px));
    width: 56px;
    height: 56px;
    min-height: 56px;
    padding: 0;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.18);
    border-radius: 8px;
    background: rgba(27, 32, 40, 0.86);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
    transform: none;
    z-index: 20;
  }

  .shell:fullscreen .panel.open,
  .shell:-webkit-full-screen .panel.open {
    width: min(92vw, 360px);
    height: auto;
    min-height: 0;
    padding: 30px 12px 12px;
    overflow: visible;
  }

  .shell:fullscreen .panel:not(.open) > :not(.panel-handle),
  .shell:-webkit-full-screen .panel:not(.open) > :not(.panel-handle) {
    opacity: 0;
    pointer-events: none;
  }

  .shell:fullscreen .panel .panel-handle,
  .shell:-webkit-full-screen .panel .panel-handle {
    height: 56px;
    border-radius: 8px;
  }

  .shell:fullscreen .panel.open .panel-handle,
  .shell:-webkit-full-screen .panel.open .panel-handle {
    height: 28px;
    border-radius: 8px 8px 0 0;
  }

  .shell:fullscreen .panel:not(.open) .panel-handle span,
  .shell:-webkit-full-screen .panel:not(.open) .panel-handle span {
    width: 24px;
    height: 24px;
    border: 2px solid var(--accent);
    background: transparent;
  }

  .header {
    align-items: center;
  }

  h1 {
    margin-bottom: 2px;
    font-size: 17px;
  }

  p,
  dd {
    font-size: 12px;
  }

  .status-light {
    margin-top: 0;
  }

  .facts {
    grid-template-columns: repeat(4, minmax(0, 1fr));
    gap: 8px;
  }

  .facts div {
    padding-bottom: 0;
    border-bottom: 0;
  }

  dt {
    margin-bottom: 2px;
    font-size: 10px;
  }

  .controls {
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 8px;
  }

  button,
  .button {
    width: 100%;
    height: 40px;
    font-size: 14px;
  }

  .text-box {
    grid-template-columns: 42px minmax(0, 1fr);
    align-items: center;
  }

  .text-box div {
    min-width: 0;
  }

  input {
    height: 38px;
    font-size: 14px;
  }

  .message {
    display: none;
  }
}

@media (max-width: 420px) {
  .phone {
    width: min(100vw, calc(100svh * 1200 / 2652));
    max-height: 100svh;
  }

  .panel {
    padding-inline: 8px;
  }
}

.auth-page {
  display: grid;
  place-items: center;
  min-height: 100vh;
  min-height: 100svh;
  padding: 18px;
  overflow: auto;
}

.auth-box,
.admin-box {
  width: min(100%, 420px);
  padding: 22px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: var(--panel);
}

.admin-box {
  width: min(100%, 760px);
}

.auth-form {
  display: grid;
  gap: 12px;
  margin: 20px 0 14px;
}

.auth-form button {
  width: 100%;
}

.admin-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 18px;
  margin-bottom: 18px;
}

.users-list {
  display: grid;
  gap: 10px;
}

.user-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #10141b;
}

.user-row strong,
.user-row span {
  display: block;
}

.user-row span {
  margin-top: 4px;
  color: var(--muted);
  font-size: 12px;
}

.user-actions {
  display: flex;
  gap: 8px;
}

.user-actions button {
  width: auto;
  height: 34px;
  padding: 0 10px;
  font-size: 12px;
}
