html,
body {
  margin: 0;
  padding: 0;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  font-family: Arial, sans-serif;
  user-select: none;
  background: transparent;
}

#box {
  width: 100vw;
  height: 100vh;
  box-sizing: border-box;
  background: #cccccc;
  color: #000000;
  display: flex;
  flex-direction: column;
  position: relative;
  font-weight: 700;
  border: 1px solid rgba(0, 0, 0, 0.15);
}

#dragBar {
  min-height: 28px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 6px;
  padding: calc(4px + env(safe-area-inset-top)) calc(5px + env(safe-area-inset-right)) 4px calc(5px + env(safe-area-inset-left));
  box-sizing: border-box;
  background: rgba(0, 0, 0, 0.08);
}

#barActions {
  display: flex;
  align-items: center;
  gap: 4px;
}

#titleBarText {
  font-size: 11px;
  opacity: 0.8;
  letter-spacing: 0.5px;
}

#dragBar button {
  width: 20px;
  height: 20px;
  padding: 0;
  border: none;
  border-radius: 3px;
  background: rgba(0, 0, 0, 0.12);
  color: #000000;
  font-size: 11px;
  font-weight: 700;
  line-height: 20px;
  cursor: pointer;
}

#dragBar button:hover {
  background: rgba(0, 0, 0, 0.22);
}

#menuBtn,
#popupBtn {
  font-size: 13px;
}

#content {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 2px 4px 6px 4px;
  box-sizing: border-box;
}

#title {
  font-size: clamp(15px, 5vmin, 40px);
  line-height: 1.15;
  opacity: 0.85;
  margin-bottom: 1px;
}

#period {
  font-size: clamp(10px, 3vmin, 24px);
  line-height: 1.2;
  opacity: 0.7;
  margin-bottom: 8px;
}

#value {
  font-size: clamp(28px, 17vmin, 120px);
  line-height: 1.05;
  text-align: center;
  letter-spacing: -1px;
  max-width: 100%;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: clip;
}

#details {
  margin-top: 12px;
  font-size: clamp(13px, 4vmin, 32px);
  opacity: 0.82;
  text-align: center;
  line-height: 1.4;
}

#spotRow,
#futuresRow,
#unifiedRow {
  display: block;
}

#error {
  margin-top: 4px;
  font-size: 9px;
  text-align: center;
  color: #7a0000;
  max-width: calc(100vw - 8px);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#menu {
  position: fixed;
  z-index: 10;
  min-width: 200px;
  max-height: calc(100vh - 8px);
  overflow-y: auto;
  padding: 4px 0;
  background: #f4f4f4;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.25);
  font-family: Arial, sans-serif;
  font-size: 12px;
}

#menu[hidden] {
  display: none;
}

.menuHeader {
  padding: 4px 12px 2px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  opacity: 0.55;
}

.menuItem {
  display: block;
  width: 100%;
  padding: 5px 12px 5px 26px;
  border: none;
  background: none;
  color: #000000;
  font: inherit;
  text-align: left;
  cursor: pointer;
  position: relative;
}

.menuItem:hover {
  background: rgba(0, 0, 0, 0.08);
}

.menuItem.checked::before {
  content: '●';
  position: absolute;
  left: 11px;
  font-size: 8px;
  line-height: 16px;
}

.menuSeparator {
  height: 1px;
  margin: 4px 0;
  background: rgba(0, 0, 0, 0.12);
}

#loginView {
  position: fixed;
  inset: 0;
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 16px;
  background: #cccccc;
  font-family: Arial, sans-serif;
}

#loginView[hidden] {
  display: none;
}

#loginTitle {
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  opacity: 0.8;
}

#loginView input,
#loginView button {
  width: 100%;
  max-width: 260px;
  box-sizing: border-box;
  padding: 9px 10px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 6px;
  font-size: 16px;
}

#loginView button {
  background: rgba(0, 0, 0, 0.12);
  font-weight: 700;
  cursor: pointer;
}

#loginError {
  min-height: 14px;
  font-size: 12px;
  color: #7a0000;
}

/* Телефон: шапка ниже статус-бара (safe-area выше), кнопки крупнее под палец */
@media (pointer: coarse) {
  #dragBar {
    padding-bottom: 6px;
  }

  #titleBarText {
    font-size: 14px;
  }

  #barActions {
    gap: 8px;
  }

  #dragBar button {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    font-size: 17px;
    line-height: 40px;
  }

  #menuBtn {
    font-size: 21px;
  }

  #popupBtn {
    display: none;
  }

  #content {
    padding-bottom: calc(6px + env(safe-area-inset-bottom));
  }

  .menuItem {
    padding-top: 11px;
    padding-bottom: 11px;
    font-size: 15px;
  }

  .menuItem.checked::before {
    line-height: 20px;
  }

  #menu {
    min-width: 240px;
  }
}
